-
-
-
-
diff --git a/app/views/static_pages/_fourPoolQuarterBracket.html.erb b/app/views/tournaments/_fourPoolQuarterBracket.html.erb
similarity index 100%
rename from app/views/static_pages/_fourPoolQuarterBracket.html.erb
rename to app/views/tournaments/_fourPoolQuarterBracket.html.erb
diff --git a/app/views/static_pages/_fourPoolSemiBracket.html.erb b/app/views/tournaments/_fourPoolSemiBracket.html.erb
similarity index 100%
rename from app/views/static_pages/_fourPoolSemiBracket.html.erb
rename to app/views/tournaments/_fourPoolSemiBracket.html.erb
diff --git a/app/views/static_pages/_pool.html.erb b/app/views/tournaments/_pool.html.erb
similarity index 100%
rename from app/views/static_pages/_pool.html.erb
rename to app/views/tournaments/_pool.html.erb
diff --git a/app/views/static_pages/_twoPoolFinalBracket.html.erb b/app/views/tournaments/_twoPoolFinalBracket.html.erb
similarity index 100%
rename from app/views/static_pages/_twoPoolFinalBracket.html.erb
rename to app/views/tournaments/_twoPoolFinalBracket.html.erb
diff --git a/app/views/static_pages/_twoPoolSemiBracket.html.erb b/app/views/tournaments/_twoPoolSemiBracket.html.erb
similarity index 100%
rename from app/views/static_pages/_twoPoolSemiBracket.html.erb
rename to app/views/tournaments/_twoPoolSemiBracket.html.erb
diff --git a/app/views/static_pages/all_brackets.html.erb b/app/views/tournaments/all_brackets.html.erb
similarity index 98%
rename from app/views/static_pages/all_brackets.html.erb
rename to app/views/tournaments/all_brackets.html.erb
index ad37246..e4689d9 100644
--- a/app/views/static_pages/all_brackets.html.erb
+++ b/app/views/tournaments/all_brackets.html.erb
@@ -13,7 +13,7 @@
}
-<%= link_to "Back to #{@tournament.name} weights", "/tournaments/#{@tournament.id}/weights" %>
+<%= link_to "Back to #{@tournament.name} weights", "/tournaments/#{@tournament.id}/brackets" %>
diff --git a/app/views/static_pages/brackets.html.erb b/app/views/tournaments/bracket.html.erb
similarity index 100%
rename from app/views/static_pages/brackets.html.erb
rename to app/views/tournaments/bracket.html.erb
diff --git a/app/views/tournaments/brackets.html.erb b/app/views/tournaments/brackets.html.erb
new file mode 100644
index 0000000..875b3bf
--- /dev/null
+++ b/app/views/tournaments/brackets.html.erb
@@ -0,0 +1,8 @@
+<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
+
+
+<% @weights.each do |weight| %>
+<%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/brackets/#{weight.id}" %>
+
+<% end %>
+<%= link_to "All Brackets", "/tournaments/#{@tournament.id}/all_brackets?print=true" %>
\ No newline at end of file
diff --git a/app/views/tournaments/results.html.erb b/app/views/tournaments/results.html.erb
new file mode 100644
index 0000000..6f4b178
--- /dev/null
+++ b/app/views/tournaments/results.html.erb
@@ -0,0 +1,5 @@
+<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
+
+
+
Results
+
Will be displayed here.
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index b7c55e3..e44e5e4 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -33,7 +33,7 @@
<% if tournament_permissions(@tournament) %>
<%= link_to "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { confirm: 'Are you sure? This will delete all current matches.' }, :class=>"btn btn-success" %>
-<%= link_to "Weigh In Page" , "/static_pages/weigh_in?tournament=#{@tournament.id}", :class=>"btn btn-primary" %>
+<%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in", :class=>"btn btn-primary" %>
<% end %>
@@ -77,7 +77,7 @@
<% if tournament_permissions(@tournament) %>
<%= link_to "New #{@tournament.name} Weight" , "/weights/new?tournament=#{@tournament.id}", :class=>"btn btn-success" %>
- <%= link_to "Create HS Weights" , "/static_pages/createCustomWeights?tournament=#{@tournament.id}&customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' }, :class=>"btn btn-success" %>
+ <%= link_to "Create HS Weights" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' }, :class=>"btn btn-success" %>
<% end %>
diff --git a/app/views/tournaments/weigh_in.html.erb b/app/views/tournaments/weigh_in.html.erb
new file mode 100644
index 0000000..b15a517
--- /dev/null
+++ b/app/views/tournaments/weigh_in.html.erb
@@ -0,0 +1,20 @@
+<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %>
+
+
+ <% @weights.each do |weight| %>
+ <%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/weigh_in/#{weight.id}" %>
+
+ <% end %>
+
+ <% if tournament_permissions(@tournament) %>
+ <%= form_for(@tournament) do |f| %>
+
-
- <%= f.submit 'Submit', :class=>"btn btn-success" %>
- <% end %>
- <% end %>
-<% end %>
-
-<% if @weight %>
- <%= link_to "Back to weigh in weights","/static_pages/weigh_in?tournament=#{@tournament_id}", :class=>"btn btn-default" %>
-
-
-
-
-
Name
-
School
-
Seed
-
Weight Class
-
Offical Weight
-
-
-
- <%= form_tag @wrestlers_update_path do %>
- <% @wrestlers.order("original_seed asc").each do |wrestler| %>
- <% if wrestler.weight_id == @weight.id %>
-
-
<%= wrestler.name %>
-
<%= School.find(wrestler.school_id).name %>
-
<%= wrestler.original_seed %>
-
<%= wrestler.weight.max %>
-
- <% if user_signed_in? %>
- <%= fields_for "wrestler[]", wrestler do |w| %>
- <%= w.number_field :offical_weight, :step => 'any' %>
- <% end %>
- <% else %>
- <%= wrestler.offical_weight %>
- <% end %>
-
-
- <% end %>
- <% end %>
-
-
- <%= hidden_field_tag :tournament, @tournament_id %>
- <% if tournament_permissions(@tournament) %>
- <%= submit_tag "Save", :class=>"btn btn-success"%>
- <% end %>
- <% end %>
-<% end %>
+<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %>
+
+
+ <%= link_to "Back to weigh ins","/tournaments/#{@tournament_id}/weigh_in", :class=>"btn btn-default" %>
+
+
+
+
+
Name
+
School
+
Seed
+
Weight Class
+
Offical Weight
+
+
+
+ <%= form_tag @wrestlers_update_path do %>
+ <% @wrestlers.order("original_seed asc").each do |wrestler| %>
+ <% if wrestler.weight_id == @weight.id %>
+
+
<%= wrestler.name %>
+
<%= School.find(wrestler.school_id).name %>
+
<%= wrestler.original_seed %>
+
<%= wrestler.weight.max %>
+
+ <% if user_signed_in? %>
+ <%= fields_for "wrestler[]", wrestler do |w| %>
+ <%= w.number_field :offical_weight, :step => 'any' %>
+ <% end %>
+ <% else %>
+ <%= wrestler.offical_weight %>
+ <% end %>
+
+
+ <% end %>
+ <% end %>
+
+
+ <%= hidden_field_tag :tournament, @tournament_id %>
+ <% if tournament_permissions(@tournament) %>
+ <%= submit_tag "Save", :class=>"btn btn-success"%>
+ <% end %>
+ <% end %>
diff --git a/app/views/tournaments/weights.html.erb b/app/views/tournaments/weights.html.erb
deleted file mode 100644
index c724595..0000000
--- a/app/views/tournaments/weights.html.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
-
-
-<% @weights.each do |weight| %>
-<%= link_to "#{weight.max}" , "/static_pages/brackets?weight=#{weight.id}" %>
-
-<% end %>
-<%= link_to "All Brackets", "/static_pages/all_brackets?print=true&tournament=#{@tournament.id}" %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index fbd6f5d..30175f9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -22,19 +22,19 @@ Wrestling::Application.routes.draw do
# You can have the root of your site routed with "root"
root 'static_pages#home'
- get 'static_pages/brackets'
- get 'static_pages/all_brackets'
get 'admin/index'
get 'static_pages/control_match'
- get 'static_pages/results'
- get 'static_pages/createCustomWeights'
- get 'static_pages/weigh_in'
- post 'static_pages/weigh_in'
get 'static_pages/not_allowed'
-
+ get 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
+ post 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
+ get 'tournaments/:id/weigh_in' => 'tournaments#weigh_in'
+ get 'tournaments/:id/create_custom_weights' => 'tournaments#create_custom_weights'
+ get 'tournaments/:id/all_brackets' => 'tournaments#all_brackets'
+ get 'tournaments/:id/results' => 'tournaments#results'
+ get 'tournaments/:id/brackets' => 'tournaments#brackets'
+ get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket'
get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches'
- get 'tournaments/:id/weights' => 'tournaments#weights'
get 'tournaments/:id/team_scores' => 'tournaments#team_scores'
get 'tournaments/:id/up_matches' => 'tournaments#up_matches'
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb
index 52bb5f4..8aae91f 100644
--- a/test/controllers/static_pages_controller_test.rb
+++ b/test/controllers/static_pages_controller_test.rb
@@ -26,28 +26,5 @@ class StaticPagesControllerTest < ActionController::TestCase
end
- test "logged in tournament owner can access weigh_ins" do
- sign_in_owner
- get :weigh_in, tournament: 1
- success
- end
-
- test "logged in non tournament owner cannot access weigh_ins" do
- sign_in_non_owner
- get :weigh_in, tournament: 1
- redirect
- end
-
- test "logged in tournament owner can create custom weights" do
- sign_in_owner
- get :createCustomWeights, tournament: 1, customValue: 'hs'
- assert_redirected_to '/tournaments/1'
- end
-
- test "logged in non tournament owner cannot create custom weights" do
- sign_in_non_owner
- get :createCustomWeights, tournament: 1, customValue: 'hs'
- redirect
- end
end
diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb
index 7c0f518..143df94 100644
--- a/test/controllers/tournaments_controller_test.rb
+++ b/test/controllers/tournaments_controller_test.rb
@@ -9,6 +9,14 @@ include Devise::TestHelpers
@school = @tournament.schools.first
end
+ def post_update
+ patch :update, id: 1, tournament: {name: @tournament.name}
+ end
+
+ def get_edit
+ get :edit, id: 1
+ end
+
def sign_in_owner
sign_in users(:one)
end
@@ -24,6 +32,12 @@ include Devise::TestHelpers
def redirect
assert_redirected_to '/static_pages/not_allowed'
end
+
+ def destroy
+ delete :destroy, id: 1
+ end
+
+
test "logged in tournament owner can generate matches" do
sign_in_owner
get :generate_matches, id: 1
@@ -36,4 +50,90 @@ include Devise::TestHelpers
redirect
end
+ test "logged in tournament owner can create custom weights" do
+ sign_in_owner
+ get :create_custom_weights, id: 1, customValue: 'hs'
+ assert_redirected_to '/tournaments/1'
+ end
+
+ test "logged in non tournament owner cannot create custom weights" do
+ sign_in_non_owner
+ get :create_custom_weights, id: 1, customValue: 'hs'
+ redirect
+ end
+
+
+ test "logged in tournament owner can access weigh_ins" do
+ sign_in_owner
+ get :weigh_in, id: 1
+ success
+ end
+
+ test "logged in non tournament owner cannot access weigh_ins" do
+ sign_in_non_owner
+ get :weigh_in, id: 1
+ redirect
+ end
+
+ test "logged in tournament owner can access weigh_in_weight" do
+ sign_in_owner
+ get :weigh_in, id: 1, weight: 1
+ success
+ end
+
+ test "logged in non tournament owner cannot access weigh_in_weight" do
+ sign_in_non_owner
+ get :weigh_in_weight, id: 1, weight: 1
+ redirect
+ end
+
+
+ test "logged in tournament owner should get edit tournament page" do
+ sign_in_owner
+ get_edit
+ success
+ end
+
+ test "logged in user should not get edit tournament page if not owner" do
+ sign_in_non_owner
+ get_edit
+ redirect
+ end
+
+ test "non logged in user should not get edit tournament page" do
+ get_edit
+ redirect
+ end
+
+ test "non logged in user should get post update tournament" do
+ post_update
+ assert_redirected_to '/static_pages/not_allowed'
+ end
+
+ test "logged in user should not post update tournament if not owner" do
+ sign_in_non_owner
+ post_update
+ assert_redirected_to '/static_pages/not_allowed'
+ end
+
+ test "logged in tournament owner should post update tournament" do
+ sign_in_owner
+ post_update
+ assert_redirected_to tournament_path(1)
+ end
+
+
+ test "logged in tournament owner can destroy a tournament" do
+ sign_in_owner
+ destroy
+ assert_redirected_to tournaments_path
+ end
+
+ test "logged in user not tournament owner cannot destroy tournament" do
+ sign_in_non_owner
+ destroy
+ redirect
+ end
+
+
end