forked from opf/openproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_spec.rb
More file actions
130 lines (108 loc) · 4.1 KB
/
Copy pathmy_spec.rb
File metadata and controls
130 lines (108 loc) · 4.1 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe 'my', type: :feature, js: true do
let(:user_password) { 'bob' * 4 }
let(:user) do
FactoryBot.create(:user,
mail: 'old@mail.com',
login: 'bob',
password: user_password,
password_confirmation: user_password)
end
##
# Expecations for a successful account change
def expect_changed!
expect(page).to have_content 'Account was successfully updated.'
user.reload
expect(user.mail).to eq 'foo@mail.com'
expect(user.name).to eq 'Foo Bar'
end
before do
login_as(user)
end
context 'user' do
context '#account' do
let(:dialog) { ::Components::PasswordConfirmationDialog.new }
before do
visit my_account_path
fill_in 'user[mail]', with: 'foo@mail.com'
fill_in 'user[firstname]', with: 'Foo'
fill_in 'user[lastname]', with: 'Bar'
click_on 'Save'
end
context 'when confirmation disabled',
with_config: { internal_password_confirmation: false } do
it 'does not request confirmation' do
expect_changed!
end
end
context 'when confirmation required',
with_config: { internal_password_confirmation: true } do
it 'requires the password for a regular user' do
dialog.confirm_flow_with(user_password)
expect_changed!
end
it 'declines the change when invalid password is given' do
dialog.confirm_flow_with(user_password + 'INVALID', should_fail: true)
user.reload
expect(user.mail).to eq('old@mail.com')
end
context 'as admin' do
let(:user) {
FactoryBot.create :admin,
password: user_password,
password_confirmation: user_password
}
it 'requires the password' do
dialog.confirm_flow_with(user_password)
expect_changed!
end
end
end
end
it 'in Access Tokens they can generate their API key' do
visit my_access_token_path
expect(page).to have_content 'Missing API access key'
find(:xpath, "//tr[contains(.,'API')]/td/a", text: 'Generate').click
expect(page).to have_content 'A new API token has been generated. Your access token is'
User.current.reload
visit my_access_token_path
expect(page).not_to have_content 'Missing API access key'
end
it 'in Access Tokens they can generate their RSS key' do
visit my_access_token_path
expect(page).to have_content 'Missing RSS access key'
find(:xpath, "//tr[contains(.,'RSS')]/td/a", text: 'Generate').click
expect(page).to have_content 'A new RSS token has been generated. Your access token is'
User.current.reload
visit my_access_token_path
expect(page).not_to have_content 'Missing RSS access key'
end
end
end