More specs for home controller

openid
Marcin Kulik 13 years ago
parent 1c574fca4a
commit 98d80ae1fd

@ -1,7 +1,8 @@
class HomeController < ApplicationController
def show
offset = (Asciicast.featured.count * rand).to_i
asciicast = Asciicast.featured.offset(offset).first || @asciicasts.first
asciicast = Asciicast.featured.offset(offset).first ||
Asciicast.order("created_at DESC").first
@asciicast = AsciicastDecorator.new(asciicast)
end
end

@ -3,9 +3,33 @@ require 'spec_helper'
describe HomeController do
describe "GET 'show'" do
it "returns http success" do
get 'show'
response.should be_success
describe 'when there is at least one featured cast' do
before do
Factory(:asciicast, :featured => true)
end
it "returns http success" do
get 'show'
response.should be_success
end
end
describe 'when there is no featured cast but any cast exists' do
before do
Factory(:asciicast, :featured => false)
end
it "returns http success" do
get 'show'
response.should be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
response.should be_success
end
end
end

Loading…
Cancel
Save