forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount_spec.rb
More file actions
120 lines (100 loc) · 4.1 KB
/
Copy pathaccount_spec.rb
File metadata and controls
120 lines (100 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
#
# Copyright (C) 2012 - 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 AccountsController do
context "SAML meta data" do
before(:each) do
skip("requires SAML extension") unless AccountAuthorizationConfig::SAML.enabled?
@account = Account.create!(:name => "test")
end
it 'should render for non SAML configured accounts' do
get "/saml2"
expect(response).to be_success
expect(response.body).not_to eq ""
end
it "should use the correct entity_id" do
HostUrl.stubs(:default_host).returns('bob.cody.instructure.com')
@aac = @account.authentication_providers.create!(:auth_type => "saml")
get "/saml2"
expect(response).to be_success
doc = Nokogiri::XML(response.body)
expect(doc.at_xpath("md:EntityDescriptor", SAML2::Namespaces::ALL)['entityID']).to eq "http://bob.cody.instructure.com/saml2"
end
it "renders valid schema" do
allow(HostUrl).to receive(:context_hosts).and_return(['bob.cody.instructure.com'])
get "/saml2"
expect(response).to be_success
entity = SAML2::Entity.parse(response.body)
expect(entity).to be_valid_schema
end
end
context "section tabs" do
it "should change in response to role override changes" do
enable_cache do
# cache permissions and tabs for a user
@account = Account.default
account_admin_user account: @account
user_session @admin
Timecop.freeze(61.minutes.ago) do
get "/accounts/#{@account.id}"
expect(response).to be_ok
doc = Nokogiri::HTML(response.body)
expect(doc.at_css('#section-tabs .section .outcomes')).not_to be_nil
end
# change a permission on the user's role
@account.role_overrides.create! role: admin_role, permission: 'manage_outcomes',
enabled: false
# ensure the change is reflected once the user's cached permissions expire
get "/accounts/#{@account.id}"
expect(response).to be_ok
doc = Nokogiri::HTML(response.body)
expect(doc.at_css('#section-tabs .section .outcomes')).to be_nil
end
end
end
it "should show the correct students counts" do
account_model
account_admin_user(:account => @account)
user_session(@user)
course_with_student(:active_all => true, :account => @account)
@course.student_view_student # shouldn't count
get "/accounts/#{@account.id}"
doc = Nokogiri::HTML(response.body)
expect(doc.at_css(".course .details").text).to include("1 Student")
end
it 'shows special master/blueprint course stuff in course index' do
@domain_root_account = Account.default
Account.default.enable_feature!(:master_courses)
account_admin_user
user_session(@user)
bc = course_factory(:course_name => "blooprint")
template = MasterCourses::MasterTemplate.set_as_master_course(bc)
2.times do
template.add_child_course!(course_factory)
end
time = DateTime.parse("2016-05-12 22:00 UTC")
template.master_migrations.create!(:imports_completed_at => time, :workflow_state => 'completed')
get "/accounts/#{Account.default.id}?only_master_courses=1"
doc = Nokogiri::HTML(response.body)
text = doc.at_css(".course .details").text
expect(text).to include("Blueprint Course")
expect(text).to include("Last Pushed Update: May 12")
expect(text).to include("2 Associated Courses")
end
end