Sha256: 14c22f0c5642d4a4b62b0e7300d74790d2fcb20528826b5d3e5779db5fdcf116

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe ContentBlockHelper do
  let(:content_block) { FactoryGirl.create(:content_block, value: "<p>foo bar</p>") }

  subject { helper.editable_content_block(content_block) }

  context "for someone" do
    context "with access" do
      before do
        expect(helper).to receive(:can?).with(:update, content_block).and_return(true)
      end
      let(:node) { Capybara::Node::Simple.new(subject) }
      it "should show the preview and the form" do
        expect(node).to have_selector "button[data-target='#edit_content_block_1'][data-behavior='reveal-editor']"
        expect(node).to have_selector "form#edit_content_block_1[action='#{sufia.content_block_path(content_block)}']"
        expect(subject).to be_html_safe
      end
    end
  end

  context "anonymous" do
    before do
      expect(helper).to receive(:can?).with(:update, content_block).and_return(false)
    end
    it "should show the content" do
      expect(subject).to eq '<p>foo bar</p>'
      expect(subject).to be_html_safe
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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