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

Version Path
sufia-4.0.1 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.rc2 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.rc1 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.beta4 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.beta3 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.beta2 spec/controllers/content_blocks_controller_spec.rb
sufia-4.0.0.beta1 spec/controllers/content_blocks_controller_spec.rb