Sha256: b285141cd65661fb802b7fd47ec62ca8efa35f18640751599f24a333a4301019

Contents?: true

Size: 1.66 KB

Versions: 21

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

shared_examples "reports" do
  context "when the user is not logged in" do
    it "should be given the option to sign in" do
      visit reportable_path

      expect(page).to have_selector(".author-data__extra")

      within ".author-data__extra", match: :first do
        page.find("button").click
      end

      expect(page).to have_css("#loginModal", visible: true)
    end
  end

  context "when the user is logged in" do
    before do
      login_as user, scope: :user
    end

    context "and the user has not reported the resource yet" do
      it "reports the resource" do
        visit reportable_path

        expect(page).to have_selector(".author-data__extra")

        within ".author-data__extra", match: :first do
          page.find("button").click
        end

        expect(page).to have_css(".flag-modal", visible: true)

        within ".flag-modal" do
          click_button "Report"
        end

        expect(page).to have_content "report has been created"
      end
    end

    context "and the user has reported the resource previously" do
      before do
        moderation = create(:moderation, reportable: reportable, participatory_space: participatory_process)
        create(:report, moderation: moderation, user: user, reason: "spam")
      end

      it "cannot report it twice" do
        visit reportable_path

        expect(page).to have_selector(".author-data__extra")

        within ".author-data__extra", match: :first do
          page.find("button").click
        end

        expect(page).to have_css(".flag-modal", visible: true)

        expect(page).to have_content "already reported"
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
decidim-core-0.7.2 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.7.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.7.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.8 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.8 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.7 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.7 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.6 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.6 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.5 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.5 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.4 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.4 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.3 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.3 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.2 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.2 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-0.6.1 decidim-core/lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.6.0 lib/decidim/core/test/shared_examples/reports_examples.rb