From: Matt Wagner <mawagner(a)redhat.com>
Fixes a bug where ProviderImages were always saved with provider_id => 1,
even when no Provider with that ID existed. (The 'provider' variable here
is a Provider, not its ID.)
---
src/app/models/image.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index 7d71089..d4b3f0b 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -97,7 +97,7 @@ class Image < ActiveRecord::Base
)
ProviderImage.create!(
:image_id => img.id,
- :provider_id => provider
+ :provider => provider
)
end
return img
--
1.7.4
Show replies by thread
This adds a test for the 'Fix bug setting ProviderImage provider_id'
patch sent earlier.
---
src/spec/models/image_spec.rb | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/spec/models/image_spec.rb b/src/spec/models/image_spec.rb
index 63b11dc..379c970 100644
--- a/src/spec/models/image_spec.rb
+++ b/src/spec/models/image_spec.rb
@@ -75,4 +75,13 @@ describe Image do
end.should change(Template, :count).by(1)
end.should change(ProviderImage, :count).by(1)
end
+
+ it "should correctly handle multiple provider accounts" do
+ provider_account1 = Factory(:mock_provider_account)
+ provider_account2 = Factory(:mock_provider_account)
+ provider_account1.destroy
+ image = Image.build(Factory(:template), Provider::MOCK)
+ provider_image = ProviderImage.find_by_image_id(image.id)
+ provider_image.provider_id.equal?(provider_account2.provider.id).should be_true
+ end
end
--
1.7.4