diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-25 16:30:13 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-25 16:30:13 -0400 |
commit | 4e754e04d6bd04267e5a55011aa9f4f2a2fc7859 (patch) | |
tree | 6e152c868457d24de16653e5a696cdd9518cf9d6 | |
parent | ecef4973baed5580e3b2500ce0a65def1132d172 (diff) |
Tournament has a NAME now
-rw-r--r-- | app/controllers/tournaments_controller.rb | 2 | ||||
-rw-r--r-- | app/views/tournaments/_form.html.erb | 4 | ||||
-rw-r--r-- | app/views/tournaments/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/tournaments/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/tournaments/show.json.jbuilder | 2 | ||||
-rw-r--r-- | db/migrate/20140325202820_create_servers.rb (renamed from db/migrate/20140325201020_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202823_create_matches.rb (renamed from db/migrate/20140325201022_create_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202826_create_teams.rb (renamed from db/migrate/20140325201025_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202828_create_alerts.rb (renamed from db/migrate/20140325201027_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202831_create_pms.rb (renamed from db/migrate/20140325201030_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202833_create_tournaments.rb (renamed from db/migrate/20140325201033_create_tournaments.rb) | 1 | ||||
-rw-r--r-- | db/migrate/20140325202836_create_games.rb (renamed from db/migrate/20140325201035_create_games.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202838_create_users.rb (renamed from db/migrate/20140325201038_create_users.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202841_create_sessions.rb (renamed from db/migrate/20140325201040_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202843_create_server_settings.rb (renamed from db/migrate/20140325201043_create_server_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202846_create_tournament_options.rb (renamed from db/migrate/20140325201045_create_tournament_options.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202848_create_game_settings.rb (renamed from db/migrate/20140325201047_create_game_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202850_create_scores.rb (renamed from db/migrate/20140325201050_create_scores.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202853_create_tournament_players_join_table.rb (renamed from db/migrate/20140325201052_create_tournament_players_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202855_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140325201055_create_tournament_hosts_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202858_create_team_user_join_table.rb (renamed from db/migrate/20140325201057_create_team_user_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202900_create_match_team_join_table.rb (renamed from db/migrate/20140325201059_create_match_team_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325202910_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140325201109_add_hidden_attrs_to_user.rb) | 0 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rwxr-xr-x | generate.sh | 2 | ||||
-rw-r--r-- | test/controllers/tournaments_controller_test.rb | 4 | ||||
-rw-r--r-- | test/fixtures/tournaments.yml | 2 |
28 files changed, 22 insertions, 7 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 571203c..d7db632 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -69,6 +69,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, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams) + params.require(:tournament).permit(:name, :game_id, :status, :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/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index d098cbb..38855a0 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -12,6 +12,10 @@ <% end %> <div class="field"> + <%= f.label :name %><br> + <%= f.text_field :name %> + </div> + <div class="field"> <%= f.label :game_id %><br> <%= f.text_field :game_id %> </div> diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index fb8b381..f8f21e7 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -3,6 +3,7 @@ <table> <thead> <tr> + <th>Name</th> <th>Game</th> <th>Status</th> <th>Min players per team</th> @@ -20,6 +21,7 @@ <tbody> <% @tournaments.each do |tournament| %> <tr> + <td><%= tournament.name %></td> <td><%= tournament.game %></td> <td><%= tournament.status %></td> <td><%= tournament.min_players_per_team %></td> diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder index e95c6a7..4038f04 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, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams + json.extract! tournament, :id, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams 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 208c6f4..3cb6179 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,6 +1,11 @@ <p id="notice"><%= notice %></p> <p> + <strong>Name:</strong> + <%= @tournament.name %> +</p> + +<p> <strong>Game:</strong> <%= @tournament.game %> </p> diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder index de2fbe0..27fd5c0 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at +json.extract! @tournament, :id, :name, :game_id, :status, :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/db/migrate/20140325201020_create_servers.rb b/db/migrate/20140325202820_create_servers.rb index f33241a..f33241a 100644 --- a/db/migrate/20140325201020_create_servers.rb +++ b/db/migrate/20140325202820_create_servers.rb diff --git a/db/migrate/20140325201022_create_matches.rb b/db/migrate/20140325202823_create_matches.rb index 67a5b7b..67a5b7b 100644 --- a/db/migrate/20140325201022_create_matches.rb +++ b/db/migrate/20140325202823_create_matches.rb diff --git a/db/migrate/20140325201025_create_teams.rb b/db/migrate/20140325202826_create_teams.rb index fdf9a68..fdf9a68 100644 --- a/db/migrate/20140325201025_create_teams.rb +++ b/db/migrate/20140325202826_create_teams.rb diff --git a/db/migrate/20140325201027_create_alerts.rb b/db/migrate/20140325202828_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140325201027_create_alerts.rb +++ b/db/migrate/20140325202828_create_alerts.rb diff --git a/db/migrate/20140325201030_create_pms.rb b/db/migrate/20140325202831_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140325201030_create_pms.rb +++ b/db/migrate/20140325202831_create_pms.rb diff --git a/db/migrate/20140325201033_create_tournaments.rb b/db/migrate/20140325202833_create_tournaments.rb index 545e603..c0d8929 100644 --- a/db/migrate/20140325201033_create_tournaments.rb +++ b/db/migrate/20140325202833_create_tournaments.rb @@ -1,6 +1,7 @@ class CreateTournaments < ActiveRecord::Migration def change create_table :tournaments do |t| + t.string :name t.references :game, index: true t.integer :status t.integer :min_players_per_team diff --git a/db/migrate/20140325201035_create_games.rb b/db/migrate/20140325202836_create_games.rb index 5e4f56f..5e4f56f 100644 --- a/db/migrate/20140325201035_create_games.rb +++ b/db/migrate/20140325202836_create_games.rb diff --git a/db/migrate/20140325201038_create_users.rb b/db/migrate/20140325202838_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140325201038_create_users.rb +++ b/db/migrate/20140325202838_create_users.rb diff --git a/db/migrate/20140325201040_create_sessions.rb b/db/migrate/20140325202841_create_sessions.rb index fe25bf2..fe25bf2 100644 --- a/db/migrate/20140325201040_create_sessions.rb +++ b/db/migrate/20140325202841_create_sessions.rb diff --git a/db/migrate/20140325201043_create_server_settings.rb b/db/migrate/20140325202843_create_server_settings.rb index dfdd91b..dfdd91b 100644 --- a/db/migrate/20140325201043_create_server_settings.rb +++ b/db/migrate/20140325202843_create_server_settings.rb diff --git a/db/migrate/20140325201045_create_tournament_options.rb b/db/migrate/20140325202846_create_tournament_options.rb index 53b601c..53b601c 100644 --- a/db/migrate/20140325201045_create_tournament_options.rb +++ b/db/migrate/20140325202846_create_tournament_options.rb diff --git a/db/migrate/20140325201047_create_game_settings.rb b/db/migrate/20140325202848_create_game_settings.rb index 0ebbf18..0ebbf18 100644 --- a/db/migrate/20140325201047_create_game_settings.rb +++ b/db/migrate/20140325202848_create_game_settings.rb diff --git a/db/migrate/20140325201050_create_scores.rb b/db/migrate/20140325202850_create_scores.rb index 4ca0b0b..4ca0b0b 100644 --- a/db/migrate/20140325201050_create_scores.rb +++ b/db/migrate/20140325202850_create_scores.rb diff --git a/db/migrate/20140325201052_create_tournament_players_join_table.rb b/db/migrate/20140325202853_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140325201052_create_tournament_players_join_table.rb +++ b/db/migrate/20140325202853_create_tournament_players_join_table.rb diff --git a/db/migrate/20140325201055_create_tournament_hosts_join_table.rb b/db/migrate/20140325202855_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140325201055_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140325202855_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140325201057_create_team_user_join_table.rb b/db/migrate/20140325202858_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140325201057_create_team_user_join_table.rb +++ b/db/migrate/20140325202858_create_team_user_join_table.rb diff --git a/db/migrate/20140325201059_create_match_team_join_table.rb b/db/migrate/20140325202900_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140325201059_create_match_team_join_table.rb +++ b/db/migrate/20140325202900_create_match_team_join_table.rb diff --git a/db/migrate/20140325201109_add_hidden_attrs_to_user.rb b/db/migrate/20140325202910_add_hidden_attrs_to_user.rb index 2f1b0b2..2f1b0b2 100644 --- a/db/migrate/20140325201109_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140325202910_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index 0394946..952cb26 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: 20140325201109) do +ActiveRecord::Schema.define(version: 20140325202910) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -139,6 +139,7 @@ ActiveRecord::Schema.define(version: 20140325201109) do add_index "tournament_options", ["tournament_id"], name: "index_tournament_options_on_tournament_id" create_table "tournaments", force: true do |t| + t.string "name" t.integer "game_id" t.integer "status" t.integer "min_players_per_team" diff --git a/generate.sh b/generate.sh index 5079abd..1ff486f 100755 --- a/generate.sh +++ b/generate.sh @@ -22,7 +22,7 @@ bundle exec rails generate scaffold match tournament:references name:string winn 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 tournament game:references status:integer \ +bundle exec rails generate scaffold tournament name:string:unique game:references status:integer \ 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 diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 02e578a..d5ab2af 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, 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 } + 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, name: @tournament.name, 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, 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 } + 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, name: @tournament.name, 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/tournaments.yml b/test/fixtures/tournaments.yml index 27c92f9..89edc9f 100644 --- a/test/fixtures/tournaments.yml +++ b/test/fixtures/tournaments.yml @@ -1,6 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: + name: MyString game_id: status: 1 min_players_per_team: 1 @@ -11,6 +12,7 @@ one: randomized_teams: false two: + name: MyString game_id: status: 1 min_players_per_team: 1 |