Permalink
Browse files

Merge branch 'release/0.1.5'

  • Loading branch information...
2 parents b6fdb11 + 08748f0 commit 47c91f242897624a9ef1f51e9c0b6c02a0b710a9 @jeffkreeftmeijer jeffkreeftmeijer committed Jun 23, 2011
@@ -14,7 +14,6 @@ h2
h3
font-size: 20px
- margin-top: 20px
a
font-weight: 900
@@ -150,10 +149,12 @@ form
#entries li.entry, .contestants li
padding: 10px
-#contests li, #entries li.entry, #entry, .contestants li
+#contests li, #entries li.entry, #entry
background-color: #ddd
border-radius: 2px
box-shadow: 0 -1px 0 #ccc, 0 1px 0 #fff
+
+#contests li, #entries li.entry
margin-bottom: 20px
.description
@@ -1,6 +1,7 @@
class ContestsController < ApplicationController
def index
+ redirect_to root_path unless request.path == root_path
@contests = Contest.all.order_by([:starting_on, :desc]).reject do |contest|
contest.state == 'pending'
end
@@ -8,16 +8,16 @@ def create
user = User.first(:conditions => parameters) || User.create(parameters.merge(auth['user_info']))
session[:user_id] = user.id
- redirect_to request.env['omniauth.origin'] || contests_path
+ redirect_to request.env['omniauth.origin'] || root_path
end
def destroy
session[:user_id] = nil
- redirect_to contests_path
+ redirect_to root_path
end
def failure
- redirect_to contests_path, :alert => 'Something went wrong while trying to log you in.'
+ redirect_to root_path, :alert => 'Something went wrong while trying to log you in.'
end
end
@@ -1,33 +1,39 @@
+- content_for(:title){ @contest.name }
+- content_for(:description){ @contest.tagline }
+
%h2= @contest.name
= raw Kramdown::Document.new(@contest.description).to_html
-- if @contest.open? && @contest.entries.any?
-
- %h3= "This contest has #{@contest.entries.length} #{@contest.entries.length > 1 ? 'entries' : 'entry'} already"
- %p The entries will become visible when the voting period begins. Until that, you can still submit yours!
+- if @contest.open?
+ #entry
-- unless @contest.open?
+ - if @contest.entries.any?
- %h3 Entries
+ %h3= "This contest has #{@contest.entries.length} #{@contest.entries.length > 1 ? 'entries' : 'entry'} already"
+ %p The entries will become visible when the voting period begins.
- = form_for [@contest, Vote.new] do |f|
+ - if @entry
- %ul#entries
- = render :partial => "entries/entry", :collection => @contest.entries.order_by([:score, :desc]), :locals => { :f => f }
-
- = f.submit 'Submit your votes' if logged_in? && @contest.voting? && @voted_entries != @contest.entries
-
-- if @contest.open?
- - if @entry
- #entry
%h3
:erb
You entered <%= link_to "gist #{@entry.gist_id}", "https://gist.github.com/#{@entry.gist_id}" %>
%p
:erb
You can keep updating your gist, we'll take a snapshot of it when the voting period begins. If you want, you can always <%= link_to "delete your entry", [@contest, @entry], :method => :delete %>.
- - else
+
+ - if @entry.nil?
= link_to 'Enter', [:new, @contest, :entry], :class => 'button'
+- else
+
+ %h3 Entries
+
+ = form_for [@contest, Vote.new] do |f|
+
+ %ul#entries
+ = render :partial => "entries/entry", :collection => @contest.entries.order_by([:score, :desc]), :locals => { :f => f }
+
+ = f.submit 'Submit your votes' if logged_in? && @contest.voting? && @voted_entries != @contest.entries
+
@@ -2,7 +2,10 @@
%html
%head
%meta{:name => 'viewport', :content => 'width=385', 'maximum-scale' => '1.0' }
- %title Codebrawl
+ %title= "#{yield(:title)} #{yield(:title).present? ? ' - ' : ''} Codebrawl"
+ -if yield(:description).present?
+ %meta{:name => 'description', :content => yield(:description) }
+
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tags
@@ -12,7 +15,7 @@
#wrapper
#header
- %h1= link_to 'Codebrawl', contests_path
+ %h1= link_to 'Codebrawl', root_path
%code if ( ready? && set? ) { fight! };
#container
View
@@ -1,17 +1,22 @@
require 'fabrication'
require 'faker'
+require 'vcr'
+
+VCR.config do |c|
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
+ c.stub_with :fakeweb
+end
Dir[Rails.root.join("spec/fabricators/**/*.rb")].each {|f| require f}
[Contest, User].each { |model| model.delete_all }
-3.times do |i|
- Fabricate(
- :contest,
- :starting_on => (i.weeks + 1.day).ago.to_time,
- :entries => [
- Fabricate(:entry, :gist_id => '830060'),
- Fabricate(:entry, :gist_id => '813725'),
- Fabricate(:entry, :gist_id => '676219')
- ]
- )
+VCR.use_cassette('existing_gist') do
+ 3.times do |i|
+ contest = Fabricate(
+ :contest,
+ :starting_on => (i.weeks + 1.day).ago.to_time,
+ )
+
+ 3.times { Fabricate(:entry_with_files, :contest => contest) }
+ end
end
@@ -1,6 +1,12 @@
require 'acceptance/acceptance_helper'
feature 'Homepage' 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
@@ -31,7 +37,7 @@
)
end
- before { visit '/contests' }
+ before { visit '/' }
scenario 'see the Codebrawl header' do
page.should have_content 'Codebrawl'
@@ -3,14 +3,14 @@
feature 'Log in' do
scenario 'log in via Github' do
- visit '/contests'
+ visit '/'
click_link 'log in via Github'
page.should have_content 'charlie'
end
scenario 'fail to log in using invalid credentials' do
OmniAuth.config.mock_auth[:github] = :invalid_credentials
- visit '/contests'
+ visit '/'
click_link 'log in via Github'
page.should have_content 'Something went wrong while trying to log you in.'
end
@@ -33,7 +33,7 @@
background { User.delete_all }
scenario 'see the login link' do
- visit '/contests'
+ visit '/'
page.should have_content 'log in via Github'
end

0 comments on commit 47c91f2

Please sign in to comment.