Sha256: de103be03c0f2f8e319fa56bd48f976306c20df2efb6ada56cd06e151bff8f24

Contents?: true

Size: 1.49 KB

Versions: 37

Compression:

Stored size: 1.49 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 "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

37 entries across 37 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.27.0.rc1 lib/decidim/core/test/shared_examples/follows_examples.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/follows_examples.rb