Sha256: b19c1da664c40f04c7079a0199fda307c827a11810ef9fb1ed40335e57752043

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

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

  subject { rendered }

  before do
    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

3 entries across 3 versions & 1 rubygems

Version Path
sufia-7.0.0.beta3 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-7.0.0.beta2 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-7.0.0.beta1 spec/views/homepage/_announcement.html.erb_spec.rb