From c1f714a479eb7ca9e9125e283361a471dd928278 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Fri, 7 Mar 2014 00:25:38 -0500 Subject: Merge branch 'clean' Conflicts: app/models/match.rb app/views/matches/index.html.erb app/views/matches/show.html.erb db/migrate/20140304043618_create_servers.rb db/migrate/20140304043622_create_matches.rb db/migrate/20140304043624_create_teams.rb db/migrate/20140304043626_create_alerts.rb db/migrate/20140304043629_create_pms.rb db/migrate/20140304043633_create_users.rb db/migrate/20140304043637_create_server_settings.rb db/migrate/20140304043700_create_tournament_options.rb db/migrate/20140307045916_create_servers.rb db/migrate/20140307045922_create_matches.rb db/migrate/20140307045927_create_teams.rb db/migrate/20140307045934_create_alerts.rb db/migrate/20140307045941_create_pms.rb db/migrate/20140307050001_create_users.rb db/migrate/20140307050016_create_server_settings.rb db/migrate/20140307050023_create_tournament_options.rb db/migrate/20140307051752_create_servers.rb db/migrate/20140307051756_create_tournaments.rb db/migrate/20140307051800_create_matches.rb db/migrate/20140307051804_create_teams.rb db/migrate/20140307051808_create_alerts.rb db/migrate/20140307051812_create_pms.rb db/migrate/20140307051816_create_games.rb db/migrate/20140307051820_create_users.rb db/migrate/20140307051824_create_game_attributes.rb db/migrate/20140307051827_create_server_settings.rb db/migrate/20140307051831_create_user_team_pairs.rb db/migrate/20140307051835_create_team_match_pairs.rb db/migrate/20140307051853_add_index_to_users_email.rb db/migrate/20140307051857_add_index_to_users_user_name.rb db/migrate/20140307051901_add_password_digest_to_users.rb db/migrate/20140307051904_add_remember_token_to_users.rb db/migrate/20140307051908_create_tournament_options.rb db/schema.rb generate.sh --- app/controllers/matches_controller.rb | 2 +- app/models/match.rb | 1 + 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/20140307045916_create_servers.rb | 8 -------- db/migrate/20140307045922_create_matches.rb | 10 ---------- db/migrate/20140307045927_create_teams.rb | 9 --------- db/migrate/20140307045934_create_alerts.rb | 10 ---------- db/migrate/20140307045941_create_pms.rb | 11 ----------- db/migrate/20140307045948_create_tournaments.rb | 16 ---------------- db/migrate/20140307045954_create_games.rb | 15 --------------- db/migrate/20140307050001_create_users.rb | 13 ------------- db/migrate/20140307050008_create_sessions.rb | 9 --------- db/migrate/20140307050016_create_server_settings.rb | 8 -------- db/migrate/20140307050023_create_tournament_options.rb | 12 ------------ db/migrate/20140307050029_create_game_options.rb | 11 ----------- db/migrate/20140307050035_create_scores.rb | 11 ----------- ...0140307050041_create_tournament_players_join_table.rb | 8 -------- .../20140307050046_create_tournament_hosts_join_table.rb | 8 -------- db/migrate/20140307050052_create_team_user_join_table.rb | 8 -------- .../20140307050059_create_match_team_join_table.rb | 8 -------- db/migrate/20140307050124_add_hidden_attrs_to_user.rb | 8 -------- db/migrate/20140307052327_create_servers.rb | 8 ++++++++ db/migrate/20140307052331_create_matches.rb | 11 +++++++++++ db/migrate/20140307052334_create_teams.rb | 9 +++++++++ db/migrate/20140307052338_create_alerts.rb | 10 ++++++++++ db/migrate/20140307052342_create_pms.rb | 11 +++++++++++ db/migrate/20140307052346_create_tournaments.rb | 16 ++++++++++++++++ db/migrate/20140307052350_create_games.rb | 15 +++++++++++++++ db/migrate/20140307052354_create_users.rb | 13 +++++++++++++ db/migrate/20140307052358_create_sessions.rb | 9 +++++++++ db/migrate/20140307052402_create_server_settings.rb | 8 ++++++++ db/migrate/20140307052405_create_tournament_options.rb | 12 ++++++++++++ db/migrate/20140307052409_create_game_options.rb | 11 +++++++++++ db/migrate/20140307052413_create_scores.rb | 11 +++++++++++ ...0140307052417_create_tournament_players_join_table.rb | 8 ++++++++ .../20140307052421_create_tournament_hosts_join_table.rb | 8 ++++++++ db/migrate/20140307052424_create_team_user_join_table.rb | 8 ++++++++ .../20140307052428_create_match_team_join_table.rb | 8 ++++++++ db/migrate/20140307052443_add_hidden_attrs_to_user.rb | 8 ++++++++ db/schema.rb | 4 +++- generate.sh | 2 +- test/controllers/matches_controller_test.rb | 4 ++-- test/fixtures/matches.yml | 2 ++ 47 files changed, 207 insertions(+), 190 deletions(-) delete mode 100644 db/migrate/20140307045916_create_servers.rb delete mode 100644 db/migrate/20140307045922_create_matches.rb delete mode 100644 db/migrate/20140307045927_create_teams.rb delete mode 100644 db/migrate/20140307045934_create_alerts.rb delete mode 100644 db/migrate/20140307045941_create_pms.rb delete mode 100644 db/migrate/20140307045948_create_tournaments.rb delete mode 100644 db/migrate/20140307045954_create_games.rb delete mode 100644 db/migrate/20140307050001_create_users.rb delete mode 100644 db/migrate/20140307050008_create_sessions.rb delete mode 100644 db/migrate/20140307050016_create_server_settings.rb delete mode 100644 db/migrate/20140307050023_create_tournament_options.rb delete mode 100644 db/migrate/20140307050029_create_game_options.rb delete mode 100644 db/migrate/20140307050035_create_scores.rb delete mode 100644 db/migrate/20140307050041_create_tournament_players_join_table.rb delete mode 100644 db/migrate/20140307050046_create_tournament_hosts_join_table.rb delete mode 100644 db/migrate/20140307050052_create_team_user_join_table.rb delete mode 100644 db/migrate/20140307050059_create_match_team_join_table.rb delete mode 100644 db/migrate/20140307050124_add_hidden_attrs_to_user.rb create mode 100644 db/migrate/20140307052327_create_servers.rb create mode 100644 db/migrate/20140307052331_create_matches.rb create mode 100644 db/migrate/20140307052334_create_teams.rb create mode 100644 db/migrate/20140307052338_create_alerts.rb create mode 100644 db/migrate/20140307052342_create_pms.rb create mode 100644 db/migrate/20140307052346_create_tournaments.rb create mode 100644 db/migrate/20140307052350_create_games.rb create mode 100644 db/migrate/20140307052354_create_users.rb create mode 100644 db/migrate/20140307052358_create_sessions.rb create mode 100644 db/migrate/20140307052402_create_server_settings.rb create mode 100644 db/migrate/20140307052405_create_tournament_options.rb create mode 100644 db/migrate/20140307052409_create_game_options.rb create mode 100644 db/migrate/20140307052413_create_scores.rb create mode 100644 db/migrate/20140307052417_create_tournament_players_join_table.rb create mode 100644 db/migrate/20140307052421_create_tournament_hosts_join_table.rb create mode 100644 db/migrate/20140307052424_create_team_user_join_table.rb create mode 100644 db/migrate/20140307052428_create_match_team_join_table.rb create mode 100644 db/migrate/20140307052443_add_hidden_attrs_to_user.rb diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 984be3f..8329da5 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, :name) + params.require(:match).permit(:tournament_id, :name, :winner_id) end end diff --git a/app/models/match.rb b/app/models/match.rb index 533435a..bb814c1 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,3 +1,4 @@ class Match < ActiveRecord::Base belongs_to :tournament + belongs_to :winner end diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index c5f1ba8..f1e6047 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -19,6 +19,10 @@ <%= f.label :name %>
<%= f.text_field :name %> +
+ <%= f.label :winner_id %>
+ <%= f.text_field :winner_id %> +
<%= f.submit %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 0742770..71db08c 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -5,6 +5,7 @@ Tournament Name + Winner @@ -16,6 +17,7 @@ <%= match.tournament %> <%= match.name %> + <%= match.winner %> <%= 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 08ae0ef..0b2bfcd 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 + json.extract! match, :id, :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 0b02ae7..3abb1f7 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -10,5 +10,10 @@ <%= @match.name %>

+

+ Winner: + <%= @match.winner %> +

+ <%= 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 128550f..fe14010 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :name, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at diff --git a/db/migrate/20140307045916_create_servers.rb b/db/migrate/20140307045916_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140307045916_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/20140307045922_create_matches.rb b/db/migrate/20140307045922_create_matches.rb deleted file mode 100644 index 325863d..0000000 --- a/db/migrate/20140307045922_create_matches.rb +++ /dev/null @@ -1,10 +0,0 @@ -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/20140307045927_create_teams.rb b/db/migrate/20140307045927_create_teams.rb deleted file mode 100644 index fdf9a68..0000000 --- a/db/migrate/20140307045927_create_teams.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140307045934_create_alerts.rb b/db/migrate/20140307045934_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140307045934_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/20140307045941_create_pms.rb b/db/migrate/20140307045941_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140307045941_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/20140307045948_create_tournaments.rb b/db/migrate/20140307045948_create_tournaments.rb deleted file mode 100644 index 545e603..0000000 --- a/db/migrate/20140307045948_create_tournaments.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - t.references :game, index: true - t.integer :status - 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/20140307045954_create_games.rb b/db/migrate/20140307045954_create_games.rb deleted file mode 100644 index 5e4f56f..0000000 --- a/db/migrate/20140307045954_create_games.rb +++ /dev/null @@ -1,15 +0,0 @@ -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/20140307050001_create_users.rb b/db/migrate/20140307050001_create_users.rb deleted file mode 100644 index 8032870..0000000 --- a/db/migrate/20140307050001_create_users.rb +++ /dev/null @@ -1,13 +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 - add_index :users, :email, unique: true - add_index :users, :user_name, unique: true - end -end diff --git a/db/migrate/20140307050008_create_sessions.rb b/db/migrate/20140307050008_create_sessions.rb deleted file mode 100644 index fe25bf2..0000000 --- a/db/migrate/20140307050008_create_sessions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateSessions < ActiveRecord::Migration - def change - create_table :sessions do |t| - t.references :user, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140307050016_create_server_settings.rb b/db/migrate/20140307050016_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140307050016_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/20140307050023_create_tournament_options.rb b/db/migrate/20140307050023_create_tournament_options.rb deleted file mode 100644 index 53b601c..0000000 --- a/db/migrate/20140307050023_create_tournament_options.rb +++ /dev/null @@ -1,12 +0,0 @@ -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 - end -end diff --git a/db/migrate/20140307050029_create_game_options.rb b/db/migrate/20140307050029_create_game_options.rb deleted file mode 100644 index 2f62ef7..0000000 --- a/db/migrate/20140307050029_create_game_options.rb +++ /dev/null @@ -1,11 +0,0 @@ -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/20140307050035_create_scores.rb b/db/migrate/20140307050035_create_scores.rb deleted file mode 100644 index 4ca0b0b..0000000 --- a/db/migrate/20140307050035_create_scores.rb +++ /dev/null @@ -1,11 +0,0 @@ -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/20140307050041_create_tournament_players_join_table.rb b/db/migrate/20140307050041_create_tournament_players_join_table.rb deleted file mode 100644 index be240e8..0000000 --- a/db/migrate/20140307050041_create_tournament_players_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentPlayersJoinTable < ActiveRecord::Migration - def change - create_join_table :players, :tournaments do |t| - # t.index [:player_id, :tournament_id] - # t.index [:tournament_id, :player_id] - end - end -end diff --git a/db/migrate/20140307050046_create_tournament_hosts_join_table.rb b/db/migrate/20140307050046_create_tournament_hosts_join_table.rb deleted file mode 100644 index 7521d89..0000000 --- a/db/migrate/20140307050046_create_tournament_hosts_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentHostsJoinTable < ActiveRecord::Migration - def change - create_join_table :hosts, :tournaments do |t| - # t.index [:host_id, :tournament_id] - # t.index [:tournament_id, :host_id] - end - end -end diff --git a/db/migrate/20140307050052_create_team_user_join_table.rb b/db/migrate/20140307050052_create_team_user_join_table.rb deleted file mode 100644 index f3b57fc..0000000 --- a/db/migrate/20140307050052_create_team_user_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeamUserJoinTable < ActiveRecord::Migration - def change - create_join_table :teams, :users do |t| - # t.index [:team_id, :user_id] - # t.index [:user_id, :team_id] - end - end -end diff --git a/db/migrate/20140307050059_create_match_team_join_table.rb b/db/migrate/20140307050059_create_match_team_join_table.rb deleted file mode 100644 index c2ed1b7..0000000 --- a/db/migrate/20140307050059_create_match_team_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateMatchTeamJoinTable < ActiveRecord::Migration - def change - create_join_table :matches, :teams do |t| - # t.index [:match_id, :team_id] - # t.index [:team_id, :match_id] - end - end -end diff --git a/db/migrate/20140307050124_add_hidden_attrs_to_user.rb b/db/migrate/20140307050124_add_hidden_attrs_to_user.rb deleted file mode 100644 index 2f1b0b2..0000000 --- a/db/migrate/20140307050124_add_hidden_attrs_to_user.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddHiddenAttrsToUser < ActiveRecord::Migration - def change - add_column :users, :password_digest, :string - add_column :users, :remember_token, :string - add_index :users, :remember_token, unique: true - add_column :users, :groups, :integer - end -end diff --git a/db/migrate/20140307052327_create_servers.rb b/db/migrate/20140307052327_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140307052327_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/20140307052331_create_matches.rb b/db/migrate/20140307052331_create_matches.rb new file mode 100644 index 0000000..67a5b7b --- /dev/null +++ b/db/migrate/20140307052331_create_matches.rb @@ -0,0 +1,11 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + t.string :name + t.references :winner, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140307052334_create_teams.rb b/db/migrate/20140307052334_create_teams.rb new file mode 100644 index 0000000..fdf9a68 --- /dev/null +++ b/db/migrate/20140307052334_create_teams.rb @@ -0,0 +1,9 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140307052338_create_alerts.rb b/db/migrate/20140307052338_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140307052338_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/20140307052342_create_pms.rb b/db/migrate/20140307052342_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140307052342_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/20140307052346_create_tournaments.rb b/db/migrate/20140307052346_create_tournaments.rb new file mode 100644 index 0000000..545e603 --- /dev/null +++ b/db/migrate/20140307052346_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 :status + 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/20140307052350_create_games.rb b/db/migrate/20140307052350_create_games.rb new file mode 100644 index 0000000..5e4f56f --- /dev/null +++ b/db/migrate/20140307052350_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/20140307052354_create_users.rb b/db/migrate/20140307052354_create_users.rb new file mode 100644 index 0000000..8032870 --- /dev/null +++ b/db/migrate/20140307052354_create_users.rb @@ -0,0 +1,13 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :user_name + + t.timestamps + end + add_index :users, :email, unique: true + add_index :users, :user_name, unique: true + end +end diff --git a/db/migrate/20140307052358_create_sessions.rb b/db/migrate/20140307052358_create_sessions.rb new file mode 100644 index 0000000..fe25bf2 --- /dev/null +++ b/db/migrate/20140307052358_create_sessions.rb @@ -0,0 +1,9 @@ +class CreateSessions < ActiveRecord::Migration + def change + create_table :sessions do |t| + t.references :user, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140307052402_create_server_settings.rb b/db/migrate/20140307052402_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140307052402_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/20140307052405_create_tournament_options.rb b/db/migrate/20140307052405_create_tournament_options.rb new file mode 100644 index 0000000..53b601c --- /dev/null +++ b/db/migrate/20140307052405_create_tournament_options.rb @@ -0,0 +1,12 @@ +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 + end +end diff --git a/db/migrate/20140307052409_create_game_options.rb b/db/migrate/20140307052409_create_game_options.rb new file mode 100644 index 0000000..2f62ef7 --- /dev/null +++ b/db/migrate/20140307052409_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/20140307052413_create_scores.rb b/db/migrate/20140307052413_create_scores.rb new file mode 100644 index 0000000..4ca0b0b --- /dev/null +++ b/db/migrate/20140307052413_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/20140307052417_create_tournament_players_join_table.rb b/db/migrate/20140307052417_create_tournament_players_join_table.rb new file mode 100644 index 0000000..be240e8 --- /dev/null +++ b/db/migrate/20140307052417_create_tournament_players_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentPlayersJoinTable < ActiveRecord::Migration + def change + create_join_table :players, :tournaments do |t| + # t.index [:player_id, :tournament_id] + # t.index [:tournament_id, :player_id] + end + end +end diff --git a/db/migrate/20140307052421_create_tournament_hosts_join_table.rb b/db/migrate/20140307052421_create_tournament_hosts_join_table.rb new file mode 100644 index 0000000..7521d89 --- /dev/null +++ b/db/migrate/20140307052421_create_tournament_hosts_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentHostsJoinTable < ActiveRecord::Migration + def change + create_join_table :hosts, :tournaments do |t| + # t.index [:host_id, :tournament_id] + # t.index [:tournament_id, :host_id] + end + end +end diff --git a/db/migrate/20140307052424_create_team_user_join_table.rb b/db/migrate/20140307052424_create_team_user_join_table.rb new file mode 100644 index 0000000..f3b57fc --- /dev/null +++ b/db/migrate/20140307052424_create_team_user_join_table.rb @@ -0,0 +1,8 @@ +class CreateTeamUserJoinTable < ActiveRecord::Migration + def change + create_join_table :teams, :users do |t| + # t.index [:team_id, :user_id] + # t.index [:user_id, :team_id] + end + end +end diff --git a/db/migrate/20140307052428_create_match_team_join_table.rb b/db/migrate/20140307052428_create_match_team_join_table.rb new file mode 100644 index 0000000..c2ed1b7 --- /dev/null +++ b/db/migrate/20140307052428_create_match_team_join_table.rb @@ -0,0 +1,8 @@ +class CreateMatchTeamJoinTable < ActiveRecord::Migration + def change + create_join_table :matches, :teams do |t| + # t.index [:match_id, :team_id] + # t.index [:team_id, :match_id] + end + end +end diff --git a/db/migrate/20140307052443_add_hidden_attrs_to_user.rb b/db/migrate/20140307052443_add_hidden_attrs_to_user.rb new file mode 100644 index 0000000..2f1b0b2 --- /dev/null +++ b/db/migrate/20140307052443_add_hidden_attrs_to_user.rb @@ -0,0 +1,8 @@ +class AddHiddenAttrsToUser < ActiveRecord::Migration + def change + add_column :users, :password_digest, :string + add_column :users, :remember_token, :string + add_index :users, :remember_token, unique: true + add_column :users, :groups, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index c9c0fa6..55f4046 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: 20140307050124) do +ActiveRecord::Schema.define(version: 20140307052443) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -50,11 +50,13 @@ ActiveRecord::Schema.define(version: 20140307050124) do create_table "matches", force: true do |t| t.integer "tournament_id" t.string "name" + t.integer "winner_id" t.datetime "created_at" t.datetime "updated_at" end add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id" + add_index "matches", ["winner_id"], name: "index_matches_on_winner_id" create_table "matches_teams", id: false, force: true do |t| t.integer "match_id", null: false diff --git a/generate.sh b/generate.sh index 739c195..45a8ab6 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 --force $NOTEST +bundle exec rails generate scaffold match 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 50675d8..51b7f37 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 } + post :create, match: { name: @match.name, 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 } + patch :update, id: @match, match: { name: @match.name, 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 089fc65..956229c 100644 --- a/test/fixtures/matches.yml +++ b/test/fixtures/matches.yml @@ -3,7 +3,9 @@ one: tournament_id: name: MyString + winner_id: two: tournament_id: name: MyString + winner_id: -- cgit v1.2.3