debian-mirror-gitlab/spec/features/issues/user_toggles_subscription_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.2 KiB
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require "spec_helper"
2023-03-04 22:38:38 +05:30
RSpec.describe "User toggles subscription", :js, feature_category: :team_planning do
2018-10-15 14:42:47 +05:30
let(:project) { create(:project_empty_repo, :public) }
let(:user) { create(:user) }
2021-09-04 01:27:46 +05:30
let(:user2) { create(:user) }
2018-10-15 14:42:47 +05:30
let(:issue) { create(:issue, project: project, author: user) }
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
context 'user is not logged in' do
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(moved_mr_sidebar: false)
2021-09-04 01:27:46 +05:30
visit(project_issue_path(project, issue))
end
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
it 'does not display the Notification toggle' do
expect(page).not_to have_button('Notifications')
end
2018-05-09 12:01:36 +05:30
end
2021-09-04 01:27:46 +05:30
context 'user is logged in' do
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(moved_mr_sidebar: false)
2021-09-04 01:27:46 +05:30
project.add_developer(user)
sign_in(user)
visit(project_issue_path(project, issue))
end
it 'unsubscribes from issue' do
subscription_button = find('[data-testid="subscription-toggle"]')
# Check we're subscribed.
expect(subscription_button).to have_css("button.is-checked")
# Toggle subscription.
find('[data-testid="subscription-toggle"]').click
wait_for_requests
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
# Check we're unsubscribed.
expect(subscription_button).to have_css("button:not(.is-checked)")
end
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
context 'when project emails are disabled' do
let(:project) { create(:project_empty_repo, :public, emails_disabled: true) }
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
it 'is disabled' do
expect(page).to have_content('Disabled by project owner')
2021-12-11 22:18:48 +05:30
expect(page).to have_selector('[data-testid="subscription-toggle"]', class: 'is-disabled')
2021-09-04 01:27:46 +05:30
end
end
2018-05-09 12:01:36 +05:30
end
2019-10-12 21:52:04 +05:30
2021-09-04 01:27:46 +05:30
context 'user is logged in without edit permission' do
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(moved_mr_sidebar: false)
2021-09-04 01:27:46 +05:30
sign_in(user2)
visit(project_issue_path(project, issue))
end
it 'subscribes to issue' do
subscription_button = find('[data-testid="subscription-toggle"]')
# Check we're not subscribed.
expect(subscription_button).to have_css("button:not(.is-checked)")
# Toggle subscription.
find('[data-testid="subscription-toggle"]').click
wait_for_requests
2019-10-12 21:52:04 +05:30
2021-09-04 01:27:46 +05:30
# Check we're subscribed.
expect(subscription_button).to have_css("button.is-checked")
2019-10-12 21:52:04 +05:30
end
end
2018-05-09 12:01:36 +05:30
end