paperclip_upload 1.1.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +24 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +210 -0
- data/Guardfile +11 -0
- data/README.md +246 -0
- data/app/controllers/paperclip_upload/uploads_controller.rb +18 -1
- data/app/models/paperclip_upload/upload.rb +17 -2
- data/app/serializers/paperclip_upload/upload_serializer.rb +1 -1
- data/bin/rails +12 -0
- data/config/routes.rb +1 -0
- data/lib/generators/paperclip_upload/upload_controller/templates/controller.rb +18 -1
- data/lib/generators/paperclip_upload/upload_controller/upload_controller_generator.rb +33 -5
- data/lib/paperclip_upload/active_record_extension.rb +2 -2
- data/lib/paperclip_upload/version.rb +1 -1
- data/paperclip_upload.gemspec +34 -0
- metadata +96 -188
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/promotion.rb +0 -21
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/paperclip_upload.rb +0 -9
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150612173816_create_paperclip_upload_uploads.paperclip_upload.rb +0 -8
- data/spec/dummy/db/migrate/20150612173817_add_attachment_file_to_uploads.paperclip_upload.rb +0 -12
- data/spec/dummy/db/migrate/20150613212501_create_promotions.rb +0 -8
- data/spec/dummy/db/migrate/20150613212609_add_attachment_photo_to_promotions.rb +0 -11
- data/spec/dummy/db/migrate/20150717201744_add_attachment_prefixed_file_one_to_promotions.rb +0 -11
- data/spec/dummy/db/migrate/20150717201754_add_attachment_prefixed_file_two_to_promotions.rb +0 -11
- data/spec/dummy/db/migrate/20150717202131_add_attachment_prefixed_file_to_promotions.rb +0 -11
- data/spec/dummy/db/schema.rb +0 -46
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -5282
- data/spec/dummy/log/test.log +0 -39940
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/system/promotions/photos/000/000/021/original/data +0 -0
- data/spec/dummy/spec/assets/bukowski.jpg +0 -0
- data/spec/dummy/spec/controllers/paperclip_upload/uploads_controller_spec.rb +0 -17
- data/spec/dummy/spec/models/paperclip_upload/upload_spec.rb +0 -25
- data/spec/dummy/spec/models/promotion_spec.rb +0 -110
- data/spec/dummy/tmp/promotions/1/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/1/data +0 -0
- data/spec/dummy/tmp/promotions/11/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/13/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/15/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/17/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/19/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/21/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/21/data +0 -0
- data/spec/dummy/tmp/promotions/3/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/5/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/7/bukowski.jpg +0 -0
- data/spec/dummy/tmp/promotions/9/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/10/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/12/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/14/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/18/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/2/Marilyn_Manson_imagen_003.jpg +0 -0
- data/spec/dummy/tmp/uploads/2/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/20/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/21/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/3/Marilyn_Manson_imagen_005.jpg +0 -0
- data/spec/dummy/tmp/uploads/4/Marilyn_Manson_imagen_005.jpg +0 -0
- data/spec/dummy/tmp/uploads/4/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/6/bukowski.jpg +0 -0
- data/spec/dummy/tmp/uploads/8/bukowski.jpg +0 -0
- data/spec/factories/paperclip_upload/uploads.rb +0 -7
- data/spec/factories/promotions.rb +0 -13
- data/spec/rails_helper.rb +0 -26
- data/spec/spec_helper.rb +0 -87
- data/spec/support/controller_helpers.rb +0 -16
- /data/{spec/dummy/log/RAILS_ENV=test.log → app/assets/images/paperclip_upload/.keep} +0 -0
data/spec/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/404.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
File without changes
|
Binary file
|
Binary file
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PaperclipUpload::UploadsController, type: :controller do
|
4
|
-
routes { PaperclipUpload::Engine.routes }
|
5
|
-
|
6
|
-
describe "POST 'create'" do
|
7
|
-
context "sending file attachment" do
|
8
|
-
let(:file) { fixture_file_upload(Rails.root.join('spec', 'assets', 'bukowski.jpg')) }
|
9
|
-
|
10
|
-
it "returns 201" do
|
11
|
-
post :create, file: file, format: :json
|
12
|
-
expect(response).to be_success
|
13
|
-
expect(json_response.upload.identifier).not_to be_nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe PaperclipUpload::Upload, type: :model do
|
4
|
-
let(:upload) { create(:upload) }
|
5
|
-
|
6
|
-
it "has a valid factory" do
|
7
|
-
expect(upload).to be_valid
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "validations" do
|
11
|
-
it { should have_attached_file(:file) }
|
12
|
-
it { should validate_attachment_presence(:file) }
|
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
|
25
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe Promotion, type: :model do
|
4
|
-
let(:promotion) { create(:promotion) }
|
5
|
-
|
6
|
-
describe "#has_attached_upload" do
|
7
|
-
it "has has_attached_upload method" do
|
8
|
-
expect(Promotion).to respond_to(:has_attached_upload)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "wraps has_attached_file paperclip method" do
|
12
|
-
expect(Promotion.new.photo).to be_a(Paperclip::Attachment)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has upload accessor" do
|
16
|
-
expect(promotion).to respond_to(:upload)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "has upload_identifier accessor" do
|
20
|
-
expect(promotion).to respond_to(:upload_identifier)
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with use_prefix option enabled" do
|
24
|
-
it "has upload accessors" do
|
25
|
-
expect(promotion).to respond_to(:prefixed_file_upload)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "has upload_identifier accessor" do
|
29
|
-
expect(promotion).to respond_to(:prefixed_file_upload_identifier)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "raises error trying to redefine upload_accessor", focus: true do
|
33
|
-
expect { Promotion.has_attached_upload(:photo) }.to raise_error(
|
34
|
-
"you are trying to redefine upload_identifier attribute")
|
35
|
-
expect { Promotion.has_attached_upload(:prefixed_file, upload: { use_prefix: true }) }.to raise_error(
|
36
|
-
"you are trying to redefine prefixed_file_upload_identifier attribute")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "saving promotion" do
|
41
|
-
context "with invalid upload" do
|
42
|
-
it "raises error passing an invalid upload_identifier" do
|
43
|
-
promotion.upload_identifier = "invalid upload identifier"
|
44
|
-
expect { promotion.save }.to raise_error(ActiveRecord::RecordNotFound)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "raises error passing an invalid upload" do
|
48
|
-
promotion.upload = "invalid upload"
|
49
|
-
expect { promotion.save }.to raise_error("invalid PaperclipUpload::Upload instance")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "with valid upload" do
|
54
|
-
let!(:upload) { create(:upload) }
|
55
|
-
|
56
|
-
def saves_with_upload(_paperclip_attr)
|
57
|
-
expect(promotion.photo.exists?).to be_falsy
|
58
|
-
yield(promotion)
|
59
|
-
expect(promotion.save).to be_truthy
|
60
|
-
expect(promotion.send(_paperclip_attr).exists?).to be_truthy
|
61
|
-
expect { PaperclipUpload::Upload.find(upload.id) }.to(
|
62
|
-
raise_error(ActiveRecord::RecordNotFound))
|
63
|
-
end
|
64
|
-
|
65
|
-
it "saves photo using upload instance" do
|
66
|
-
saves_with_upload(:photo) { promotion.upload = upload }
|
67
|
-
end
|
68
|
-
|
69
|
-
it "saves photo using upload_identifier" do
|
70
|
-
saves_with_upload(:photo) { promotion.upload_identifier = upload.identifier }
|
71
|
-
end
|
72
|
-
|
73
|
-
context "with use_prefix option enabled" do
|
74
|
-
it "saves prefixed_file using upload_identifier" do
|
75
|
-
saves_with_upload(:prefixed_file) do
|
76
|
-
promotion.prefixed_file_upload_identifier = upload.identifier
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "saves prefixed_file using upload instance" do
|
81
|
-
saves_with_upload(:prefixed_file) { promotion.prefixed_file_upload = upload }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#allow_encoded_file_for" do
|
89
|
-
it "has allow_encoded_file_for method" do
|
90
|
-
expect(Promotion).to respond_to(:allow_encoded_file_for)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "has encoded_photo accessor" do
|
94
|
-
promotion.encoded_photo = "encoded_photo"
|
95
|
-
expect(promotion.encoded_photo).to eq("encoded_photo")
|
96
|
-
end
|
97
|
-
|
98
|
-
context "saving promotion" do
|
99
|
-
context "with encoded photo" do
|
100
|
-
let(:encoded_promotion) { build(:promotion_with_encoded_photo) }
|
101
|
-
|
102
|
-
it "decodes and save photo" do
|
103
|
-
expect(encoded_promotion.photo.exists?).to be_falsy
|
104
|
-
expect(encoded_promotion.save).to be_truthy
|
105
|
-
expect(encoded_promotion.photo.exists?).to be_truthy
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,13 +0,0 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
factory :promotion do
|
3
|
-
photo nil
|
4
|
-
|
5
|
-
factory :promotion_with_photo do
|
6
|
-
photo { fixture_file_upload(Rails.root.join('spec', 'assets', 'bukowski.jpg')) }
|
7
|
-
end
|
8
|
-
|
9
|
-
factory :promotion_with_encoded_photo do
|
10
|
-
encoded_photo { Base64.encode64(File.open(Rails.root.join('spec', 'assets', 'bukowski.jpg')).read) }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] ||= 'test'
|
2
|
-
|
3
|
-
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
-
require 'rspec/rails'
|
5
|
-
require 'spec_helper'
|
6
|
-
require 'factory_girl_rails'
|
7
|
-
require 'shoulda-matchers'
|
8
|
-
require 'paperclip/matchers'
|
9
|
-
require 'recursive_open_struct'
|
10
|
-
|
11
|
-
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
12
|
-
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
13
|
-
|
14
|
-
ActiveRecord::Migration.maintain_test_schema!
|
15
|
-
|
16
|
-
RSpec.configure do |config|
|
17
|
-
config.use_transactional_fixtures = true
|
18
|
-
config.infer_spec_type_from_file_location!
|
19
|
-
config.order = :random
|
20
|
-
config.render_views
|
21
|
-
config.include FactoryGirl::Syntax::Methods
|
22
|
-
config.include Paperclip::Shoulda::Matchers
|
23
|
-
config.include ControllerHelpers, type: :controller
|
24
|
-
|
25
|
-
FactoryGirl::SyntaxRunner.send(:include, RSpec::Mocks::ExampleMethods)
|
26
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
-
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
-
# files.
|
6
|
-
#
|
7
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
-
# a separate helper file that requires the additional dependencies and performs
|
12
|
-
# the additional setup, and require it from the spec files that actually need
|
13
|
-
# it.
|
14
|
-
#
|
15
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
-
# users commonly want.
|
17
|
-
#
|
18
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
-
RSpec.configure do |config|
|
20
|
-
# rspec-expectations config goes here. You can use an alternate
|
21
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
-
# assertions if you prefer.
|
23
|
-
config.expect_with :rspec do |expectations|
|
24
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
-
# and `failure_message` of custom matchers include text for helper methods
|
26
|
-
# defined using `chain`, e.g.:
|
27
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
-
# # => "be bigger than 2 and smaller than 4"
|
29
|
-
# ...rather than:
|
30
|
-
# # => "be bigger than 2"
|
31
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
-
end
|
33
|
-
|
34
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
-
config.mock_with :rspec do |mocks|
|
37
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
-
# a real object. This is generally recommended, and will default to
|
39
|
-
# `true` in RSpec 4.
|
40
|
-
mocks.verify_partial_doubles = true
|
41
|
-
end
|
42
|
-
|
43
|
-
# The settings below are suggested to provide a good initial experience
|
44
|
-
# with RSpec, but feel free to customize to your heart's content.
|
45
|
-
=begin
|
46
|
-
# These two settings work together to allow you to limit a spec run
|
47
|
-
# to individual examples or groups you care about by tagging them with
|
48
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
-
# get run.
|
50
|
-
config.filter_run :focus
|
51
|
-
config.run_all_when_everything_filtered = true
|
52
|
-
|
53
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
54
|
-
# recommended. For more details, see:
|
55
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
-
config.disable_monkey_patching!
|
59
|
-
|
60
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
61
|
-
# file, and it's useful to allow more verbose output when running an
|
62
|
-
# individual spec file.
|
63
|
-
if config.files_to_run.one?
|
64
|
-
# Use the documentation formatter for detailed output,
|
65
|
-
# unless a formatter has already been configured
|
66
|
-
# (e.g. via a command-line flag).
|
67
|
-
config.default_formatter = 'doc'
|
68
|
-
end
|
69
|
-
|
70
|
-
# Print the 10 slowest examples and example groups at the
|
71
|
-
# end of the spec run, to help surface which specs are running
|
72
|
-
# particularly slow.
|
73
|
-
config.profile_examples = 10
|
74
|
-
|
75
|
-
# Run specs in random order to surface order dependencies. If you find an
|
76
|
-
# order dependency and want to debug it, you can fix the order by providing
|
77
|
-
# the seed, which is printed after each run.
|
78
|
-
# --seed 1234
|
79
|
-
config.order = :random
|
80
|
-
|
81
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
82
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
83
|
-
# test failures related to randomization by passing the same `--seed` value
|
84
|
-
# as the one that triggered the failure.
|
85
|
-
Kernel.srand config.seed
|
86
|
-
=end
|
87
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module ControllerHelpers
|
2
|
-
def json_response
|
3
|
-
@json_response ||= ControllerHelpers.calculate_json_response(JSON.parse(response.body))
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.calculate_json_response(item)
|
7
|
-
case item
|
8
|
-
when Array
|
9
|
-
item.map! { |i| calculate_json_response(i) }
|
10
|
-
when Hash
|
11
|
-
RecursiveOpenStruct.new(item)
|
12
|
-
else
|
13
|
-
item
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
File without changes
|