dragonfly 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dragonfly might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
data/dragonfly.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Evans"]
12
- s.date = %q{2010-03-27}
12
+ s.date = %q{2010-04-13}
13
13
  s.email = %q{mark@new-bamboo.co.uk}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -39,10 +39,8 @@ module Dragonfly
39
39
  end
40
40
 
41
41
  def save!
42
- if changed?
43
- destroy!
44
- self.uid = app.datastore.store(temp_object) if temp_object
45
- end
42
+ destroy! if uid_changed?
43
+ self.uid = app.datastore.store(temp_object) if has_data_to_store?
46
44
  end
47
45
 
48
46
  def temp_object
@@ -97,7 +95,11 @@ module Dragonfly
97
95
  uid && !uid.is_a?(PendingUID)
98
96
  end
99
97
 
100
- def changed?
98
+ def has_data_to_store?
99
+ uid.is_a?(PendingUID)
100
+ end
101
+
102
+ def uid_changed?
101
103
  parent_model.send("#{attribute_name}_uid_changed?")
102
104
  end
103
105
 
@@ -72,6 +72,24 @@ describe Item do
72
72
  end
73
73
  end
74
74
 
75
+ describe "when the uid is set manually" do
76
+ before(:each) do
77
+ @item.preview_image_uid = 'some_known_uid'
78
+ end
79
+ it "should not try to retrieve any data" do
80
+ @app.datastore.should_not_receive(:retrieve)
81
+ @item.save!
82
+ end
83
+ it "should not try to destroy any data" do
84
+ @app.datastore.should_not_receive(:destroy)
85
+ @item.save!
86
+ end
87
+ it "should not try to store any data" do
88
+ @app.datastore.should_not_receive(:store)
89
+ @item.save!
90
+ end
91
+ end
92
+
75
93
  describe "when there has been some thing assigned but not saved" do
76
94
  before(:each) do
77
95
  @item.preview_image = "DATASTRING"
@@ -98,6 +116,24 @@ describe Item do
98
116
  temp_object.should be_a(Dragonfly::ExtendedTempObject)
99
117
  temp_object.data.should == 'DATASTRING'
100
118
  end
119
+ describe "when the uid is set manually" do
120
+ before(:each) do
121
+ @item.preview_image_uid = 'some_known_uid'
122
+ end
123
+ it "should not try to retrieve any data" do
124
+ @app.datastore.should_not_receive(:retrieve)
125
+ @item.save!
126
+ end
127
+ it "should not try to destroy any data" do
128
+ @app.datastore.should_not_receive(:destroy)
129
+ @item.save!
130
+ end
131
+ it "should not try to store any data" do
132
+ @app.datastore.should_not_receive(:store)
133
+ @item.save!
134
+ end
135
+ end
136
+
101
137
  end
102
138
 
103
139
  describe "when something has been assigned and saved" do
@@ -132,6 +168,12 @@ describe Item do
132
168
  @item.preview_image.url(:arg).should == 'some.url'
133
169
  end
134
170
 
171
+ it "should destroy the old data when the uid is set manually" do
172
+ @app.datastore.should_receive(:destroy).with('some_uid')
173
+ @item.preview_image_uid = 'some_known_uid'
174
+ @item.save!
175
+ end
176
+
135
177
  describe "when accessed by a new model object" do
136
178
  before(:each) do
137
179
  @item = Item.find(@item.id)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 3
9
- version: 0.5.3
8
+ - 4
9
+ version: 0.5.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Evans
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-27 00:00:00 +00:00
17
+ date: 2010-04-13 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency