diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 20:35:55 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 20:35:55 -0400 |
commit | 1d24cb050f198e9c8bec8dd014de203d889ab56a (patch) | |
tree | 9f10e7a5be75d7ffb4cb829d3738a144b5250b9b | |
parent | 2d0fe1a4197e70cb99f4285a8b32a645914d8beb (diff) | |
parent | dfbbe46fdcca392b3dec703cf347d1b1d57ca94f (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r-- | app/controllers/brackets_controller.rb | 25 | ||||
-rw-r--r-- | app/controllers/games_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/matches_controller.rb | 55 | ||||
-rw-r--r-- | app/controllers/tournaments_controller.rb | 2 | ||||
-rw-r--r-- | app/models/bracket.rb | 7 | ||||
-rw-r--r-- | app/models/tournament.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/brackets/index.html.erb | 7 | ||||
-rw-r--r-- | app/views/brackets/new.html.erb | 4 | ||||
-rw-r--r-- | app/views/brackets/show.html.erb | 14 | ||||
-rw-r--r-- | app/views/common/_show_tournament.html.erb | 3 | ||||
-rw-r--r-- | app/views/games/_form.html.erb | 4 | ||||
-rw-r--r-- | app/views/games/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/games/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/games/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/games/show.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 20 | ||||
-rw-r--r-- | app/views/tournaments/_form.html.erb | 4 | ||||
-rw-r--r-- | app/views/tournaments/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/tournaments/show.json.jbuilder | 2 | ||||
-rw-r--r-- | config/routes.rb | 8 | ||||
-rw-r--r-- | db/migrate/20140426201409_create_simple_captcha_data.rb (renamed from db/migrate/20140424190540_create_simple_captcha_data.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001406_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001407_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001408_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001409_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140424230539_add_attachments.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001410_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001411_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001413_create_delayed_jobs.rb (renamed from db/migrate/20140424230543_create_delayed_jobs.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001416_create_servers.rb (renamed from db/migrate/20140424230547_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001420_create_matches.rb (renamed from db/migrate/20140424230550_create_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001424_create_teams.rb (renamed from db/migrate/20140424230554_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001428_create_alerts.rb (renamed from db/migrate/20140424230558_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001431_create_pms.rb (renamed from db/migrate/20140424230602_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001435_create_tournaments.rb (renamed from db/migrate/20140424230605_create_tournaments.rb) | 1 | ||||
-rw-r--r-- | db/migrate/20140427001439_create_games.rb (renamed from db/migrate/20140424230609_create_games.rb) | 1 | ||||
-rw-r--r-- | db/migrate/20140427001443_create_users.rb (renamed from db/migrate/20140424230613_create_users.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001446_create_sessions.rb (renamed from db/migrate/20140424230617_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001450_create_brackets.rb (renamed from db/migrate/20140424230620_create_brackets.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001454_create_game_settings.rb (renamed from db/migrate/20140424230624_create_game_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001458_create_tournament_settings.rb (renamed from db/migrate/20140424230628_create_tournament_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001502_create_tournament_stages.rb (renamed from db/migrate/20140424230632_create_tournament_stages.rb) | 3 | ||||
-rw-r--r-- | db/migrate/20140427001505_create_statistics.rb (renamed from db/migrate/20140424230635_create_statistics.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001509_create_remote_usernames.rb (renamed from db/migrate/20140424230639_create_remote_usernames.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001513_create_bracket_matches.rb (renamed from db/migrate/20140424230643_create_bracket_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001516_create_api_requests.rb (renamed from db/migrate/20140424230646_create_api_requests.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001520_create_tournament_players_join_table.rb (renamed from db/migrate/20140424230650_create_tournament_players_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001523_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140424230654_create_tournament_hosts_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001527_create_team_user_join_table.rb (renamed from db/migrate/20140424230657_create_team_user_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001531_create_match_team_join_table.rb (renamed from db/migrate/20140424230701_create_match_team_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140427001542_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140424230712_add_hidden_attrs_to_user.rb) | 0 | ||||
-rw-r--r-- | db/schema.rb | 7 | ||||
-rw-r--r-- | db/seeds.rb | 26 | ||||
-rwxr-xr-x | generate.sh | 6 | ||||
-rw-r--r-- | test/controllers/games_controller_test.rb | 4 | ||||
-rw-r--r-- | test/controllers/tournaments_controller_test.rb | 4 | ||||
-rw-r--r-- | test/fixtures/games.yml | 2 | ||||
-rw-r--r-- | test/fixtures/tournament_stages.yml | 6 | ||||
-rw-r--r-- | test/fixtures/tournaments.yml | 2 |
59 files changed, 130 insertions, 107 deletions
diff --git a/app/controllers/brackets_controller.rb b/app/controllers/brackets_controller.rb index fe43ca9..ed335d6 100644 --- a/app/controllers/brackets_controller.rb +++ b/app/controllers/brackets_controller.rb @@ -1,10 +1,11 @@ class BracketsController < ApplicationController - before_action :set_bracket, only: [:show, :edit, :update, :destroy] + before_action :set_tournament, only: [:index, :create] # GET /brackets # GET /brackets.json def index - @brackets = Bracket.all + @tournament = Tournament.find(params[:tournament_id]) + @brackets = @tournament.brackets end # GET /brackets/1 @@ -12,11 +13,6 @@ class BracketsController < ApplicationController def show end - # GET /brackets/new - def new - @bracket = Bracket.new - end - # GET /brackets/1/edit def edit end @@ -24,12 +20,14 @@ class BracketsController < ApplicationController # POST /brackets # POST /brackets.json def create - @bracket = Bracket.new(bracket_params) + @bracket = @tournament.brackets.create(user: current_user) + @bracket.name = current_user.user_name + "'s Prediction for " + @tournament.name + @bracket.create_matches respond_to do |format| if @bracket.save format.html { redirect_to @bracket, notice: 'Bracket was successfully created.' } - format.json { render action: 'show', status: :created, location: @bracket } + format.json { render action: 'edit', status: :created, location: @bracket } else format.html { render action: 'new' } format.json { render json: @bracket.errors, status: :unprocessable_entity } @@ -64,11 +62,20 @@ class BracketsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_bracket + @tournament = Tournament.find(params[:tournament_id]) @bracket = Bracket.find(params[:id]) end + def set_tournament + @tournament = Tournament.find(params[:tournament_id]) + end + # Never trust parameters from the scary internet, only allow the white list through. def bracket_params params.require(:bracket).permit(:user_id, :tournament_id, :name) end + + def is_owner?(bracket) + bracket.user == current_user + end end diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index aec5294..09119c8 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -67,6 +67,6 @@ class GamesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def game_params - params.require(:game).permit(:parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method) + params.require(:game).permit(:parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method) end end diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index b1b283b..a2a1269 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -168,6 +168,10 @@ class MatchesController < ApplicationController def update case params[:update_action] when "start" + # + # Redirect to the current match page for this tournament with the correct sampling view rendered + # + @match.status = 1 respond_to do |format| if @match.save @@ -179,39 +183,13 @@ class MatchesController < ApplicationController end end when "finish" + # + # Get the winner and blowout status from the params given by the correct sampling view + # - #make this use the statistics interface for scoring and ScoringAlgorithms - - @match.winner = @match.teams.find_by_id(params['winner']) - @match.blowout = false - - @match.statistics['Score'] = @tournament.settings['ScoringMethod'].constantize.score(@match, @match.statistics) - -=begin - - # Individual scores - #scores = params["scores"] - #scores.each do |user_name, score| - # Statistic.create(user: User.find_by_user_name(user_name), match: @match, name: "score", value: score.to_i) - #end - - # Team scores (processing for manual) - team_scores = {} - @match.teams.each do |team| - team_scores[team] = 0 - team.users.each do |user| - team_scores[team] += scores[user.user_name].to_i - end + unless @match.tournament_stage.tournament.sampling.sampling_done? + @match.tournament_stage.tournament.sampling.handle_user_interaction(@match, current_user, params) end - teams = team_scores.invert - @match.winner = teams[teams.keys.sort.last] - - # Schedule next match - #cur_match_num = @tournament.matches_ordered.invert[@match] - #unless cur_match_num == 1 - # @match.winner.matches.push(@tournament.matches_ordered[cur_match_num/2]) - #end -=end # Skip peer evaluation if there aren't enough players per team peer = false @@ -222,7 +200,6 @@ class MatchesController < ApplicationController end @match.status = peer ? 2 : 3 - respond_to do |format| if @match.save format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Peer evaluation started.' } @@ -233,6 +210,12 @@ class MatchesController < ApplicationController end end when "peer" + # + # Update user scores via scoring method + # + + #update this to use scoring interface + order = params[:review_action] base_score = 2 next_score = 3 @@ -262,10 +245,14 @@ class MatchesController < ApplicationController end end when "reset" - @match.status = 0 + # + # Reset Match Status to 1 in case something needs to be replayed. + # + + @match.status = 1 respond_to do |format| if @match.save - format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 0' } + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 1' } format.json { head :no_content } else format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 6ba259e..60f8789 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -163,7 +163,7 @@ class TournamentsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def tournament_attribute_params if params[:tournament] - params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method) + params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method) else return {} end diff --git a/app/models/bracket.rb b/app/models/bracket.rb index e8d9c5a..acd33ca 100644 --- a/app/models/bracket.rb +++ b/app/models/bracket.rb @@ -1,4 +1,11 @@ class Bracket < ActiveRecord::Base belongs_to :user belongs_to :tournament + has_many :bracket_matches + + def create_matches + tournament.stages.first.matches.each do |m| + bracket_matches.create(match: m) + end + end end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 861be6c..7460a7d 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,6 +1,7 @@ class Tournament < ActiveRecord::Base belongs_to :game has_many :stages, class_name: "TournamentStage" + has_many :brackets has_many :settings_raw, class_name: "TournamentSetting" has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" diff --git a/app/models/user.rb b/app/models/user.rb index d87f988..b2c7862 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,6 +74,10 @@ class User < ActiveRecord::Base :edit_permissions => (2**19), :edit_server => (2**20), + + :create_bracket => (2**21), + :edit_bracket => (2**22), + :delete_bracket => (2**23) } end diff --git a/app/views/brackets/index.html.erb b/app/views/brackets/index.html.erb index 2195d69..9effe37 100644 --- a/app/views/brackets/index.html.erb +++ b/app/views/brackets/index.html.erb @@ -8,7 +8,6 @@ <th>Name</th> <th></th> <th></th> - <th></th> </tr> </thead> @@ -18,9 +17,8 @@ <td><%= bracket.user %></td> <td><%= bracket.tournament %></td> <td><%= bracket.name %></td> - <td><%= link_to 'Show', bracket %></td> - <td><%= link_to 'Edit', edit_bracket_path(bracket) %></td> - <td><%= link_to 'Destroy', bracket, method: :delete, data: { confirm: 'Are you sure?' } %></td> + <td><%= link_to 'Show', tournament_bracket_path(@tournament, bracket) %></td> + <td><%= link_to 'Edit', edit_tournament_bracket_path(@tournament, bracket) %></td> </tr> <% end %> </tbody> @@ -28,4 +26,3 @@ <br> -<%= link_to 'New Bracket', new_bracket_path %> diff --git a/app/views/brackets/new.html.erb b/app/views/brackets/new.html.erb index c379c15..91d0033 100644 --- a/app/views/brackets/new.html.erb +++ b/app/views/brackets/new.html.erb @@ -1,5 +1,3 @@ <h1>New bracket</h1> -<%= render 'form' %> - -<%= link_to 'Back', brackets_path %> +<%= link_to 'Back', tournament_brackets_path %> diff --git a/app/views/brackets/show.html.erb b/app/views/brackets/show.html.erb index 9c7c14b..2e92bfb 100644 --- a/app/views/brackets/show.html.erb +++ b/app/views/brackets/show.html.erb @@ -1,13 +1,11 @@ -<p id="notice"><%= notice %></p> - <p> <strong>User:</strong> - <%= @bracket.user %> + <%= @bracket.user.user_name %> </p> <p> <strong>Tournament:</strong> - <%= @bracket.tournament %> + <%= @bracket.tournament.name %> </p> <p> @@ -15,5 +13,9 @@ <%= @bracket.name %> </p> -<%= link_to 'Edit', edit_bracket_path(@bracket) %> | -<%= link_to 'Back', brackets_path %> +<% @bracket.bracket_matches.each do |m| %> + <p><b><%= m.match.id %></b></p> +<% end %> + + +<%= link_to 'Back', tournaments_path %> diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb index 0f60fad..b16a37b 100644 --- a/app/views/common/_show_tournament.html.erb +++ b/app/views/common/_show_tournament.html.erb @@ -29,6 +29,9 @@ <% else %> <p style="margin-top:10px;"> You've signed up for this tournament! </p> <% end %> + <%= form_tag(tournament_brackets_path(target), method: "post") do %> + <%= submit_tag("Make Bracket") %> + <% end %> <% end %> </div> </div>
\ No newline at end of file diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb index 20cb214..b1db0b3 100644 --- a/app/views/games/_form.html.erb +++ b/app/views/games/_form.html.erb @@ -47,6 +47,10 @@ <%= f.label :sampling_method %><br> <%= f.text_field :sampling_method %> </div> + <div class="field"> + <%= f.label :scoring_method %><br> + <%= f.text_field :scoring_method %> + </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index bcd10dd..3045325 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -12,6 +12,7 @@ <th>Set rounds</th> <th>Randomized teams</th> <th>Sampling method</th> + <th>Scoring method</th> <th></th> <th></th> <th></th> @@ -30,6 +31,7 @@ <td><%= game.set_rounds %></td> <td><%= game.randomized_teams %></td> <td><%= game.sampling_method %></td> + <td><%= game.scoring_method %></td> <td><%= link_to 'Show', game %></td> <td><%= link_to 'Edit', edit_game_path(game) %></td> <td><%= link_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %></td> diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder index 6b20f60..7964f2c 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, :parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method + json.extract! game, :id, :parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method 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 1250cbd..1a18356 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -43,5 +43,10 @@ <%= @game.sampling_method %> </p> +<p> + <strong>Scoring method:</strong> + <%= @game.scoring_method %> +</p> + <%= link_to 'Edit', edit_game_path(@game) %> | <%= link_to 'Back', games_path %> diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index 087a156..c5fb4ed 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1 +1 @@ -json.extract! @game, :id, :parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :created_at, :updated_at +json.extract! @game, :id, :parent_id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method, :created_at, :updated_at diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 7a82527..8344a7a 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -78,24 +78,8 @@ function score_peers() { <!-- Started, waiting to finish --> <!-- This will depend on the Sampling Method Eventually instead of always being Manual --> - <% case @tournament.sampling_method %> - <% when "Manual" %> - <% if @tournament.hosts.include? current_user %> - <input type="hidden" name="update_action" value="finish"> - <% @match.teams.each do |team| %> - <%= tag :input, {"type" => "radio", "name" => "winner", "value" => "#{team.id}" } %> - <%= "Team #{team.id} Won" %> - <% end %> - <%= submit_tag("Finish match") %> - <%= @tournament.settings['ScoringMethod'] %> - <% else %> - <p>The match is running; the host has yet to post the scores of the match.</p> - <% end %> - <% when "Double Blind" %> - <p>Double Blind isn't implemented yet.</p> - <% when "RiotAPI" %> - <p>Riot API is being called for Statistics. Results will appear shortly.</p> - <% end %> + <%= raw @match.tournament_stage.tournament.sampling_method.camelcase.constantize.render_user_interaction(@match, current_user) %> + <% when 2 %> <!-- Finished, waiting for peer reviews --> <input type="hidden" name="update_action" value="peer"> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 9b9681c..7127d38 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -51,6 +51,10 @@ <%= f.label :sampling_method %><br> <%= f.text_field :sampling_method %> </div> + <div class="field"> + <%= f.label :scoring_method %><br> + <%= f.text_field :scoring_method %> + </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder index 7118ecc..bd86e04 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, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method + json.extract! tournament, :id, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method json.url tournament_url(tournament, format: :json) end diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder index 4542e52..ff82412 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :created_at, :updated_at +json.extract! @tournament, :id, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method, :created_at, :updated_at diff --git a/config/routes.rb b/config/routes.rb index d7807f0..a4df5b4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Leaguer::Application.routes.draw do - resources :brackets resources :sessions, only: [:new, :create, :destroy] @@ -15,6 +14,7 @@ Leaguer::Application.routes.draw do resources :tournaments do resources :matches, only: [:index, :show, :update] + resources :brackets end resource :server, only: [:show, :edit, :update] @@ -33,6 +33,12 @@ Leaguer::Application.routes.named_routes.module.module_eval do def match_url(match, options={}) tournament_match_url(match.tournament_stage.tournament, match, options) end + def bracket_path(bracket, options={}) + tournament_bracket_path(bracket.tournament, bracket, options) + end + def bracket_url(bracket, options={}) + tournament_bracket_url(bracket.tournament, bracket, options) + end end if false diff --git a/db/migrate/20140424190540_create_simple_captcha_data.rb b/db/migrate/20140426201409_create_simple_captcha_data.rb index 4573b20..4573b20 100644 --- a/db/migrate/20140424190540_create_simple_captcha_data.rb +++ b/db/migrate/20140426201409_create_simple_captcha_data.rb diff --git a/db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140427001406_create_mailboxer.mailboxer_engine.rb index 690cec2..690cec2 100644 --- a/db/migrate/20140424230536_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20140427001406_create_mailboxer.mailboxer_engine.rb diff --git a/db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb b/db/migrate/20140427001407_add_notified_object.mailboxer_engine.rb index 7f41ac6..7f41ac6 100644 --- a/db/migrate/20140424230537_add_notified_object.mailboxer_engine.rb +++ b/db/migrate/20140427001407_add_notified_object.mailboxer_engine.rb diff --git a/db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb b/db/migrate/20140427001408_add_notification_code.mailboxer_engine.rb index 04c12ef..04c12ef 100644 --- a/db/migrate/20140424230538_add_notification_code.mailboxer_engine.rb +++ b/db/migrate/20140427001408_add_notification_code.mailboxer_engine.rb diff --git a/db/migrate/20140424230539_add_attachments.mailboxer_engine.rb b/db/migrate/20140427001409_add_attachments.mailboxer_engine.rb index b8d6588..b8d6588 100644 --- a/db/migrate/20140424230539_add_attachments.mailboxer_engine.rb +++ b/db/migrate/20140427001409_add_attachments.mailboxer_engine.rb diff --git a/db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140427001410_rename_receipts_read.mailboxer_engine.rb index 9ce904f..9ce904f 100644 --- a/db/migrate/20140424230540_rename_receipts_read.mailboxer_engine.rb +++ b/db/migrate/20140427001410_rename_receipts_read.mailboxer_engine.rb diff --git a/db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140427001411_add_global_notification_support.mailboxer_engine.rb index 60f67ab..60f67ab 100644 --- a/db/migrate/20140424230541_add_global_notification_support.mailboxer_engine.rb +++ b/db/migrate/20140427001411_add_global_notification_support.mailboxer_engine.rb diff --git a/db/migrate/20140424230543_create_delayed_jobs.rb b/db/migrate/20140427001413_create_delayed_jobs.rb index ec0dd93..ec0dd93 100644 --- a/db/migrate/20140424230543_create_delayed_jobs.rb +++ b/db/migrate/20140427001413_create_delayed_jobs.rb diff --git a/db/migrate/20140424230547_create_servers.rb b/db/migrate/20140427001416_create_servers.rb index fbe1b02..fbe1b02 100644 --- a/db/migrate/20140424230547_create_servers.rb +++ b/db/migrate/20140427001416_create_servers.rb diff --git a/db/migrate/20140424230550_create_matches.rb b/db/migrate/20140427001420_create_matches.rb index bac92d1..bac92d1 100644 --- a/db/migrate/20140424230550_create_matches.rb +++ b/db/migrate/20140427001420_create_matches.rb diff --git a/db/migrate/20140424230554_create_teams.rb b/db/migrate/20140427001424_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140424230554_create_teams.rb +++ b/db/migrate/20140427001424_create_teams.rb diff --git a/db/migrate/20140424230558_create_alerts.rb b/db/migrate/20140427001428_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140424230558_create_alerts.rb +++ b/db/migrate/20140427001428_create_alerts.rb diff --git a/db/migrate/20140424230602_create_pms.rb b/db/migrate/20140427001431_create_pms.rb index eb9f443..eb9f443 100644 --- a/db/migrate/20140424230602_create_pms.rb +++ b/db/migrate/20140427001431_create_pms.rb diff --git a/db/migrate/20140424230605_create_tournaments.rb b/db/migrate/20140427001435_create_tournaments.rb index 716871f..03b42b2 100644 --- a/db/migrate/20140424230605_create_tournaments.rb +++ b/db/migrate/20140427001435_create_tournaments.rb @@ -11,6 +11,7 @@ class CreateTournaments < ActiveRecord::Migration t.integer :set_rounds t.boolean :randomized_teams t.string :sampling_method + t.string :scoring_method t.timestamps end diff --git a/db/migrate/20140424230609_create_games.rb b/db/migrate/20140427001439_create_games.rb index 23edf0b..fe2e596 100644 --- a/db/migrate/20140424230609_create_games.rb +++ b/db/migrate/20140427001439_create_games.rb @@ -10,6 +10,7 @@ class CreateGames < ActiveRecord::Migration t.integer :set_rounds t.boolean :randomized_teams t.string :sampling_method + t.string :scoring_method t.timestamps end diff --git a/db/migrate/20140424230613_create_users.rb b/db/migrate/20140427001443_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140424230613_create_users.rb +++ b/db/migrate/20140427001443_create_users.rb diff --git a/db/migrate/20140424230617_create_sessions.rb b/db/migrate/20140427001446_create_sessions.rb index f667f1e..f667f1e 100644 --- a/db/migrate/20140424230617_create_sessions.rb +++ b/db/migrate/20140427001446_create_sessions.rb diff --git a/db/migrate/20140424230620_create_brackets.rb b/db/migrate/20140427001450_create_brackets.rb index 8813bf2..8813bf2 100644 --- a/db/migrate/20140424230620_create_brackets.rb +++ b/db/migrate/20140427001450_create_brackets.rb diff --git a/db/migrate/20140424230624_create_game_settings.rb b/db/migrate/20140427001454_create_game_settings.rb index 06fb72e..06fb72e 100644 --- a/db/migrate/20140424230624_create_game_settings.rb +++ b/db/migrate/20140427001454_create_game_settings.rb diff --git a/db/migrate/20140424230628_create_tournament_settings.rb b/db/migrate/20140427001458_create_tournament_settings.rb index e56697f..e56697f 100644 --- a/db/migrate/20140424230628_create_tournament_settings.rb +++ b/db/migrate/20140427001458_create_tournament_settings.rb diff --git a/db/migrate/20140424230632_create_tournament_stages.rb b/db/migrate/20140427001502_create_tournament_stages.rb index e3668cb..6e52bf0 100644 --- a/db/migrate/20140424230632_create_tournament_stages.rb +++ b/db/migrate/20140427001502_create_tournament_stages.rb @@ -2,8 +2,9 @@ class CreateTournamentStages < ActiveRecord::Migration def change create_table :tournament_stages do |t| t.references :tournament, index: true - t.string :scheduling t.text :structure + t.string :scheduling_method + t.string :seeding_method t.timestamps end diff --git a/db/migrate/20140424230635_create_statistics.rb b/db/migrate/20140427001505_create_statistics.rb index cc2e97d..cc2e97d 100644 --- a/db/migrate/20140424230635_create_statistics.rb +++ b/db/migrate/20140427001505_create_statistics.rb diff --git a/db/migrate/20140424230639_create_remote_usernames.rb b/db/migrate/20140427001509_create_remote_usernames.rb index e265985..e265985 100644 --- a/db/migrate/20140424230639_create_remote_usernames.rb +++ b/db/migrate/20140427001509_create_remote_usernames.rb diff --git a/db/migrate/20140424230643_create_bracket_matches.rb b/db/migrate/20140427001513_create_bracket_matches.rb index 3323e31..3323e31 100644 --- a/db/migrate/20140424230643_create_bracket_matches.rb +++ b/db/migrate/20140427001513_create_bracket_matches.rb diff --git a/db/migrate/20140424230646_create_api_requests.rb b/db/migrate/20140427001516_create_api_requests.rb index 544c330..544c330 100644 --- a/db/migrate/20140424230646_create_api_requests.rb +++ b/db/migrate/20140427001516_create_api_requests.rb diff --git a/db/migrate/20140424230650_create_tournament_players_join_table.rb b/db/migrate/20140427001520_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140424230650_create_tournament_players_join_table.rb +++ b/db/migrate/20140427001520_create_tournament_players_join_table.rb diff --git a/db/migrate/20140424230654_create_tournament_hosts_join_table.rb b/db/migrate/20140427001523_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140424230654_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140427001523_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140424230657_create_team_user_join_table.rb b/db/migrate/20140427001527_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140424230657_create_team_user_join_table.rb +++ b/db/migrate/20140427001527_create_team_user_join_table.rb diff --git a/db/migrate/20140424230701_create_match_team_join_table.rb b/db/migrate/20140427001531_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140424230701_create_match_team_join_table.rb +++ b/db/migrate/20140427001531_create_match_team_join_table.rb diff --git a/db/migrate/20140424230712_add_hidden_attrs_to_user.rb b/db/migrate/20140427001542_add_hidden_attrs_to_user.rb index 9b5c505..9b5c505 100644 --- a/db/migrate/20140424230712_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140427001542_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index d7e4efd..0616ef2 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: 20140424230712) do +ActiveRecord::Schema.define(version: 20140427001542) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -97,6 +97,7 @@ ActiveRecord::Schema.define(version: 20140424230712) do t.integer "set_rounds" t.boolean "randomized_teams" t.string "sampling_method" + t.string "scoring_method" t.datetime "created_at" t.datetime "updated_at" end @@ -254,8 +255,9 @@ ActiveRecord::Schema.define(version: 20140424230712) do create_table "tournament_stages", force: true do |t| t.integer "tournament_id" - t.string "scheduling" t.text "structure" + t.string "scheduling_method" + t.string "seeding_method" t.datetime "created_at" t.datetime "updated_at" end @@ -273,6 +275,7 @@ ActiveRecord::Schema.define(version: 20140424230712) do t.integer "set_rounds" t.boolean "randomized_teams" t.string "sampling_method" + t.string "scoring_method" t.datetime "created_at" t.datetime "updated_at" end diff --git a/db/seeds.rb b/db/seeds.rb index 87bf540..3b98070 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,7 +7,7 @@ # Mayor.create(name: 'Emanuel', city: cities.first) # p = User.permission_bits -Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm]) +Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm] | p[:create_bracket] | p[:edit_bracket]) Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind,RiotAPI") Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind") @@ -16,26 +16,26 @@ Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_ Game.find_by_name("League of Legends").settings.create(name: "Map", default: "Summoners Rift", type_opt: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", description: "Select a map to play on.", vartype: 5, display_order: 1) Game.find_by_name("League of Legends").settings.create(name: "Pick Type", type_opt: "Blind Pick,Draft", description: "Select a pick type.", vartype: 5, display_order: 2) -Game.find_by_name("League of Legends").settings.create(name: "Scoring Method", type_opt: "FibonacciPeerWithBlowout,MarginalPeer,WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 3) -Game.find_by_name("League of Legends").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 4) -Game.find_by_name("League of Legends").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 5) +#Game.find_by_name("League of Legends").settings.create(name: "Scoring Method", type_opt: "FibonacciPeerWithBlowout,MarginalPeer,WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 3) +#Game.find_by_name("League of Legends").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 4) +#Game.find_by_name("League of Legends").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 5) Game.find_by_name("Chess").settings.create(name: "Time Control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: 0, display_order: 1) -Game.find_by_name("Chess").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) -Game.find_by_name("Chess").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) -Game.find_by_name("Chess").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) +#Game.find_by_name("Chess").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) +#Game.find_by_name("Chess").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) +#Game.find_by_name("Chess").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) Game.find_by_name("Hearthstone").settings.create(name: "Deck Name", description: "Enter a name for your deck, be descriptive.", vartype: 1, display_order: 1) -Game.find_by_name("Hearthstone").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) -Game.find_by_name("Hearthstone").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) -Game.find_by_name("Hearthstone").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) +#Game.find_by_name("Hearthstone").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) +#Game.find_by_name("Hearthstone").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) +#Game.find_by_name("Hearthstone").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Favorite Object", description: "What is your favorite object in RPS?", type_opt: "Rock,Paper,Scissors", vartype: 2, display_order: 5) Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Lizard, Spock allowed?", description: "Will you allow Lizard and Spock?", vartype: 4, display_order: 4) Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Why are those up there even called radio buttons?", description: "Check boxes make sense at least", type_opt: "I do not know.,There is now spoon.,Wow.,Because electricity.,Wat?", vartype: 3, display_order: 6) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 1) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 2) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 3) +#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 1) +#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 2) +#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 3) if Rails.env.development? #user 1, the ADMIN diff --git a/generate.sh b/generate.sh index a81c0b3..f01e482 100755 --- a/generate.sh +++ b/generate.sh @@ -44,8 +44,8 @@ bundle exec rails generate scaffold match status:integer tournament_stage:refere bundle exec rails generate scaffold team bundle exec rails generate scaffold alert author:references message:text bundle exec rails generate scaffold pm author:references recipient:references message:text subject:text conversation:references -bundle exec rails generate scaffold tournament game:references status:integer name:string:uniq 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 sampling_method:string -bundle exec rails generate scaffold game parent:references name:string:uniq 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 sampling_method:string +bundle exec rails generate scaffold tournament game:references status:integer name:string:uniq 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 sampling_method:string scoring_method:string +bundle exec rails generate scaffold game parent:references name:string:uniq 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 sampling_method:string scoring_method:string bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq bundle exec rails generate scaffold session user:references token:string:uniq bundle exec rails generate scaffold bracket user:references tournament:references name:string @@ -54,7 +54,7 @@ bundle exec rails generate scaffold bracket user:references tournament:reference bundle exec rails generate model game_setting game:references name:string vartype:integer type_opt:text description:text display_order:integer default:text bundle exec rails generate model tournament_setting tournament:references name:string vartype:integer type_opt:text description:text display_order:integer value:text -bundle exec rails generate model tournament_stage tournament:references scheduling:string structure:text +bundle exec rails generate model tournament_stage tournament:references structure:text scheduling_method:string seeding_method:string bundle exec rails generate model statistic user:references match:references name:string value:integer bundle exec rails generate model remote_username game:references user:references json_value:text diff --git a/test/controllers/games_controller_test.rb b/test/controllers/games_controller_test.rb index be97aa0..567ecb9 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: { 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, parent_id: @game.parent_id, randomized_teams: @game.randomized_teams, sampling_method: @game.sampling_method, set_rounds: @game.set_rounds } + 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, parent_id: @game.parent_id, randomized_teams: @game.randomized_teams, sampling_method: @game.sampling_method, scoring_method: @game.scoring_method, 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: { 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, parent_id: @game.parent_id, randomized_teams: @game.randomized_teams, sampling_method: @game.sampling_method, set_rounds: @game.set_rounds } + 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, parent_id: @game.parent_id, randomized_teams: @game.randomized_teams, sampling_method: @game.sampling_method, scoring_method: @game.scoring_method, set_rounds: @game.set_rounds } assert_redirected_to game_path(assigns(:game)) end diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 0e5673c..0ee875a 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, name: @tournament.name, randomized_teams: @tournament.randomized_teams, sampling_method: @tournament.sampling_method, 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, sampling_method: @tournament.sampling_method, scoring_method: @tournament.scoring_method, 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, name: @tournament.name, randomized_teams: @tournament.randomized_teams, sampling_method: @tournament.sampling_method, 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, sampling_method: @tournament.sampling_method, scoring_method: @tournament.scoring_method, set_rounds: @tournament.set_rounds, status: @tournament.status } assert_redirected_to tournament_path(assigns(:tournament)) end diff --git a/test/fixtures/games.yml b/test/fixtures/games.yml index b811dec..ac5bad8 100644 --- a/test/fixtures/games.yml +++ b/test/fixtures/games.yml @@ -10,6 +10,7 @@ one: set_rounds: 1 randomized_teams: false sampling_method: MyString + scoring_method: MyString two: parent_id: @@ -21,3 +22,4 @@ two: set_rounds: 1 randomized_teams: false sampling_method: MyString + scoring_method: MyString diff --git a/test/fixtures/tournament_stages.yml b/test/fixtures/tournament_stages.yml index fdb263c..32eaba3 100644 --- a/test/fixtures/tournament_stages.yml +++ b/test/fixtures/tournament_stages.yml @@ -2,10 +2,12 @@ one: tournament_id: - scheduling: MyString structure: MyText + scheduling_method: MyString + seeding_method: MyString two: tournament_id: - scheduling: MyString structure: MyText + scheduling_method: MyString + seeding_method: MyString diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml index 714a963..dd9b56d 100644 --- a/test/fixtures/tournaments.yml +++ b/test/fixtures/tournaments.yml @@ -11,6 +11,7 @@ one: set_rounds: 1 randomized_teams: false sampling_method: MyString + scoring_method: MyString two: game_id: @@ -23,3 +24,4 @@ two: set_rounds: 1 randomized_teams: false sampling_method: MyString + scoring_method: MyString |