summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/remote_usernames.js.coffee3
-rw-r--r--app/assets/stylesheets/remote_usernames.css.scss3
-rw-r--r--app/controllers/matches_controller.rb4
-rw-r--r--app/controllers/remote_usernames_controller.rb74
-rw-r--r--app/controllers/sessions_controller.rb1
-rw-r--r--app/controllers/users_controller.rb1
-rw-r--r--app/helpers/remote_usernames_helper.rb2
-rw-r--r--app/models/tournament.rb2
-rw-r--r--app/views/remote_usernames/_form.html.erb29
-rw-r--r--app/views/remote_usernames/edit.html.erb6
-rw-r--r--app/views/remote_usernames/index.html.erb31
-rw-r--r--app/views/remote_usernames/index.json.jbuilder4
-rw-r--r--app/views/remote_usernames/new.html.erb5
-rw-r--r--app/views/remote_usernames/show.html.erb19
-rw-r--r--app/views/remote_usernames/show.json.jbuilder1
-rw-r--r--app/views/tournaments/_form.html.erb20
-rw-r--r--app/views/tournaments/index.json.jbuilder2
-rw-r--r--app/views/tournaments/show.html.erb25
-rw-r--r--app/views/tournaments/show.json.jbuilder2
-rwxr-xr-xbin/autoindent10
-rw-r--r--config/routes.rb2
-rw-r--r--db/migrate/20140401215809_add_hidden_attrs_to_user.rb8
-rw-r--r--db/migrate/20140403155007_create_servers.rb (renamed from db/migrate/20140401215718_create_servers.rb)0
-rw-r--r--db/migrate/20140403155008_create_matches.rb (renamed from db/migrate/20140401215720_create_matches.rb)0
-rw-r--r--db/migrate/20140403155011_create_teams.rb (renamed from db/migrate/20140401215723_create_teams.rb)0
-rw-r--r--db/migrate/20140403155012_create_alerts.rb (renamed from db/migrate/20140401215725_create_alerts.rb)0
-rw-r--r--db/migrate/20140403155014_create_pms.rb (renamed from db/migrate/20140401215728_create_pms.rb)0
-rw-r--r--db/migrate/20140403155017_create_tournaments.rb (renamed from db/migrate/20140401215730_create_tournaments.rb)5
-rw-r--r--db/migrate/20140403155019_create_games.rb (renamed from db/migrate/20140401215733_create_games.rb)0
-rw-r--r--db/migrate/20140403155020_create_users.rb (renamed from db/migrate/20140401215735_create_users.rb)0
-rw-r--r--db/migrate/20140403155022_create_sessions.rb (renamed from db/migrate/20140401215738_create_sessions.rb)2
-rw-r--r--db/migrate/20140403155024_create_remote_usernames.rb (renamed from db/migrate/20140401215750_create_remote_usernames.rb)2
-rw-r--r--db/migrate/20140403155026_create_server_settings.rb (renamed from db/migrate/20140401215740_create_server_settings.rb)0
-rw-r--r--db/migrate/20140403155029_create_game_settings.rb (renamed from db/migrate/20140401215743_create_game_settings.rb)0
-rw-r--r--db/migrate/20140403155030_create_tournament_preferences.rb (renamed from db/migrate/20140401215745_create_tournament_preferences.rb)0
-rw-r--r--db/migrate/20140403155032_create_scores.rb (renamed from db/migrate/20140401215747_create_scores.rb)0
-rw-r--r--db/migrate/20140403155035_create_tournament_players_join_table.rb (renamed from db/migrate/20140401215752_create_tournament_players_join_table.rb)0
-rw-r--r--db/migrate/20140403155038_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140401215755_create_tournament_hosts_join_table.rb)0
-rw-r--r--db/migrate/20140403155039_create_team_user_join_table.rb (renamed from db/migrate/20140401215757_create_team_user_join_table.rb)0
-rw-r--r--db/migrate/20140403155042_create_match_team_join_table.rb (renamed from db/migrate/20140401215800_create_match_team_join_table.rb)0
-rw-r--r--db/migrate/20140403155049_add_hidden_attrs_to_user.rb6
-rw-r--r--db/schema.rb15
-rwxr-xr-xgenerate.sh22
-rw-r--r--test/controllers/remote_usernames_controller_test.rb49
-rw-r--r--test/controllers/sessions_controller_test.rb4
-rw-r--r--test/controllers/tournaments_controller_test.rb4
-rw-r--r--test/fixtures/remote_usernames.yml4
-rw-r--r--test/fixtures/sessions.yml2
-rw-r--r--test/fixtures/tournaments.yml10
-rw-r--r--test/helpers/remote_usernames_helper_test.rb4
50 files changed, 342 insertions, 41 deletions
diff --git a/app/assets/javascripts/remote_usernames.js.coffee b/app/assets/javascripts/remote_usernames.js.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/remote_usernames.js.coffee
@@ -0,0 +1,3 @@
+# 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/stylesheets/remote_usernames.css.scss b/app/assets/stylesheets/remote_usernames.css.scss
new file mode 100644
index 0000000..b9e841e
--- /dev/null
+++ b/app/assets/stylesheets/remote_usernames.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the remote_usernames controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 8d65960..ba6ab16 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -14,7 +14,6 @@ class MatchesController < ApplicationController
# GET /matches/new
def new
-
end
# GET /matches/1/edit
@@ -54,10 +53,10 @@ class MatchesController < ApplicationController
# DELETE /matches/1
# DELETE /matches/1.json
def destroy
-
@match.destroy
respond_to do |format|
format.html { redirect_to tournament_matches_path }
+ format.json { head :no_content }
end
end
@@ -70,6 +69,7 @@ class MatchesController < ApplicationController
def set_tournament
@tournament = Tournament.find(params[:tournament_id])
end
+
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
params.require(:match).permit(:status, :tournament_id, :name, :winner_id, :remote_id)
diff --git a/app/controllers/remote_usernames_controller.rb b/app/controllers/remote_usernames_controller.rb
new file mode 100644
index 0000000..8676c00
--- /dev/null
+++ b/app/controllers/remote_usernames_controller.rb
@@ -0,0 +1,74 @@
+class RemoteUsernamesController < ApplicationController
+ before_action :set_remote_username, only: [:show, :edit, :update, :destroy]
+
+ # GET /remote_usernames
+ # GET /remote_usernames.json
+ def index
+ @remote_usernames = RemoteUsername.all
+ end
+
+ # GET /remote_usernames/1
+ # GET /remote_usernames/1.json
+ def show
+ end
+
+ # GET /remote_usernames/new
+ def new
+ @remote_username = RemoteUsername.new
+ end
+
+ # GET /remote_usernames/1/edit
+ def edit
+ end
+
+ # POST /remote_usernames
+ # POST /remote_usernames.json
+ def create
+ @remote_username = RemoteUsername.new(remote_username_params)
+
+ respond_to do |format|
+ if @remote_username.save
+ format.html { redirect_to @remote_username, notice: 'Remote username was successfully created.' }
+ format.json { render action: 'show', status: :created, location: @remote_username }
+ else
+ format.html { render action: 'new' }
+ format.json { render json: @remote_username.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /remote_usernames/1
+ # PATCH/PUT /remote_usernames/1.json
+ def update
+ respond_to do |format|
+ if @remote_username.update(remote_username_params)
+ format.html { redirect_to @remote_username, notice: 'Remote username was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: 'edit' }
+ format.json { render json: @remote_username.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /remote_usernames/1
+ # DELETE /remote_usernames/1.json
+ def destroy
+ @remote_username.destroy
+ respond_to do |format|
+ format.html { redirect_to remote_usernames_url }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_remote_username
+ @remote_username = RemoteUsername.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def remote_username_params
+ params.require(:remote_username).permit(:game_id, :user_id, :user_name)
+ end
+end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index aaaccd7..1bae258 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -39,7 +39,6 @@ class SessionsController < ApplicationController
end
private
-
# Use callbacks to share common setup or constraints between actions.
def set_session
#@session = Session.find(cookies[:remember_token])
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 26c5d49..8a8b994 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -12,7 +12,6 @@ class UsersController < ApplicationController
# GET /users/1
# GET /users/1.json
def show
- @user = User.find(params[:id])
end
# GET /users/new
diff --git a/app/helpers/remote_usernames_helper.rb b/app/helpers/remote_usernames_helper.rb
new file mode 100644
index 0000000..3240c4f
--- /dev/null
+++ b/app/helpers/remote_usernames_helper.rb
@@ -0,0 +1,2 @@
+module RemoteUsernamesHelper
+end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 21dc9bb..87b516e 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -43,6 +43,4 @@ class Tournament < ActiveRecord::Base
end
end
end
-
-
end
diff --git a/app/views/remote_usernames/_form.html.erb b/app/views/remote_usernames/_form.html.erb
new file mode 100644
index 0000000..5da1f8f
--- /dev/null
+++ b/app/views/remote_usernames/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form_for(@remote_username) do |f| %>
+ <% if @remote_username.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@remote_username.errors.count, "error") %> prohibited this remote_username from being saved:</h2>
+
+ <ul>
+ <% @remote_username.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :game_id %><br>
+ <%= f.text_field :game_id %>
+ </div>
+ <div class="field">
+ <%= f.label :user_id %><br>
+ <%= f.text_field :user_id %>
+ </div>
+ <div class="field">
+ <%= f.label :user_name %><br>
+ <%= f.text_field :user_name %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
diff --git a/app/views/remote_usernames/edit.html.erb b/app/views/remote_usernames/edit.html.erb
new file mode 100644
index 0000000..52d4b37
--- /dev/null
+++ b/app/views/remote_usernames/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing remote_username</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @remote_username %> |
+<%= link_to 'Back', remote_usernames_path %>
diff --git a/app/views/remote_usernames/index.html.erb b/app/views/remote_usernames/index.html.erb
new file mode 100644
index 0000000..14f5876
--- /dev/null
+++ b/app/views/remote_usernames/index.html.erb
@@ -0,0 +1,31 @@
+<h1>Listing remote_usernames</h1>
+
+<table>
+ <thead>
+ <tr>
+ <th>Game</th>
+ <th>User</th>
+ <th>User name</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @remote_usernames.each do |remote_username| %>
+ <tr>
+ <td><%= remote_username.game %></td>
+ <td><%= remote_username.user %></td>
+ <td><%= remote_username.user_name %></td>
+ <td><%= link_to 'Show', remote_username %></td>
+ <td><%= link_to 'Edit', edit_remote_username_path(remote_username) %></td>
+ <td><%= link_to 'Destroy', remote_username, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Remote username', new_remote_username_path %>
diff --git a/app/views/remote_usernames/index.json.jbuilder b/app/views/remote_usernames/index.json.jbuilder
new file mode 100644
index 0000000..c9fbc0f
--- /dev/null
+++ b/app/views/remote_usernames/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.array!(@remote_usernames) do |remote_username|
+ json.extract! remote_username, :id, :game_id, :user_id, :user_name
+ json.url remote_username_url(remote_username, format: :json)
+end
diff --git a/app/views/remote_usernames/new.html.erb b/app/views/remote_usernames/new.html.erb
new file mode 100644
index 0000000..b9cfcf4
--- /dev/null
+++ b/app/views/remote_usernames/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New remote_username</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', remote_usernames_path %>
diff --git a/app/views/remote_usernames/show.html.erb b/app/views/remote_usernames/show.html.erb
new file mode 100644
index 0000000..416ca9d
--- /dev/null
+++ b/app/views/remote_usernames/show.html.erb
@@ -0,0 +1,19 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <strong>Game:</strong>
+ <%= @remote_username.game %>
+</p>
+
+<p>
+ <strong>User:</strong>
+ <%= @remote_username.user %>
+</p>
+
+<p>
+ <strong>User name:</strong>
+ <%= @remote_username.user_name %>
+</p>
+
+<%= link_to 'Edit', edit_remote_username_path(@remote_username) %> |
+<%= link_to 'Back', remote_usernames_path %>
diff --git a/app/views/remote_usernames/show.json.jbuilder b/app/views/remote_usernames/show.json.jbuilder
new file mode 100644
index 0000000..1a0f6f9
--- /dev/null
+++ b/app/views/remote_usernames/show.json.jbuilder
@@ -0,0 +1 @@
+json.extract! @remote_username, :id, :game_id, :user_id, :user_name, :created_at, :updated_at
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 3dadbf7..38855a0 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -24,6 +24,26 @@
<%= f.number_field :status %>
</div>
<div class="field">
+ <%= f.label :min_players_per_team %><br>
+ <%= f.number_field :min_players_per_team %>
+ </div>
+ <div class="field">
+ <%= f.label :max_players_per_team %><br>
+ <%= f.number_field :max_players_per_team %>
+ </div>
+ <div class="field">
+ <%= f.label :min_teams_per_match %><br>
+ <%= f.number_field :min_teams_per_match %>
+ </div>
+ <div class="field">
+ <%= f.label :max_teams_per_match %><br>
+ <%= f.number_field :max_teams_per_match %>
+ </div>
+ <div class="field">
+ <%= f.label :set_rounds %><br>
+ <%= f.number_field :set_rounds %>
+ </div>
+ <div class="field">
<%= f.label :randomized_teams %><br>
<%= f.check_box :randomized_teams %>
</div>
diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder
index 32587df..4038f04 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, :name, :game_id, :status, :randomized_teams
+ json.extract! tournament, :id, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams
json.url tournament_url(tournament, format: :json)
end
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 1ebf4c5..b771701 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -46,6 +46,31 @@
</p>
<p>
+ <strong>Min players per team:</strong>
+ <%= @tournament.min_players_per_team %>
+</p>
+
+<p>
+ <strong>Max players per team:</strong>
+ <%= @tournament.max_players_per_team %>
+</p>
+
+<p>
+ <strong>Min teams per match:</strong>
+ <%= @tournament.min_teams_per_match %>
+</p>
+
+<p>
+ <strong>Max teams per match:</strong>
+ <%= @tournament.max_teams_per_match %>
+</p>
+
+<p>
+ <strong>Set rounds:</strong>
+ <%= @tournament.set_rounds %>
+</p>
+
+<p>
<strong>Randomized teams:</strong>
<%= @tournament.randomized_teams %>
</p>
diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder
index d543c76..27fd5c0 100644
--- a/app/views/tournaments/show.json.jbuilder
+++ b/app/views/tournaments/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @tournament, :id, :name, :game_id, :status, :randomized_teams, :created_at, :updated_at
+json.extract! @tournament, :id, :name, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at
diff --git a/bin/autoindent b/bin/autoindent
new file mode 100755
index 0000000..c45da1e
--- /dev/null
+++ b/bin/autoindent
@@ -0,0 +1,10 @@
+#!/bin/bash
+file=$1
+sed -i 's/^\s*//' "$file"
+emacs --batch "$file" \
+ --eval '(setq indent-tabs-mode t)' \
+ --eval '(setq ruby-indent-level 4)' \
+ --eval '(setq tab-width 4)' \
+ --eval '(setq make-backup-files nil)' \
+ --eval '(indent-region (point-min) (point-max) nil)' \
+ -f save-buffer
diff --git a/config/routes.rb b/config/routes.rb
index 70e5359..571e629 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,6 @@
Leaguer::Application.routes.draw do
+ resources :remote_usernames
- #creates sessions as a resource but limits it to these actions
resources :sessions, only: [:new, :create, :destroy]
resources :users
diff --git a/db/migrate/20140401215809_add_hidden_attrs_to_user.rb b/db/migrate/20140401215809_add_hidden_attrs_to_user.rb
deleted file mode 100644
index 2f1b0b2..0000000
--- a/db/migrate/20140401215809_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/20140401215718_create_servers.rb b/db/migrate/20140403155007_create_servers.rb
index f33241a..f33241a 100644
--- a/db/migrate/20140401215718_create_servers.rb
+++ b/db/migrate/20140403155007_create_servers.rb
diff --git a/db/migrate/20140401215720_create_matches.rb b/db/migrate/20140403155008_create_matches.rb
index 31eea12..31eea12 100644
--- a/db/migrate/20140401215720_create_matches.rb
+++ b/db/migrate/20140403155008_create_matches.rb
diff --git a/db/migrate/20140401215723_create_teams.rb b/db/migrate/20140403155011_create_teams.rb
index fdf9a68..fdf9a68 100644
--- a/db/migrate/20140401215723_create_teams.rb
+++ b/db/migrate/20140403155011_create_teams.rb
diff --git a/db/migrate/20140401215725_create_alerts.rb b/db/migrate/20140403155012_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140401215725_create_alerts.rb
+++ b/db/migrate/20140403155012_create_alerts.rb
diff --git a/db/migrate/20140401215728_create_pms.rb b/db/migrate/20140403155014_create_pms.rb
index 93bb5c6..93bb5c6 100644
--- a/db/migrate/20140401215728_create_pms.rb
+++ b/db/migrate/20140403155014_create_pms.rb
diff --git a/db/migrate/20140401215730_create_tournaments.rb b/db/migrate/20140403155017_create_tournaments.rb
index 55f76a3..c0d8929 100644
--- a/db/migrate/20140401215730_create_tournaments.rb
+++ b/db/migrate/20140403155017_create_tournaments.rb
@@ -4,6 +4,11 @@ class CreateTournaments < ActiveRecord::Migration
t.string :name
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
diff --git a/db/migrate/20140401215733_create_games.rb b/db/migrate/20140403155019_create_games.rb
index 5e4f56f..5e4f56f 100644
--- a/db/migrate/20140401215733_create_games.rb
+++ b/db/migrate/20140403155019_create_games.rb
diff --git a/db/migrate/20140401215735_create_users.rb b/db/migrate/20140403155020_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140401215735_create_users.rb
+++ b/db/migrate/20140403155020_create_users.rb
diff --git a/db/migrate/20140401215738_create_sessions.rb b/db/migrate/20140403155022_create_sessions.rb
index fe25bf2..f667f1e 100644
--- a/db/migrate/20140401215738_create_sessions.rb
+++ b/db/migrate/20140403155022_create_sessions.rb
@@ -2,8 +2,10 @@ class CreateSessions < ActiveRecord::Migration
def change
create_table :sessions do |t|
t.references :user, index: true
+ t.string :token
t.timestamps
end
+ add_index :sessions, :token, unique: true
end
end
diff --git a/db/migrate/20140401215750_create_remote_usernames.rb b/db/migrate/20140403155024_create_remote_usernames.rb
index e265985..b837e53 100644
--- a/db/migrate/20140401215750_create_remote_usernames.rb
+++ b/db/migrate/20140403155024_create_remote_usernames.rb
@@ -3,7 +3,7 @@ class CreateRemoteUsernames < ActiveRecord::Migration
create_table :remote_usernames do |t|
t.references :game, index: true
t.references :user, index: true
- t.text :json_value
+ t.string :user_name
t.timestamps
end
diff --git a/db/migrate/20140401215740_create_server_settings.rb b/db/migrate/20140403155026_create_server_settings.rb
index dfdd91b..dfdd91b 100644
--- a/db/migrate/20140401215740_create_server_settings.rb
+++ b/db/migrate/20140403155026_create_server_settings.rb
diff --git a/db/migrate/20140401215743_create_game_settings.rb b/db/migrate/20140403155029_create_game_settings.rb
index 0ebbf18..0ebbf18 100644
--- a/db/migrate/20140401215743_create_game_settings.rb
+++ b/db/migrate/20140403155029_create_game_settings.rb
diff --git a/db/migrate/20140401215745_create_tournament_preferences.rb b/db/migrate/20140403155030_create_tournament_preferences.rb
index 991d659..991d659 100644
--- a/db/migrate/20140401215745_create_tournament_preferences.rb
+++ b/db/migrate/20140403155030_create_tournament_preferences.rb
diff --git a/db/migrate/20140401215747_create_scores.rb b/db/migrate/20140403155032_create_scores.rb
index 4ca0b0b..4ca0b0b 100644
--- a/db/migrate/20140401215747_create_scores.rb
+++ b/db/migrate/20140403155032_create_scores.rb
diff --git a/db/migrate/20140401215752_create_tournament_players_join_table.rb b/db/migrate/20140403155035_create_tournament_players_join_table.rb
index be240e8..be240e8 100644
--- a/db/migrate/20140401215752_create_tournament_players_join_table.rb
+++ b/db/migrate/20140403155035_create_tournament_players_join_table.rb
diff --git a/db/migrate/20140401215755_create_tournament_hosts_join_table.rb b/db/migrate/20140403155038_create_tournament_hosts_join_table.rb
index 7521d89..7521d89 100644
--- a/db/migrate/20140401215755_create_tournament_hosts_join_table.rb
+++ b/db/migrate/20140403155038_create_tournament_hosts_join_table.rb
diff --git a/db/migrate/20140401215757_create_team_user_join_table.rb b/db/migrate/20140403155039_create_team_user_join_table.rb
index f3b57fc..f3b57fc 100644
--- a/db/migrate/20140401215757_create_team_user_join_table.rb
+++ b/db/migrate/20140403155039_create_team_user_join_table.rb
diff --git a/db/migrate/20140401215800_create_match_team_join_table.rb b/db/migrate/20140403155042_create_match_team_join_table.rb
index c2ed1b7..c2ed1b7 100644
--- a/db/migrate/20140401215800_create_match_team_join_table.rb
+++ b/db/migrate/20140403155042_create_match_team_join_table.rb
diff --git a/db/migrate/20140403155049_add_hidden_attrs_to_user.rb b/db/migrate/20140403155049_add_hidden_attrs_to_user.rb
new file mode 100644
index 0000000..9b5c505
--- /dev/null
+++ b/db/migrate/20140403155049_add_hidden_attrs_to_user.rb
@@ -0,0 +1,6 @@
+class AddHiddenAttrsToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :password_digest, :string
+ add_column :users, :permissions, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c3be661..113f16d 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: 20140401215809) do
+ActiveRecord::Schema.define(version: 20140403155049) do
create_table "alerts", force: true do |t|
t.integer "author_id"
@@ -90,7 +90,7 @@ ActiveRecord::Schema.define(version: 20140401215809) do
create_table "remote_usernames", force: true do |t|
t.integer "game_id"
t.integer "user_id"
- t.text "json_value"
+ t.string "user_name"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -121,10 +121,12 @@ ActiveRecord::Schema.define(version: 20140401215809) do
create_table "sessions", force: true do |t|
t.integer "user_id"
+ t.string "token"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "sessions", ["token"], name: "index_sessions_on_token", unique: true
add_index "sessions", ["user_id"], name: "index_sessions_on_user_id"
create_table "teams", force: true do |t|
@@ -155,6 +157,11 @@ ActiveRecord::Schema.define(version: 20140401215809) do
t.string "name"
t.integer "game_id"
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.datetime "created_at"
t.datetime "updated_at"
@@ -169,12 +176,10 @@ ActiveRecord::Schema.define(version: 20140401215809) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_digest"
- t.string "remember_token"
- t.integer "groups"
+ t.integer "permissions"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
- add_index "users", ["remember_token"], name: "index_users_on_remember_token", unique: true
add_index "users", ["user_name"], name: "index_users_on_user_name", unique: true
end
diff --git a/generate.sh b/generate.sh
index 8fc3368..728e122 100755
--- a/generate.sh
+++ b/generate.sh
@@ -1,17 +1,13 @@
#!/bin/bash
-set -x
-# The generate.sh bash file is used to generate all of the necessary .rb files to run the website
-#
+# The generate.sh bash file is used to generate all of the necessary
+# .rb files to run the website
+set -x
-# To Start Rails Server:
-# bundle exec rails server
-#
-# To Clear the Generated Files:
-# git clean -df
-#
-#NOTEST='--skip-test-unit'
+# figure out where we are running from
+srcdir=$(dirname "$(readlink -f "$0")")
+cd "$srcdir"
git rm -rf app test config/routes.rb db/migrate
git checkout clean-start -- app test config/routes.rb
@@ -32,7 +28,7 @@ bundle exec rails generate scaffold game \
min_teams_per_match:integer max_teams_per_match:integer \
set_rounds:integer randomized_teams:boolean
bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq
-bundle exec rails generate scaffold session user:references
+bundle exec rails generate scaffold session user:references token:string:uniq
bundle exec rails generate scaffold remote_username game:references user:references user_name:string
# Just models
@@ -56,7 +52,7 @@ bundle exec rails generate controller static $NOTEST
# Migrations
# By having these separate from the original 'generate', it makes it
# not stick these in the views or anything.
-bundle exec rails generate migration AddHiddenAttrsToUser password_digest:string remember_token:string:uniq groups:integer
+bundle exec rails generate migration AddHiddenAttrsToUser password_digest:string permissions:integer
#for the tournament controller to generate options
#bundle exec rails generate scaffold
@@ -65,4 +61,6 @@ bundle exec rake db:drop RAILS_ENV=development
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rake db:seed
+find app -type f -name '*.rb' -exec bin/autoindent {} \;
+
git add app test config/routes.rb db/migrate db/schema.rb
diff --git a/test/controllers/remote_usernames_controller_test.rb b/test/controllers/remote_usernames_controller_test.rb
new file mode 100644
index 0000000..ff6a91d
--- /dev/null
+++ b/test/controllers/remote_usernames_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class RemoteUsernamesControllerTest < ActionController::TestCase
+ setup do
+ @remote_username = remote_usernames(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:remote_usernames)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create remote_username" do
+ assert_difference('RemoteUsername.count') do
+ post :create, remote_username: { game_id: @remote_username.game_id, user_id: @remote_username.user_id, user_name: @remote_username.user_name }
+ end
+
+ assert_redirected_to remote_username_path(assigns(:remote_username))
+ end
+
+ test "should show remote_username" do
+ get :show, id: @remote_username
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @remote_username
+ assert_response :success
+ end
+
+ test "should update remote_username" do
+ patch :update, id: @remote_username, remote_username: { game_id: @remote_username.game_id, user_id: @remote_username.user_id, user_name: @remote_username.user_name }
+ assert_redirected_to remote_username_path(assigns(:remote_username))
+ end
+
+ test "should destroy remote_username" do
+ assert_difference('RemoteUsername.count', -1) do
+ delete :destroy, id: @remote_username
+ end
+
+ assert_redirected_to remote_usernames_path
+ end
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
index a5cc8cb..a144bf8 100644
--- a/test/controllers/sessions_controller_test.rb
+++ b/test/controllers/sessions_controller_test.rb
@@ -18,7 +18,7 @@ class SessionsControllerTest < ActionController::TestCase
test "should create session" do
assert_difference('Session.count') do
- post :create, session: { user_id: @session.user_id }
+ post :create, session: { token: @session.token, user_id: @session.user_id }
end
assert_redirected_to session_path(assigns(:session))
@@ -35,7 +35,7 @@ class SessionsControllerTest < ActionController::TestCase
end
test "should update session" do
- patch :update, id: @session, session: { user_id: @session.user_id }
+ patch :update, id: @session, session: { token: @session.token, user_id: @session.user_id }
assert_redirected_to session_path(assigns(:session))
end
diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb
index 0c1ff60..d5ab2af 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, name: @tournament.name, randomized_teams: @tournament.randomized_teams, 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, 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, name: @tournament.name, randomized_teams: @tournament.randomized_teams, 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, set_rounds: @tournament.set_rounds, status: @tournament.status }
assert_redirected_to tournament_path(assigns(:tournament))
end
diff --git a/test/fixtures/remote_usernames.yml b/test/fixtures/remote_usernames.yml
index baa1714..0b3055a 100644
--- a/test/fixtures/remote_usernames.yml
+++ b/test/fixtures/remote_usernames.yml
@@ -3,9 +3,9 @@
one:
game_id:
user_id:
- json_value: MyText
+ user_name: MyString
two:
game_id:
user_id:
- json_value: MyText
+ user_name: MyString
diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml
index d9098d9..aea4379 100644
--- a/test/fixtures/sessions.yml
+++ b/test/fixtures/sessions.yml
@@ -2,6 +2,8 @@
one:
user_id:
+ token: MyString
two:
user_id:
+ token: MyString
diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml
index d5a4366..89edc9f 100644
--- a/test/fixtures/tournaments.yml
+++ b/test/fixtures/tournaments.yml
@@ -4,10 +4,20 @@ one:
name: MyString
game_id:
status: 1
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
+ set_rounds: 1
randomized_teams: false
two:
name: MyString
game_id:
status: 1
+ min_players_per_team: 1
+ max_players_per_team: 1
+ min_teams_per_match: 1
+ max_teams_per_match: 1
+ set_rounds: 1
randomized_teams: false
diff --git a/test/helpers/remote_usernames_helper_test.rb b/test/helpers/remote_usernames_helper_test.rb
new file mode 100644
index 0000000..1c9a795
--- /dev/null
+++ b/test/helpers/remote_usernames_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class RemoteUsernamesHelperTest < ActionView::TestCase
+end