From fefe3f469243d6c932c256cc8798bae35e4ff1c4 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 2 Mar 2014 21:10:49 -0500 Subject: Added Tournament Name. --- app/controllers/matches_controller.rb | 2 +- app/views/matches/_form.html.erb | 4 ++++ app/views/matches/index.html.erb | 2 ++ app/views/matches/index.json.jbuilder | 2 +- app/views/matches/show.html.erb | 5 +++++ app/views/matches/show.json.jbuilder | 2 +- db/migrate/20140304020531_create_servers.rb | 8 -------- db/migrate/20140304020533_create_tournaments.rb | 9 --------- db/migrate/20140304020536_create_matches.rb | 9 --------- db/migrate/20140304020538_create_teams.rb | 8 -------- db/migrate/20140304020545_create_users.rb | 11 ----------- db/migrate/20140304020547_create_user_team_pairs.rb | 10 ---------- db/migrate/20140304020549_create_team_match_pairs.rb | 10 ---------- db/migrate/20140304020551_create_alerts.rb | 10 ---------- db/migrate/20140304020554_create_pms.rb | 11 ----------- db/migrate/20140304020556_create_games.rb | 13 ------------- db/migrate/20140304020558_create_game_attributes.rb | 11 ----------- db/migrate/20140304020601_create_server_settings.rb | 8 -------- db/migrate/20140304020609_create_tournament_options.rb | 8 -------- db/migrate/20140304020709_create_servers.rb | 8 ++++++++ db/migrate/20140304020711_create_tournaments.rb | 9 +++++++++ db/migrate/20140304020713_create_matches.rb | 10 ++++++++++ db/migrate/20140304020716_create_teams.rb | 8 ++++++++ db/migrate/20140304020722_create_users.rb | 11 +++++++++++ db/migrate/20140304020724_create_user_team_pairs.rb | 10 ++++++++++ db/migrate/20140304020727_create_team_match_pairs.rb | 10 ++++++++++ db/migrate/20140304020729_create_alerts.rb | 10 ++++++++++ db/migrate/20140304020731_create_pms.rb | 11 +++++++++++ db/migrate/20140304020733_create_games.rb | 13 +++++++++++++ db/migrate/20140304020736_create_game_attributes.rb | 11 +++++++++++ db/migrate/20140304020738_create_server_settings.rb | 8 ++++++++ db/migrate/20140304020747_create_tournament_options.rb | 8 ++++++++ db/schema.rb | 3 ++- generate.sh | 2 +- spec/views/matches/edit.html.erb_spec.rb | 4 +++- spec/views/matches/index.html.erb_spec.rb | 7 +++++-- spec/views/matches/new.html.erb_spec.rb | 4 +++- spec/views/matches/show.html.erb_spec.rb | 4 +++- 38 files changed, 158 insertions(+), 136 deletions(-) delete mode 100644 db/migrate/20140304020531_create_servers.rb delete mode 100644 db/migrate/20140304020533_create_tournaments.rb delete mode 100644 db/migrate/20140304020536_create_matches.rb delete mode 100644 db/migrate/20140304020538_create_teams.rb delete mode 100644 db/migrate/20140304020545_create_users.rb delete mode 100644 db/migrate/20140304020547_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304020549_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304020551_create_alerts.rb delete mode 100644 db/migrate/20140304020554_create_pms.rb delete mode 100644 db/migrate/20140304020556_create_games.rb delete mode 100644 db/migrate/20140304020558_create_game_attributes.rb delete mode 100644 db/migrate/20140304020601_create_server_settings.rb delete mode 100644 db/migrate/20140304020609_create_tournament_options.rb create mode 100644 db/migrate/20140304020709_create_servers.rb create mode 100644 db/migrate/20140304020711_create_tournaments.rb create mode 100644 db/migrate/20140304020713_create_matches.rb create mode 100644 db/migrate/20140304020716_create_teams.rb create mode 100644 db/migrate/20140304020722_create_users.rb create mode 100644 db/migrate/20140304020724_create_user_team_pairs.rb create mode 100644 db/migrate/20140304020727_create_team_match_pairs.rb create mode 100644 db/migrate/20140304020729_create_alerts.rb create mode 100644 db/migrate/20140304020731_create_pms.rb create mode 100644 db/migrate/20140304020733_create_games.rb create mode 100644 db/migrate/20140304020736_create_game_attributes.rb create mode 100644 db/migrate/20140304020738_create_server_settings.rb create mode 100644 db/migrate/20140304020747_create_tournament_options.rb diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index e9f3c5a..984be3f 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -69,6 +69,6 @@ class MatchesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def match_params - params.require(:match).permit(:tournament_id) + params.require(:match).permit(:tournament_id, :name) end end diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 34494c3..c5f1ba8 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -15,6 +15,10 @@ <%= f.label :tournament_id %>
<%= f.text_field :tournament_id %> +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
<%= f.submit %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index d8122ac..0742770 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -4,6 +4,7 @@ Tournament + Name @@ -14,6 +15,7 @@ <% @matches.each do |match| %> <%= match.tournament %> + <%= match.name %> <%= link_to 'Show', match %> <%= link_to 'Edit', edit_match_path(match) %> <%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index c8ada7a..08ae0ef 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 + json.extract! match, :id, :tournament_id, :name 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 7bab721..0b02ae7 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -5,5 +5,10 @@ <%= @match.tournament %>

