Sha256: 08de6f3f10e79f3ac084b8d78bd87047d40025d7ac102b234920ba8ea9fb51ca
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' module Alchemy describe AttachmentsController do let(:attachment) { FactoryGirl.build_stubbed(:attachment) } it "should raise ActiveRecord::RecordNotFound for requesting not existing attachments" do expect { get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound) end context 'with restricted attachment' do before do attachment.stub(:restricted?).and_return(true) Attachment.stub(:find).and_return(attachment) end context 'as anonymous user' do it "should not be possible to download attachments from restricted pages" do get :download, :id => attachment.id response.status.should == 302 response.should redirect_to(Alchemy.login_path) end it "should not be possible to see attachments from restricted pages" do get :show, :id => attachment.id response.status.should == 302 response.should redirect_to(Alchemy.login_path) end end context "as registered user" do before { sign_in(registered_user) } it "should be possible to download attachments from restricted pages" do get :download, :id => attachment.id response.status.should == 200 end it "should be possible to see attachments from restricted pages" do get :show, :id => attachment.id response.status.should == 200 end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alchemy_cms-2.9.1 | spec/controllers/attachments_controller_spec.rb |
alchemy_cms-2.9.0 | spec/controllers/attachments_controller_spec.rb |