aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/organizations.json1
-rw-r--r--spec/models/organisation_spec.rb6
-rw-r--r--spec/models/user_spec.rb9
3 files changed, 15 insertions, 1 deletions
diff --git a/spec/fixtures/organizations.json b/spec/fixtures/organizations.json
index b70f99520..6b507b445 100644
--- a/spec/fixtures/organizations.json
+++ b/spec/fixtures/organizations.json
@@ -84,6 +84,7 @@
"code": "RATP",
"created_at": "2016-05-17T16:04:26.646Z",
"updated_at": "2016-05-31T10:06:39.349Z",
+ "functional_scope": "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]",
"organization_users": {
"users_count": 8
},
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index 9d9749b18..c0aba2eb8 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -33,6 +33,12 @@ describe Organisation, :type => :model do
expect(Organisation.all.map(&:name)).to include 'ALBATRANS', 'OPTILE', 'SNCF', 'STIF'
end
+ it 'should retrieve functional scope' do
+ Organisation.portail_sync
+ org = Organisation.find_by(code: 'RATP')
+ expect(org.sso_attributes['functional_scope']).to eq "[STIF:CODIFLIGNE:Line:C00840, STIF:CODIFLIGNE:Line:C00086]"
+ end
+
it 'should update existing organisations' do
create :organisation, name: 'dummy_name', code:'RATP', updated_at: 10.days.ago
Organisation.portail_sync
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 16fbed27a..c20e80ca1 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -12,7 +12,8 @@ describe User, :type => :model do
:username => 'john.doe',
:email => 'john.doe@af83.com',
:organisation_code => '0083',
- :organisation_name => 'af83'
+ :organisation_name => 'af83',
+ :functional_scope => "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]"
}
ticket.user = "john.doe"
ticket.success = true
@@ -32,6 +33,12 @@ describe User, :type => :model do
expect(Organisation.find_by(code: ticket.extra_attributes[:organisation_code])).to be_truthy
end
+ it 'should store organisation functional_scope' do
+ User.authenticate_with_cas_ticket(ticket)
+ org = Organisation.find_by(code: ticket.extra_attributes[:organisation_code])
+ expect(org.sso_attributes['functional_scope']).to eq "[STIF:CODIFLIGNE:Line:C00840, STIF:CODIFLIGNE:Line:C00086]"
+ end
+
it 'should not create a new organisation if organisation is already present' do
ticket.extra_attributes[:organisation_code] = create(:organisation).code
expect{User.authenticate_with_cas_ticket(ticket)}.not_to change{ Organisation.count }