Sha256: c1bfedfb636517968dba47b93f309434af0261ee36360c32f00d58f29c9d1091
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
require 'spec_helper' describe ContentBlocksController do describe "#update" do let(:content_block) { FactoryGirl.create(:content_block) } before { request.env["HTTP_REFERER"] = "whence_i_came" } context "when not logged in" do it "should redirect to root path" do patch :update, id: content_block, content_block: { value: 'foo' } expect(response).to redirect_to main_app.new_user_session_path end end context "when logged in" do let(:user) { FactoryGirl.create(:user) } before { controller.stub(current_user: user) } context "as a user in the admin group" do before { user.should_receive(:groups).and_return( ['admin', 'registered']) } it "should save" do patch :update, id: content_block, content_block: { value: 'foo' } expect(response).to redirect_to "whence_i_came" expect(assigns[:content_block].value).to eq 'foo' end end context "as a user without permission" do it "should redirect to root path" do patch :update, id: content_block, content_block: { value: 'foo' } expect(response).to redirect_to root_path end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems