Sha256: 2a66aea4fbd5b0826ba250c3c40e3b7ba634f056478d6ec3861b56fb876d094e
Contents?: true
Size: 1.24 KB
Versions: 8
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' describe ContentBlocksController, :type => :controller 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 { allow(controller).to receive_messages(current_user: user) } context "as a user in the admin group" do before { expect(user).to 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