diff options
| author | Xinhui | 2016-11-14 10:55:18 +0100 |
|---|---|---|
| committer | Xinhui | 2016-11-14 10:55:18 +0100 |
| commit | 32f12d8a3db8cae6cf29c9c85aeb9d899aecf814 (patch) | |
| tree | 7f05e2ca18001ea4d482026e78a7c62ccb93714d /spec | |
| parent | f0a63658e609eef1f1e3967ac0729e5543974203 (diff) | |
| download | chouette-core-32f12d8a3db8cae6cf29c9c85aeb9d899aecf814.tar.bz2 | |
Fix organisation functional_scope not updated
Refs #1941
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/organisation_spec.rb | 13 | ||||
| -rw-r--r-- | spec/models/user_spec.rb | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 5cf2ded01..9b4235755 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe Organisation, :type => :model do - it { should validate_presence_of(:name) } it { should validate_uniqueness_of(:code) } @@ -40,13 +39,13 @@ describe Organisation, :type => :model do end it 'should update existing organisations' do - create :organisation, name: 'dummy_name', code:'RATP', updated_at: 10.days.ago + create :organisation, name: 'dummy_name', code:'RATP', updated_at: 10.days.ago, sso_attributes: {functional_scope: "[\"STIF:CODIFLIGNE:Line:C00840\"]"} Organisation.portail_sync - Organisation.find_by(code: 'RATP').tap do |org| - expect(org.name).to eq('RATP') - expect(org.updated_at.utc).to be_within(1.second).of Time.now - expect(org.synced_at.utc).to be_within(1.second).of Time.now - end + org = Organisation.find_by(code: 'RATP') + expect(org.name).to eq('RATP') + expect(org.updated_at.utc).to be_within(1.second).of Time.now + expect(org.synced_at.utc).to be_within(1.second).of Time.now + expect(org.sso_attributes['functional_scope']).to eq "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]" end it 'should not create organisation if code is already present' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bb43be63e..7d0a548c1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -39,6 +39,13 @@ describe User, :type => :model do expect(org.sso_attributes['functional_scope']).to eq "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]" end + it 'should update organisation functional_scope' do + create :organisation, code: ticket.extra_attributes[:organisation_code], sso_attributes: {functional_scope: "[\"STIF:CODIFLIGNE:Line:C00840\"]"} + 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 } |
