forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug zammad#1070: Existing resources get "save!"ed without chang…
…es. This triggers Rails model callbacks and executes unneeded actions. This was caused by an error in the detection of changed associations. Unchanged associations were interpreted as a reset of the association. Therefore all associations without a new value won't get tracked anymore. This is the right behavior since they won't change the current value of the resource without a value.
- Loading branch information
1 parent
199686d
commit 22f87c8
Showing
3 changed files
with
38 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,24 +220,6 @@ | |
} | ||
end | ||
|
||
it 'keeps local roles if signup roles are configured' do | ||
|
||
ldap_config[:unassigned_users] = 'sigup_roles' | ||
expect do | ||
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) | ||
end.not_to change { | ||
User.last.role_ids | ||
} | ||
end | ||
|
||
it "doesn't detect false changes if signup roles are configured" do | ||
# make sure that the nothing has changed | ||
User.find_by(login: uid).update_attribute(:email, '[email protected]') | ||
|
||
instance = described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) | ||
expect(instance.action).to eq(:unchanged) | ||
end | ||
|
||
it 'skips user if configured' do | ||
|
||
ldap_config[:unassigned_users] = 'skip_sync' | ||
|
@@ -250,6 +232,27 @@ | |
} | ||
expect(instance.action).to eq(:skipped) | ||
end | ||
|
||
context 'signup roles configuration' do | ||
it 'keeps local roles' do | ||
|
||
ldap_config[:unassigned_users] = 'sigup_roles' | ||
expect do | ||
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) | ||
end.not_to change { | ||
User.last.role_ids | ||
} | ||
end | ||
|
||
it "doesn't detect false changes" do | ||
# make sure that the nothing has changed | ||
User.find_by(login: uid).update_attribute(:email, '[email protected]') | ||
|
||
expect_any_instance_of(User).not_to receive(:save!) | ||
instance = described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) | ||
expect(instance.action).to eq(:unchanged) | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
@@ -265,7 +268,6 @@ | |
User.count | ||
} | ||
expect(instance.action).to eq(:skipped) | ||
|
||
end | ||
|
||
it 'skips entries without attributes' do | ||
|
@@ -288,6 +290,5 @@ | |
expect(HttpLog.last.status).to eq('success') | ||
expect(HttpLog.last.url).to start_with('skipped') | ||
end | ||
|
||
end | ||
end |