mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added is_public to a tournament to hide lineups and brackets until you're ready to make it public
This commit is contained in:
@@ -2,7 +2,7 @@ class SchoolsController < ApplicationController
|
|||||||
before_action :set_school, only: [:import_baumspage_roster, :show, :edit, :update, :destroy, :stats]
|
before_action :set_school, only: [:import_baumspage_roster, :show, :edit, :update, :destroy, :stats]
|
||||||
before_action :check_access_director, only: [:new,:create,:destroy]
|
before_action :check_access_director, only: [:new,:create,:destroy]
|
||||||
before_action :check_access_delegate, only: [:import_baumspage_roster, :update,:edit]
|
before_action :check_access_delegate, only: [:import_baumspage_roster, :update,:edit]
|
||||||
|
before_action :check_read_access, only: [:show]
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
@tournament = @school.tournament
|
@tournament = @school.tournament
|
||||||
@@ -108,5 +108,9 @@ class SchoolsController < ApplicationController
|
|||||||
def check_access_delegate
|
def check_access_delegate
|
||||||
authorize! :manage, @school
|
authorize! :manage, @school
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_read_access
|
||||||
|
authorize! :read, @school
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class TournamentsController < ApplicationController
|
|||||||
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
||||||
before_action :check_tournament_errors, only: [:generate_matches]
|
before_action :check_tournament_errors, only: [:generate_matches]
|
||||||
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
||||||
|
before_action :check_access_read, only: [:up_matches,:bracket,:all_brackets]
|
||||||
|
|
||||||
def weigh_in_sheet
|
def weigh_in_sheet
|
||||||
|
|
||||||
@@ -289,7 +290,7 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def tournament_params
|
def tournament_params
|
||||||
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId)
|
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId, :is_public)
|
||||||
end
|
end
|
||||||
|
|
||||||
#Check for tournament owner
|
#Check for tournament owner
|
||||||
@@ -301,6 +302,10 @@ class TournamentsController < ApplicationController
|
|||||||
authorize! :manage, @tournament
|
authorize! :manage, @tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_access_read
|
||||||
|
authorize! :read, @tournament
|
||||||
|
end
|
||||||
|
|
||||||
def check_for_matches
|
def check_for_matches
|
||||||
if @tournament
|
if @tournament
|
||||||
if @tournament.matches.empty? or @tournament.curently_generating_matches == 1
|
if @tournament.matches.empty? or @tournament.curently_generating_matches == 1
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class WeightsController < ApplicationController
|
class WeightsController < ApplicationController
|
||||||
before_action :set_weight, only: [:pool_order, :show, :edit, :update, :destroy,:re_gen]
|
before_action :set_weight, only: [:pool_order, :show, :edit, :update, :destroy,:re_gen]
|
||||||
before_action :check_access, only: [:pool_order, :new,:create,:update,:destroy,:edit, :re_gen]
|
before_action :check_access_manage, only: [:pool_order, :new,:create,:update,:destroy,:edit, :re_gen]
|
||||||
|
before_action :check_access_read, only: [:show]
|
||||||
|
|
||||||
|
|
||||||
# GET /weights/1
|
# GET /weights/1
|
||||||
@@ -103,7 +104,7 @@ class WeightsController < ApplicationController
|
|||||||
def weight_params
|
def weight_params
|
||||||
params.require(:weight).permit(:max, :tournament_id, :mat_id)
|
params.require(:weight).permit(:max, :tournament_id, :mat_id)
|
||||||
end
|
end
|
||||||
def check_access
|
def check_access_manage
|
||||||
if params[:tournament]
|
if params[:tournament]
|
||||||
@tournament = Tournament.find(params[:tournament])
|
@tournament = Tournament.find(params[:tournament])
|
||||||
elsif params[:weight]
|
elsif params[:weight]
|
||||||
@@ -114,5 +115,16 @@ class WeightsController < ApplicationController
|
|||||||
authorize! :manage, @tournament
|
authorize! :manage, @tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_access_read
|
||||||
|
if params[:tournament]
|
||||||
|
@tournament = Tournament.find(params[:tournament])
|
||||||
|
elsif params[:weight]
|
||||||
|
@tournament = Tournament.find(params[:weight]["tournament_id"])
|
||||||
|
elsif @weight
|
||||||
|
@tournament = @weight.tournament
|
||||||
|
end
|
||||||
|
authorize! :read, @tournament
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ class Ability
|
|||||||
cannot :destroy, Tournament do |tournament|
|
cannot :destroy, Tournament do |tournament|
|
||||||
tournament.delegates.map(&:user_id).include? user.id
|
tournament.delegates.map(&:user_id).include? user.id
|
||||||
end
|
end
|
||||||
|
# Can read tournament if tournament owner or tournament delegate
|
||||||
|
can :read, Tournament do |tournament|
|
||||||
|
if tournament.is_public
|
||||||
|
true
|
||||||
|
elsif tournament.delegates.map(&:user_id).include? user.id or tournament.user_id == user.id
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
#Can manage school if tournament owner
|
#Can manage school if tournament owner
|
||||||
can :manage, School do |school|
|
can :manage, School do |school|
|
||||||
school.tournament.user_id == user.id
|
school.tournament.user_id == user.id
|
||||||
@@ -53,6 +63,34 @@ class Ability
|
|||||||
cannot :destroy, School do |school|
|
cannot :destroy, School do |school|
|
||||||
school.delegates.map(&:user_id).include? user.id
|
school.delegates.map(&:user_id).include? user.id
|
||||||
end
|
end
|
||||||
|
# Can read school if school delegate, tournament delegate, or tournament director
|
||||||
|
can :read, School do |school|
|
||||||
|
if school.tournament.is_public
|
||||||
|
true
|
||||||
|
elsif school.delegates.map(&:user_id).include? user.id or school.tournament.delegates.map(&:user_id).include? user.id or school.tournament.user_id == user.id
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Default for non logged in users
|
||||||
|
else
|
||||||
|
# Can read tournament if tournament is public
|
||||||
|
can :read, Tournament do |tournament|
|
||||||
|
if tournament.is_public
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Can read school if tournament is public
|
||||||
|
can :read, School do |school|
|
||||||
|
if school.tournament.is_public
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,6 +43,15 @@
|
|||||||
<%= f.hidden_field :user_id, :value => current_user.id %>
|
<%= f.hidden_field :user_id, :value => current_user.id %>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label "Information is public" %> <br />
|
||||||
|
<%= f.check_box :is_public %> <br />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Leave this unchecked until you're ready to share seeding info, brackets, and lineups.
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<%= f.submit 'Submit',:class=>"btn btn-success" %>
|
<%= f.submit 'Submit',:class=>"btn btn-success" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,6 +17,14 @@
|
|||||||
<strong>Tournament Type:</strong>
|
<strong>Tournament Type:</strong>
|
||||||
<%= @tournament.tournament_type %>
|
<%= @tournament.tournament_type %>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Tournament Date:</strong>
|
||||||
|
<%= @tournament.date %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Tournament Information Is Public:</strong>
|
||||||
|
<%= @tournament.is_public %>
|
||||||
|
</p>
|
||||||
<p>Brackets and team scores can be found in the white nav-bar up top.</p>
|
<p>Brackets and team scores can be found in the white nav-bar up top.</p>
|
||||||
<br>
|
<br>
|
||||||
<h3>Schools</h3>
|
<h3>Schools</h3>
|
||||||
@@ -32,15 +40,20 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% @schools.each do |school| %>
|
<% @schools.each do |school| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to "#{school.name}", school %>
|
<td>
|
||||||
|
<% if can? :read, school %>
|
||||||
|
<%= link_to "#{school.name}", school %>
|
||||||
|
<% else %>
|
||||||
|
<%= "#{school.name}" %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
<% if can? :manage, school %>
|
<% if can? :manage, school %>
|
||||||
<td><%= link_to '', edit_school_path(school), :class=>"fas fa-edit" %>
|
<%= link_to '', edit_school_path(school), :class=>"fas fa-edit" %>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<%= link_to '', school, method: :delete, data: { confirm: "Are you sure you want to delete #{school.name}?" }, :class=>"fas fa-trash-alt" %>
|
<%= link_to '', school, method: :delete, data: { confirm: "Are you sure you want to delete #{school.name}?" }, :class=>"fas fa-trash-alt" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -61,7 +74,13 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% @weights.each do |weight| %>
|
<% @weights.each do |weight| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to "#{weight.max} lbs", weight %></td>
|
<td>
|
||||||
|
<% if can? :read, @tournament %>
|
||||||
|
<%= link_to "#{weight.max} lbs", weight %>
|
||||||
|
<% else %>
|
||||||
|
<%= "#{weight.max}" %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td><%= weight.bracket_size %></td>
|
<td><%= weight.bracket_size %></td>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddIsPublicToTournaments < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :tournaments, :is_public, :boolean
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class SetAllExistingTournamentsAsPublic < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
Tournament.update_all(is_public: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
Tournament.update_all(is_public: nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_09_12_171922) do
|
ActiveRecord::Schema.define(version: 2023_01_02_040503) do
|
||||||
|
|
||||||
create_table "delayed_jobs", force: :cascade do |t|
|
create_table "delayed_jobs", force: :cascade do |t|
|
||||||
t.integer "priority", default: 0, null: false
|
t.integer "priority", default: 0, null: false
|
||||||
@@ -108,6 +108,7 @@ ActiveRecord::Schema.define(version: 2022_09_12_171922) do
|
|||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "curently_generating_matches"
|
t.integer "curently_generating_matches"
|
||||||
t.date "date"
|
t.date "date"
|
||||||
|
t.boolean "is_public"
|
||||||
t.index ["user_id"], name: "index_tournaments_on_user_id"
|
t.index ["user_id"], name: "index_tournaments_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
10
db/seeds.rb
10
db/seeds.rb
@@ -31,7 +31,7 @@
|
|||||||
User.create(id: 1, email: 'test@test.com', password: 'password', password_confirmation: 'password')
|
User.create(id: 1, email: 'test@test.com', password: 'password', password_confirmation: 'password')
|
||||||
|
|
||||||
# Pool to bracket
|
# Pool to bracket
|
||||||
tournament = Tournament.create(id: 200, name: 'Test1', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today)
|
tournament = Tournament.create(id: 200, name: 'Test1', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today, is_public: true)
|
||||||
create_schools(tournament, 16)
|
create_schools(tournament, 16)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Modified 16 Man Double Elimination 1-6
|
# Modified 16 Man Double Elimination 1-6
|
||||||
tournament = Tournament.create(id: 201, name: 'Test2', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-6', user_id: 1, date: Date.today)
|
tournament = Tournament.create(id: 201, name: 'Test2', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-6', user_id: 1, date: Date.today, is_public: true)
|
||||||
create_schools(tournament, 16)
|
create_schools(tournament, 16)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Modified 16 Man Double Elimination 1-8
|
# Modified 16 Man Double Elimination 1-8
|
||||||
tournament = Tournament.create(id: 202, name: 'Test3', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-8', user_id: 1, date: Date.today)
|
tournament = Tournament.create(id: 202, name: 'Test3', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-8', user_id: 1, date: Date.today, is_public: true)
|
||||||
create_schools(tournament, 16)
|
create_schools(tournament, 16)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Regular Double Elimination 1-6
|
# Regular Double Elimination 1-6
|
||||||
tournament = Tournament.create(id: 203, name: 'Test4', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-6', user_id: 1, date: Date.today)
|
tournament = Tournament.create(id: 203, name: 'Test4', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-6', user_id: 1, date: Date.today, is_public: true)
|
||||||
create_schools(tournament, 16)
|
create_schools(tournament, 16)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Regular Double Elimination 1-8
|
# Regular Double Elimination 1-8
|
||||||
tournament = Tournament.create(id: 204, name: 'Test5', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: Date.today)
|
tournament = Tournament.create(id: 204, name: 'Test5', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: Date.today, is_public: true)
|
||||||
create_schools(tournament, 16)
|
create_schools(tournament, 16)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
get :new, params: { tournament: @tournament.id }
|
get :new, params: { tournament: @tournament.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_show
|
||||||
|
get :show, params: { id: @school.id }
|
||||||
|
end
|
||||||
|
|
||||||
def post_update
|
def post_update
|
||||||
patch :update, params: { id: @school.id, school: {name: @school.name, tournament_id: @school.tournament_id} }
|
patch :update, params: { id: @school.id, school: {name: @school.name, tournament_id: @school.tournament_id} }
|
||||||
end
|
end
|
||||||
@@ -205,4 +209,85 @@ Some Guy
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||||
|
test "logged in school delegate can get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user cannot get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_tournament_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
get_show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||||
|
test "logged in school delegate can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_tournament_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
# END SHOW PAGE PERMISSIONS
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,18 @@ class TournamentsControllerTest < ActionController::TestCase
|
|||||||
def post_update
|
def post_update
|
||||||
patch :update, params: { id: 1, tournament: {name: @tournament.name} }
|
patch :update, params: { id: 1, tournament: {name: @tournament.name} }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_bracket
|
||||||
|
get :up_matches, params: { id: 1 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_all_brackets
|
||||||
|
get :all_brackets, params: { id: 1 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_up_matches
|
||||||
|
get :up_matches, params: { id: 1 }
|
||||||
|
end
|
||||||
|
|
||||||
def get_edit
|
def get_edit
|
||||||
get :edit, params: { id: 1 }
|
get :edit, params: { id: 1 }
|
||||||
@@ -211,6 +223,248 @@ class TournamentsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||||
|
test "logged in school delegate cannot get bracket page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_bracket
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user cannot get bracket page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_bracket
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get bracket page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get bracket page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot get bracket page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
get_bracket
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||||
|
test "logged in school delegate can get bracket page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user can get bracket page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get bracket page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get bracket page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user can get bracket page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
get_bracket
|
||||||
|
success
|
||||||
|
end
|
||||||
|
# END BRACKETS PAGE PERMISSIONS
|
||||||
|
|
||||||
|
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||||
|
test "logged in school delegate cannot get all brackets page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_all_brackets
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user cannot get all brackets page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_all_brackets
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get all brackets page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get all brackets page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot get all brackets page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
get_all_brackets
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||||
|
test "logged in school delegate can get all brackets page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user can get all brackets page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get all brackets page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get all brackets page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user can get all brackets page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
get_all_brackets
|
||||||
|
success
|
||||||
|
end
|
||||||
|
# END ALL BRACKETS PAGE PERMISSIONS
|
||||||
|
|
||||||
|
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||||
|
test "logged in school delegate cannot get up matches page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_up_matches
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user cannot get up matches page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_up_matches
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get up matches page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get up matches page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot get up matches page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
get_up_matches
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||||
|
test "logged in school delegate can get up matches page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user can get up matches page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get up matches page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_delegate
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get up matches page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user can get up matches page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
get_up_matches
|
||||||
|
success
|
||||||
|
end
|
||||||
|
# END UP MATCHES PAGE PERMISSIONS
|
||||||
|
|
||||||
#TESTS THAT NEED MATCHES PUT ABOVE THIS
|
#TESTS THAT NEED MATCHES PUT ABOVE THIS
|
||||||
test "redirect up_matches if no matches" do
|
test "redirect up_matches if no matches" do
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
get :edit, params: { id: @weight.id }
|
get :edit, params: { id: @weight.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_show
|
||||||
|
get :show, params: { id: @weight.id }
|
||||||
|
end
|
||||||
|
|
||||||
def get_pool_order
|
def get_pool_order
|
||||||
post :pool_order, params: {pool_to_order: 1, id: @weight.id}
|
post :pool_order, params: {pool_to_order: 1, id: @weight.id}
|
||||||
end
|
end
|
||||||
@@ -210,6 +214,87 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
|
||||||
|
test "logged in school delegate cannot get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user cannot get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_tournament_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot get show page when tournament is not public" do
|
||||||
|
@tournament.is_public = false
|
||||||
|
@tournament.save
|
||||||
|
get_show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
|
||||||
|
test "logged in school delegate can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_non_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_tournament_delegate
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament owner can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
sign_in_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user can get show page when tournament is public" do
|
||||||
|
@tournament.is_public = true
|
||||||
|
@tournament.save
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
end
|
||||||
|
# END SHOW PAGE PERMISSIONS
|
||||||
|
|
||||||
test "view wegiht" do
|
test "view wegiht" do
|
||||||
get :show, params: { id: 1 }
|
get :show, params: { id: 1 }
|
||||||
success
|
success
|
||||||
|
|||||||
3
test/fixtures/tournaments.yml
vendored
3
test/fixtures/tournaments.yml
vendored
@@ -8,4 +8,5 @@ one:
|
|||||||
director_email: jacob.wimer@gmail.com
|
director_email: jacob.wimer@gmail.com
|
||||||
tournament_type: Pool to bracket
|
tournament_type: Pool to bracket
|
||||||
user_id: 1
|
user_id: 1
|
||||||
date: 2015-12-30
|
date: 2015-12-30
|
||||||
|
is_public: true
|
||||||
@@ -21,6 +21,7 @@ class ActiveSupport::TestCase
|
|||||||
@tournament.director_email= "test@test.com"
|
@tournament.director_email= "test@test.com"
|
||||||
@tournament.tournament_type = "Pool to bracket"
|
@tournament.tournament_type = "Pool to bracket"
|
||||||
@tournament.date = "2015-12-30"
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.is_public = true
|
||||||
@tournament.save
|
@tournament.save
|
||||||
@school = School.new
|
@school = School.new
|
||||||
@school.name = "Test"
|
@school.name = "Test"
|
||||||
@@ -43,6 +44,7 @@ class ActiveSupport::TestCase
|
|||||||
@tournament.director_email= "test@test.com"
|
@tournament.director_email= "test@test.com"
|
||||||
@tournament.tournament_type = "Regular Double Elimination 1-6"
|
@tournament.tournament_type = "Regular Double Elimination 1-6"
|
||||||
@tournament.date = "2015-12-30"
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.is_public = true
|
||||||
@tournament.save
|
@tournament.save
|
||||||
@school = School.new
|
@school = School.new
|
||||||
@school.name = "Test"
|
@school.name = "Test"
|
||||||
@@ -65,6 +67,7 @@ class ActiveSupport::TestCase
|
|||||||
@tournament.director_email= "test@test.com"
|
@tournament.director_email= "test@test.com"
|
||||||
@tournament.tournament_type = tournament_type
|
@tournament.tournament_type = tournament_type
|
||||||
@tournament.date = "2015-12-30"
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.is_public = true
|
||||||
@tournament.save
|
@tournament.save
|
||||||
@school = School.new
|
@school = School.new
|
||||||
@school.name = "Test"
|
@school.name = "Test"
|
||||||
@@ -100,6 +103,7 @@ class ActiveSupport::TestCase
|
|||||||
@tournament.director_email= "test@test.com"
|
@tournament.director_email= "test@test.com"
|
||||||
@tournament.tournament_type = "Pool to bracket"
|
@tournament.tournament_type = "Pool to bracket"
|
||||||
@tournament.date = "2015-12-30"
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.is_public = true
|
||||||
@tournament.save
|
@tournament.save
|
||||||
|
|
||||||
# First school
|
# First school
|
||||||
|
|||||||
Reference in New Issue
Block a user