Sha256: 99df1cc57da7c7dabdf10448b3807539a3a8e8ce3cc079db0057b18ae5483eb6

Contents?: true

Size: 1.5 KB

Versions: 8

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

shared_examples "follows" do
  include_context "with a component"

  before do
    login_as user, scope: :user
  end

  context "when not following the followable" do
    context "when user clicks the Follow button" do
      it "makes the user follow the followable" do
        visit followable_path
        expect do
          click_button "Follow"
          expect(page).to have_content "Stop following"
        end.to change(Decidim::Follow, :count).by(1)
      end
    end
  end

  context "when the user is following the followable" do
    before do
      create(:follow, followable: followable, user: user)
    end

    context "when user clicks the Follow button" do
      it "makes the user follow the followable" do
        visit followable_path
        expect do
          click_button "Stop following"
          expect(page).to have_content "Follow"
        end.to change(Decidim::Follow, :count).by(-1)
      end
    end
  end

  context "when the user is following the followable's participatory space" do
    before do
      create(:follow, followable: followable.participatory_space, user: user)
    end

    context "when user clicks the Follow button" do
      it "makes the user follow the followable" do
        visit followable_path
        expect do
          click_button "Already following #{translated(followable.participatory_space.title)}"
          expect(page).to have_content "Stop following"
        end.to change(Decidim::Follow, :count).by(1)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-core-0.23.6 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.5 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.4 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.3 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.2 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.1 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.1.rc1 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.23.0 lib/decidim/core/test/shared_examples/follows_examples.rb