+

+ Name: + <%= @match.name %> +

+ <%= link_to 'Edit', edit_match_path(@match) %> | <%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index 2e45395..128550f 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :name, :created_at, :updated_at diff --git a/db/migrate/20140304020531_create_servers.rb b/db/migrate/20140304020531_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304020531_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020533_create_tournaments.rb b/db/migrate/20140304020533_create_tournaments.rb deleted file mode 100644 index 36fcf7e..0000000 --- a/db/migrate/20140304020533_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/20140304020536_create_matches.rb b/db/migrate/20140304020536_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304020536_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020538_create_teams.rb b/db/migrate/20140304020538_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304020538_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020545_create_users.rb b/db/migrate/20140304020545_create_users.rb deleted file mode 100644 index f0986d4..0000000 --- a/db/migrate/20140304020545_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.string :name - t.string :email - t.string :user_name - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020547_create_user_team_pairs.rb b/db/migrate/20140304020547_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304020547_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020549_create_team_match_pairs.rb b/db/migrate/20140304020549_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304020549_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020551_create_alerts.rb b/db/migrate/20140304020551_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304020551_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020554_create_pms.rb b/db/migrate/20140304020554_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304020554_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020556_create_games.rb b/db/migrate/20140304020556_create_games.rb deleted file mode 100644 index 59d4ef0..0000000 --- a/db/migrate/20140304020556_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/20140304020558_create_game_attributes.rb b/db/migrate/20140304020558_create_game_attributes.rb deleted file mode 100644 index b63f134..0000000 --- a/db/migrate/20140304020558_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/20140304020601_create_server_settings.rb b/db/migrate/20140304020601_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304020601_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020609_create_tournament_options.rb b/db/migrate/20140304020609_create_tournament_options.rb deleted file mode 100644 index d2df22e..0000000 --- a/db/migrate/20140304020609_create_tournament_options.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentOptions < ActiveRecord::Migration - def change - create_table :tournament_options do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304020709_create_servers.rb b/db/migrate/20140304020709_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304020709_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020711_create_tournaments.rb b/db/migrate/20140304020711_create_tournaments.rb new file mode 100644 index 0000000..36fcf7e --- /dev/null +++ b/db/migrate/20140304020711_create_tournaments.rb @@ -0,0 +1,9 @@ +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/20140304020713_create_matches.rb b/db/migrate/20140304020713_create_matches.rb new file mode 100644 index 0000000..325863d --- /dev/null +++ b/db/migrate/20140304020713_create_matches.rb @@ -0,0 +1,10 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020716_create_teams.rb b/db/migrate/20140304020716_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304020716_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020722_create_users.rb b/db/migrate/20140304020722_create_users.rb new file mode 100644 index 0000000..f0986d4 --- /dev/null +++ b/db/migrate/20140304020722_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :user_name + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020724_create_user_team_pairs.rb b/db/migrate/20140304020724_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304020724_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020727_create_team_match_pairs.rb b/db/migrate/20140304020727_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304020727_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020729_create_alerts.rb b/db/migrate/20140304020729_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304020729_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020731_create_pms.rb b/db/migrate/20140304020731_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304020731_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020733_create_games.rb b/db/migrate/20140304020733_create_games.rb new file mode 100644 index 0000000..59d4ef0 --- /dev/null +++ b/db/migrate/20140304020733_create_games.rb @@ -0,0 +1,13 @@ +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/20140304020736_create_game_attributes.rb b/db/migrate/20140304020736_create_game_attributes.rb new file mode 100644 index 0000000..b63f134 --- /dev/null +++ b/db/migrate/20140304020736_create_game_attributes.rb @@ -0,0 +1,11 @@ +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/20140304020738_create_server_settings.rb b/db/migrate/20140304020738_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304020738_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304020747_create_tournament_options.rb b/db/migrate/20140304020747_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304020747_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 847a686..9069230 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: 20140304020609) do +ActiveRecord::Schema.define(version: 20140304020747) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20140304020609) do create_table "matches", force: true do |t| t.integer "tournament_id" + t.string "name" t.datetime "created_at" t.datetime "updated_at" end diff --git a/generate.sh b/generate.sh index ea96b9b..336ea5b 100755 --- a/generate.sh +++ b/generate.sh @@ -15,7 +15,7 @@ NOTEST='--skip-test-unit' set -x bundle exec rails generate scaffold server --force $NOTEST bundle exec rails generate scaffold tournament game:references --force $NOTEST -bundle exec rails generate scaffold match tournament:references --force $NOTEST +bundle exec rails generate scaffold match tournament:references name:string --force $NOTEST bundle exec rails generate scaffold team $NOTEST bundle exec rails generate controller users $NOTEST bundle exec rails generate controller Sessions diff --git a/spec/views/matches/edit.html.erb_spec.rb b/spec/views/matches/edit.html.erb_spec.rb index 0f7c673..fca468f 100644 --- a/spec/views/matches/edit.html.erb_spec.rb +++ b/spec/views/matches/edit.html.erb_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' describe "matches/edit" do before(:each) do @match = assign(:match, stub_model(Match, - :tournament => nil + :tournament => nil, + :name => "MyString" )) end @@ -13,6 +14,7 @@ describe "matches/edit" do # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form[action=?][method=?]", match_path(@match), "post" do assert_select "input#match_tournament[name=?]", "match[tournament]" + assert_select "input#match_name[name=?]", "match[name]" end end end diff --git a/spec/views/matches/index.html.erb_spec.rb b/spec/views/matches/index.html.erb_spec.rb index e920f16..d3be1b5 100644 --- a/spec/views/matches/index.html.erb_spec.rb +++ b/spec/views/matches/index.html.erb_spec.rb @@ -4,10 +4,12 @@ describe "matches/index" do before(:each) do assign(:matches, [ stub_model(Match, - :tournament => nil + :tournament => nil, + :name => "Name" ), stub_model(Match, - :tournament => nil + :tournament => nil, + :name => "Name" ) ]) end @@ -16,5 +18,6 @@ describe "matches/index" do render # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "tr>td", :text => nil.to_s, :count => 2 + assert_select "tr>td", :text => "Name".to_s, :count => 2 end end diff --git a/spec/views/matches/new.html.erb_spec.rb b/spec/views/matches/new.html.erb_spec.rb index c3537dc..4423d2c 100644 --- a/spec/views/matches/new.html.erb_spec.rb +++ b/spec/views/matches/new.html.erb_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' describe "matches/new" do before(:each) do assign(:match, stub_model(Match, - :tournament => nil + :tournament => nil, + :name => "MyString" ).as_new_record) end @@ -13,6 +14,7 @@ describe "matches/new" do # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form[action=?][method=?]", matches_path, "post" do assert_select "input#match_tournament[name=?]", "match[tournament]" + assert_select "input#match_name[name=?]", "match[name]" end end end diff --git a/spec/views/matches/show.html.erb_spec.rb b/spec/views/matches/show.html.erb_spec.rb index 4460feb..642119d 100644 --- a/spec/views/matches/show.html.erb_spec.rb +++ b/spec/views/matches/show.html.erb_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' describe "matches/show" do before(:each) do @match = assign(:match, stub_model(Match, - :tournament => nil + :tournament => nil, + :name => "Name" )) end @@ -11,5 +12,6 @@ describe "matches/show" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(//) + rendered.should match(/Name/) end end -- cgit v1.2.3-2-g168b