<%= @tournament.name %>
@@ -31,7 +31,7 @@
<% if tournament_permissions(@tournament) %>
-<%= link_to "Generate Pool Matches" , "/static_pages/generate_matches?tournament=#{@tournament.id}", data: { confirm: 'Are you sure? This will delete all current matches.' }, :class=>"btn btn-success" %>
+<%= 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" %>
diff --git a/app/views/static_pages/team_scores.html.erb b/app/views/tournaments/team_scores.html.erb
similarity index 100%
rename from app/views/static_pages/team_scores.html.erb
rename to app/views/tournaments/team_scores.html.erb
diff --git a/app/views/static_pages/up_matches.html.erb b/app/views/tournaments/up_matches.html.erb
similarity index 100%
rename from app/views/static_pages/up_matches.html.erb
rename to app/views/tournaments/up_matches.html.erb
diff --git a/app/views/static_pages/weights.html.erb b/app/views/tournaments/weights.html.erb
similarity index 100%
rename from app/views/static_pages/weights.html.erb
rename to app/views/tournaments/weights.html.erb
diff --git a/config/routes.rb b/config/routes.rb
index f333cbf..fbd6f5d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -22,22 +22,23 @@ Wrestling::Application.routes.draw do
# You can have the root of your site routed with "root"
root 'static_pages#home'
- get 'static_pages/tournaments'
get 'static_pages/brackets'
get 'static_pages/all_brackets'
- get 'static_pages/weights'
get 'admin/index'
- get 'static_pages/up_matches'
get 'static_pages/control_match'
get 'static_pages/results'
- get 'static_pages/team_scores'
- get 'static_pages/noMatches'
get 'static_pages/createCustomWeights'
- get 'static_pages/generate_matches'
get 'static_pages/weigh_in'
post 'static_pages/weigh_in'
get 'static_pages/not_allowed'
+
+ 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'
+
# Example of regular route:
# get 'products/:id' => 'catalog#view'
diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb
index f3e28ab..52bb5f4 100644
--- a/test/controllers/static_pages_controller_test.rb
+++ b/test/controllers/static_pages_controller_test.rb
@@ -9,10 +9,6 @@ class StaticPagesControllerTest < ActionController::TestCase
@school = @tournament.schools.first
end
- def new
- get :new, tournament: @tournament.id
- end
-
def sign_in_owner
sign_in users(:one)
end
@@ -29,17 +25,6 @@ class StaticPagesControllerTest < ActionController::TestCase
assert_redirected_to '/static_pages/not_allowed'
end
- test "logged in tournament owner can generate matches" do
- sign_in_owner
- get :generate_matches, tournament: 1
- success
- end
-
- test "logged in non tournament owner cannot generate matches" do
- sign_in_non_owner
- get :generate_matches, tournament: 1
- redirect
- end
test "logged in tournament owner can access weigh_ins" do
sign_in_owner
diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb
index a5d7534..7c0f518 100644
--- a/test/controllers/tournaments_controller_test.rb
+++ b/test/controllers/tournaments_controller_test.rb
@@ -1,11 +1,39 @@
require 'test_helper'
class TournamentsControllerTest < ActionController::TestCase
- # setup do
- # @tournament = tournaments(:one)
- # end
+include Devise::TestHelpers
+
+ setup do
+ @tournament = Tournament.find(1)
+ @tournament.generateMatchups
+ @school = @tournament.schools.first
+ end
+
+ def sign_in_owner
+ sign_in users(:one)
+ end
+
+ def sign_in_non_owner
+ sign_in users(:two)
+ end
+
+ def success
+ assert_response :success
+ end
+
+ def redirect
+ assert_redirected_to '/static_pages/not_allowed'
+ end
+ test "logged in tournament owner can generate matches" do
+ sign_in_owner
+ get :generate_matches, id: 1
+ success
+ end
+
+ test "logged in non tournament owner cannot generate matches" do
+ sign_in_non_owner
+ get :generate_matches, id: 1
+ redirect
+ end
- test "the truth" do
- assert true
- end
end