mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-08 15:29:20 +00:00
Merge branch 'development' of https://github.com/jcwimer/wrestlingApp into development
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
class SchoolsController < ApplicationController
|
class SchoolsController < ApplicationController
|
||||||
before_action :set_school, only: [:show, :edit, :update, :destroy]
|
before_action :set_school, only: [:show, :edit, :update, :destroy]
|
||||||
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit]
|
before_filter :check_access_director, only: [:new,:create,:destroy]
|
||||||
|
before_filter :check_access_delegate, only: [:update,:edit]
|
||||||
|
|
||||||
|
|
||||||
# GET /schools/1
|
# GET /schools/1
|
||||||
@@ -76,15 +77,21 @@ class SchoolsController < ApplicationController
|
|||||||
params.require(:school).permit(:name, :score, :tournament_id)
|
params.require(:school).permit(:name, :score, :tournament_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_access
|
def check_access_director
|
||||||
if params[:tournament]
|
if params[:tournament]
|
||||||
@tournament = Tournament.find(params[:tournament])
|
@tournament = Tournament.find(params[:tournament])
|
||||||
elsif params[:school]
|
elsif params[:school]
|
||||||
@tournament = Tournament.find(params[:school]["tournament_id"])
|
@tournament = Tournament.find(params[:school]["tournament_id"])
|
||||||
elsif @school
|
elsif @school
|
||||||
@tournament = @school.tournament
|
@tournament = @school.tournament
|
||||||
|
elsif school_params
|
||||||
|
@tournament = Tournament.find(school_params[:tournament_id])
|
||||||
end
|
end
|
||||||
authorize! :manage, @tournament
|
authorize! :manage, @tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_access_delegate
|
||||||
|
authorize! :manage, @school
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class StaticPagesController < ApplicationController
|
|||||||
tournaments_delegated = current_user.delegated_tournaments
|
tournaments_delegated = current_user.delegated_tournaments
|
||||||
all_tournaments = tournaments_created + tournaments_delegated
|
all_tournaments = tournaments_created + tournaments_delegated
|
||||||
@tournaments = all_tournaments.sort_by{|t| t.daysUntil}
|
@tournaments = all_tournaments.sort_by{|t| t.daysUntil}
|
||||||
|
@schools = current_user.delegated_schools
|
||||||
end
|
end
|
||||||
|
|
||||||
def not_allowed
|
def not_allowed
|
||||||
|
|||||||
@@ -1,10 +1,73 @@
|
|||||||
class TournamentsController < ApplicationController
|
class TournamentsController < ApplicationController
|
||||||
before_action :set_tournament, only: [:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
|
before_action :set_tournament, only: [:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
|
||||||
before_filter :check_access_manage, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
|
before_filter :check_access_manage, only: [:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
|
||||||
before_filter :check_access_destroy, only: [:destroy]
|
before_filter :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
||||||
|
|
||||||
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
before_filter :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
|
||||||
|
|
||||||
|
def remove_delegate
|
||||||
|
if params[:delegate]
|
||||||
|
@delegate = TournamentDelegate.find(params[:delegate])
|
||||||
|
@delegate.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'Delegated permissions removed successfully' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_school_delegate
|
||||||
|
if params[:delegate]
|
||||||
|
@delegate = SchoolDelegate.find(params[:delegate])
|
||||||
|
@delegate.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'Delegated permissions removed successfully' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def school_delegate
|
||||||
|
if params[:search]
|
||||||
|
@users = User.search(params[:search])
|
||||||
|
elsif params[:school_delegate]
|
||||||
|
@delegate = SchoolDelegate.new
|
||||||
|
@delegate.user_id = params[:school_delegate]["user_id"]
|
||||||
|
@delegate.school_id = params[:school_delegate]["school_id"]
|
||||||
|
respond_to do |format|
|
||||||
|
if @delegate.save
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'Delegated permissions added successfully' }
|
||||||
|
else
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'There was an issue delegating permissions please try again' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@users_delegates = []
|
||||||
|
@tournament.schools.each do |s|
|
||||||
|
s.delegates.each do |d|
|
||||||
|
@users_delegates << d
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def delegate
|
||||||
|
if params[:search]
|
||||||
|
@users = User.search(params[:search])
|
||||||
|
elsif params[:tournament_delegate]
|
||||||
|
@delegate = TournamentDelegate.new
|
||||||
|
@delegate.user_id = params[:tournament_delegate]["user_id"]
|
||||||
|
@delegate.tournament_id = @tournament.id
|
||||||
|
respond_to do |format|
|
||||||
|
if @delegate.save
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'Delegated permissions added successfully' }
|
||||||
|
else
|
||||||
|
format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'There was an issue delegating permissions please try again' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@users_delegates = @tournament.delegates
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def matches
|
def matches
|
||||||
@matches = @tournament.matches.sort_by{|m| m.bout_number}
|
@matches = @tournament.matches.sort_by{|m| m.bout_number}
|
||||||
if @match
|
if @match
|
||||||
|
|||||||
@@ -92,13 +92,16 @@ class WrestlersController < ApplicationController
|
|||||||
def check_access
|
def check_access
|
||||||
if params[:school]
|
if params[:school]
|
||||||
@school = School.find(params[:school])
|
@school = School.find(params[:school])
|
||||||
@tournament = Tournament.find(@school.tournament.id)
|
#@tournament = Tournament.find(@school.tournament.id)
|
||||||
elsif params[:wrestler]
|
elsif params[:wrestler]
|
||||||
@school = School.find(params[:wrestler]["school_id"])
|
@school = School.find(params[:wrestler]["school_id"])
|
||||||
@tournament = Tournament.find(@school.tournament.id)
|
#@tournament = Tournament.find(@school.tournament.id)
|
||||||
elsif @wrestler
|
elsif @wrestler
|
||||||
@tournament = @wrestler.tournament
|
@school = @wrestler.school
|
||||||
|
#@tournament = @wrestler.tournament
|
||||||
|
elsif wrestler_params
|
||||||
|
@school = School.find(wrestler_params[:school_id])
|
||||||
end
|
end
|
||||||
authorize! :manage, @tournament
|
authorize! :manage, @school
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Ability
|
|||||||
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.map(&:user_id).include? user.id
|
school.tournament.user_id == user.id
|
||||||
end
|
end
|
||||||
#Can manage school if tournament delegate
|
#Can manage school if tournament delegate
|
||||||
can :manage, School do |school|
|
can :manage, School do |school|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Mat < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assignNextMatch
|
def assignNextMatch
|
||||||
t_matches = tournament.matches.select{|m| m.mat_id == nil}
|
t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1}
|
||||||
if t_matches.size > 0
|
if t_matches.size > 0
|
||||||
match = t_matches.sort_by{|m| m.bout_number}.first
|
match = t_matches.sort_by{|m| m.bout_number}.first
|
||||||
match.mat_id = self.id
|
match.mat_id = self.id
|
||||||
|
|||||||
@@ -52,9 +52,11 @@ class Match < ActiveRecord::Base
|
|||||||
if self.w1 && self.w2
|
if self.w1 && self.w2
|
||||||
@w1 = wrestler1
|
@w1 = wrestler1
|
||||||
@w2 = wrestler2
|
@w2 = wrestler2
|
||||||
@w1.advanceInBracket
|
@w1.advanceInBracket(self)
|
||||||
@w2.advanceInBracket
|
@w2.advanceInBracket(self)
|
||||||
self.mat.assignNextMatch
|
if self.mat
|
||||||
|
self.mat.assignNextMatch
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class PoolAdvance
|
class PoolAdvance
|
||||||
|
|
||||||
def initialize(wrestler)
|
def initialize(wrestler,previousMatch)
|
||||||
@wrestler = wrestler
|
@wrestler = wrestler
|
||||||
|
@previousMatch = previousMatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def advanceWrestler
|
def advanceWrestler
|
||||||
@@ -29,10 +30,10 @@ class PoolAdvance
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bracketAdvancment
|
def bracketAdvancment
|
||||||
if @wrestler.winnerOfLastMatch?
|
if @previousMatch.winner_id == @wrestler.id
|
||||||
winnerAdvance
|
winnerAdvance
|
||||||
end
|
end
|
||||||
if !@wrestler.winnerOfLastMatch?
|
if @previousMatch.winner_id != @wrestler.id
|
||||||
loserAdvance
|
loserAdvance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
class SchoolDelegate < ActiveRecord::Base
|
class SchoolDelegate < ActiveRecord::Base
|
||||||
|
belongs_to :school
|
||||||
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def resetMats
|
def resetMats
|
||||||
matchesToReset = matches.select{|m| m.finished != 1 && m.mat_id != nil}
|
matchesToReset = matches.select{|m| m.mat_id != nil}
|
||||||
# matchesToReset.update_all( {:mat_id => nil } )
|
# matchesToReset.update_all( {:mat_id => nil } )
|
||||||
matchesToReset.each do |m|
|
matchesToReset.each do |m|
|
||||||
m.mat_id = nil
|
m.mat_id = nil
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class TournamentDelegate < ActiveRecord::Base
|
class TournamentDelegate < ActiveRecord::Base
|
||||||
# belongs_to :tournament
|
belongs_to :tournament
|
||||||
# has_one :user
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,10 +2,29 @@ class User < ActiveRecord::Base
|
|||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
has_many :tournaments
|
has_many :tournaments
|
||||||
has_many :delegated_tournaments, class_name: "TournamentDelegate"
|
has_many :delegated_tournament_permissions, class_name: "TournamentDelegate"
|
||||||
has_many :delegated_schools, class_name: "SchoolDelegate"
|
has_many :delegated_school_permissions, class_name: "SchoolDelegate"
|
||||||
|
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
def delegated_tournaments
|
||||||
|
tournaments_delegated = []
|
||||||
|
delegated_tournament_permissions.each do |t|
|
||||||
|
tournaments_delegated << t.tournament
|
||||||
|
end
|
||||||
|
tournaments_delegated
|
||||||
|
end
|
||||||
|
|
||||||
|
def delegated_schools
|
||||||
|
schools_delegated = []
|
||||||
|
delegated_school_permissions.each do |t|
|
||||||
|
schools_delegated << t.school
|
||||||
|
end
|
||||||
|
schools_delegated
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.search(search)
|
||||||
|
where("email LIKE ?", "%#{search}%")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class Wrestler < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def advanceInBracket
|
def advanceInBracket(match)
|
||||||
PoolAdvance.new(self).advanceWrestler
|
PoolAdvance.new(self,match).advanceWrestler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,5 +12,8 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.map"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.map"></script>
|
||||||
|
|
||||||
|
<!--Mobile and tablet detection-->
|
||||||
|
<script type='text/javascript' src="//wurfl.io/wurfl.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -7,9 +7,15 @@
|
|||||||
<li><%= link_to "Browse Tournaments", "/tournaments/" %></li>
|
<li><%= link_to "Browse Tournaments", "/tournaments/" %></li>
|
||||||
<li><%= link_to "About", "/static_pages/about" %></li>
|
<li><%= link_to "About", "/static_pages/about" %></li>
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<li><%=link_to "Log out", destroy_user_session_url ,:method => 'delete' %></li>
|
<li class="dropdown">
|
||||||
<li><%=link_to "Edit user", edit_user_registration_path %></li>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= current_user.email %>
|
||||||
<li><%=link_to "My tournaments","/static_pages/my_tournaments" %></li>
|
<span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><%=link_to "Log out", destroy_user_session_url ,:method => 'delete' %></li>
|
||||||
|
<li><%=link_to "Edit user", edit_user_registration_path %></li>
|
||||||
|
<li><%=link_to "My tournaments and schools","/static_pages/my_tournaments" %></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Log In" , new_user_session_path %></li>
|
<li><%= link_to "Log In" , new_user_session_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
<br><%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
|
<br><%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
|
||||||
<br><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %>
|
<br><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %>
|
||||||
<br><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" %>
|
<br><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" %>
|
||||||
|
<% if can? :destroy, @tournament %>
|
||||||
|
<br><%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %>
|
||||||
|
<% end %>
|
||||||
|
<br><%= link_to "School Delegation" , "/tournaments/#{@tournament.id}/school_delegate"%>
|
||||||
|
|
||||||
<br><br><strong>Time Savers</strong><br>
|
<br><br><strong>Time Savers</strong><br>
|
||||||
<br><%= link_to "Create High School Weights" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
|
<br><%= link_to "Create High School Weights" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
|
||||||
@@ -31,7 +35,33 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<br><br>
|
<br>
|
||||||
|
<% if Rails.env.production? %>
|
||||||
|
<div class="adLNav">
|
||||||
|
<script type="text/javascript">
|
||||||
|
if(WURFL.is_mobile){
|
||||||
|
//Mobile and tablet ad
|
||||||
|
(function (){
|
||||||
|
if(window.CHITIKA===undefined) {window.CHITIKA = {'units' :[]};};
|
||||||
|
var unit = {"calltype":"async[2]","publisher":"cwimer","width":468,"height":60,"sid":"Chitika Default"};
|
||||||
|
var placement_id = window.CHITIKA.units.length;
|
||||||
|
window.CHITIKA.units.push(unit);
|
||||||
|
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
|
||||||
|
}());
|
||||||
|
} else {
|
||||||
|
//Desktop ad
|
||||||
|
(function (){
|
||||||
|
if(window.CHITIKA===undefined) {window.CHITIKA = {'units' :[]};};
|
||||||
|
var unit = {"calltype":"async[2]","publisher":"cwimer","width":160,"height":160,"sid":"Chitika Default"};
|
||||||
|
var placement_id = window.CHITIKA.units.length;
|
||||||
|
window.CHITIKA.units.push(unit);
|
||||||
|
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
<% if Rails.env.production? %>
|
<% if Rails.env.production? %>
|
||||||
<div class="ad">
|
<div class="adRnav">
|
||||||
<script type='text/javascript' src='//eclkmpbn.com/adServe/banners?tid=85597_138467_6&size=158x21'></script>
|
<script type="text/javascript">
|
||||||
|
if(WURFL.is_mobile){
|
||||||
|
//Mobile and tablet ad
|
||||||
|
(function (){
|
||||||
|
if(window.CHITIKA===undefined) {window.CHITIKA = {'units' :[]};};
|
||||||
|
var unit = {"calltype":"async[2]","publisher":"cwimer","width":468,"height":60,"sid":"Chitika Default"};
|
||||||
|
var placement_id = window.CHITIKA.units.length;
|
||||||
|
window.CHITIKA.units.push(unit);
|
||||||
|
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
|
||||||
|
}());
|
||||||
|
} else {
|
||||||
|
//Desktop ad
|
||||||
|
(function (){
|
||||||
|
if(window.CHITIKA===undefined) {window.CHITIKA = {'units' :[]};};
|
||||||
|
var unit = {"calltype":"async[2]","publisher":"cwimer","width":120,"height":600,"sid":"Chitika Default"};
|
||||||
|
var placement_id = window.CHITIKA.units.length;
|
||||||
|
window.CHITIKA.units.push(unit);
|
||||||
|
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="afs_ads"> </div>
|
<div class="afs_ads"> </div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %>
|
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @school %>
|
||||||
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
|
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @school %>
|
||||||
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
|
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
@@ -39,8 +39,6 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Weight</th>
|
<th>Weight</th>
|
||||||
<th>Seed</th>
|
<th>Seed</th>
|
||||||
<th>Record</th>
|
|
||||||
<th>Seed Criteria</th>
|
|
||||||
<th>Team Points Scored</th>
|
<th>Team Points Scored</th>
|
||||||
<th>Extra?</th>
|
<th>Extra?</th>
|
||||||
<th>Next Bout/Mat</th>
|
<th>Next Bout/Mat</th>
|
||||||
@@ -57,8 +55,6 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= wrestler.original_seed %>
|
<%= wrestler.original_seed %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
|
||||||
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td>
|
|
||||||
<td><%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %></td>
|
<td><%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %></td>
|
||||||
<td><% if wrestler.extra? == true %>
|
<td><% if wrestler.extra? == true %>
|
||||||
Yes
|
Yes
|
||||||
@@ -66,7 +62,7 @@
|
|||||||
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td>
|
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %>
|
<%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, wrestler.school %>
|
||||||
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %>
|
||||||
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
|
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
|
||||||
<% if can? :manage, tournament %>
|
<% if can? :manage, tournament %>
|
||||||
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
<% end %>
|
||||||
|
<% if can? :destroy, tournament %>
|
||||||
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
@@ -34,7 +36,38 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<% if @schools.size > 0 %>
|
||||||
|
<h1>My Schools</h1>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<table class="table table-striped table-bordered table-condensed" id="tournamentList">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Tournament Name</th>
|
||||||
|
<th>Tournament Date</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @schools.each do |school| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= school.name %></td>
|
||||||
|
<td><%= school.tournament.name %></td>
|
||||||
|
<td><%= school.tournament.date %></td>
|
||||||
|
<td><%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %>
|
||||||
|
<% if can? :manage, school %>
|
||||||
|
<%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,6 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<%= link_to "Back to #{@tournament.name} weights", "/tournaments/#{@tournament.id}/brackets" %>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div id="exportable">
|
<div id="exportable">
|
||||||
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
|
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
|
||||||
<table class='pagebreak'>
|
<table class='pagebreak'>
|
||||||
|
|||||||
66
app/views/tournaments/delegate.html.erb
Normal file
66
app/views/tournaments/delegate.html.erb
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% if @users %>
|
||||||
|
<h1>Search results</h1> <%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %>
|
||||||
|
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
<p>Search by email address</p>
|
||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User Email</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @users.each do |user| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= user.email %></td>
|
||||||
|
<td>
|
||||||
|
<%= form_for TournamentDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "post") do |f| %>
|
||||||
|
<%= f.hidden_field :user_id, :value => user.id %>
|
||||||
|
<% if can? :manage, @tournament %>
|
||||||
|
<%= submit_tag "Give permissions", :class=>"btn btn-success"%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @users_delegates %>
|
||||||
|
<h1>Delegated users</h1> <%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %>
|
||||||
|
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
<p>Search by email address</p>
|
||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User Email</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @users_delegates.each do |delegate| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= delegate.user.email %></td>
|
||||||
|
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
|
<td><%= link_to 'Show', tournament, :class=>"btn btn-default btn-sm" %>
|
||||||
<% if can? :manage, tournament %>
|
<% if can? :manage, tournament %>
|
||||||
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
<% end %>
|
||||||
|
<% if can? :destroy, tournament %>
|
||||||
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
71
app/views/tournaments/school_delegate.html.erb
Normal file
71
app/views/tournaments/school_delegate.html.erb
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<%= link_to "Back to #{@tournament_name}", "/tournaments/#{@tournament_id}", :class=>"btn btn-default" %>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% if @users %>
|
||||||
|
<h1>Search results</h1> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
|
||||||
|
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
<p>Search by email address</p>
|
||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User Email</th>
|
||||||
|
<th>School to delegate</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @users.each do |user| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= user.email %></td>
|
||||||
|
<%= form_for SchoolDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'school_delegate', :method => "post") do |f| %>
|
||||||
|
<td><%= f.collection_select :school_id, @tournament.schools, :id, :name %></td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= f.hidden_field :user_id, :value => user.id %>
|
||||||
|
<% if can? :manage, @tournament %>
|
||||||
|
<%= submit_tag "Give permissions", :class=>"btn btn-success"%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @users_delegates %>
|
||||||
|
<h1>Delegated users schools</h1> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
|
||||||
|
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
<p>Search by email address</p>
|
||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
<table class="table table-striped table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User Email</th>
|
||||||
|
<th>School</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @users_delegates.each do |delegate| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= delegate.user.email %></td>
|
||||||
|
<td><%= delegate.school.name %></td>
|
||||||
|
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_school_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
@@ -53,8 +53,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= school.name %></td>
|
<td><%= school.name %></td>
|
||||||
<td><%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %>
|
<td><%= link_to 'Show', school, :class=>"btn btn-default btn-sm" %>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, school %>
|
||||||
<%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Edit', edit_school_path(school), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
<% end %>
|
||||||
|
<% if can? :manage, @tournament %>
|
||||||
<%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
<%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
|
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @school %>
|
||||||
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
|
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% cache ["wrestlers", @wrestler] do %>
|
<% cache ["wrestlers", @wrestler] do %>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ Wrestling::Application.routes.draw do
|
|||||||
|
|
||||||
# You can have the root of your site routed with "root"
|
# You can have the root of your site routed with "root"
|
||||||
root 'static_pages#home'
|
root 'static_pages#home'
|
||||||
get 'admin/index'
|
|
||||||
get 'static_pages/control_match'
|
get 'static_pages/control_match'
|
||||||
get 'static_pages/not_allowed'
|
get 'static_pages/not_allowed'
|
||||||
get 'static_pages/about'
|
get 'static_pages/about'
|
||||||
@@ -34,12 +33,18 @@ Wrestling::Application.routes.draw do
|
|||||||
get 'tournaments/:id/create_custom_weights' => 'tournaments#create_custom_weights'
|
get 'tournaments/:id/create_custom_weights' => 'tournaments#create_custom_weights'
|
||||||
get 'tournaments/:id/all_brackets' => 'tournaments#all_brackets'
|
get 'tournaments/:id/all_brackets' => 'tournaments#all_brackets'
|
||||||
get 'tournaments/:id/brackets' => 'tournaments#brackets'
|
get 'tournaments/:id/brackets' => 'tournaments#brackets'
|
||||||
get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket'
|
get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket', :as => :weight_bracket
|
||||||
get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches'
|
get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches'
|
||||||
get 'tournaments/:id/team_scores' => 'tournaments#team_scores'
|
get 'tournaments/:id/team_scores' => 'tournaments#team_scores'
|
||||||
get 'tournaments/:id/up_matches' => 'tournaments#up_matches'
|
get 'tournaments/:id/up_matches' => 'tournaments#up_matches', :as => :up_matches
|
||||||
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
|
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
|
||||||
get 'tournaments/:id/matches' => 'tournaments#matches'
|
get 'tournaments/:id/matches' => 'tournaments#matches'
|
||||||
|
get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate
|
||||||
|
post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate
|
||||||
|
delete 'tournaments/:id/:delegate/remove_delegate' => 'tournaments#remove_delegate', :as => :delete_delegate_path
|
||||||
|
get 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :school_delegate
|
||||||
|
post 'tournaments/:id/school_delegate' => 'tournaments#school_delegate', :as => :set_school_delegate
|
||||||
|
delete 'tournaments/:id/:delegate/remove_school_delegate' => 'tournaments#remove_school_delegate', :as => :delete_school_delegate_path
|
||||||
|
|
||||||
# Example of regular route:
|
# Example of regular route:
|
||||||
# get 'products/:id' => 'catalog#view'
|
# get 'products/:id' => 'catalog#view'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ FROM ruby:2.2.3
|
|||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get -y upgrade
|
RUN apt-get -y upgrade
|
||||||
|
|
||||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs mysql-client
|
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs mysql-client postfix
|
||||||
|
|
||||||
#New Relic
|
#New Relic
|
||||||
#RUN echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list
|
#RUN echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -53,6 +57,12 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not get edit match page if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user should not get edit match page" do
|
test "non logged in user should not get edit match page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -69,6 +79,12 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not post update match if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament delegate should get edit match page" do
|
test "logged in tournament delegate should get edit match page" do
|
||||||
sign_in_tournament_delegate
|
sign_in_tournament_delegate
|
||||||
get_edit
|
get_edit
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -79,6 +83,12 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not get edit mat page if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user should not get edit mat page" do
|
test "non logged in user should not get edit mat page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -95,6 +105,12 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not post update mat if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner should post update mat" do
|
test "logged in tournament owner should post update mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -131,6 +147,14 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate not tournament owner cannot create a mat" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
new
|
||||||
|
redirect
|
||||||
|
create
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can destroy a mat" do
|
test "logged in tournament owner can destroy a mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
destroy
|
destroy
|
||||||
@@ -149,12 +173,24 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate not tournament owner cannot destroy mat" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user should not get show mat" do
|
test "logged in user should not get show mat" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
show
|
show
|
||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not get show mat" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
show
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner should get show mat" do
|
test "logged in tournament owner should get show mat" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
show
|
show
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -61,6 +65,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should get edit school page" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user should not get edit school page if not owner" do
|
test "logged in user should not get edit school page if not owner" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
get_edit
|
get_edit
|
||||||
@@ -95,6 +105,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to tournament_path(@school.tournament_id)
|
assert_redirected_to tournament_path(@school.tournament_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should post update school" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
assert_redirected_to tournament_path(@school.tournament_id)
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can create a new school" do
|
test "logged in tournament owner can create a new school" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
new
|
new
|
||||||
@@ -111,6 +127,14 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to tournament_path(@school.tournament_id)
|
assert_redirected_to tournament_path(@school.tournament_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot create a new school" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
new
|
||||||
|
redirect
|
||||||
|
create
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user not tournament owner cannot create a school" do
|
test "logged in user not tournament owner cannot create a school" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
new
|
new
|
||||||
@@ -131,6 +155,12 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to tournament_path(@tournament.id)
|
assert_redirected_to tournament_path(@tournament.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate can destroy a school" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user not tournament owner cannot destroy school" do
|
test "logged in user not tournament owner cannot destroy school" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
destroy
|
destroy
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ include Devise::TestHelpers
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -62,6 +66,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot generate matches" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get :generate_matches, id: 1
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can create custom weights" do
|
test "logged in tournament owner can create custom weights" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
get :create_custom_weights, id: 1, customValue: 'hs'
|
get :create_custom_weights, id: 1, customValue: 'hs'
|
||||||
@@ -74,6 +84,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot create custom weights" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get :create_custom_weights, id: 1, customValue: 'hs'
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
test "logged in tournament owner can access weigh_ins" do
|
test "logged in tournament owner can access weigh_ins" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
@@ -87,6 +103,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot access weigh_ins" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get :weigh_in, id: 1
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can access weigh_in_weight" do
|
test "logged in tournament owner can access weigh_in_weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
get :weigh_in, id: 1, weight: 1
|
get :weigh_in, id: 1, weight: 1
|
||||||
@@ -99,6 +121,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot access weigh_in_weight" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get :weigh_in_weight, id: 1, weight: 1
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can access post weigh_in_weight" do
|
test "logged in tournament owner can access post weigh_in_weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
|
post :weigh_in, id: 1, weight: 1, wrestler: @wrestlers
|
||||||
@@ -110,6 +138,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot access post weigh_in_weight" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post :weigh_in_weight, id: 1, weight: 1, wrestler: @wrestlers
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
test "logged in tournament owner should get edit tournament page" do
|
test "logged in tournament owner should get edit tournament page" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
@@ -123,6 +157,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should not get edit tournament page if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user should not get edit tournament page" do
|
test "non logged in user should not get edit tournament page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -139,6 +179,12 @@ include Devise::TestHelpers
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should not post update tournament if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner should post update tournament" do
|
test "logged in tournament owner should post update tournament" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -158,6 +204,12 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate not tournament owner cannot destroy tournament" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#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
|
||||||
@@ -222,4 +274,54 @@ include Devise::TestHelpers
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament owner can delegate a user' do
|
||||||
|
sign_in_owner
|
||||||
|
get :delegate, id: 1
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament delegate cannot delegate a user' do
|
||||||
|
sign_in_delegate
|
||||||
|
get :delegate, id: 1
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament owner can delegate a school user' do
|
||||||
|
sign_in_owner
|
||||||
|
get :school_delegate, id: 1
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament delegate can delegate a school user' do
|
||||||
|
sign_in_delegate
|
||||||
|
get :school_delegate, id: 1
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament owner can delete a school delegate' do
|
||||||
|
sign_in_owner
|
||||||
|
patch :remove_school_delegate, id: 1, delegate: SchoolDelegate.find(1)
|
||||||
|
assert_redirected_to "/tournaments/#{@tournament.id}/school_delegate"
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament delegate can delete a school delegate' do
|
||||||
|
sign_in_delegate
|
||||||
|
patch :remove_school_delegate, id: 1, delegate: SchoolDelegate.find(1)
|
||||||
|
assert_redirected_to "/tournaments/#{@tournament.id}/school_delegate"
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament owner can delete a delegate' do
|
||||||
|
sign_in_owner
|
||||||
|
patch :remove_delegate, id: 1, delegate: TournamentDelegate.find(1)
|
||||||
|
assert_redirected_to "/tournaments/#{@tournament.id}/delegate"
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'logged in tournament delegate cannot delete a delegate' do
|
||||||
|
sign_in_delegate
|
||||||
|
patch :remove_delegate, id: 1, delegate: TournamentDelegate.find(1)
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -67,6 +71,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not get edit weight page if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user should not get edit weight page" do
|
test "non logged in user should not get edit weight page" do
|
||||||
get_edit
|
get_edit
|
||||||
redirect
|
redirect
|
||||||
@@ -83,6 +93,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate should not post update weight if not owner" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner should post update weight" do
|
test "logged in tournament owner should post update weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -119,6 +135,14 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate not tournament owner cannot create a weight" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
new
|
||||||
|
redirect
|
||||||
|
create
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can destroy a weight" do
|
test "logged in tournament owner can destroy a weight" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
destroy
|
destroy
|
||||||
@@ -137,6 +161,12 @@ class WeightsControllerTest < ActionController::TestCase
|
|||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged school delegate not tournament owner cannot destroy weight" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "view wegiht" do
|
test "view wegiht" do
|
||||||
get :show, id: 1
|
get :show, id: 1
|
||||||
success
|
success
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
sign_in users(:three)
|
sign_in users(:three)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_in_school_delegate
|
||||||
|
sign_in users(:four)
|
||||||
|
end
|
||||||
|
|
||||||
def success
|
def success
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
@@ -62,6 +66,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should get edit wrestler page" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user should not get edit wrestler page if not owner" do
|
test "logged in user should not get edit wrestler page if not owner" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
get_edit
|
get_edit
|
||||||
@@ -96,6 +106,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to school_path(@school.id)
|
assert_redirected_to school_path(@school.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate should post update wrestler" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
post_update
|
||||||
|
assert_redirected_to school_path(@school.id)
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner can create a new wrestler" do
|
test "logged in tournament owner can create a new wrestler" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
new
|
new
|
||||||
@@ -112,6 +128,14 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to school_path(@school.id)
|
assert_redirected_to school_path(@school.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate can create a new wrestler" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
new
|
||||||
|
success
|
||||||
|
create
|
||||||
|
assert_redirected_to school_path(@school.id)
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user not tournament owner cannot create a wrestler" do
|
test "logged in user not tournament owner cannot create a wrestler" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
new
|
new
|
||||||
@@ -132,6 +156,12 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to school_path(@school.id)
|
assert_redirected_to school_path(@school.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate can destroy a wrestler" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
destroy
|
||||||
|
assert_redirected_to school_path(@school.id)
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user not tournament owner cannot destroy wrestler" do
|
test "logged in user not tournament owner cannot destroy wrestler" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
destroy
|
destroy
|
||||||
|
|||||||
5
test/fixtures/school_delegates.yml
vendored
5
test/fixtures/school_delegates.yml
vendored
@@ -7,3 +7,8 @@
|
|||||||
# two:
|
# two:
|
||||||
# user_id: 1
|
# user_id: 1
|
||||||
# school_id: 1
|
# school_id: 1
|
||||||
|
|
||||||
|
one:
|
||||||
|
id: 1
|
||||||
|
user_id: 4
|
||||||
|
school_id: 1
|
||||||
1
test/fixtures/tournament_delegates.yml
vendored
1
test/fixtures/tournament_delegates.yml
vendored
@@ -9,5 +9,6 @@
|
|||||||
# tournament_id: 1
|
# tournament_id: 1
|
||||||
|
|
||||||
one:
|
one:
|
||||||
|
id: 1
|
||||||
user_id: 3
|
user_id: 3
|
||||||
tournament_id: 1
|
tournament_id: 1
|
||||||
4
test/fixtures/users.yml
vendored
4
test/fixtures/users.yml
vendored
@@ -19,3 +19,7 @@ two:
|
|||||||
three:
|
three:
|
||||||
email: test3@test.com
|
email: test3@test.com
|
||||||
id: 3
|
id: 3
|
||||||
|
|
||||||
|
four:
|
||||||
|
email: test4@test.com
|
||||||
|
id: 4
|
||||||
|
|||||||
@@ -222,9 +222,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Decision"
|
match.win_type = "Decision"
|
||||||
match.score = 1-0
|
match.score = 1-0
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -234,9 +232,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Decision"
|
match.win_type = "Decision"
|
||||||
match.score = 0-2
|
match.score = 0-2
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -246,9 +242,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Major"
|
match.win_type = "Major"
|
||||||
match.score = 8-0
|
match.score = 8-0
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -257,9 +251,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.finished = 1
|
match.finished = 1
|
||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Tech Fall"
|
match.win_type = "Tech Fall"
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -269,9 +261,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Pin"
|
match.win_type = "Pin"
|
||||||
match.score = "5:00"
|
match.score = "5:00"
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -281,9 +271,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Pin"
|
match.win_type = "Pin"
|
||||||
match.score = "0:20"
|
match.score = "0:20"
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -293,9 +281,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.winner_id = translateNameToId(winner)
|
match.winner_id = translateNameToId(winner)
|
||||||
match.win_type = "Pin"
|
match.win_type = "Pin"
|
||||||
match.score = "1:20"
|
match.score = "1:20"
|
||||||
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
|
||||||
mat = @tournament.mats.first
|
|
||||||
match.mat_id = mat.id
|
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -550,6 +536,16 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal 2, wrestler.teamPointsEarned
|
assert_equal 2, wrestler.teamPointsEarned
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "Test mat assignment when adding a mat and when destroying a mat" do
|
||||||
|
@mat2 = Mat.new
|
||||||
|
@mat2.name = "2"
|
||||||
|
@mat2.tournament_id = 1
|
||||||
|
@mat2.save
|
||||||
|
assert_equal 4, @mat2.matches.size
|
||||||
|
elevenManBracketFinished
|
||||||
|
@mat2.destroy
|
||||||
|
@mat1 = Mat.find(1)
|
||||||
|
assert_equal 4, @mat1.matches.size
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user