2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe "User toggles subscription", :js do
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:project) { create(:project_empty_repo, :public) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:issue) { create(:issue, project: project, author: user) }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(project_issue_path(project, issue))
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it "unsubscribes from issue" do
|
2021-03-11 19:13:27 +05:30
|
|
|
subscription_button = find('[data-testid="subscription-toggle"]')
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
# Check we're subscribed.
|
|
|
|
expect(subscription_button).to have_css("button.is-checked")
|
|
|
|
|
|
|
|
# Toggle subscription.
|
2021-03-11 19:13:27 +05:30
|
|
|
find('[data-testid="subscription-toggle"]').click
|
2018-05-09 12:01:36 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
# Check we're unsubscribed.
|
|
|
|
expect(subscription_button).to have_css("button:not(.is-checked)")
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
context 'when project emails are disabled' do
|
|
|
|
let(:project) { create(:project_empty_repo, :public, emails_disabled: true) }
|
|
|
|
|
|
|
|
it 'is disabled' do
|
|
|
|
expect(page).to have_content('Notifications have been disabled by the project or group owner')
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).not_to have_selector('[data-testid="subscription-toggle"]')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|