paperclip_upload 0.1.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/app/controllers/paperclip_upload/uploads_controller.rb +0 -8
- data/app/models/paperclip_upload/upload.rb +17 -0
- data/app/serializers/paperclip_upload/upload_serializer.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/generators/paperclip_upload/{install_generator.rb → install/install_generator.rb} +8 -1
- data/lib/generators/paperclip_upload/install/templates/initializer.rb +5 -0
- data/lib/generators/paperclip_upload/upload_controller/templates/controller.rb +14 -0
- data/lib/generators/paperclip_upload/upload_controller/upload_controller_generator.rb +29 -0
- data/lib/paperclip_upload/active_record_extension.rb +5 -2
- data/lib/paperclip_upload/version.rb +1 -1
- data/lib/paperclip_upload.rb +14 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/config/initializers/paperclip_upload.rb +5 -0
- data/spec/dummy/config/routes.rb +1 -2
- data/spec/dummy/log/development.log +20 -0
- data/spec/dummy/log/test.log +3571 -0
- data/spec/dummy/spec/controllers/paperclip_upload/uploads_controller_spec.rb +1 -11
- data/spec/dummy/spec/models/paperclip_upload/upload_spec.rb +12 -1
- data/spec/dummy/spec/models/promotion_spec.rb +7 -7
- metadata +24 -5
- data/spec/dummy/README.rdoc +0 -28
@@ -3,16 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe PaperclipUpload::UploadsController, type: :controller do
|
4
4
|
routes { PaperclipUpload::Engine.routes }
|
5
5
|
|
6
|
-
describe "GET 'show'" do
|
7
|
-
let!(:upload) { create(:upload) }
|
8
|
-
|
9
|
-
it "returns 200 with existent id" do
|
10
|
-
get :show, id: upload.id, format: :json
|
11
|
-
expect(response).to be_success
|
12
|
-
expect(json_response.upload.id).to eq(upload.id)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
6
|
describe "POST 'create'" do
|
17
7
|
context "sending file attachment" do
|
18
8
|
let(:file) { fixture_file_upload(Rails.root.join('spec', 'assets', 'bukowski.jpg')) }
|
@@ -20,7 +10,7 @@ describe PaperclipUpload::UploadsController, type: :controller do
|
|
20
10
|
it "returns 201" do
|
21
11
|
post :create, file: file, format: :json
|
22
12
|
expect(response).to be_success
|
23
|
-
expect(json_response.upload.
|
13
|
+
expect(json_response.upload.identifier).not_to be_nil
|
24
14
|
end
|
25
15
|
end
|
26
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe PaperclipUpload::Upload, type: :model do
|
4
|
-
let(:upload) {
|
4
|
+
let(:upload) { create(:upload) }
|
5
5
|
|
6
6
|
it "has a valid factory" do
|
7
7
|
expect(upload).to be_valid
|
@@ -11,4 +11,15 @@ RSpec.describe PaperclipUpload::Upload, type: :model do
|
|
11
11
|
it { should have_attached_file(:file) }
|
12
12
|
it { should validate_attachment_presence(:file) }
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "#identifier" do
|
16
|
+
it "returns hash" do
|
17
|
+
expect(PaperclipUpload::Upload.hashid.decode(upload.identifier).first).to eq(upload.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "raises error with blank id" do
|
21
|
+
expect { PaperclipUpload::Upload.new.identifier }.to(
|
22
|
+
raise_error("valid with saved instance only"))
|
23
|
+
end
|
24
|
+
end
|
14
25
|
end
|
@@ -17,15 +17,15 @@ RSpec.describe Promotion, type: :model do
|
|
17
17
|
expect(promotion.upload).to eq("upload")
|
18
18
|
end
|
19
19
|
|
20
|
-
it "has
|
21
|
-
promotion.
|
22
|
-
expect(promotion.
|
20
|
+
it "has upload_identifier accessor" do
|
21
|
+
promotion.upload_identifier = "upload_identifier"
|
22
|
+
expect(promotion.upload_identifier).to eq("upload_identifier")
|
23
23
|
end
|
24
24
|
|
25
25
|
context "saving promotion" do
|
26
26
|
context "with invalid upload" do
|
27
|
-
it "raise error passing an invalid
|
28
|
-
promotion.
|
27
|
+
it "raise error passing an invalid upload_identifier" do
|
28
|
+
promotion.upload_identifier = "invalid upload identifier"
|
29
29
|
expect { promotion.save }.to raise_error(ActiveRecord::RecordNotFound)
|
30
30
|
end
|
31
31
|
|
@@ -51,8 +51,8 @@ RSpec.describe Promotion, type: :model do
|
|
51
51
|
saves_with_upload { |promo| promotion.upload = upload }
|
52
52
|
end
|
53
53
|
|
54
|
-
it "saves photo using
|
55
|
-
saves_with_upload { |promo| promotion.
|
54
|
+
it "saves photo using upload_identifier" do
|
55
|
+
saves_with_upload { |promo| promotion.upload_identifier = upload.identifier }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip_upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Segovia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashids
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: paperclip
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,7 +225,10 @@ files:
|
|
211
225
|
- config/routes.rb
|
212
226
|
- db/migrate/20150612152328_create_paperclip_upload_uploads.rb
|
213
227
|
- db/migrate/20150612152417_add_attachment_file_to_uploads.rb
|
214
|
-
- lib/generators/paperclip_upload/install_generator.rb
|
228
|
+
- lib/generators/paperclip_upload/install/install_generator.rb
|
229
|
+
- lib/generators/paperclip_upload/install/templates/initializer.rb
|
230
|
+
- lib/generators/paperclip_upload/upload_controller/templates/controller.rb
|
231
|
+
- lib/generators/paperclip_upload/upload_controller/upload_controller_generator.rb
|
215
232
|
- lib/paperclip_upload/active_record_extension.rb
|
216
233
|
- lib/paperclip_upload/engine.rb
|
217
234
|
- lib/paperclip_upload/version.rb
|
@@ -242,6 +259,7 @@ files:
|
|
242
259
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
243
260
|
- spec/dummy/config/initializers/inflections.rb
|
244
261
|
- spec/dummy/config/initializers/mime_types.rb
|
262
|
+
- spec/dummy/config/initializers/paperclip_upload.rb
|
245
263
|
- spec/dummy/config/initializers/session_store.rb
|
246
264
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
247
265
|
- spec/dummy/config/locales/en.yml
|
@@ -263,7 +281,7 @@ files:
|
|
263
281
|
- spec/dummy/public/500.html
|
264
282
|
- spec/dummy/public/favicon.ico
|
265
283
|
- spec/dummy/Rakefile
|
266
|
-
- spec/dummy/README.
|
284
|
+
- spec/dummy/README.md
|
267
285
|
- spec/dummy/spec/assets/bukowski.jpg
|
268
286
|
- spec/dummy/spec/controllers/paperclip_upload/uploads_controller_spec.rb
|
269
287
|
- spec/dummy/spec/models/paperclip_upload/upload_spec.rb
|
@@ -329,6 +347,7 @@ test_files:
|
|
329
347
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
330
348
|
- spec/dummy/config/initializers/inflections.rb
|
331
349
|
- spec/dummy/config/initializers/mime_types.rb
|
350
|
+
- spec/dummy/config/initializers/paperclip_upload.rb
|
332
351
|
- spec/dummy/config/initializers/session_store.rb
|
333
352
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
334
353
|
- spec/dummy/config/locales/en.yml
|
@@ -350,7 +369,7 @@ test_files:
|
|
350
369
|
- spec/dummy/public/500.html
|
351
370
|
- spec/dummy/public/favicon.ico
|
352
371
|
- spec/dummy/Rakefile
|
353
|
-
- spec/dummy/README.
|
372
|
+
- spec/dummy/README.md
|
354
373
|
- spec/dummy/spec/assets/bukowski.jpg
|
355
374
|
- spec/dummy/spec/controllers/paperclip_upload/uploads_controller_spec.rb
|
356
375
|
- spec/dummy/spec/models/paperclip_upload/upload_spec.rb
|
data/spec/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|