summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/games_controller.rb2
-rw-r--r--app/controllers/teams_controller.rb2
-rw-r--r--app/controllers/tournaments_controller.rb2
-rw-r--r--app/models/game_attribute.rb3
-rw-r--r--app/models/game_option.rb2
-rw-r--r--app/models/score.rb4
-rw-r--r--app/models/team.rb1
-rw-r--r--app/models/tournament_option.rb1
-rw-r--r--app/models/tournament_user_pair.rb4
-rw-r--r--app/views/games/_form.html.erb18
-rw-r--r--app/views/games/index.html.erb12
-rw-r--r--app/views/games/index.json.jbuilder2
-rw-r--r--app/views/games/show.html.erb18
-rw-r--r--app/views/games/show.json.jbuilder2
-rw-r--r--app/views/teams/_form.html.erb4
-rw-r--r--app/views/teams/index.html.erb2
-rw-r--r--app/views/teams/index.json.jbuilder2
-rw-r--r--app/views/teams/show.html.erb7
-rw-r--r--app/views/teams/show.json.jbuilder2
-rw-r--r--app/views/tournaments/_form.html.erb28
-rw-r--r--app/views/tournaments/index.html.erb24
-rw-r--r--app/views/tournaments/index.json.jbuilder2
-rw-r--r--app/views/tournaments/show.html.erb35
-rw-r--r--app/views/tournaments/show.json.jbuilder2
-rw-r--r--db/migrate/20140306024709_create_tournaments.rb9
-rw-r--r--db/migrate/20140306024720_create_games.rb13
-rw-r--r--db/migrate/20140306024727_create_game_attributes.rb11
-rw-r--r--db/migrate/20140306222309_create_servers.rb (renamed from db/migrate/20140306024707_create_servers.rb)0
-rw-r--r--db/migrate/20140306222314_create_tournaments.rb16
-rw-r--r--db/migrate/20140306222320_create_matches.rb (renamed from db/migrate/20140306024711_create_matches.rb)0
-rw-r--r--db/migrate/20140306222325_create_teams.rb (renamed from db/migrate/20140306024713_create_teams.rb)1
-rw-r--r--db/migrate/20140306222330_create_alerts.rb (renamed from db/migrate/20140306024715_create_alerts.rb)0
-rw-r--r--db/migrate/20140306222336_create_pms.rb (renamed from db/migrate/20140306024718_create_pms.rb)0
-rw-r--r--db/migrate/20140306222341_create_games.rb15
-rw-r--r--db/migrate/20140306222347_create_users.rb (renamed from db/migrate/20140306024722_create_users.rb)0
-rw-r--r--db/migrate/20140306222352_create_sessions.rb (renamed from db/migrate/20140306024724_create_sessions.rb)0
-rw-r--r--db/migrate/20140306222357_create_server_settings.rb (renamed from db/migrate/20140306024729_create_server_settings.rb)0
-rw-r--r--db/migrate/20140306222402_create_tournament_options.rb (renamed from db/migrate/20140306024735_create_tournament_options.rb)4
-rw-r--r--db/migrate/20140306222407_create_game_options.rb11
-rw-r--r--db/migrate/20140306222412_create_scores.rb11
-rw-r--r--db/migrate/20140306222417_create_tournament_user_pairs.rb10
-rw-r--r--db/migrate/20140306222422_create_user_team_pairs.rb (renamed from db/migrate/20140306024731_create_user_team_pairs.rb)0
-rw-r--r--db/migrate/20140306222427_create_team_match_pairs.rb (renamed from db/migrate/20140306024733_create_team_match_pairs.rb)0
-rw-r--r--db/migrate/20140306222447_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140306024744_add_hidden_attrs_to_user.rb)0
-rw-r--r--db/schema.rb57
-rwxr-xr-xgenerate.sh14
-rw-r--r--test/controllers/games_controller_test.rb4
-rw-r--r--test/controllers/teams_controller_test.rb4
-rw-r--r--test/controllers/tournaments_controller_test.rb4
-rw-r--r--test/fixtures/game_options.yml11
-rw-r--r--test/fixtures/games.yml16
-rw-r--r--test/fixtures/scores.yml (renamed from test/fixtures/game_attributes.yml)12
-rw-r--r--test/fixtures/teams.yml14
-rw-r--r--test/fixtures/tournament_options.yml20
-rw-r--r--test/fixtures/tournament_user_pairs.yml9
-rw-r--r--test/fixtures/tournaments.yml14
-rw-r--r--test/models/game_option_test.rb (renamed from test/models/game_attribute_test.rb)2
-rw-r--r--test/models/score_test.rb7
-rw-r--r--test/models/tournament_user_pair_test.rb7
59 files changed, 362 insertions, 115 deletions
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 4ecff17..5780152 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -69,6 +69,6 @@ class GamesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def game_params
- params.require(:game).permit(:name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams)
+ params.require(:game).permit(:name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams)
end
end
diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb
index f14c97f..ccd6781 100644
--- a/app/controllers/teams_controller.rb
+++ b/app/controllers/teams_controller.rb
@@ -69,6 +69,6 @@ class TeamsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def team_params
- params[:team]
+ params.require(:team).permit(:match_id)
end
end
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 1d17205..cf618aa 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -81,6 +81,6 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game_id, :game)
+ params.require(:tournament).permit(:game, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status)
end
end
diff --git a/app/models/game_attribute.rb b/app/models/game_attribute.rb
deleted file mode 100644
index c12723b..0000000
--- a/app/models/game_attribute.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class GameAttribute < ActiveRecord::Base
- belongs_to :game
-end
diff --git a/app/models/game_option.rb b/app/models/game_option.rb
new file mode 100644
index 0000000..bdc5560
--- /dev/null
+++ b/app/models/game_option.rb
@@ -0,0 +1,2 @@
+class GameOption < ActiveRecord::Base
+end
diff --git a/app/models/score.rb b/app/models/score.rb
new file mode 100644
index 0000000..a9b9c71
--- /dev/null
+++ b/app/models/score.rb
@@ -0,0 +1,4 @@
+class Score < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :match
+end
diff --git a/app/models/team.rb b/app/models/team.rb
index fa7ba9e..9e71557 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -1,2 +1,3 @@
class Team < ActiveRecord::Base
+ belongs_to :match
end
diff --git a/app/models/tournament_option.rb b/app/models/tournament_option.rb
index 950b351..242a6f6 100644
--- a/app/models/tournament_option.rb
+++ b/app/models/tournament_option.rb
@@ -1,2 +1,3 @@
class TournamentOption < ActiveRecord::Base
+ belongs_to :tournament
end
diff --git a/app/models/tournament_user_pair.rb b/app/models/tournament_user_pair.rb
new file mode 100644
index 0000000..eb4e9c5
--- /dev/null
+++ b/app/models/tournament_user_pair.rb
@@ -0,0 +1,4 @@
+class TournamentUserPair < ActiveRecord::Base
+ belongs_to :tournament
+ belongs_to :user
+end
diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb
index 8941c59..f68e28f 100644
--- a/app/views/games/_form.html.erb
+++ b/app/views/games/_form.html.erb
@@ -16,12 +16,20 @@
<%= f.text_area :name %>
</div>
<div class="field">
- <%= f.label :players_per_team %><br>
- <%= f.number_field :players_per_team %>
+ <%= f.label :min_players_per_team %><br>
+ <%= f.number_field :min_players_per_team %>
</div>
<div class="field">
- <%= f.label :teams_per_match %><br>
- <%= f.number_field :teams_per_match %>
+ <%= f.label :max_players_per_team %><br>
+ <%= f.number_field :max_players_per_team %>
+ </div>
+ <div class="field">
+ <%= f.label :min_teams_per_match %><br>
+ <%= f.number_field :min_teams_per_match %>
+ </div>
+ <div class="field">
+ <%= f.label :max_teams_per_match %><br>
+ <%= f.number_field :max_teams_per_match %>
</div>
<div class="field">
<%= f.label :set_rounds %><br>
@@ -29,7 +37,7 @@
</div>
<div class="field">
<%= f.label :randomized_teams %><br>
- <%= f.number_field :randomized_teams %>
+ <%= f.check_box :randomized_teams %>
</div>
<div class="actions">
<%= f.submit %>
diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb
index 9893cbc..79acd1e 100644
--- a/app/views/games/index.html.erb
+++ b/app/views/games/index.html.erb
@@ -4,8 +4,10 @@
<thead>
<tr>
<th>Name</th>
- <th>Players per team</th>
- <th>Teams per match</th>
+ <th>Min players per team</th>
+ <th>Max players per team</th>
+ <th>Min teams per match</th>
+ <th>Max teams per match</th>
<th>Set rounds</th>
<th>Randomized teams</th>
<th></th>
@@ -18,8 +20,10 @@
<% @games.each do |game| %>
<tr>
<td><%= game.name %></td>
- <td><%= game.players_per_team %></td>
- <td><%= game.teams_per_match %></td>
+ <td><%= game.min_players_per_team %></td>
+ <td><%= game.max_players_per_team %></td>
+ <td><%= game.min_teams_per_match %></td>
+ <td><%= game.max_teams_per_match %></td>
<td><%= game.set_rounds %></td>
<td><%= game.randomized_teams %></td>
<td><%= link_to 'Show', game %></td>
diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder
index 7e5c1a1..f8b3e96 100644
--- a/app/views/games/index.json.jbuilder
+++ b/app/views/games/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@games) do |game|
- json.extract! game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams
+ json.extract! game, :id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams
json.url game_url(game, format: :json)
end
diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb
index 88bf91c..39d4a97 100644
--- a/app/views/games/show.html.erb
+++ b/app/views/games/show.html.erb
@@ -4,13 +4,23 @@
</p>
<p>
- <strong>Players per team:</strong>
- <%= @game.players_per_team %>
+ <strong>Min players per team:</strong>
+ <%= @game.min_players_per_team %>
</p>
<p>
- <strong>Teams per match:</strong>
- <%= @game.teams_per_match %>
+ <strong>Max players per team:</strong>
+ <%= @game.max_players_per_team %>
+</p>
+
+<p>
+ <strong>Min teams per match:</strong>
+ <%= @game.min_teams_per_match %>
+</p>
+
+<p>
+ <strong>Max teams per match:</strong>
+ <%= @game.max_teams_per_match %>
</p>
<p>
diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder
index 1a2d0c7..e689e7b 100644
--- a/app/views/games/show.json.jbuilder
+++ b/app/views/games/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at
+json.extract! @game, :id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at
diff --git a/app/views/teams/_form.html.erb b/app/views/teams/_form.html.erb
index fd10129..cdd4299 100644
--- a/app/views/teams/_form.html.erb
+++ b/app/views/teams/_form.html.erb
@@ -11,6 +11,10 @@
</div>
<% end %>
+ <div class="field">
+ <%= f.label :match_id %><br>
+ <%= f.text_field :match_id %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/teams/index.html.erb b/app/views/teams/index.html.erb
index b077e10..6a3188d 100644
--- a/app/views/teams/index.html.erb
+++ b/app/views/teams/index.html.erb
@@ -3,6 +3,7 @@
<table>
<thead>
<tr>
+ <th>Match</th>
<th></th>
<th></th>
<th></th>
@@ -12,6 +13,7 @@
<tbody>
<% @teams.each do |team| %>
<tr>
+ <td><%= team.match %></td>
<td><%= link_to 'Show', team %></td>
<td><%= link_to 'Edit', edit_team_path(team) %></td>
<td><%= link_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %></td>
diff --git a/app/views/teams/index.json.jbuilder b/app/views/teams/index.json.jbuilder
index b29428b..ca0ec8b 100644
--- a/app/views/teams/index.json.jbuilder
+++ b/app/views/teams/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@teams) do |team|
- json.extract! team, :id
+ json.extract! team, :id, :match_id
json.url team_url(team, format: :json)
end
diff --git a/app/views/teams/show.html.erb b/app/views/teams/show.html.erb
index ab49d65..e41692a 100644
--- a/app/views/teams/show.html.erb
+++ b/app/views/teams/show.html.erb
@@ -1,2 +1,9 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <strong>Match:</strong>
+ <%= @team.match %>
+</p>
+
<%= link_to 'Edit', edit_team_path(@team) %> |
<%= link_to 'Back', teams_path %>
diff --git a/app/views/teams/show.json.jbuilder b/app/views/teams/show.json.jbuilder
index 1538019..8a85dcc 100644
--- a/app/views/teams/show.json.jbuilder
+++ b/app/views/teams/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @team, :id, :created_at, :updated_at
+json.extract! @team, :id, :match_id, :created_at, :updated_at
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 1fd63e9..c2c0ba7 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -15,6 +15,34 @@
<%= f.label :game_id %><br>
<%= f.text_field :game_id %>
</div>
+ <div class="field">
+ <%= f.label :min_players_per_team %><br>
+ <%= f.number_field :min_players_per_team %>
+ </div>
+ <div class="field">
+ <%= f.label :max_players_per_team %><br>
+ <%= f.number_field :max_players_per_team %>
+ </div>
+ <div class="field">
+ <%= f.label :min_teams_per_match %><br>
+ <%= f.number_field :min_teams_per_match %>
+ </div>
+ <div class="field">
+ <%= f.label :max_teams_per_match %><br>
+ <%= f.number_field :max_teams_per_match %>
+ </div>
+ <div class="field">
+ <%= f.label :set_rounds %><br>
+ <%= f.number_field :set_rounds %>
+ </div>
+ <div class="field">
+ <%= f.label :randomized_teams %><br>
+ <%= f.check_box :randomized_teams %>
+ </div>
+ <div class="field">
+ <%= f.label :status %><br>
+ <%= f.number_field :status %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index e9147f6..80d68a3 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -4,17 +4,31 @@
<table class="table table-hover">
<thead>
<tr>
- <th>Tournament ID</th>
- <th>Show Tournament</th>
- <th>Edit Tournament</th>
- <th>Delete Tournament</th>
+ <th>Game</th>
+ <th>Min players per team</th>
+ <th>Max players per team</th>
+ <th>Min teams per match</th>
+ <th>Max teams per match</th>
+ <th>Set rounds</th>
+ <th>Randomized teams</th>
+ <th>Status</th>
+ <th></th>
+ <th></th>
+ <th></th>
</tr>
</thead>
<tbody>
<% @tournaments.each do |tournament| %>
<tr>
- <td><%= tournament.id %></td>
+ <td><%= tournament.game %></td>
+ <td><%= tournament.min_players_per_team %></td>
+ <td><%= tournament.max_players_per_team %></td>
+ <td><%= tournament.min_teams_per_match %></td>
+ <td><%= tournament.max_teams_per_match %></td>
+ <td><%= tournament.set_rounds %></td>
+ <td><%= tournament.randomized_teams %></td>
+ <td><%= tournament.status %></td>
<td><%= link_to 'Show', tournament %></td>
<td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>
<td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td>
diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder
index e6f3b49..df8eee4 100644
--- a/app/views/tournaments/index.json.jbuilder
+++ b/app/views/tournaments/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@tournaments) do |tournament|
- json.extract! tournament, :id, :game_id
+ json.extract! tournament, :id, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status
json.url tournament_url(tournament, format: :json)
end
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 0d9dd10..4f97c7c 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -3,5 +3,40 @@
<%= @tournament.game %>
</p>
+<p>
+ <strong>Min players per team:</strong>
+ <%= @tournament.min_players_per_team %>
+</p>
+
+<p>
+ <strong>Max players per team:</strong>
+ <%= @tournament.max_players_per_team %>
+</p>
+
+<p>
+ <strong>Min teams per match:</strong>
+ <%= @tournament.min_teams_per_match %>
+</p>
+
+<p>
+ <strong>Max teams per match:</strong>
+ <%= @tournament.max_teams_per_match %>
+</p>
+
+<p>
+ <strong>Set rounds:</strong>
+ <%= @tournament.set_rounds %>
+</p>
+
+<p>
+ <strong>Randomized teams:</strong>
+ <%= @tournament.randomized_teams %>
+</p>
+
+<p>
+ <strong>Status:</strong>
+ <%= @tournament.status %>
+</p>
+
<%= link_to 'Edit', edit_tournament_path(@tournament) %> |
<%= link_to 'Back', tournaments_path %>
diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder
index 0fe65a6..7bedd4b 100644
--- a/app/views/tournaments/show.json.jbuilder
+++ b/app/views/tournaments/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @tournament, :id, :game_id, :created_at, :updated_at
+json.extract! @tournament, :id, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status, :created_at, :updated_at
diff --git a/db/migrate/20140306024709_create_tournaments.rb b/db/migrate/20140306024709_create_tournaments.rb
deleted file mode 100644
index 36fcf7e..0000000
--- a/db/migrate/20140306024709_create_tournaments.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class CreateTournaments < ActiveRecord::Migration
- def change
- create_table :tournaments do |t|
- t.references :game, index: true
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140306024720_create_games.rb b/db/migrate/20140306024720_create_games.rb
deleted file mode 100644
index 59d4ef0..0000000
--- a/db/migrate/20140306024720_create_games.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class CreateGames < ActiveRecord::Migration
- def change
- create_table :games do |t|
- t.text :name
- t.integer :players_per_team
- t.integer :teams_per_match
- t.integer :set_rounds
- t.integer :randomized_teams
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140306024727_create_game_attributes.rb b/db/migrate/20140306024727_create_game_attributes.rb
deleted file mode 100644
index b63f134..0000000
--- a/db/migrate/20140306024727_create_game_attributes.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class CreateGameAttributes < ActiveRecord::Migration
- def change
- create_table :game_attributes do |t|
- t.references :game, index: true
- t.text :key
- t.integer :type
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140306024707_create_servers.rb b/db/migrate/20140306222309_create_servers.rb
index f33241a..f33241a 100644
--- a/db/migrate/20140306024707_create_servers.rb
+++ b/db/migrate/20140306222309_create_servers.rb
diff --git a/db/migrate/20140306222314_create_tournaments.rb b/db/migrate/20140306222314_create_tournaments.rb
new file mode 100644
index 0000000..c7ec765
--- /dev/null
+++ b/db/migrate/20140306222314_create_tournaments.rb
@@ -0,0 +1,16 @@
+class CreateTournaments < ActiveRecord::Migration
+ def change
+ create_table :tournaments do |t|
+ t.references :game, index: true
+ t.integer :min_players_per_team
+ t.integer :max_players_per_team
+ t.integer :min_teams_per_match
+ t.integer :max_teams_per_match
+ t.integer :set_rounds
+ t.boolean :randomized_teams
+ t.integer :status
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20140306024711_create_matches.rb b/db/migrate/20140306222320_create_matches.rb
index 325863d..325863d 100644
--- a/db/migrate/20140306024711_create_matches.rb
+++ b/db/migrate/20140306222320_create_matches.rb
diff --git a/db/migrate/20140306024713_create_teams.rb b/db/migrate/20140306222325_create_teams.rb
index dd8397d..fdf9a68 100644
--- a/db/migrate/20140306024713_create_teams.rb
+++ b/db/migrate/20140306222325_create_teams.rb
@@ -1,6 +1,7 @@
class CreateTeams < ActiveRecord::Migration
def change
create_table :teams do |t|
+ t.references :match, index: true
t.timestamps
end
diff --git a/db/migrate/20140306024715_create_alerts.rb b/db/migrate/20140306222330_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140306024715_create_alerts.rb
+++ b/db/migrate/20140306222330_create_alerts.rb
diff --git a/db/migrate/20140306024718_create_pms.rb b/db/migrate/20140306222336_create_pms.rb
index 93bb5c6..93bb5c6 100644
--- a/db/migrate/20140306024718_create_pms.rb
+++ b/db/migrate/20140306222336_create_pms.rb
diff --git a/db/migrate/20140306222341_create_games.rb b/db/migrate/20140306222341_create_games.rb
new file mode 100644
index 0000000..5e4f56f
--- /dev/null
+++ b/db/migrate/20140306222341_create_games.rb
@@ -0,0 +1,15 @@
+class CreateGames < ActiveRecord::Migration
+ def change
+ create_table :games do |t|
+ t.text :name
+ t.integer :min_players_per_team
+ t.integer :max_players_per_team
+ t.integer :min_teams_per_match
+ t.integer :max_teams_per_match
+ t.integer :set_rounds
+ t.boolean :randomized_teams
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20140306024722_create_users.rb b/db/migrate/20140306222347_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140306024722_create_users.rb
+++ b/db/migrate/20140306222347_create_users.rb
diff --git a/db/migrate/20140306024724_create_sessions.rb b/db/migrate/20140306222352_create_sessions.rb
index fe25bf2..fe25bf2 100644
--- a/db/migrate/20140306024724_create_sessions.rb
+++ b/db/migrate/20140306222352_create_sessions.rb
diff --git a/db/migrate/20140306024729_create_server_settings.rb b/db/migrate/20140306222357_create_server_settings.rb
index dfdd91b..dfdd91b 100644
--- a/db/migrate/20140306024729_create_server_settings.rb
+++ b/db/migrate/20140306222357_create_server_settings.rb
diff --git a/db/migrate/20140306024735_create_tournament_options.rb b/db/migrate/20140306222402_create_tournament_options.rb
index d2df22e..53b601c 100644
--- a/db/migrate/20140306024735_create_tournament_options.rb
+++ b/db/migrate/20140306222402_create_tournament_options.rb
@@ -1,6 +1,10 @@
class CreateTournamentOptions < ActiveRecord::Migration
def change
create_table :tournament_options do |t|
+ t.references :tournament, index: true
+ t.integer :vartype
+ t.string :name
+ t.text :value
t.timestamps
end
diff --git a/db/migrate/20140306222407_create_game_options.rb b/db/migrate/20140306222407_create_game_options.rb
new file mode 100644
index 0000000..2f62ef7
--- /dev/null
+++ b/db/migrate/20140306222407_create_game_options.rb
@@ -0,0 +1,11 @@
+class CreateGameOptions < ActiveRecord::Migration
+ def change
+ create_table :game_options do |t|
+ t.integer :vartype
+ t.string :name
+ t.text :default
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20140306222412_create_scores.rb b/db/migrate/20140306222412_create_scores.rb
new file mode 100644
index 0000000..4ca0b0b
--- /dev/null
+++ b/db/migrate/20140306222412_create_scores.rb
@@ -0,0 +1,11 @@
+class CreateScores < ActiveRecord::Migration
+ def change
+ create_table :scores do |t|
+ t.references :user, index: true
+ t.references :match, index: true
+ t.integer :value
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20140306222417_create_tournament_user_pairs.rb b/db/migrate/20140306222417_create_tournament_user_pairs.rb
new file mode 100644
index 0000000..ab72aad
--- /dev/null
+++ b/db/migrate/20140306222417_create_tournament_user_pairs.rb
@@ -0,0 +1,10 @@
+class CreateTournamentUserPairs < ActiveRecord::Migration
+ def change
+ create_table :tournament_user_pairs do |t|
+ t.references :tournament, index: true
+ t.references :user, index: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20140306024731_create_user_team_pairs.rb b/db/migrate/20140306222422_create_user_team_pairs.rb
index 2c492ac..2c492ac 100644
--- a/db/migrate/20140306024731_create_user_team_pairs.rb
+++ b/db/migrate/20140306222422_create_user_team_pairs.rb
diff --git a/db/migrate/20140306024733_create_team_match_pairs.rb b/db/migrate/20140306222427_create_team_match_pairs.rb
index 8fac07e..8fac07e 100644
--- a/db/migrate/20140306024733_create_team_match_pairs.rb
+++ b/db/migrate/20140306222427_create_team_match_pairs.rb
diff --git a/db/migrate/20140306024744_add_hidden_attrs_to_user.rb b/db/migrate/20140306222447_add_hidden_attrs_to_user.rb
index 2f1b0b2..2f1b0b2 100644
--- a/db/migrate/20140306024744_add_hidden_attrs_to_user.rb
+++ b/db/migrate/20140306222447_add_hidden_attrs_to_user.rb
diff --git a/db/schema.rb b/db/schema.rb
index b0d0766..eadf24e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140306024744) do
+ActiveRecord::Schema.define(version: 20140306222447) do
create_table "alerts", force: true do |t|
t.integer "author_id"
@@ -22,22 +22,22 @@ ActiveRecord::Schema.define(version: 20140306024744) do
add_index "alerts", ["author_id"], name: "index_alerts_on_author_id"
- create_table "game_attributes", force: true do |t|
- t.integer "game_id"
- t.text "key"
- t.integer "type"
+ create_table "game_options", force: true do |t|
+ t.integer "vartype"
+ t.string "name"
+ t.text "default"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "game_attributes", ["game_id"], name: "index_game_attributes_on_game_id"
-
create_table "games", force: true do |t|
t.text "name"
- t.integer "players_per_team"
- t.integer "teams_per_match"
+ t.integer "min_players_per_team"
+ t.integer "max_players_per_team"
+ t.integer "min_teams_per_match"
+ t.integer "max_teams_per_match"
t.integer "set_rounds"
- t.integer "randomized_teams"
+ t.boolean "randomized_teams"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -62,6 +62,17 @@ ActiveRecord::Schema.define(version: 20140306024744) do
add_index "pms", ["author_id"], name: "index_pms_on_author_id"
add_index "pms", ["recipient_id"], name: "index_pms_on_recipient_id"
+ create_table "scores", force: true do |t|
+ t.integer "user_id"
+ t.integer "match_id"
+ t.integer "value"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "scores", ["match_id"], name: "index_scores_on_match_id"
+ add_index "scores", ["user_id"], name: "index_scores_on_user_id"
+
create_table "server_settings", force: true do |t|
t.datetime "created_at"
t.datetime "updated_at"
@@ -91,17 +102,43 @@ ActiveRecord::Schema.define(version: 20140306024744) do
add_index "team_match_pairs", ["team_id"], name: "index_team_match_pairs_on_team_id"
create_table "teams", force: true do |t|
+ t.integer "match_id"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "teams", ["match_id"], name: "index_teams_on_match_id"
+
create_table "tournament_options", force: true do |t|
+ t.integer "tournament_id"
+ t.integer "vartype"
+ t.string "name"
+ t.text "value"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "tournament_options", ["tournament_id"], name: "index_tournament_options_on_tournament_id"
+
+ create_table "tournament_user_pairs", force: true do |t|
+ t.integer "tournament_id"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "tournament_user_pairs", ["tournament_id"], name: "index_tournament_user_pairs_on_tournament_id"
+ add_index "tournament_user_pairs", ["user_id"], name: "index_tournament_user_pairs_on_user_id"
+
create_table "tournaments", force: true do |t|
t.integer "game_id"
+ t.integer "min_players_per_team"
+ t.integer "max_players_per_team"
+ t.integer "min_teams_per_match"
+ t.integer "max_teams_per_match"
+ t.integer "set_rounds"
+ t.boolean "randomized_teams"
+ t.integer "status"
t.datetime "created_at"
t.datetime "updated_at"
end
diff --git a/generate.sh b/generate.sh
index fcd962f..c6e63dd 100755
--- a/generate.sh
+++ b/generate.sh
@@ -18,21 +18,25 @@ git checkout clean-start -- app test config/routes.rb
# The whole shebang, models, views, and controllers
bundle exec rails generate scaffold server --force $NOTEST
-bundle exec rails generate scaffold tournament game:references $NOTEST
+bundle exec rails generate scaffold tournament game:references min_players_per_team:integer max_players_per_team:integer min_teams_per_match:integer max_teams_per_match:integer set_rounds:integer randomized_teams:boolean status:integer $NOTEST
bundle exec rails generate scaffold match tournament:references name:string --force $NOTEST
-bundle exec rails generate scaffold team $NOTEST
+bundle exec rails generate scaffold team match:references $NOTEST
bundle exec rails generate scaffold alert author:references message:text $NOTEST
bundle exec rails generate scaffold pm author:references recipient:references message:text $NOTEST
-bundle exec rails generate scaffold game name:text players_per_team:integer teams_per_match:integer set_rounds:integer randomized_teams:integer --force $NOTEST
+bundle exec rails generate scaffold game name:text min_players_per_team:integer max_players_per_team:integer min_teams_per_match:integer max_teams_per_match:integer set_rounds:integer randomized_teams:boolean --force $NOTEST
bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq
bundle exec rails generate scaffold session user:references
+
# Just models
-bundle exec rails generate model game_attribute game:references key:text type:integer $NOTEST
bundle exec rails generate model server_settings $NOTEST
+bundle exec rails generate model tournament_option tournament:references vartype:integer name:string value:text $NOTEST
+bundle exec rails generate model game_option vartype:integer name:string default:text $NOTEST
+bundle exec rails generate model score user:references match:references value:integer $NOTEST
+# Bridge Models
+bundle exec rails generate model tournament_user_pair tournament:references user:references $NOTEST
bundle exec rails generate model user_team_pair user:references team:references $NOTEST
bundle exec rails generate model team_match_pair team:references match:references $NOTEST
-bundle exec rails generate model tournament_option $NOTEST
# Just controllers
bundle exec rails generate controller search $NOTEST
diff --git a/test/controllers/games_controller_test.rb b/test/controllers/games_controller_test.rb
index 95c3145..b93feac 100644
--- a/test/controllers/games_controller_test.rb
+++ b/test/controllers/games_controller_test.rb
@@ -18,7 +18,7 @@ class GamesControllerTest < ActionController::TestCase
test "should create game" do
assert_difference('Game.count') do
- post :create, game: { name: @game.name, players_per_team: @game.players_per_team, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds, teams_per_match: @game.teams_per_match }
+ post :create, game: { max_players_per_team: @game.max_players_per_team, max_teams_per_match: @game.max_teams_per_match, min_players_per_team: @game.min_players_per_team, min_teams_per_match: @game.min_teams_per_match, name: @game.name, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds }
end
assert_redirected_to game_path(assigns(:game))
@@ -35,7 +35,7 @@ class GamesControllerTest < ActionController::TestCase
end
test "should update game" do
- patch :update, id: @game, game: { name: @game.name, players_per_team: @game.players_per_team, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds, teams_per_match: @game.teams_per_match }
+ patch :update, id: @game, game: { max_players_per_team: @game.max_players_per_team, max_teams_per_match: @game.max_teams_per_match, min_players_per_team: @game.min_players_per_team, min_teams_per_match: @game.min_teams_per_match, name: @game.name, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds }
assert_redirected_to game_path(assigns(:game))
end
diff --git a/test/controllers/teams_controller_test.rb b/test/controllers/teams_controller_test.rb
index 8bf60be..52f7c17 100644
--- a/test/controllers/teams_controller_test.rb
+++ b/test/controllers/teams_controller_test.rb
@@ -18,7 +18,7 @@ class TeamsControllerTest < ActionController::TestCase
test "should create team" do
assert_difference('Team.count') do
- post :create, team: { }
+ post :create, team: { match_id: @team.match_id }
end
assert_redirected_to team_path(assigns(:team))
@@ -35,7 +35,7 @@ class TeamsControllerTest < ActionController::TestCase
end
test "should update team" do
- patch :update, id: @team, team: { }
+ patch :update, id: @team, team: { match_id: @team.match_id }
assert_redirected_to team_path(assigns(:team))
end
diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb
index bdbbfac..02e578a 100644
--- a/test/controllers/tournaments_controller_test.rb
+++ b/test/controllers/tournaments_controller_test.rb
@@ -18,7 +18,7 @@ class TournamentsControllerTest < ActionController::TestCase
test "should create tournament" do
assert_difference('Tournament.count') do
- post :create, tournament: { game_id: @tournament.game_id }
+ post :create, tournament: { game_id: @tournament.game_id, max_players_per_team: @tournament.max_players_per_team, max_teams_per_match: @tournament.max_teams_per_match, min_players_per_team: @tournament.min_players_per_team, min_teams_per_match: @tournament.min_teams_per_match, randomized_teams: @tournament.randomized_teams, set_rounds: @tournament.set_rounds, status: @tournament.status }
end
assert_redirected_to tournament_path(assigns(:tournament))
@@ -35,7 +35,7 @@ class TournamentsControllerTest < ActionController::TestCase
end
test "should update tournament" do
- patch :update, id: @tournament, tournament: { game_id: @tournament.game_id }
+ patch :update, id: @tournament, tournament: { game_id: @tournament.game_id, max_players_per_team: @tournament.max_players_per_team, max_teams_per_match: @tournament.max_teams_per_match, min_players_per_team: @tournament.min_players_per_team, min_teams_per_match: @tournament.min_teams_per_match, randomized_teams: @tournament.randomized_teams, set_rounds: @tournament.set_rounds, status: @tournament.status }
assert_redirected_to tournament_path(assigns(:tournament))
end
diff --git a/test/fixtures/game_options.yml b/test/fixtures/game_options.yml
new file mode 100644
index 0000000..eb4760a
--- /dev/null
+++ b/test/fixtures/game_options.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ vartype: 1
+ name: MyString
+ default: MyText
+
+two:
+ vartype: 1
+ name: MyString
+ default: MyText
diff --git a/test/fixtures/games.yml b/test/fixtures/games.yml
index 3068527..16f792e 100644
--- a/test/fixtures/games.yml
+++ b/test/fixtures/games.yml
@@ -2,14 +2,18 @@
one:
name: MyText
- players_per_team: 1
- teams_per_match: 1
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
set_rounds: 1
- randomized_teams: 1
+ randomized_teams: false
two:
name: MyText
- players_per_team: 1
- teams_per_match: 1
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
set_rounds: 1
- randomized_teams: 1
+ randomized_teams: false
diff --git a/test/fixtures/game_attributes.yml b/test/fixtures/scores.yml
index eff7212..26065df 100644
--- a/test/fixtures/game_attributes.yml
+++ b/test/fixtures/scores.yml
@@ -1,11 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- game_id:
- key: MyText
- type: 1
+ user_id:
+ match_id:
+ value: 1
two:
- game_id:
- key: MyText
- type: 1
+ user_id:
+ match_id:
+ value: 1
diff --git a/test/fixtures/teams.yml b/test/fixtures/teams.yml
index 937a0c0..4efc76e 100644
--- a/test/fixtures/teams.yml
+++ b/test/fixtures/teams.yml
@@ -1,11 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-# This model initially had no columns defined. If you add columns to the
-# model remove the '{}' from the fixture names and add the columns immediately
-# below each fixture, per the syntax in the comments below
-#
-one: {}
-# column: value
-#
-two: {}
-# column: value
+one:
+ match_id:
+
+two:
+ match_id:
diff --git a/test/fixtures/tournament_options.yml b/test/fixtures/tournament_options.yml
index 937a0c0..aa5eaef 100644
--- a/test/fixtures/tournament_options.yml
+++ b/test/fixtures/tournament_options.yml
@@ -1,11 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-# This model initially had no columns defined. If you add columns to the
-# model remove the '{}' from the fixture names and add the columns immediately
-# below each fixture, per the syntax in the comments below
-#
-one: {}
-# column: value
-#
-two: {}
-# column: value
+one:
+ tournament_id:
+ vartype: 1
+ name: MyString
+ value: MyText
+
+two:
+ tournament_id:
+ vartype: 1
+ name: MyString
+ value: MyText
diff --git a/test/fixtures/tournament_user_pairs.yml b/test/fixtures/tournament_user_pairs.yml
new file mode 100644
index 0000000..dbc4a88
--- /dev/null
+++ b/test/fixtures/tournament_user_pairs.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ tournament_id:
+ user_id:
+
+two:
+ tournament_id:
+ user_id:
diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml
index 4cba7ca..c58a1ed 100644
--- a/test/fixtures/tournaments.yml
+++ b/test/fixtures/tournaments.yml
@@ -2,6 +2,20 @@
one:
game_id:
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
+ set_rounds: 1
+ randomized_teams: false
+ status: 1
two:
game_id:
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
+ set_rounds: 1
+ randomized_teams: false
+ status: 1
diff --git a/test/models/game_attribute_test.rb b/test/models/game_option_test.rb
index 13c6e65..1ae5701 100644
--- a/test/models/game_attribute_test.rb
+++ b/test/models/game_option_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class GameAttributeTest < ActiveSupport::TestCase
+class GameOptionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
diff --git a/test/models/score_test.rb b/test/models/score_test.rb
new file mode 100644
index 0000000..d38cb0a
--- /dev/null
+++ b/test/models/score_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ScoreTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/tournament_user_pair_test.rb b/test/models/tournament_user_pair_test.rb
new file mode 100644
index 0000000..c8d1789
--- /dev/null
+++ b/test/models/tournament_user_pair_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class TournamentUserPairTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end