Sha256: 1d5e0c75f93b38bb5f1e6d523c67b28b6f34ed9063f434f89ae1c6221bf386b8

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe "Comment notifications", type: :feature do
  let!(:organization) { create(:organization) }
  let!(:feature) { create(:feature, manifest_name: :dummy, organization: organization) }
  let!(:user) { create(:user, :confirmed, organization: organization) }
  let!(:commentable) { create(:dummy_resource, feature: feature) }
  let!(:comments) { create_list(:comment, 3, commentable: commentable) }

  before do
    switch_to_host(organization.host)
    login_as user, scope: :user
  end

  it "commentable author receives an email with a link to the comment", perform_enqueued: true do
    visit decidim_dummy.dummy_resource_path(commentable, feature_id: commentable.feature, participatory_process_id: commentable.feature.participatory_process)
    expect(page).to have_selector(".add-comment form")

    within ".add-comment form" do
      fill_in "add-comment-#{commentable.class.name}-#{commentable.id}", with: "This is a new comment"
      click_button "Send"
    end

    within "#comments" do
      expect(page).to have_content user.name
      expect(page).to have_content "This is a new comment"
    end

    wait_for_email subject: "a new comment"

    relogin_as commentable.author, scope: :user

    visit last_email_first_link

    within "#comments" do
      expect(page).to have_content user.name
      expect(page).to have_content "This is a new comment"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-0.4.3 decidim-comments/spec/features/notifications_spec.rb
decidim-0.4.2 decidim-comments/spec/features/notifications_spec.rb
decidim-0.4.1 decidim-comments/spec/features/notifications_spec.rb
decidim-0.4.0 decidim-comments/spec/features/notifications_spec.rb