rails-uploader 0.5.7 → 0.5.9
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/README.md +7 -7
- data/lib/generators/uploader/install/templates/20130905144515_create_assets.rb +1 -1
- data/lib/uploader/fileupload_glue.rb +22 -0
- data/lib/uploader/fileuploads.rb +2 -1
- data/lib/uploader/helpers/field_tag.rb +4 -8
- data/lib/uploader/version.rb +1 -1
- data/spec/dummy/Rakefile +2 -3
- data/spec/dummy/app/assets/config/manifest.js +1 -1
- data/spec/dummy/app/assets/stylesheets/application.css +7 -5
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -1
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/article.rb +1 -1
- data/spec/dummy/app/models/asset.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +18 -9
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/pwa/manifest.json.erb +22 -0
- data/spec/dummy/app/views/pwa/service-worker.js +26 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +37 -0
- data/spec/dummy/config/application.rb +39 -47
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +20 -13
- data/spec/dummy/config/environment.rb +4 -4
- data/spec/dummy/config/environments/development.rb +64 -22
- data/spec/dummy/config/environments/production.rb +74 -41
- data/spec/dummy/config/environments/test.rb +51 -20
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -9
- data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
- data/spec/dummy/config/locales/en.yml +28 -2
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +4 -2
- data/spec/dummy/db/migrate/20120508093830_create_articles.rb +1 -1
- data/spec/dummy/db/migrate/20130905144515_create_assets.rb +34 -0
- data/spec/dummy/log/test.log +1677 -0
- data/spec/dummy/public/404.html +55 -14
- data/spec/dummy/public/406-unsupported-browser.html +66 -0
- data/spec/dummy/public/422.html +55 -14
- data/spec/dummy/public/500.html +54 -13
- data/spec/dummy/public/icon.png +0 -0
- data/spec/dummy/public/icon.svg +3 -0
- data/spec/dummy/public/uploads/picture/data/1/rails.png +0 -0
- data/spec/dummy/public/uploads/picture/data/1/thumb_rails.png +0 -0
- data/spec/dummy/storage/test.sqlite3 +0 -0
- data/spec/dummy/tmp/local_secret.txt +1 -0
- data/spec/factories/factories.rb +16 -0
- data/spec/fileuploads_spec.rb +30 -30
- data/spec/mongoid_spec.rb +5 -3
- data/spec/rails_helper.rb +80 -0
- data/spec/requests/attachments_controller_spec.rb +4 -4
- data/spec/spec_helper.rb +84 -45
- data/spec/uploader_spec.rb +5 -3
- metadata +88 -91
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/script/rails +0 -6
- data/spec/factories/articles.rb +0 -9
- data/spec/factories/assets.rb +0 -11
- /data/spec/dummy/{public/favicon.ico → log/development.log} +0 -0
data/spec/dummy/public/404.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page 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
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page 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
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
20
58
|
<!-- This file lives in public/404.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
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>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Your browser is not supported (406)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page 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
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page 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 class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/406-unsupported-browser.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>Your browser is not supported.</h1>
|
62
|
+
<p>Please upgrade your browser to continue.</p>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
data/spec/dummy/public/422.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page 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
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page 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
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
20
58
|
<!-- This file lives in public/422.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
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>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/spec/dummy/public/500.html
CHANGED
@@ -2,24 +2,65 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page 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
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page 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
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
20
58
|
<!-- This file lives in public/500.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
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>
|
23
64
|
</div>
|
24
65
|
</body>
|
25
66
|
</html>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
1f554035419c76fdec75cb5218c7506fce105855df1db50413709e059bf6557109f9a67c9e67aa6458485c230cb82fb877c1779f95e76be36a37592a57674de6
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :article, class: Article do
|
5
|
+
title { 'MyString' }
|
6
|
+
content { 'MyText' }
|
7
|
+
end
|
8
|
+
|
9
|
+
factory :picture, class: Picture do
|
10
|
+
data { File.open('spec/factories/files/rails.png') }
|
11
|
+
data_content_type { 'image/png' }
|
12
|
+
data_file_name { 'rails.png' }
|
13
|
+
|
14
|
+
association :assetable, factory: :article
|
15
|
+
end
|
16
|
+
end
|
data/spec/fileuploads_spec.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe Uploader::Fileuploads do
|
6
|
+
let(:picture) { create(:picture, assetable_type: 'Article') }
|
7
7
|
|
8
|
-
it
|
9
|
-
|
8
|
+
it 'should be a Module' do
|
9
|
+
# raise FactoryBot.find_definitions.inspect
|
10
|
+
require "/Users/mario/www/gems/rails-uploader/spec/factories/factories.rb"
|
11
|
+
expect(Uploader::Fileuploads).to be_a(Module)
|
10
12
|
end
|
11
13
|
|
12
|
-
context
|
13
|
-
|
14
|
-
@article = FactoryGirl.build(:article)
|
15
|
-
end
|
14
|
+
context 'instance methods' do
|
15
|
+
let(:article) { build(:article) }
|
16
16
|
|
17
|
-
it
|
18
|
-
|
17
|
+
it 'should return asset class' do
|
18
|
+
expect(article.fileupload_klass('picture')).to eq Picture
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
|
21
|
+
it 'should find asset by guid' do
|
22
|
+
picture.update_column(:guid, article.fileupload_guid)
|
23
23
|
|
24
|
-
asset =
|
25
|
-
asset.
|
24
|
+
asset = article.fileupload_asset('picture')
|
25
|
+
expect(asset).to eq picture
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
|
28
|
+
it 'should generate guid' do
|
29
|
+
expect(article.fileupload_guid).not_to be_blank
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
it 'should change guid' do
|
33
|
+
article.fileupload_guid = 'other guid'
|
34
|
+
expect(article.fileupload_changed?).to be_truthy
|
35
|
+
expect(article.fileupload_guid).to eq 'other guid'
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
|
38
|
+
it 'should not multiplay upload' do
|
39
|
+
expect(article.fileupload_multiple?('picture')).to be_falsey
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
picture =
|
44
|
-
picture.
|
45
|
-
picture.
|
42
|
+
it 'should find uploaded asset or build new record' do
|
43
|
+
picture = article.fileupload_asset(:picture)
|
44
|
+
expect(picture).not_to be_nil
|
45
|
+
expect(picture).to be_new_record
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'must get fileupload params' do
|
49
|
-
|
49
|
+
expect(article.fileupload_params(:picture)).not_to be nil
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/spec/mongoid_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
2
4
|
require 'mongoid'
|
3
5
|
|
4
6
|
Mongoid.load!('spec/mongoid.yml', ENV['RAILS_ENV'])
|
@@ -21,7 +23,7 @@ class MongoidPicture
|
|
21
23
|
belongs_to :assetable, polymorphic: true
|
22
24
|
end
|
23
25
|
|
24
|
-
describe Uploader::Asset do
|
26
|
+
RSpec.describe Uploader::Asset do
|
25
27
|
before do
|
26
28
|
@guid = 'guid'
|
27
29
|
@article = MongoidArticle.new(fileupload_guid: @guid)
|
@@ -33,7 +35,7 @@ describe Uploader::Asset do
|
|
33
35
|
asset.should == @picture
|
34
36
|
end
|
35
37
|
|
36
|
-
it
|
38
|
+
it 'should update asset target_id by guid' do
|
37
39
|
@article.save
|
38
40
|
|
39
41
|
@picture.reload
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
require 'spec_helper'
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
require_relative 'dummy/config/environment'
|
5
|
+
# Prevent database truncation if the environment is production
|
6
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
7
|
+
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
|
8
|
+
# that will avoid rails generators crashing because migrations haven't been run yet
|
9
|
+
# return unless Rails.env.test?
|
10
|
+
require 'rspec/rails'
|
11
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
12
|
+
|
13
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
14
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
15
|
+
# run as spec files by default. This means that files in spec/support that end
|
16
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
17
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
18
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
19
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
20
|
+
#
|
21
|
+
# The following line is provided for convenience purposes. It has the downside
|
22
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
23
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
24
|
+
# require only the support files necessary.
|
25
|
+
#
|
26
|
+
# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
|
27
|
+
|
28
|
+
require 'factory_bot_rails'
|
29
|
+
|
30
|
+
require 'carrierwave'
|
31
|
+
CarrierWave.configure do |config|
|
32
|
+
config.storage = :file
|
33
|
+
config.enable_processing = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# copy gem migrations to ensure we have the *same* in the app
|
37
|
+
FileUtils.cp_r 'lib/generators/uploader/install/templates/.', 'spec/dummy/db/migrate/'
|
38
|
+
|
39
|
+
# Checks for pending migrations and applies them before tests are run.
|
40
|
+
# If you are not using ActiveRecord, you can remove these lines.
|
41
|
+
begin
|
42
|
+
ActiveRecord::Migrator.migrations_paths = [Rails.root.join('db/migrate').to_s]
|
43
|
+
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths).migrate
|
44
|
+
|
45
|
+
ActiveRecord::Migration.maintain_test_schema!
|
46
|
+
rescue ActiveRecord::PendingMigrationError => e
|
47
|
+
abort e.to_s.strip
|
48
|
+
end
|
49
|
+
|
50
|
+
RSpec.configure do |config|
|
51
|
+
config.include FactoryBot::Syntax::Methods
|
52
|
+
|
53
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
54
|
+
# examples within a transaction, remove the following line or assign false
|
55
|
+
# instead of true.
|
56
|
+
config.use_transactional_fixtures = true
|
57
|
+
|
58
|
+
# You can uncomment this line to turn off ActiveRecord support entirely.
|
59
|
+
# config.use_active_record = false
|
60
|
+
|
61
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
62
|
+
# based on their file location, for example enabling you to call `get` and
|
63
|
+
# `post` in specs under `spec/controllers`.
|
64
|
+
#
|
65
|
+
# You can disable this behaviour by removing the line below, and instead
|
66
|
+
# explicitly tag your specs with their type, e.g.:
|
67
|
+
#
|
68
|
+
# RSpec.describe UsersController, type: :controller do
|
69
|
+
# # ...
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# The different available types are documented in the features, such as in
|
73
|
+
# https://rspec.info/features/7-0/rspec-rails
|
74
|
+
config.infer_spec_type_from_file_location!
|
75
|
+
|
76
|
+
# Filter lines from Rails gems in backtraces.
|
77
|
+
config.filter_rails_from_backtrace!
|
78
|
+
# arbitrary gems may also be filtered via:
|
79
|
+
# config.filter_gems_from_backtrace("gem name")
|
80
|
+
end
|
@@ -13,7 +13,7 @@ describe Uploader::AttachmentsController do
|
|
13
13
|
|
14
14
|
it "should create new asset" do
|
15
15
|
file = Rack::Test::UploadedFile.new('spec/factories/files/rails.png', "image/png")
|
16
|
-
article =
|
16
|
+
article = create(:article)
|
17
17
|
post "/uploader/attachments", {
|
18
18
|
:klass => "Picture",
|
19
19
|
:assetable_id => article.id,
|
@@ -30,7 +30,7 @@ describe Uploader::AttachmentsController do
|
|
30
30
|
|
31
31
|
it "should destroy old asset on new asset for has_one" do
|
32
32
|
file = Rack::Test::UploadedFile.new('spec/factories/files/rails.png', "image/png")
|
33
|
-
article =
|
33
|
+
article = create(:article)
|
34
34
|
post "/uploader/attachments", {
|
35
35
|
:klass => "Picture",
|
36
36
|
:assetable_id => article.id,
|
@@ -58,7 +58,7 @@ describe Uploader::AttachmentsController do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should destroy asset" do
|
61
|
-
@asset =
|
61
|
+
@asset = create(:picture)
|
62
62
|
|
63
63
|
lambda {
|
64
64
|
delete "/uploader/attachments/#{@asset.id}", {:klass => "Picture"}
|
@@ -66,7 +66,7 @@ describe Uploader::AttachmentsController do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should not destroy asset with not exists guid" do
|
69
|
-
@asset =
|
69
|
+
@asset = create(:picture)
|
70
70
|
|
71
71
|
lambda {
|
72
72
|
delete "/uploader/attachments/wrong", {:klass => "Picture"}
|