Sha256: f94434756a12be5235f1980dd1063f6448082903c59f224f58b29e99e4d0ab19

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

module Alchemy
  describe ElementsController do

    let(:page)                { FactoryGirl.create(:public_page) }
    let(:element)             { FactoryGirl.create(:element, :page => 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 :user, FactoryGirl.create(: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

8 entries across 8 versions & 1 rubygems

Version Path
alchemy_cms-2.5.3.1 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.3 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.2.2 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.2.1 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.2 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.1 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.0 spec/controllers/elements_controller_spec.rb
alchemy_cms-2.5.0.rc3 spec/controllers/elements_controller_spec.rb