forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_spec.rb
More file actions
65 lines (54 loc) · 2.07 KB
/
Copy pathprofile_spec.rb
File metadata and controls
65 lines (54 loc) · 2.07 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
#
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'nokogiri'
describe ProfileController do
def enter_student_view(opts={})
course = opts[:course] || @course || course(opts)
@fake_student = course.student_view_student
post "/users/#{@fake_student.id}/masquerade"
expect(session[:become_user_id]).to eq @fake_student.id.to_s
end
it "should respect account setting for editing names" do
a = Account.create!
u = user_with_pseudonym(:account => a, :active_user => true)
u.short_name = 'Bracken'
u.save!
p = u.pseudonyms.first
user_session(u, p)
get '/profile/settings'
expect(Nokogiri::HTML(response.body).css('input#user_short_name')).not_to be_empty
put '/profile', :user => { :short_name => 'Cody' }
expect(response).to be_redirect
expect(u.reload.short_name).to eq 'Cody'
a.settings[:users_can_edit_name] = false
a.save!
p.reload
get '/profile/settings'
expect(Nokogiri::HTML(response.body).css('input#user_short_name')).to be_empty
put '/profile', :user => { :short_name => 'JT' }
expect(response).to be_redirect
expect(u.reload.short_name).to eq 'Cody'
end
it "should not show student view student edit profile or other services options" do
course_with_teacher_logged_in(:active_all => true)
enter_student_view
get '/profile/settings'
expect(response.status).to eq 401
end
end