diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-23 22:50:48 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-23 22:50:48 -0400 |
commit | 41a93fad32677e3f351c0e16f0c704cbfbc5404e (patch) | |
tree | aa46c550dbd15a1f0bb0faf4e8eebb92c4970bdd | |
parent | 19b04a49d01af1917385c166501ef086eddae437 (diff) | |
parent | 47be7c86ca5193ffe4331fbb9358a9171abe748b (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
94 files changed, 86 insertions, 78 deletions
diff --git a/app/assets/javascripts/common/.keep b/app/assets/javascripts/alerts/edit.js.coffee index e69de29..e69de29 100644 --- a/app/assets/javascripts/common/.keep +++ b/app/assets/javascripts/alerts/edit.js.coffee diff --git a/app/assets/javascripts/alerts/index.js.coffee b/app/assets/javascripts/alerts/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/alerts/index.js.coffee diff --git a/app/assets/javascripts/alerts/new.js.coffee b/app/assets/javascripts/alerts/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/alerts/new.js.coffee diff --git a/app/assets/javascripts/alerts/show.js.coffee b/app/assets/javascripts/alerts/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/alerts/show.js.coffee diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e9430a3..1130838 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,4 +17,4 @@ //= require 'dragsort.js' //= require 'coordinates.js' // -//= require_tree ./common +//= require_tree ./application diff --git a/app/assets/javascripts/application/.keep b/app/assets/javascripts/application/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/application/.keep diff --git a/app/assets/javascripts/brackets/edit.js.coffee b/app/assets/javascripts/brackets/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/brackets/edit.js.coffee diff --git a/app/assets/javascripts/brackets/index.js.coffee b/app/assets/javascripts/brackets/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/brackets/index.js.coffee diff --git a/app/assets/javascripts/brackets/new.js.coffee b/app/assets/javascripts/brackets/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/brackets/new.js.coffee diff --git a/app/assets/javascripts/brackets/show.js.coffee b/app/assets/javascripts/brackets/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/brackets/show.js.coffee diff --git a/app/assets/javascripts/games/edit.js.coffee b/app/assets/javascripts/games/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/games/edit.js.coffee diff --git a/app/assets/javascripts/games/index.js.coffee b/app/assets/javascripts/games/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/games/index.js.coffee diff --git a/app/assets/javascripts/games/new.js.coffee b/app/assets/javascripts/games/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/games/new.js.coffee diff --git a/app/assets/javascripts/games/show.js.coffee b/app/assets/javascripts/games/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/games/show.js.coffee diff --git a/app/assets/javascripts/main/homepage.js.coffee b/app/assets/javascripts/main/homepage.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/main/homepage.js.coffee diff --git a/app/assets/javascripts/matches_show.js.coffee b/app/assets/javascripts/matches/show.js.coffee index 2609a69..2609a69 100644 --- a/app/assets/javascripts/matches_show.js.coffee +++ b/app/assets/javascripts/matches/show.js.coffee diff --git a/app/assets/javascripts/pms/edit.js.coffee b/app/assets/javascripts/pms/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/pms/edit.js.coffee diff --git a/app/assets/javascripts/pms/index.js.coffee b/app/assets/javascripts/pms/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/pms/index.js.coffee diff --git a/app/assets/javascripts/pms/new.js.coffee b/app/assets/javascripts/pms/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/pms/new.js.coffee diff --git a/app/assets/javascripts/pms/show.js.coffee b/app/assets/javascripts/pms/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/pms/show.js.coffee diff --git a/app/assets/javascripts/search/go.js.coffee b/app/assets/javascripts/search/go.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/search/go.js.coffee diff --git a/app/assets/javascripts/server/edit.js.coffee b/app/assets/javascripts/server/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/server/edit.js.coffee diff --git a/app/assets/javascripts/server/show.js.coffee b/app/assets/javascripts/server/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/server/show.js.coffee diff --git a/app/assets/javascripts/sessions/new.js.coffee b/app/assets/javascripts/sessions/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/sessions/new.js.coffee diff --git a/app/assets/javascripts/static.js.coffee b/app/assets/javascripts/static.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/static.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/teams/edit.js.coffee b/app/assets/javascripts/teams/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/teams/edit.js.coffee diff --git a/app/assets/javascripts/teams/index.js.coffee b/app/assets/javascripts/teams/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/teams/index.js.coffee diff --git a/app/assets/javascripts/teams/new.js.coffee b/app/assets/javascripts/teams/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/teams/new.js.coffee diff --git a/app/assets/javascripts/teams/show.js.coffee b/app/assets/javascripts/teams/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/teams/show.js.coffee diff --git a/app/assets/javascripts/tournaments/edit.js.coffee b/app/assets/javascripts/tournaments/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/tournaments/edit.js.coffee diff --git a/app/assets/javascripts/tournaments/index.js.coffee b/app/assets/javascripts/tournaments/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/tournaments/index.js.coffee diff --git a/app/assets/javascripts/tournaments/new.js.coffee b/app/assets/javascripts/tournaments/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/tournaments/new.js.coffee diff --git a/app/assets/javascripts/tournaments_show.js.coffee b/app/assets/javascripts/tournaments/show.js.coffee index 1e91d3a..ef6bb82 100644 --- a/app/assets/javascripts/tournaments_show.js.coffee +++ b/app/assets/javascripts/tournaments/show.js.coffee @@ -1,4 +1,6 @@ -Update = (tournament) -> +json_url = window.location.href.replace(/\.[^/]*$/,'')+".json" + +update = (tournament) -> here = tournament["players"].length needed = (tournament["min_teams_per_match"] * tournament["min_players_per_team"]) pct_complete = here / needed @@ -21,10 +23,10 @@ Update = (tournament) -> # Do it all again setTimeout (-> - $.ajax(url: window.location.href.replace(/\..*/,'')+".json").done Update + $.ajax(url: json_url).done update return ), 2000 # Now kick off the whole process window.onload = -> - $.ajax(url: window.location.href.replace(/\..*/,'')+".json").done Update + $.ajax(url: json_url).done update diff --git a/app/assets/javascripts/users/edit.js.coffee b/app/assets/javascripts/users/edit.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/users/edit.js.coffee diff --git a/app/assets/javascripts/users/index.js.coffee b/app/assets/javascripts/users/index.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/users/index.js.coffee diff --git a/app/assets/javascripts/users/new.js.coffee b/app/assets/javascripts/users/new.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/users/new.js.coffee diff --git a/app/assets/javascripts/users/show.js.coffee b/app/assets/javascripts/users/show.js.coffee new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/assets/javascripts/users/show.js.coffee diff --git a/app/assets/stylesheets/main.css.scss b/app/assets/stylesheets/main.css.scss index a0d94c1..3859f53 100644 --- a/app/assets/stylesheets/main.css.scss +++ b/app/assets/stylesheets/main.css.scss @@ -1,3 +1,14 @@ // Place all the styles related to the main controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +.jumbotron { + background-color: #FFF; + box-shadow: 1px 1px 20px black; + width: 93%; + + p { + line-height: 1.5em; + } + +} diff --git a/app/assets/stylesheets/static.css.scss b/app/assets/stylesheets/static.css.scss deleted file mode 100644 index 6732370..0000000 --- a/app/assets/stylesheets/static.css.scss +++ /dev/null @@ -1,14 +0,0 @@ -// Place all the styles related to the static controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -.jumbotron { - background-color: #FFF; - box-shadow: 1px 1px 20px black; - width: 93%; - - p { - line-height: 1.5em; - } - -} diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 1f0bdd8..aec5294 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(: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) end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 6519d7b..0ba4d94 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,2 +1,4 @@ class MainController < ApplicationController + def homepage + end end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb deleted file mode 100644 index 038cc19..0000000 --- a/app/controllers/static_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StaticController < ApplicationController - def homepage - end - - def test - end -end diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index b276368..0390051 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -33,7 +33,7 @@ class TournamentsController < ApplicationController def new @games = Game.all if params[:tournament] - @tournament = Tournament.new(game: Game.find(params[:tournament][:game_id])) + @tournament = Tournament.new(tournament_params) else @tournament = Tournament.new() end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cfa5d67..4c36148 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -56,8 +56,25 @@ class UsersController < ApplicationController # PATCH/PUT /users/1 # PATCH/PUT /users/1.json def update + ok = true + if params[:user][:remote_usernames].nil? + ok &= @user.update(user_params) + else + params[:user][:remote_usernames].each do |game_name,user_name| + game = Game.find_by_name(game_name) + remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{user_name}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + + remote = @user.remote_usernames.where(:game => game).first + if remote.nil? + ok &= @user.remote_usernames.create(game: game, value: remote_username) + else + remote.value = remote_username + ok &= remote.save + end + end + end respond_to do |format| - if @user.update(user_params) + if ok format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :no_content } else @@ -77,19 +94,6 @@ class UsersController < ApplicationController end end - def set_remote - game = Game.find_by_name("League of Legends") - - remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - - remote = @user.find_remote_username(game) - if remote.nil? - @user.remote_username.create(game: game, value: remote_username) - else - remote.value = remote_username - remote.save - end - end private # Use callbacks to share common setup or constraints between actions. diff --git a/app/helpers/static_helper.rb b/app/helpers/static_helper.rb deleted file mode 100644 index 8cfc9af..0000000 --- a/app/helpers/static_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module StaticHelper -end diff --git a/app/models/game.rb b/app/models/game.rb index 345877e..5f4c46d 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,3 +1,5 @@ class Game < ActiveRecord::Base + belongs_to :parent, class_name: "Game" + has_many :children, class_name: "Game" has_many :settings, class_name: "GameSetting" end diff --git a/app/models/remote_username.rb b/app/models/remote_username.rb index c2c3d20..8c1ce26 100644 --- a/app/models/remote_username.rb +++ b/app/models/remote_username.rb @@ -3,7 +3,11 @@ class RemoteUsername < ActiveRecord::Base belongs_to :user def value - JSON.parse(self.json_value) + begin + return JSON.parse(self.json_value) + rescue + return {} + end end def value=(v) diff --git a/app/models/tournament.rb b/app/models/tournament.rb index e21ccb1..686e066 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -40,6 +40,7 @@ class Tournament < ActiveRecord::Base end def []=(setting_name, val) + @tournament.save tournament_setting = @tournament.settings_raw.find_by_name(setting_name) if tournament_setting.nil? game_setting = @tournament.game.settings.find_by_name(setting_name) diff --git a/app/models/user.rb b/app/models/user.rb index 138f73e..5c0b5b1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,9 +24,13 @@ class User < ActiveRecord::Base end def find_remote_username(game) - obj = remote_username.where(:game => game) - if obj.nil? and not game.parent.nil? - return find_remote_username(game.parent) + obj = self.remote_usernames.where(:game => game).first + if obj.nil? + if game.parent.nil? + return nil + else + return find_remote_username(game.parent) + end else return obj.value end diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb index ef250ad..20cb214 100644 --- a/app/views/games/_form.html.erb +++ b/app/views/games/_form.html.erb @@ -12,6 +12,10 @@ <% end %> <div class="field"> + <%= f.label :parent_id %><br> + <%= f.text_field :parent_id %> + </div> + <div class="field"> <%= f.label :name %><br> <%= f.text_field :name %> </div> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index abb0d8a..bcd10dd 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -3,6 +3,7 @@ <table class="table table-hover"> <thead> <tr> + <th>Parent</th> <th>Name</th> <th>Min players per team</th> <th>Max players per team</th> @@ -20,6 +21,7 @@ <tbody> <% @games.each do |game| %> <tr> + <td><%= game.parent %></td> <td><%= game.name %></td> <td><%= game.min_players_per_team %></td> <td><%= game.max_players_per_team %></td> diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder index cc0afc9..6b20f60 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, :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 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 d731e3d..1250cbd 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -1,4 +1,9 @@ <p> + <strong>Parent:</strong> + <%= @game.parent %> +</p> + +<p> <strong>Name:</strong> <%= @game.name %> </p> diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index 60d0a4a..087a156 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1 +1 @@ -json.extract! @game, :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, :created_at, :updated_at diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 15eba29..dd0ea91 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,7 +5,7 @@ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= javascript_include_tag "#{params[:controller]}", "data-turbolinks-track" => true %> - <%= javascript_include_tag "#{params[:controller]}_#{params[:action]}", "data-turbolinks-track" => true %> + <%= javascript_include_tag "#{params[:controller]}/#{params[:action]}", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> <%= yield :head %> </head> diff --git a/app/views/static/homepage.html.erb b/app/views/main/homepage.html.erb index 3ca8176..3ca8176 100644 --- a/app/views/static/homepage.html.erb +++ b/app/views/main/homepage.html.erb diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 81eee6f..dfebf08 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -21,11 +21,12 @@ </p> <p> - <%= label :username %><br> - <%= text_field %> - - <br><input type="submit" value="Submit"><br> - + <%= form_for @user do |f| %> + <label>Have a League of Legends Account? + <input type=text name="user[remote_usernames][League of Legends]"> + </label> + <%= f.submit "Add Username", :class => 'signup' %> + <% end %> </p> <div class="row"> diff --git a/config/routes.rb b/config/routes.rb index 5d53c0e..d7807f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,9 +19,7 @@ Leaguer::Application.routes.draw do resource :server, only: [:show, :edit, :update] - root to: 'static#homepage' - - get '/testsvg', to: 'static#test' + root to: 'main#homepage' get '/search', to: 'search#go' diff --git a/db/migrate/20140422172559_create_simple_captcha_data.rb b/db/migrate/20140423214420_create_simple_captcha_data.rb index 4573b20..4573b20 100644 --- a/db/migrate/20140422172559_create_simple_captcha_data.rb +++ b/db/migrate/20140423214420_create_simple_captcha_data.rb diff --git a/db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb index 690cec2..690cec2 100644 --- a/db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb diff --git a/db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb b/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb index 7f41ac6..7f41ac6 100644 --- a/db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb +++ b/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb diff --git a/db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb b/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb index 04c12ef..04c12ef 100644 --- a/db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb +++ b/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb diff --git a/db/migrate/20140422212558_add_attachments.mailboxer_engine.rb b/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb index b8d6588..b8d6588 100644 --- a/db/migrate/20140422212558_add_attachments.mailboxer_engine.rb +++ b/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb diff --git a/db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb index 9ce904f..9ce904f 100644 --- a/db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb +++ b/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb diff --git a/db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb index 60f67ab..60f67ab 100644 --- a/db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb +++ b/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb diff --git a/db/migrate/20140422212602_create_delayed_jobs.rb b/db/migrate/20140424014424_create_delayed_jobs.rb index ec0dd93..ec0dd93 100644 --- a/db/migrate/20140422212602_create_delayed_jobs.rb +++ b/db/migrate/20140424014424_create_delayed_jobs.rb diff --git a/db/migrate/20140422212605_create_servers.rb b/db/migrate/20140424014425_create_servers.rb index fbe1b02..fbe1b02 100644 --- a/db/migrate/20140422212605_create_servers.rb +++ b/db/migrate/20140424014425_create_servers.rb diff --git a/db/migrate/20140422212609_create_matches.rb b/db/migrate/20140424014426_create_matches.rb index bac92d1..bac92d1 100644 --- a/db/migrate/20140422212609_create_matches.rb +++ b/db/migrate/20140424014426_create_matches.rb diff --git a/db/migrate/20140422212613_create_teams.rb b/db/migrate/20140424014427_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140422212613_create_teams.rb +++ b/db/migrate/20140424014427_create_teams.rb diff --git a/db/migrate/20140422212616_create_alerts.rb b/db/migrate/20140424014428_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140422212616_create_alerts.rb +++ b/db/migrate/20140424014428_create_alerts.rb diff --git a/db/migrate/20140422212619_create_pms.rb b/db/migrate/20140424014429_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140422212619_create_pms.rb +++ b/db/migrate/20140424014429_create_pms.rb diff --git a/db/migrate/20140422212623_create_tournaments.rb b/db/migrate/20140424014431_create_tournaments.rb index 716871f..716871f 100644 --- a/db/migrate/20140422212623_create_tournaments.rb +++ b/db/migrate/20140424014431_create_tournaments.rb diff --git a/db/migrate/20140422212627_create_games.rb b/db/migrate/20140424014433_create_games.rb index 46ed30d..23edf0b 100644 --- a/db/migrate/20140422212627_create_games.rb +++ b/db/migrate/20140424014433_create_games.rb @@ -1,6 +1,7 @@ class CreateGames < ActiveRecord::Migration def change create_table :games do |t| + t.references :parent, index: true t.string :name t.integer :min_players_per_team t.integer :max_players_per_team diff --git a/db/migrate/20140422212630_create_users.rb b/db/migrate/20140424014434_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140422212630_create_users.rb +++ b/db/migrate/20140424014434_create_users.rb diff --git a/db/migrate/20140422212634_create_sessions.rb b/db/migrate/20140424014436_create_sessions.rb index f667f1e..f667f1e 100644 --- a/db/migrate/20140422212634_create_sessions.rb +++ b/db/migrate/20140424014436_create_sessions.rb diff --git a/db/migrate/20140422212637_create_brackets.rb b/db/migrate/20140424014437_create_brackets.rb index 8813bf2..8813bf2 100644 --- a/db/migrate/20140422212637_create_brackets.rb +++ b/db/migrate/20140424014437_create_brackets.rb diff --git a/db/migrate/20140422212641_create_game_settings.rb b/db/migrate/20140424014439_create_game_settings.rb index 06fb72e..06fb72e 100644 --- a/db/migrate/20140422212641_create_game_settings.rb +++ b/db/migrate/20140424014439_create_game_settings.rb diff --git a/db/migrate/20140422212644_create_tournament_settings.rb b/db/migrate/20140424014440_create_tournament_settings.rb index e56697f..e56697f 100644 --- a/db/migrate/20140422212644_create_tournament_settings.rb +++ b/db/migrate/20140424014440_create_tournament_settings.rb diff --git a/db/migrate/20140422212648_create_tournament_stages.rb b/db/migrate/20140424014442_create_tournament_stages.rb index e3668cb..e3668cb 100644 --- a/db/migrate/20140422212648_create_tournament_stages.rb +++ b/db/migrate/20140424014442_create_tournament_stages.rb diff --git a/db/migrate/20140422212651_create_statistics.rb b/db/migrate/20140424014443_create_statistics.rb index cc2e97d..cc2e97d 100644 --- a/db/migrate/20140422212651_create_statistics.rb +++ b/db/migrate/20140424014443_create_statistics.rb diff --git a/db/migrate/20140422212654_create_remote_usernames.rb b/db/migrate/20140424014445_create_remote_usernames.rb index e265985..e265985 100644 --- a/db/migrate/20140422212654_create_remote_usernames.rb +++ b/db/migrate/20140424014445_create_remote_usernames.rb diff --git a/db/migrate/20140422212657_create_bracket_matches.rb b/db/migrate/20140424014446_create_bracket_matches.rb index 3323e31..3323e31 100644 --- a/db/migrate/20140422212657_create_bracket_matches.rb +++ b/db/migrate/20140424014446_create_bracket_matches.rb diff --git a/db/migrate/20140422212701_create_api_requests.rb b/db/migrate/20140424014448_create_api_requests.rb index 544c330..544c330 100644 --- a/db/migrate/20140422212701_create_api_requests.rb +++ b/db/migrate/20140424014448_create_api_requests.rb diff --git a/db/migrate/20140422212704_create_tournament_players_join_table.rb b/db/migrate/20140424014449_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140422212704_create_tournament_players_join_table.rb +++ b/db/migrate/20140424014449_create_tournament_players_join_table.rb diff --git a/db/migrate/20140422212707_create_tournament_hosts_join_table.rb b/db/migrate/20140424014451_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140422212707_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140424014451_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140422212711_create_team_user_join_table.rb b/db/migrate/20140424014452_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140422212711_create_team_user_join_table.rb +++ b/db/migrate/20140424014452_create_team_user_join_table.rb diff --git a/db/migrate/20140422212714_create_match_team_join_table.rb b/db/migrate/20140424014454_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140422212714_create_match_team_join_table.rb +++ b/db/migrate/20140424014454_create_match_team_join_table.rb diff --git a/db/migrate/20140422212727_add_hidden_attrs_to_user.rb b/db/migrate/20140424014459_add_hidden_attrs_to_user.rb index 9b5c505..9b5c505 100644 --- a/db/migrate/20140422212727_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140424014459_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index a160f22..0e9202a 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: 20140422212727) do +ActiveRecord::Schema.define(version: 20140424014459) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 20140422212727) do add_index "game_settings", ["game_id"], name: "index_game_settings_on_game_id" create_table "games", force: true do |t| + t.integer "parent_id" t.string "name" t.integer "min_players_per_team" t.integer "max_players_per_team" @@ -101,6 +102,7 @@ ActiveRecord::Schema.define(version: 20140422212727) do end add_index "games", ["name"], name: "index_games_on_name", unique: true + add_index "games", ["parent_id"], name: "index_games_on_parent_id" create_table "hosts_tournaments", id: false, force: true do |t| t.integer "host_id", null: false diff --git a/generate.sh b/generate.sh index 5fe3c74..7d33ba3 100755 --- a/generate.sh +++ b/generate.sh @@ -29,6 +29,7 @@ cd "$srcdir" export RAILS_ENV=development git rm -rf -- app test config/routes.rb db/migrate || true +git rm -f -- config/initializers/mailboxer.rb || true git checkout clean-start -- app test config/routes.rb bundle install @@ -44,7 +45,7 @@ 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 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 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 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 @@ -73,7 +74,6 @@ bundle exec rails generate migration CreateMatchTeamJoinTable matches teams # Just controllers bundle exec rails generate controller search bundle exec rails generate controller main -bundle exec rails generate controller static # Migrations # By having these separate from the original 'generate', it makes it @@ -86,4 +86,4 @@ bundle exec rake db:seed find app config -type f -name '*.rb' -exec bin/autoindent {} \; -git add app test config/routes.rb config/initializers db/migrate db/schema.rb Gemfile.lock +git add app test config db/migrate db/schema.rb Gemfile.lock diff --git a/test/controllers/games_controller_test.rb b/test/controllers/games_controller_test.rb index f55a226..be97aa0 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, 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, 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, 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, set_rounds: @game.set_rounds } assert_redirected_to game_path(assigns(:game)) end diff --git a/test/controllers/static_controller_test.rb b/test/controllers/static_controller_test.rb deleted file mode 100644 index e62ae2a..0000000 --- a/test/controllers/static_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class StaticControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/fixtures/games.yml b/test/fixtures/games.yml index af46a13..b811dec 100644 --- a/test/fixtures/games.yml +++ b/test/fixtures/games.yml @@ -1,6 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: + parent_id: name: MyString min_players_per_team: 1 max_players_per_team: 1 @@ -11,6 +12,7 @@ one: sampling_method: MyString two: + parent_id: name: MyString min_players_per_team: 1 max_players_per_team: 1 diff --git a/test/helpers/static_helper_test.rb b/test/helpers/static_helper_test.rb deleted file mode 100644 index 3b96f2b..0000000 --- a/test/helpers/static_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class StaticHelperTest < ActionView::TestCase -end |