diff options
-rw-r--r-- | app/controllers/matches_controller.rb | 2 | ||||
-rw-r--r-- | app/views/matches/_form.html.erb | 4 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 3 | ||||
-rw-r--r-- | app/views/matches/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/matches/show.json.jbuilder | 2 | ||||
-rw-r--r-- | db/migrate/20140325214513_create_servers.rb (renamed from db/migrate/20140325202820_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214516_create_matches.rb (renamed from db/migrate/20140325202823_create_matches.rb) | 1 | ||||
-rw-r--r-- | db/migrate/20140325214518_create_teams.rb (renamed from db/migrate/20140325202826_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214521_create_alerts.rb (renamed from db/migrate/20140325202828_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214523_create_pms.rb (renamed from db/migrate/20140325202831_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214525_create_tournaments.rb (renamed from db/migrate/20140325202833_create_tournaments.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214528_create_games.rb (renamed from db/migrate/20140325202836_create_games.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214531_create_users.rb (renamed from db/migrate/20140325202838_create_users.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214533_create_sessions.rb (renamed from db/migrate/20140325202841_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214536_create_server_settings.rb (renamed from db/migrate/20140325202843_create_server_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214538_create_tournament_options.rb (renamed from db/migrate/20140325202846_create_tournament_options.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214540_create_game_settings.rb (renamed from db/migrate/20140325202848_create_game_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214543_create_scores.rb (renamed from db/migrate/20140325202850_create_scores.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214545_create_tournament_players_join_table.rb (renamed from db/migrate/20140325202853_create_tournament_players_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214548_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140325202855_create_tournament_hosts_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214550_create_team_user_join_table.rb (renamed from db/migrate/20140325202858_create_team_user_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214553_create_match_team_join_table.rb (renamed from db/migrate/20140325202900_create_match_team_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140325214602_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140325202910_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/matches_controller_test.rb | 4 | ||||
-rw-r--r-- | test/fixtures/matches.yml | 2 |
28 files changed, 23 insertions, 7 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 1f0d964..b312e9e 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -72,6 +72,6 @@ class MatchesController < ApplicationController end # Never trust parameters from the scary internet, only allow the white list through. def match_params - params.require(:match).permit(:tournament_id, :name, :winner_id) + params.require(:match).permit(:status, :tournament_id, :name, :winner_id) end end diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 015aed0..3efb566 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,6 +1,10 @@ <%= form_for([@tournament, @tournament.matches.build]) do |f| %> <div class="field"> + <%= f.label :status %><br> + <%= f.number_field :status %> + </div> + <div class="field"> <%= f.label :tournament_id %><br> <%= f.text_field :tournament_id %> </div> diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 60df1b5..d862d57 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -3,6 +3,7 @@ <table> <thead> <tr> + <th>Status</th> <th>Tournament</th> <th>Name</th> <th>Winner</th> @@ -16,6 +17,8 @@ <% @tournament.matches.each do |match| %> <tr> <td><%= match.tournament.id %></td> + <td><%= match.status %></td> + <td><%= match.tournament %></td> <td><%= match.name %></td> <td><%= match.winner %></td> <td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 0b2bfcd..1a63f5f 100644 --- a/app/views/matches/index.json.jbuilder +++ b/app/views/matches/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@matches) do |match| - json.extract! match, :id, :tournament_id, :name, :winner_id + json.extract! match, :id, :status, :tournament_id, :name, :winner_id json.url match_url(match, format: :json) end diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index b6930ea..6b962ad 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,4 +1,9 @@ <p> + <strong>Status:</strong> + <%= @match.status %> +</p> + +<p> <strong>Tournament:</strong> <%= @match.tournament.id %> </p> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index fe14010..a3ef588 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at +json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at diff --git a/db/migrate/20140325202820_create_servers.rb b/db/migrate/20140325214513_create_servers.rb index f33241a..f33241a 100644 --- a/db/migrate/20140325202820_create_servers.rb +++ b/db/migrate/20140325214513_create_servers.rb diff --git a/db/migrate/20140325202823_create_matches.rb b/db/migrate/20140325214516_create_matches.rb index 67a5b7b..30949a8 100644 --- a/db/migrate/20140325202823_create_matches.rb +++ b/db/migrate/20140325214516_create_matches.rb @@ -1,6 +1,7 @@ class CreateMatches < ActiveRecord::Migration def change create_table :matches do |t| + t.integer :status t.references :tournament, index: true t.string :name t.references :winner, index: true diff --git a/db/migrate/20140325202826_create_teams.rb b/db/migrate/20140325214518_create_teams.rb index fdf9a68..fdf9a68 100644 --- a/db/migrate/20140325202826_create_teams.rb +++ b/db/migrate/20140325214518_create_teams.rb diff --git a/db/migrate/20140325202828_create_alerts.rb b/db/migrate/20140325214521_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140325202828_create_alerts.rb +++ b/db/migrate/20140325214521_create_alerts.rb diff --git a/db/migrate/20140325202831_create_pms.rb b/db/migrate/20140325214523_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140325202831_create_pms.rb +++ b/db/migrate/20140325214523_create_pms.rb diff --git a/db/migrate/20140325202833_create_tournaments.rb b/db/migrate/20140325214525_create_tournaments.rb index c0d8929..c0d8929 100644 --- a/db/migrate/20140325202833_create_tournaments.rb +++ b/db/migrate/20140325214525_create_tournaments.rb diff --git a/db/migrate/20140325202836_create_games.rb b/db/migrate/20140325214528_create_games.rb index 5e4f56f..5e4f56f 100644 --- a/db/migrate/20140325202836_create_games.rb +++ b/db/migrate/20140325214528_create_games.rb diff --git a/db/migrate/20140325202838_create_users.rb b/db/migrate/20140325214531_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140325202838_create_users.rb +++ b/db/migrate/20140325214531_create_users.rb diff --git a/db/migrate/20140325202841_create_sessions.rb b/db/migrate/20140325214533_create_sessions.rb index fe25bf2..fe25bf2 100644 --- a/db/migrate/20140325202841_create_sessions.rb +++ b/db/migrate/20140325214533_create_sessions.rb diff --git a/db/migrate/20140325202843_create_server_settings.rb b/db/migrate/20140325214536_create_server_settings.rb index dfdd91b..dfdd91b 100644 --- a/db/migrate/20140325202843_create_server_settings.rb +++ b/db/migrate/20140325214536_create_server_settings.rb diff --git a/db/migrate/20140325202846_create_tournament_options.rb b/db/migrate/20140325214538_create_tournament_options.rb index 53b601c..53b601c 100644 --- a/db/migrate/20140325202846_create_tournament_options.rb +++ b/db/migrate/20140325214538_create_tournament_options.rb diff --git a/db/migrate/20140325202848_create_game_settings.rb b/db/migrate/20140325214540_create_game_settings.rb index 0ebbf18..0ebbf18 100644 --- a/db/migrate/20140325202848_create_game_settings.rb +++ b/db/migrate/20140325214540_create_game_settings.rb diff --git a/db/migrate/20140325202850_create_scores.rb b/db/migrate/20140325214543_create_scores.rb index 4ca0b0b..4ca0b0b 100644 --- a/db/migrate/20140325202850_create_scores.rb +++ b/db/migrate/20140325214543_create_scores.rb diff --git a/db/migrate/20140325202853_create_tournament_players_join_table.rb b/db/migrate/20140325214545_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140325202853_create_tournament_players_join_table.rb +++ b/db/migrate/20140325214545_create_tournament_players_join_table.rb diff --git a/db/migrate/20140325202855_create_tournament_hosts_join_table.rb b/db/migrate/20140325214548_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140325202855_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140325214548_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140325202858_create_team_user_join_table.rb b/db/migrate/20140325214550_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140325202858_create_team_user_join_table.rb +++ b/db/migrate/20140325214550_create_team_user_join_table.rb diff --git a/db/migrate/20140325202900_create_match_team_join_table.rb b/db/migrate/20140325214553_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140325202900_create_match_team_join_table.rb +++ b/db/migrate/20140325214553_create_match_team_join_table.rb diff --git a/db/migrate/20140325202910_add_hidden_attrs_to_user.rb b/db/migrate/20140325214602_add_hidden_attrs_to_user.rb index 2f1b0b2..2f1b0b2 100644 --- a/db/migrate/20140325202910_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140325214602_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index 952cb26..4704a45 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: 20140325202910) do +ActiveRecord::Schema.define(version: 20140325214602) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -54,6 +54,7 @@ ActiveRecord::Schema.define(version: 20140325202910) do end create_table "matches", force: true do |t| + t.integer "status" t.integer "tournament_id" t.string "name" t.integer "winner_id" diff --git a/generate.sh b/generate.sh index 1ff486f..2013703 100755 --- a/generate.sh +++ b/generate.sh @@ -18,7 +18,7 @@ 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 match tournament:references name:string winner:references --force $NOTEST +bundle exec rails generate scaffold match status:integer tournament:references name:string winner:references --force $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 diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb index 51b7f37..c3cc7a4 100644 --- a/test/controllers/matches_controller_test.rb +++ b/test/controllers/matches_controller_test.rb @@ -18,7 +18,7 @@ class MatchesControllerTest < ActionController::TestCase test "should create match" do assert_difference('Match.count') do - post :create, match: { name: @match.name, tournament_id: @match.tournament_id, winner_id: @match.winner_id } + post :create, match: { name: @match.name, status: @match.status, tournament_id: @match.tournament_id, winner_id: @match.winner_id } end assert_redirected_to match_path(assigns(:match)) @@ -35,7 +35,7 @@ class MatchesControllerTest < ActionController::TestCase end test "should update match" do - patch :update, id: @match, match: { name: @match.name, tournament_id: @match.tournament_id, winner_id: @match.winner_id } + patch :update, id: @match, match: { name: @match.name, status: @match.status, tournament_id: @match.tournament_id, winner_id: @match.winner_id } assert_redirected_to match_path(assigns(:match)) end diff --git a/test/fixtures/matches.yml b/test/fixtures/matches.yml index 956229c..00af9f5 100644 --- a/test/fixtures/matches.yml +++ b/test/fixtures/matches.yml @@ -1,11 +1,13 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: + status: 1 tournament_id: name: MyString winner_id: two: + status: 1 tournament_id: name: MyString winner_id: |