Sha256: 61893a1a59641d0f4e08ef5991a594a826b41f91fdb99d8fa41e342ae122d22d

Contents?: true

Size: 1.54 KB

Versions: 10

Compression:

Stored size: 1.54 KB

Contents

describe "hyrax/homepage/_announcement.html.erb", type: :view do
  let(:groups) { [] }
  let(:ability) { instance_double("Ability") }
  let(:announcement) { ContentBlock.new(name: ContentBlock::ANNOUNCEMENT, value: announcement_value) }

  subject { rendered }

  before do
    view.extend Hyrax::ContentBlockHelper
    assign(:announcement_text, announcement)
    allow(controller).to receive(:current_ability).and_return(ability)
    allow(ability).to receive(:can?).with(:update, ContentBlock).and_return(can_update_content_block)
    render
  end

  context "when there is an announcement" do
    let(:announcement_value) { "I have an announcement!" }

    context "when the user can update content" do
      let(:can_update_content_block) { true }

      it { is_expected.to have_content announcement_value }
      it { is_expected.to have_button("Edit") }
    end

    context "when the user can't update content" do
      let(:can_update_content_block) { false }

      it { is_expected.to have_content announcement_value }
      it { is_expected.not_to have_button("Edit") }
    end
  end

  context "when there is no announcement" do
    let(:announcement_value) { "" }

    context "when the user can update content" do
      let(:can_update_content_block) { true }

      it { is_expected.to have_selector "#announcement" }
      it { is_expected.to have_button("Edit") }
    end

    context "when the user can't update content" do
      let(:can_update_content_block) { false }

      it { is_expected.not_to have_selector "#announcement" }
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.1.0 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.5 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.4 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.3 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.2 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.1 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.0.rc2 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
hyrax-1.0.0.rc1 spec/views/hyrax/homepage/_announcement.html.erb_spec.rb
test_hyrax-0.0.1.alpha spec/views/hyrax/homepage/_announcement.html.erb_spec.rb