Sha256: ee54a28583c52c24cefbfaa66da30c14642cb3a4447166b3ed4dd7514401dbd1
Contents?: true
Size: 1.58 KB
Versions: 9
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' module Alchemy describe ElementsController do let(:public_page) { FactoryGirl.create(:public_page) } let(:element) { FactoryGirl.create(:element, :page => public_page, :name => 'download') } let(:restricted_page) { FactoryGirl.create(:public_page, :restricted => true) } let(:restricted_element) { FactoryGirl.create(:element, :page => restricted_page, :name => 'download') } describe '#show' do it "should render available elements" do get :show, :id => element.id response.status.should == 200 end it "should raise ActiveRecord::RecordNotFound error for trashed elements" do element.trash expect { get(:show, :id => element.id) }.to raise_error(ActiveRecord::RecordNotFound) end it "should raise ActiveRecord::RecordNotFound error for unpublished elements" do element.update_attributes(:public => false) expect { get(:show, :id => element.id) }.to raise_error(ActiveRecord::RecordNotFound) end context "for guest user" do it "should raise ActiveRecord::RecordNotFound error for elements of restricted pages" do expect { get(:show, :id => restricted_element.id) }.to raise_error(ActiveRecord::RecordNotFound) end end context "for registered user" do before do sign_in(registered_user) end it "should render elements of restricted pages" do get :show, :id => restricted_element.id response.status.should == 200 end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems