This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
447 additions
and
270 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,7 @@ | ||
class HomepageController < ApplicationController | ||
|
||
def index | ||
@contests = Contest.active[0..1] | ||
end | ||
|
||
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
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 |
---|---|---|
@@ -1,11 +1,2 @@ | ||
- content_for(:description){ 'Codebrawl, a code contest website focussed on the Ruby programming language and open source software.' } | ||
|
||
- unless @contests.map(&:state).include? 'open' | ||
%section.tip | ||
%h1 Get ready for next week's contest! | ||
%p | ||
:erb | ||
Our next contest will start next Monday at 14:00 (UTC). If you want to be sure you don't miss it, just subscribe to our <%= link_to 'contests feed', 'http://feeds.feedburner.com/codebrawl' %>. Also, don't forget to check out and vote for the entries in <%= link_to "last week's contest", @contests.first %>. | ||
|
||
#contests | ||
= render @contests | ||
= render @contests |
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,13 @@ | ||
- content_for(:description){ 'Codebrawl, a code contest website focussed on the Ruby programming language and open source software.' } | ||
|
||
- unless @contests.map(&:state).include? 'open' | ||
%section.tip | ||
%h1 Get ready for next week's contest! | ||
%p | ||
:erb | ||
Our next contest will start next Monday at 14:00 (UTC). If you want to be sure you don't miss it, just subscribe to our <%= link_to 'contests feed', 'http://feeds.feedburner.com/codebrawl' %>. Also, don't forget to check out and vote for the entries in <%= link_to "last week's contest", @contests.first %>. | ||
|
||
#contests | ||
= render @contests | ||
|
||
= link_to 'Contest archive', contests_path |
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,9 @@ | ||
module MongoidExtensions | ||
|
||
def not_found | ||
raise Mongoid::Errors::DocumentNotFound.new(self.class, id) | ||
end | ||
|
||
end | ||
|
||
Mongoid::Document.send(:include, MongoidExtensions) |
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 |
---|---|---|
@@ -1,162 +1,48 @@ | ||
require 'acceptance/acceptance_helper' | ||
|
||
feature 'Homepage' do | ||
feature 'Contest index' do | ||
|
||
scenario 'be redirected to the homepage when accessing /contests' do | ||
# TODO: Move this one to a controller spec | ||
visit '/contests' | ||
URI.parse(current_url).path.should == '/' | ||
end | ||
|
||
context "on the homepage" do | ||
|
||
background :all do | ||
@voting = Fabricate( | ||
background(:all) do | ||
VCR.use_cassette('existing_gist') do | ||
Fabricate( | ||
:contest, | ||
:name => 'Fun with ChunkyPNG', | ||
:tagline => 'Having a bit of with image manipulation in ChunkyPNG', | ||
:voting_on => Date.yesterday.to_time | ||
) | ||
VCR.use_cassette('existing_gist') do | ||
@finished = Fabricate( | ||
:contest, | ||
:name => 'Improving Ruby', | ||
:tagline => 'Build verything you ever wanted, monkey-patched into Ruby', | ||
:entries => [Fabricate.build(:entry_with_files, :user => Fabricate(:user, :login => 'bob'))] * 3, | ||
:closing_on => Date.yesterday.to_time | ||
) | ||
end | ||
@pending = Fabricate( | ||
:contest, | ||
:name => 'RSpec extensions', | ||
:tagline => 'Giving back to RSpec by building the funniest or most useful RSpec formatter', | ||
:starting_on => Date.tomorrow.to_time | ||
:tagline => 'Having a bit of fun with image manipulation in ChunkyPNG', | ||
:closing_on => Date.yesterday.to_time, | ||
:entries => [ | ||
Fabricate.build( | ||
:entry_with_files, | ||
:user => Fabricate(:user, :login => 'bob') | ||
) | ||
] | ||
) | ||
|
||
visit '/' | ||
end | ||
|
||
scenario 'see the "no open contests"-message' do | ||
within('.tip') do | ||
page.should have_content "Get ready for next week's contest" | ||
page.should have_content 'Our next contest will start next Monday at 14:00 (UTC)' | ||
page.should have_link 'contests feed' | ||
body.should include 'href="http://feeds.feedburner.com/codebrawl"' | ||
page.should have_link "last week's contest" | ||
body.should include 'href="/contests/fun-with-chunkypng"' | ||
end | ||
end | ||
|
||
context 'when having an open contest' do | ||
|
||
background :all do | ||
@user = Fabricate(:user) | ||
VCR.use_cassette('existing_gist') do | ||
@open = Fabricate( | ||
:contest, | ||
:name => 'Euler #74', | ||
:tagline => 'Get your Euler on and build the fastest solution to problem #123', | ||
:starting_on => Date.yesterday.to_time, | ||
:entries => [Fabricate.build(:entry_with_files, :user => Fabricate(:user, :login => 'bob'))] | ||
) | ||
end | ||
end | ||
|
||
before { visit '/' } | ||
|
||
scenario 'see the Codebrawl header' do | ||
page.should have_content 'Codebrawl' | ||
end | ||
|
||
scenario 'do not see the "no open contests"-message' do | ||
page.should have_no_content "Get ready for next week's contest" | ||
end | ||
|
||
scenario 'return to the homepage after clicking the header' do | ||
click_link 'Fun with ChunkyPNG' | ||
click_link 'Codebrawl' | ||
['Euler #74', 'Fun with ChunkyPNG'].each do |name| | ||
page.should have_link name | ||
end | ||
end | ||
|
||
scenario 'return to the homepage after clicking the "Contests" menu item' do | ||
click_link 'Fun with ChunkyPNG' | ||
click_link 'Contests' | ||
['Euler #74', 'Fun with ChunkyPNG'].each do |name| | ||
page.should have_link name | ||
end | ||
end | ||
|
||
scenario 'see a list of contest names' do | ||
['Euler #74', 'Fun with ChunkyPNG', 'Improving Ruby'].each do |name| | ||
page.should have_link name | ||
end | ||
|
||
page.should have_no_content 'RSpec extensions' | ||
end | ||
|
||
scenario 'see entry counts in the contests list' do | ||
page.should have_content "1 entry already" | ||
end | ||
|
||
scenario 'see the contest taglines' do | ||
['Get your Euler on and build the fastest solution to problem #123', 'Having a bit of with image manipulation in ChunkyPNG', 'Build verything you ever wanted, monkey-patched into Ruby'].each do |tagline| | ||
page.should have_content tagline | ||
end | ||
end | ||
|
||
scenario 'see the contest states' do | ||
within "#contest_#{@open.id}" do | ||
page.should have_content 'Open' | ||
end | ||
|
||
within "#contest_#{@voting.id}" do | ||
page.should have_content 'Voting' | ||
end | ||
|
||
within "#contest_#{@finished.id}" do | ||
page.should have_content 'Finished' | ||
end | ||
end | ||
|
||
scenario 'see the contest winners avatars and medals' do | ||
within "#contest_#{@finished.id}" do | ||
page.should have_css('img.medal') | ||
page.should have_css('img.gravatar') | ||
end | ||
end | ||
|
||
scenario "visit the winner's entry" do | ||
within "#contest_#{@finished.id}" do | ||
page.find(:xpath, "//ol[@class='winners']//a[1]").click | ||
end | ||
page.should have_content "This contest is finished" | ||
end | ||
visit '/contests' | ||
|
||
scenario 'visit the submissions page' do | ||
click_link 'Submit a contest idea' | ||
page.should have_content 'Submit your contest idea' | ||
end | ||
end | ||
|
||
scenario 'visit the hall of fame' do | ||
click_link 'Hall of Fame' | ||
within('#main') { page.should have_content 'Hall of Fame' } | ||
end | ||
scenario 'see links to the contests' do | ||
page.should have_link 'Fun with ChunkyPNG' | ||
end | ||
|
||
context 'after logging in' do | ||
scenario 'see the contest taglines' do | ||
page.should have_content 'Having a bit of fun with image manipulation in ChunkyPNG' | ||
end | ||
|
||
background { login_via_github } | ||
scenario 'see the contest states' do | ||
page.should have_content 'Finished' | ||
end | ||
|
||
scenario 'visit my profile page' do | ||
click_link 'charlie' | ||
page.should have_content 'Total points' | ||
end | ||
scenario 'see the contest winners' do | ||
page.should have_css('ol.winners li a img.gravatar') | ||
end | ||
|
||
end | ||
scenario 'click a contest winner avatar' do | ||
find('ol.winners li a').click | ||
page.should have_content 'This contest is finished' | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.