Sha256: f67f4c41089522405e763d81f8a100f0c681eaa2e93088268f7827d88d3464b1

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe "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

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-6.6.1 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-6.6.0 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-6.5.0 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-6.4.0 spec/views/homepage/_announcement.html.erb_spec.rb
sufia-6.3.0 spec/views/homepage/_announcement.html.erb_spec.rb