has_moderated 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ # Read about factories at http://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :photo_holder do
5
+ title "MyString"
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ def dirEmpty? dirname
5
+ return true unless File.directory?(dirname)
6
+ Dir.entries(dirname).size == 2
7
+ end
8
+
9
+ tempdir = File.expand_path("../../../public/uploads/tmp", __FILE__)
10
+ uploaddir = "/Users/apple/rails/has_moderated/test/dummy/public/uploads/photo/photo/1"
11
+ SAMPLE_PHOTO_URL = "http://www.arnes.si/typo3conf/ext/ag_arnes_eff_template/templates/template-index/images/logo_arnes.gif"
12
+
13
+ describe PhotoHolder do
14
+ it "should upload photo" do
15
+ photo = PhotoHolder.create!(:photos_attributes => { 0 => {:remote_photo_url => SAMPLE_PHOTO_URL}})
16
+
17
+ Photo.count.should eq(0)
18
+ dirEmpty?(tempdir).should be_false
19
+ Moderation.last.accept
20
+ dirEmpty?(tempdir).should be_true
21
+
22
+ Photo.count.should eq(1)
23
+ photo = Photo.first
24
+ photo.photo.should_not be_nil
25
+ photo.photo.file.should_not be_nil
26
+ photo.photo.file.file.should_not be_nil
27
+ assert(Photo.first.photo.file.file =~ /photo\/1\/logo_arnes.gif\Z/)
28
+ end
29
+ end
@@ -62,6 +62,7 @@ describe Photo do
62
62
  dirEmpty?(tempdir).should be_true
63
63
  dirEmpty?(uploaddir).should be_false
64
64
  Photo.first.photo.file.should_not be_nil
65
- assert(Photo.first.photo.file.file =~ /logo_arnes\.gif/)
65
+ File.exist?(Photo.first.photo.file.file).should be_true
66
+ assert(Photo.first.photo.file.file =~ /photo\/1\/logo_arnes.gif\Z/)
66
67
  end
67
68
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_moderated
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 15
10
- version: 0.0.15
9
+ - 16
10
+ version: 0.0.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Berdajs
@@ -77,6 +77,7 @@ files:
77
77
  - test/dummy/app/models/hook_test.rb
78
78
  - test/dummy/app/models/moderation.rb
79
79
  - test/dummy/app/models/photo.rb
80
+ - test/dummy/app/models/photo_holder.rb
80
81
  - test/dummy/app/models/subtask.rb
81
82
  - test/dummy/app/models/task.rb
82
83
  - test/dummy/app/models/task_all.rb
@@ -108,6 +109,7 @@ files:
108
109
  - test/dummy/db/migrate/20111003205633_create_photos.rb
109
110
  - test/dummy/db/migrate/20111003234101_create_task_photos.rb
110
111
  - test/dummy/db/migrate/20111004153147_create_hook_tests.rb
112
+ - test/dummy/db/migrate/20111004164509_create_photo_holders.rb
111
113
  - test/dummy/db/schema.rb
112
114
  - test/dummy/db/test.sqlite3
113
115
  - test/dummy/falaf/test.rb
@@ -121,10 +123,12 @@ files:
121
123
  - test/dummy/Rakefile
122
124
  - test/dummy/script/rails
123
125
  - test/dummy/spec/factories/hook_tests.rb
126
+ - test/dummy/spec/factories/photo_holders.rb
124
127
  - test/dummy/spec/factories/photos.rb
125
128
  - test/dummy/spec/factories/task_alls.rb
126
129
  - test/dummy/spec/factories/task_photos.rb
127
130
  - test/dummy/spec/models/hooks_spec.rb
131
+ - test/dummy/spec/models/photo_holder_spec.rb
128
132
  - test/dummy/spec/models/photo_spec.rb
129
133
  - test/dummy/spec/models/task_photo_spec.rb
130
134
  - test/dummy/spec/models/task_spec.rb
@@ -171,6 +175,7 @@ test_files:
171
175
  - test/dummy/app/models/hook_test.rb
172
176
  - test/dummy/app/models/moderation.rb
173
177
  - test/dummy/app/models/photo.rb
178
+ - test/dummy/app/models/photo_holder.rb
174
179
  - test/dummy/app/models/subtask.rb
175
180
  - test/dummy/app/models/task.rb
176
181
  - test/dummy/app/models/task_all.rb
@@ -202,6 +207,7 @@ test_files:
202
207
  - test/dummy/db/migrate/20111003205633_create_photos.rb
203
208
  - test/dummy/db/migrate/20111003234101_create_task_photos.rb
204
209
  - test/dummy/db/migrate/20111004153147_create_hook_tests.rb
210
+ - test/dummy/db/migrate/20111004164509_create_photo_holders.rb
205
211
  - test/dummy/db/schema.rb
206
212
  - test/dummy/db/test.sqlite3
207
213
  - test/dummy/falaf/test.rb
@@ -215,10 +221,12 @@ test_files:
215
221
  - test/dummy/Rakefile
216
222
  - test/dummy/script/rails
217
223
  - test/dummy/spec/factories/hook_tests.rb
224
+ - test/dummy/spec/factories/photo_holders.rb
218
225
  - test/dummy/spec/factories/photos.rb
219
226
  - test/dummy/spec/factories/task_alls.rb
220
227
  - test/dummy/spec/factories/task_photos.rb
221
228
  - test/dummy/spec/models/hooks_spec.rb
229
+ - test/dummy/spec/models/photo_holder_spec.rb
222
230
  - test/dummy/spec/models/photo_spec.rb
223
231
  - test/dummy/spec/models/task_photo_spec.rb
224
232
  - test/dummy/spec/models/task_spec.rb