-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from x3igh7/challonge
added tournament activation and deactivation
- Loading branch information
Showing
11 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<h1>tournaments</h1> | ||
|
||
<div class="content-inner"> | ||
<% if not @tournaments.any? %> | ||
There are currently no tournaments. | ||
<% else %> | ||
<table> | ||
<tr> | ||
<th>Name</th> | ||
<th>Description</th> | ||
<th>Active</th> | ||
<th></th> | ||
</tr> | ||
<% @tournaments.each do |tournament| %> | ||
<tr> | ||
<td><%= tournament.name %></td> | ||
<td><%= tournament.description %></td> | ||
<td><%= tournament.active.to_s.capitalize %></td> | ||
<td class="show-management" style="float:right;"><button id=<%= "manage-tourny-#{tournament.id}" %>>manage</button></td> | ||
<td class="hide-management"><button>hide</button></td> | ||
</tr> | ||
<tr class="management"> | ||
<td><%= link_to "edit", edit_admin_tournament_path(tournament), id: "edit-tourny-#{tournament.id}" %></td> | ||
<td><%= link_to "tournament teams", admin_tournament_teams_path(:tournament_id => tournament.id) %></td> | ||
<td><%= link_to "matches", admin_matches_path(:tournament_id => tournament.id) %></td> | ||
<td><%= link_to "set ranks", rankings_admin_tournaments_path(:tournament_id => tournament.id) %></td> | ||
<td><%= link_to "set schedule", schedule_admin_tournaments_path(:tournament_id => tournament.id) %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
<% end %> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'spec_helper' | ||
|
||
describe "Tournament Edit" do | ||
let!(:tournament1) {FactoryGirl.create(:tournament)} | ||
let!(:tournament2) {FactoryGirl.create(:tournament, active: false)} | ||
let!(:admin) {FactoryGirl.create(:user)} | ||
let!(:team) { FactoryGirl.create(:team) } | ||
let!(:team2) { FactoryGirl.create(:team) } | ||
let!(:tournament_team) {FactoryGirl.create(:tournament_team, team: team, tournament: tournament1)} | ||
let!(:tournament_team2) {FactoryGirl.create(:tournament_team, team: team2, tournament: tournament1)} | ||
let!(:match) { FactoryGirl.create(:match, home_team_id: tournament_team.id, away_team_id: tournament_team2.id, tournament_id: tournament1.id) } | ||
|
||
before do | ||
admin.roles = :admin | ||
admin.save | ||
sign_in_as admin | ||
end | ||
|
||
it "a tournament can be editted", :js => true do | ||
manage | ||
click_on "edit-tourny-#{tournament1.id}" | ||
fill_in "Rules", with: "New rules" | ||
click_on "update tournament" | ||
expect(Tournament.find(tournament1.id).rules).to eq("New rules") | ||
end | ||
|
||
it "a tourament can be deactivated", :js => true do | ||
manage | ||
click_on "edit-tourny-#{tournament1.id}" | ||
click_on "deactivate tournament" | ||
expect(Tournament.find(tournament1.id).active).to be_false | ||
expect(current_path).to eq(admin_root_path) | ||
end | ||
|
||
it "deactivated (all) tournaments can be viewed" do | ||
visit admin_root_path | ||
click_on "view all tournaments" | ||
expect(page).to have_content(tournament2.name) | ||
end | ||
|
||
it "a non-active tournament can be activated", :js => true do | ||
visit admin_root_path | ||
click_on "view all tournaments" | ||
click_on "manage-tourny-#{tournament2.id}" | ||
click_on "edit-tourny-#{tournament2.id}" | ||
click_on "activate tournament" | ||
expect(Tournament.find(tournament2.id).active).to be_true | ||
expect(current_path).to eq(admin_root_path) | ||
end | ||
|
||
end | ||
|
||
def manage | ||
visit admin_root_path | ||
click_button "manage" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
end | ||
|
||
it "can be deleted by admins" do | ||
pending | ||
end | ||
end |