forked from openSUSE/open-build-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
canned_responses_spec.rb
69 lines (55 loc) · 1.8 KB
/
canned_responses_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'browser_helper'
RSpec.describe 'Canned responses', :js do
let(:user) { create(:confirmed_user, login: 'burdenski') }
before do
Flipper.enable(:content_moderation)
end
context 'can be created' do
before do
login user
visit canned_responses_path
end
it do
fill_in(name: 'canned_response[title]', with: 'wow')
fill_in(name: 'canned_response[content]', with: 'a canned response')
click_button('Create')
find('.accordion-button').click
expect(page).to have_text('a canned response')
end
end
context 'with an existing canned response' do
let!(:canned_response) { create(:canned_response, user: user, title: 'wow', content: 'a canned response') }
before do
login user
visit canned_responses_path
find('.accordion-button').click
end
it 'can be modified' do
click_link('Edit')
fill_in(name: 'canned_response[content]', with: 'another response')
click_button('Save')
find('.accordion-button').click
expect(page).to have_text('another response')
end
it 'can be deleted' do
accept_confirm do
click_button('Delete')
end
expect(page).to have_no_text('wow')
end
end
context 'with decision-related canned response' do
let(:moderator) { create(:moderator) }
before do
login moderator
visit canned_responses_path
fill_in(name: 'canned_response[title]', with: 'wow')
fill_in(name: 'canned_response[content]', with: 'a decision-related canned response')
find(:id, 'canned_response_decision_kind').select('Favored')
click_button('Create')
find('.accordion-button').click
end
it { expect(page).to have_text('Favored') }
it { expect(page).to have_text('a decision-related canned response') }
end
end