diff options
| author | Valery Sizov <valery@gitlab.com> | 2015-10-14 16:01:35 +0000 |
|---|---|---|
| committer | Valery Sizov <valery@gitlab.com> | 2015-10-14 16:01:35 +0000 |
| commit | 2fb02f9252f3083b44d1999a8421b3824e1929cb (patch) | |
| tree | 21e82839c88b0ca771d8ee2240e9f205d68b7610 /spec/models/service_spec.rb | |
| parent | a2f0a3650b03fcca3c8ca428ca1d2173197b4d22 (diff) | |
| parent | b46397548056e4e8ef00efe4f641c61ba1dd5230 (diff) | |
| download | gitlab-ce-2fb02f9252f3083b44d1999a8421b3824e1929cb.tar.gz | |
Merge branch 'fix/improve_reset_service_password' into 'master'
Improve invalidation of stored service password if the endpoint URL is changed
A number of issues were found in !1490 and !1558 (triggered by support request 7395)
* It is not possible to set a new URL and a password at the same time (new password is ignored)
* An error occurs on the Service Templates admin pages (prop_updated? was referencing the service's project, which is not defined for templates)
* Passwords are reset on every save in Service Templates admin pages
This should fix these 3 issues by respectively:
* Differentiating a property that has been assigned a new value (regardless of the new value) and a property that has been assigned a new value that is different from the old one
* Providing an alternate implementation to detected updated properties, not relying on the service's project
* Filtering an empty password parameter passed to the Service Templates admin page like on the project service page
See merge request !1583
Diffstat (limited to 'spec/models/service_spec.rb')
| -rw-r--r-- | spec/models/service_spec.rb | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index da87ea5b84f..d42b96294ba 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -116,14 +116,47 @@ describe Service do ) end - it "returns false" do + it "returns false when the property has not been assigned a new value" do service.username = "key_changed" expect(service.prop_updated?(:bamboo_url)).to be_falsy end - it "returns true" do - service.bamboo_url = "http://other.com" + it "returns true when the property has been assigned a different value" do + service.bamboo_url = "http://example.com" expect(service.prop_updated?(:bamboo_url)).to be_truthy end + + it "returns true when the property has been re-assigned the same value" do + service.bamboo_url = 'http://gitlab.com' + expect(service.prop_updated?(:bamboo_url)).to be_truthy + end + end + + describe "#prop_modified?" do + let(:service) do + BambooService.create( + project: create(:project), + properties: { + bamboo_url: 'http://gitlab.com', + username: 'mic', + password: "password" + } + ) + end + + it "returns false when the property has not been assigned a new value" do + service.username = "key_changed" + expect(service.prop_modified?(:bamboo_url)).to be_falsy + end + + it "returns true when the property has been assigned a different value" do + service.bamboo_url = "http://example.com" + expect(service.prop_modified?(:bamboo_url)).to be_truthy + end + + it "returns false when the property has been re-assigned the same value" do + service.bamboo_url = 'http://gitlab.com' + expect(service.prop_modified?(:bamboo_url)).to be_falsy + end end end |
