Sha256: 3e8da5924ecb6298b17ab2388563fd35895137999193478cd522e1ac8017becc

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 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 member user" do
        before { sign_in(member_user) }

        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

Version Path
alchemy_cms-3.0.4 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.3 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.2 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.1 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.0 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.0.rc8 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.0.rc7 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.0.rc6 spec/controllers/elements_controller_spec.rb
alchemy_cms-3.0.0.rc5 spec/controllers/elements_controller_spec.rb