forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunication_channels_spec.rb
More file actions
108 lines (89 loc) · 4.26 KB
/
Copy pathcommunication_channels_spec.rb
File metadata and controls
108 lines (89 loc) · 4.26 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
require File.expand_path(File.dirname(__FILE__) + '/common')
describe "communication channel selenium tests" do
include_context "in-process server selenium tests"
context "confirm" do
it "should register the user" do
Setting.set('terms_required', 'false')
u1 = user_with_communication_channel(:user_state => 'creation_pending')
get "/register/#{u1.communication_channel.confirmation_code}"
set_value f('#pseudonym_password'), "asdfasdf"
expect_new_page_load {
f('#registration_confirmation_form').submit
}
expect_logout_link_present
end
it "should require the terms if configured to do so" do
u1 = user_with_communication_channel(:user_state => 'creation_pending')
get "/register/#{u1.communication_channel.confirmation_code}"
expect(f('input[name="user[terms_of_use]"]')).to be_present
f('#registration_confirmation_form').submit
wait_for_ajaximations
assert_error_box 'input[name="user[terms_of_use]"]:visible'
end
it "should not require the terms if the user has already accepted them" do
u1 = user_with_communication_channel(:user_state => 'creation_pending')
u1.preferences[:accepted_terms] = Time.now.utc
u1.save
get "/register/#{u1.communication_channel.confirmation_code}"
expect(f("#content")).not_to contain_css('input[name="user[terms_of_use]"]')
end
it "should allow the user to edit the pseudonym if its already taken" do
u1 = user_with_communication_channel(:username => 'asdf@qwerty.com', :user_state => 'creation_pending')
u1.accept_terms
u1.save
# d'oh, now it's taken
user_with_pseudonym(:username => 'asdf@qwerty.com', :active_user => true)
get "/register/#{u1.communication_channel.confirmation_code}"
# they can set it...
input = f('#pseudonym_unique_id')
expect(input).to be_present
set_value input, "asdf@asdf.com"
set_value f('#pseudonym_password'), "asdfasdf"
expect_new_page_load {
f('#registration_confirmation_form').submit
}
expect_logout_link_present
end
it 'confirms the communication channels', priority: "2", test_id: 193786 do
user_with_pseudonym({active_user: true})
create_session(@pseudonym)
get '/profile/settings'
expect(f('.email_channels')).to contain_css('.unconfirmed')
f('.email_channels .path').click
Notification.create!(name: 'Confirm Email Communication Channel', category: 'Registration')
f('#confirm_email_channel .re_send_confirmation_link').click
expect(Message.last.subject).to eq('Confirm Email: Canvas')
url = Message.last.url
# get the registration id from the url
get '/register/' + url.split('/')[4]
expect(f('#flash_message_holder')).to include_text 'Registration confirmed!'
get '/profile/settings'
# the email id does not have a link anymore
expect(f('.email_channels')).not_to contain_link('nobody@example.com')
end
it 'should show the bounce count reset button when a siteadmin is masquerading' do
u = user_with_pseudonym(active_all: true)
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active'; cc.bounce_count = 3 }
site_admin_logged_in
masquerade_as(u)
get '/profile/settings'
expect(f('.reset_bounce_count_link')).to be_present
end
it 'should not show the bounce count reset button when an account admin is masquerading' do
u = user_with_pseudonym(active_all: true)
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active'; cc.bounce_count = 3 }
admin_logged_in
masquerade_as(u)
get '/profile/settings'
expect(f("#content")).not_to contain_css('.reset_bounce_count_link')
end
it 'should not show the bounce count reset button when the channel is not bouncing' do
u = user_with_pseudonym(active_all: true)
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active' }
site_admin_logged_in
masquerade_as(u)
get '/profile/settings'
expect(f("#content")).not_to contain_css('.reset_bounce_count_link')
end
end
end