kt-paperclip 5.4.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/issue_template.md +3 -0
- data/.hound.yml +27 -32
- data/.travis.yml +23 -2
- data/Appraisals +17 -0
- data/Gemfile +9 -7
- data/NEWS +21 -0
- data/README.md +27 -37
- data/Rakefile +29 -21
- data/UPGRADING +3 -3
- data/features/basic_integration.feature +4 -0
- data/features/migration.feature +10 -51
- data/features/step_definitions/attachment_steps.rb +12 -12
- data/features/step_definitions/html_steps.rb +5 -5
- data/features/step_definitions/rails_steps.rb +29 -9
- data/features/step_definitions/s3_steps.rb +3 -3
- data/features/step_definitions/web_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/features/support/fakeweb.rb +3 -5
- data/features/support/file_helpers.rb +2 -2
- data/features/support/paths.rb +4 -4
- data/features/support/rails.rb +7 -7
- data/features/support/selectors.rb +1 -1
- data/gemfiles/4.2.gemfile +7 -4
- data/gemfiles/5.0.gemfile +7 -4
- data/gemfiles/5.1.gemfile +20 -0
- data/gemfiles/5.2.gemfile +20 -0
- data/gemfiles/6.0.gemfile +20 -0
- data/lib/generators/paperclip/paperclip_generator.rb +6 -8
- data/lib/paperclip/attachment.rb +102 -104
- data/lib/paperclip/attachment_registry.rb +2 -2
- data/lib/paperclip/file_command_content_type_detector.rb +1 -3
- data/lib/paperclip/filename_cleaner.rb +0 -1
- data/lib/paperclip/geometry.rb +18 -19
- data/lib/paperclip/geometry_detector_factory.rb +13 -16
- data/lib/paperclip/geometry_parser_factory.rb +5 -5
- data/lib/paperclip/glue.rb +3 -3
- data/lib/paperclip/has_attached_file.rb +5 -4
- data/lib/paperclip/helpers.rb +3 -3
- data/lib/paperclip/interpolations.rb +42 -38
- data/lib/paperclip/io_adapters/abstract_adapter.rb +16 -14
- data/lib/paperclip/io_adapters/attachment_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/file_adapter.rb +1 -3
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +3 -3
- data/lib/paperclip/io_adapters/identity_adapter.rb +1 -2
- data/lib/paperclip/io_adapters/registry.rb +1 -1
- data/lib/paperclip/io_adapters/stringio_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +6 -8
- data/lib/paperclip/io_adapters/uri_adapter.rb +9 -7
- data/lib/paperclip/logger.rb +1 -1
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +4 -4
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +19 -18
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +4 -4
- data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +11 -10
- data/lib/paperclip/matchers.rb +4 -4
- data/lib/paperclip/media_type_spoof_detector.rb +13 -13
- data/lib/paperclip/missing_attachment_styles.rb +11 -6
- data/lib/paperclip/processor.rb +13 -6
- data/lib/paperclip/processor_helpers.rb +3 -1
- data/lib/paperclip/rails_environment.rb +1 -5
- data/lib/paperclip/railtie.rb +5 -5
- data/lib/paperclip/schema.rb +18 -14
- data/lib/paperclip/storage/filesystem.rb +5 -7
- data/lib/paperclip/storage/fog.rb +36 -32
- data/lib/paperclip/storage/s3.rb +67 -75
- data/lib/paperclip/style.rb +3 -6
- data/lib/paperclip/tempfile.rb +4 -5
- data/lib/paperclip/tempfile_factory.rb +0 -1
- data/lib/paperclip/thumbnail.rb +11 -11
- data/lib/paperclip/url_generator.rb +5 -12
- data/lib/paperclip/validators/attachment_content_type_validator.rb +3 -3
- data/lib/paperclip/validators/attachment_file_name_validator.rb +5 -10
- data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +1 -2
- data/lib/paperclip/validators/attachment_presence_validator.rb +3 -5
- data/lib/paperclip/validators/attachment_size_validator.rb +8 -8
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +3 -1
- data/lib/paperclip/validators.rb +12 -13
- data/lib/paperclip/version.rb +1 -3
- data/lib/paperclip.rb +49 -48
- data/lib/tasks/paperclip.rake +23 -24
- data/paperclip.gemspec +29 -33
- data/shoulda_macros/paperclip.rb +16 -16
- data/spec/paperclip/attachment_definitions_spec.rb +5 -5
- data/spec/paperclip/attachment_processing_spec.rb +22 -23
- data/spec/paperclip/attachment_registry_spec.rb +15 -15
- data/spec/paperclip/attachment_spec.rb +238 -196
- data/spec/paperclip/content_type_detector_spec.rb +11 -12
- data/spec/paperclip/file_command_content_type_detector_spec.rb +10 -10
- data/spec/paperclip/filename_cleaner_spec.rb +3 -4
- data/spec/paperclip/geometry_detector_spec.rb +7 -8
- data/spec/paperclip/geometry_parser_spec.rb +31 -31
- data/spec/paperclip/geometry_spec.rb +24 -24
- data/spec/paperclip/glue_spec.rb +3 -5
- data/spec/paperclip/has_attached_file_spec.rb +46 -126
- data/spec/paperclip/integration_spec.rb +111 -77
- data/spec/paperclip/interpolations_spec.rb +101 -93
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +41 -13
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +8 -10
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +13 -14
- data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +4 -4
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +12 -12
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +42 -26
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/nil_adapter_spec.rb +2 -2
- data/spec/paperclip/io_adapters/registry_spec.rb +4 -4
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +10 -10
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +6 -6
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +80 -31
- data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +3 -3
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +4 -5
- data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +4 -4
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +4 -4
- data/spec/paperclip/media_type_spoof_detector_spec.rb +50 -24
- data/spec/paperclip/meta_class_spec.rb +3 -3
- data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +28 -24
- data/spec/paperclip/paperclip_spec.rb +15 -11
- data/spec/paperclip/plural_cache_spec.rb +8 -8
- data/spec/paperclip/processor_helpers_spec.rb +35 -35
- data/spec/paperclip/processor_spec.rb +8 -8
- data/spec/paperclip/rails_environment_spec.rb +7 -10
- data/spec/paperclip/rake_spec.rb +39 -39
- data/spec/paperclip/schema_spec.rb +57 -53
- data/spec/paperclip/storage/filesystem_spec.rb +6 -6
- data/spec/paperclip/storage/fog_spec.rb +76 -82
- data/spec/paperclip/storage/s3_live_spec.rb +22 -22
- data/spec/paperclip/storage/s3_spec.rb +585 -583
- data/spec/paperclip/style_spec.rb +67 -71
- data/spec/paperclip/tempfile_factory_spec.rb +5 -5
- data/spec/paperclip/thumbnail_spec.rb +68 -67
- data/spec/paperclip/url_generator_spec.rb +18 -29
- data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +27 -27
- data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +15 -16
- data/spec/paperclip/validators/attachment_presence_validator_spec.rb +5 -5
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +21 -21
- data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +9 -13
- data/spec/paperclip/validators_spec.rb +40 -40
- data/spec/spec_helper.rb +21 -23
- data/spec/support/assertions.rb +8 -6
- data/spec/support/fake_model.rb +1 -2
- data/spec/support/fake_rails.rb +1 -1
- data/spec/support/matchers/exist.rb +1 -1
- data/spec/support/matchers/have_column.rb +1 -1
- data/spec/support/mock_url_generator_builder.rb +2 -3
- data/spec/support/model_reconstruction.rb +16 -12
- data/spec/support/reporting.rb +1 -1
- data/spec/support/test_data.rb +2 -2
- metadata +49 -105
- data/lib/kt-paperclip.rb +0 -1
- data/spec/support/conditional_filter_helper.rb +0 -5
data/features/migration.feature
CHANGED
@@ -2,69 +2,28 @@ Feature: Migration
|
|
2
2
|
|
3
3
|
Background:
|
4
4
|
Given I generate a new rails application
|
5
|
-
And I
|
6
|
-
"""
|
7
|
-
class User < ActiveRecord::Base; end
|
8
|
-
"""
|
5
|
+
And I generate a "User" model:
|
9
6
|
|
10
7
|
Scenario: Vintage syntax
|
11
|
-
|
12
|
-
"""
|
13
|
-
class AddAttachmentToUsers < ActiveRecord::Migration
|
14
|
-
def self.up
|
15
|
-
create_table :users do |t|
|
16
|
-
t.has_attached_file :avatar
|
17
|
-
end
|
18
|
-
end
|
8
|
+
Given I run a paperclip migration to add a paperclip "attach" to the "User" model
|
19
9
|
|
20
|
-
def self.down
|
21
|
-
drop_attached_file :users, :avatar
|
22
|
-
end
|
23
|
-
end
|
24
|
-
"""
|
25
10
|
And I run a migration
|
26
|
-
Then I should have attachment columns for "
|
11
|
+
Then I should have attachment columns for "attach"
|
27
12
|
|
28
13
|
When I rollback a migration
|
29
|
-
Then I should not have attachment columns for "
|
14
|
+
Then I should not have attachment columns for "attach"
|
30
15
|
|
31
16
|
Scenario: New syntax with create_table
|
32
|
-
|
33
|
-
|
34
|
-
class AddAttachmentToUsers < ActiveRecord::Migration
|
35
|
-
def self.up
|
36
|
-
create_table :users do |t|
|
37
|
-
t.attachment :avatar
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
"""
|
17
|
+
Given I run a paperclip migration to add a paperclip "attach" to the "User" model
|
18
|
+
|
42
19
|
And I run a migration
|
43
|
-
Then I should have attachment columns for "
|
20
|
+
Then I should have attachment columns for "attach"
|
44
21
|
|
45
22
|
Scenario: New syntax outside of create_table
|
46
|
-
|
47
|
-
"""
|
48
|
-
class CreateUsers < ActiveRecord::Migration
|
49
|
-
def self.up
|
50
|
-
create_table :users
|
51
|
-
end
|
52
|
-
end
|
53
|
-
"""
|
54
|
-
And I write to "db/migrate/02_add_attachment_to_users.rb" with:
|
55
|
-
"""
|
56
|
-
class AddAttachmentToUsers < ActiveRecord::Migration
|
57
|
-
def self.up
|
58
|
-
add_attachment :users, :avatar
|
59
|
-
end
|
23
|
+
Given I run a paperclip migration to add a paperclip "attachment_sample" to the "User" model
|
60
24
|
|
61
|
-
def self.down
|
62
|
-
remove_attachment :users, :avatar
|
63
|
-
end
|
64
|
-
end
|
65
|
-
"""
|
66
25
|
And I run a migration
|
67
|
-
Then I should have attachment columns for "
|
26
|
+
Then I should have attachment columns for "attachment_sample"
|
68
27
|
|
69
28
|
When I rollback a migration
|
70
|
-
Then I should not have attachment columns for "
|
29
|
+
Then I should not have attachment columns for "attachment_sample"
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
|
42
42
|
When /^I swap the attachment "([^"]*)" with the fixture "([^"]*)"$/ do |attachment_filename, fixture_filename|
|
43
43
|
cd(".") do
|
44
|
-
require
|
44
|
+
require "fileutils"
|
45
45
|
FileUtils.rm_f attachment_path(attachment_filename)
|
46
46
|
FileUtils.cp fixture_path(fixture_filename), attachment_path(attachment_filename)
|
47
47
|
end
|
@@ -76,7 +76,7 @@ Then /^the attachment should have the same file size as the fixture "([^"]*)"$/
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
Then /^the attachment file "([^"]*)" should (not )?exist$/ do |filename,
|
79
|
+
Then /^the attachment file "([^"]*)" should (not )?exist$/ do |filename, _not_exist|
|
80
80
|
cd(".") do
|
81
81
|
expect(attachment_path(filename)).not_to be_an_existing_file
|
82
82
|
end
|
@@ -84,12 +84,12 @@ end
|
|
84
84
|
|
85
85
|
Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name|
|
86
86
|
cd(".") do
|
87
|
-
columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.
|
87
|
+
columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.sql_type] }.inspect"`.strip)
|
88
88
|
expect_columns = [
|
89
|
-
["#{attachment_name}_file_name",
|
90
|
-
["#{attachment_name}_content_type",
|
91
|
-
["#{attachment_name}_file_size",
|
92
|
-
["#{attachment_name}_updated_at",
|
89
|
+
["#{attachment_name}_file_name", "varchar"],
|
90
|
+
["#{attachment_name}_content_type", "varchar"],
|
91
|
+
["#{attachment_name}_file_size", "bigint"],
|
92
|
+
["#{attachment_name}_updated_at", "datetime"]
|
93
93
|
]
|
94
94
|
expect(columns).to include(*expect_columns)
|
95
95
|
end
|
@@ -97,12 +97,12 @@ end
|
|
97
97
|
|
98
98
|
Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name|
|
99
99
|
cd(".") do
|
100
|
-
columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.
|
100
|
+
columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.sql_type] }.inspect"`.strip)
|
101
101
|
expect_columns = [
|
102
|
-
["#{attachment_name}_file_name",
|
103
|
-
["#{attachment_name}_content_type",
|
104
|
-
["#{attachment_name}_file_size",
|
105
|
-
["#{attachment_name}_updated_at",
|
102
|
+
["#{attachment_name}_file_name", "varchar"],
|
103
|
+
["#{attachment_name}_content_type", "varchar"],
|
104
|
+
["#{attachment_name}_file_size", "bigint"],
|
105
|
+
["#{attachment_name}_updated_at", "datetime"]
|
106
106
|
]
|
107
107
|
|
108
108
|
expect(columns).not_to include(*expect_columns)
|
@@ -5,11 +5,11 @@ end
|
|
5
5
|
Then %r{^the file at "([^"]*)" is the same as "([^"]*)"$} do |web_file, path|
|
6
6
|
expected = IO.read(path)
|
7
7
|
actual = if web_file.match %r{^https?://}
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
Net::HTTP.get(URI.parse(web_file))
|
9
|
+
else
|
10
|
+
visit(web_file)
|
11
|
+
page.body
|
12
|
+
end
|
13
13
|
actual.force_encoding("UTF-8") if actual.respond_to?(:force_encoding)
|
14
14
|
expect(actual).to eq(expected)
|
15
15
|
end
|
@@ -17,7 +17,7 @@ Given /^I generate a new rails application$/ do
|
|
17
17
|
gem "jruby-openssl", :platform => :jruby
|
18
18
|
gem "capybara"
|
19
19
|
gem "gherkin"
|
20
|
-
gem "aws-sdk"
|
20
|
+
gem "aws-sdk-s3"
|
21
21
|
gem "racc", :platform => :rbx
|
22
22
|
gem "rubysl", :platform => :rbx
|
23
23
|
"""
|
@@ -30,6 +30,14 @@ Given /^I generate a new rails application$/ do
|
|
30
30
|
FileUtils.chdir("../../..")
|
31
31
|
end
|
32
32
|
|
33
|
+
Given /^I generate a "([^"]*)" model:$/ do |model_name|
|
34
|
+
step %[I successfully run `rails generate model #{model_name}`]
|
35
|
+
end
|
36
|
+
|
37
|
+
Given /^I run a paperclip migration to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name|
|
38
|
+
step %[I successfully run `rails generate paperclip #{model_name} #{attachment_name}`]
|
39
|
+
end
|
40
|
+
|
33
41
|
Given "I allow the attachment to be submitted" do
|
34
42
|
cd(".") do
|
35
43
|
transform_file("app/controllers/users_controller.rb") do |content|
|
@@ -84,7 +92,7 @@ end
|
|
84
92
|
|
85
93
|
Given "I empty the application.js file" do
|
86
94
|
cd(".") do
|
87
|
-
transform_file("app/assets/javascripts/application.js") do |
|
95
|
+
transform_file("app/assets/javascripts/application.js") do |_content|
|
88
96
|
""
|
89
97
|
end
|
90
98
|
end
|
@@ -135,7 +143,7 @@ Given /^I add this snippet to the User model:$/ do |snippet|
|
|
135
143
|
file_name = "app/models/user.rb"
|
136
144
|
cd(".") do
|
137
145
|
content = File.read(file_name)
|
138
|
-
File.open(file_name,
|
146
|
+
File.open(file_name, "w") { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
|
139
147
|
end
|
140
148
|
end
|
141
149
|
|
@@ -143,7 +151,21 @@ Given /^I add this snippet to config\/application.rb:$/ do |snippet|
|
|
143
151
|
file_name = "config/application.rb"
|
144
152
|
cd(".") do
|
145
153
|
content = File.read(file_name)
|
146
|
-
File.open(file_name,
|
154
|
+
File.open(file_name, "w") do |f|
|
155
|
+
f << content.sub(/class Application < Rails::Application.*$/,
|
156
|
+
"class Application < Rails::Application\n#{snippet}\n")
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
Given /^I replace this snippet to app\/views\/layouts\/application.html.erb:$/ do |snippet|
|
162
|
+
file_name = "app/views/layouts/application.html.erb"
|
163
|
+
cd(".") do
|
164
|
+
content = File.read(file_name)
|
165
|
+
File.open(file_name, "w") do |f|
|
166
|
+
f << content.sub(/<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>$/,
|
167
|
+
"#{snippet}")
|
168
|
+
end
|
147
169
|
end
|
148
170
|
end
|
149
171
|
|
@@ -166,7 +188,7 @@ When /^I turn off class caching$/ do
|
|
166
188
|
config = IO.read(file)
|
167
189
|
config.gsub!(%r{^\s*config.cache_classes.*$},
|
168
190
|
"config.cache_classes = false")
|
169
|
-
File.open(file, "w"){|f| f.write(config) }
|
191
|
+
File.open(file, "w") { |f| f.write(config) }
|
170
192
|
end
|
171
193
|
end
|
172
194
|
|
@@ -186,10 +208,8 @@ When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
|
|
186
208
|
end
|
187
209
|
|
188
210
|
When /^I append gems from Appraisal Gemfile$/ do
|
189
|
-
File.read(ENV[
|
190
|
-
if line =~ /^gem "(?!rails|appraisal)/
|
191
|
-
append_to_gemfile line.strip
|
192
|
-
end
|
211
|
+
File.read(ENV["BUNDLE_GEMFILE"]).split(/\n/).each do |line|
|
212
|
+
append_to_gemfile line.strip if line =~ /^gem "(?!rails|appraisal)/
|
193
213
|
end
|
194
214
|
end
|
195
215
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field|
|
2
2
|
definition = Paperclip::AttachmentRegistry.definitions_for(User)[field.downcase.to_sym]
|
3
3
|
path = "https://paperclip.s3.us-west-2.amazonaws.com#{definition[:path]}"
|
4
|
-
path.gsub!(
|
5
|
-
path.gsub!(/:([^\/\.]+)/) do |
|
4
|
+
path.gsub!(":filename", File.basename(file_path))
|
5
|
+
path.gsub!(/:([^\/\.]+)/) do |_match|
|
6
6
|
"([^\/\.]+)"
|
7
7
|
end
|
8
|
-
FakeWeb.register_uri(:put, Regexp.new(path), :
|
8
|
+
FakeWeb.register_uri(:put, Regexp.new(path), body: "<xml></xml>")
|
9
9
|
step "I attach the file \"#{file_path}\" to \"#{field}\""
|
10
10
|
end
|
11
11
|
|
@@ -18,9 +18,8 @@
|
|
18
18
|
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
19
19
|
#
|
20
20
|
|
21
|
-
|
22
|
-
require
|
23
|
-
require 'cgi'
|
21
|
+
require "uri"
|
22
|
+
require "cgi"
|
24
23
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
24
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
25
|
|
@@ -58,11 +57,11 @@ When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
58
57
|
end
|
59
58
|
|
60
59
|
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
-
fill_in(field, :
|
60
|
+
fill_in(field, with: value)
|
62
61
|
end
|
63
62
|
|
64
63
|
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
-
fill_in(field, :
|
64
|
+
fill_in(field, with: value)
|
66
65
|
end
|
67
66
|
|
68
67
|
# Use this to fill in an entire form with data from a table. Example:
|
@@ -83,7 +82,7 @@ When /^(?:|I )fill in the following:$/ do |fields|
|
|
83
82
|
end
|
84
83
|
|
85
84
|
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
-
select(value, :
|
85
|
+
select(value, from: field)
|
87
86
|
end
|
88
87
|
|
89
88
|
When /^(?:|I )check "([^"]*)"$/ do |field|
|
data/features/support/env.rb
CHANGED
data/features/support/fakeweb.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "fake_web"
|
2
2
|
|
3
3
|
FakeWeb.allow_net_connect = false
|
4
4
|
|
5
5
|
module FakeWeb
|
6
6
|
class StubSocket
|
7
|
-
def read_timeout=(_ignored)
|
8
|
-
end
|
7
|
+
def read_timeout=(_ignored); end
|
9
8
|
|
10
|
-
def continue_timeout=(_ignored)
|
11
|
-
end
|
9
|
+
def continue_timeout=(_ignored); end
|
12
10
|
end
|
13
11
|
end
|
@@ -9,14 +9,14 @@ module FileHelpers
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def append_to_gemfile(contents)
|
12
|
-
append_to(
|
12
|
+
append_to("Gemfile", contents)
|
13
13
|
end
|
14
14
|
|
15
15
|
def comment_out_gem_in_gemfile(gemname)
|
16
16
|
cd(".") do
|
17
17
|
gemfile = File.read("Gemfile")
|
18
18
|
gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2")
|
19
|
-
File.open("Gemfile",
|
19
|
+
File.open("Gemfile", "w") { |file| file.write(gemfile) }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
data/features/support/paths.rb
CHANGED
@@ -9,17 +9,17 @@ module NavigationHelpers
|
|
9
9
|
case page_name
|
10
10
|
|
11
11
|
when /the home\s?page/
|
12
|
-
|
12
|
+
"/"
|
13
13
|
when /the new user page/
|
14
|
-
|
14
|
+
"/users/new"
|
15
15
|
else
|
16
16
|
begin
|
17
17
|
page_name =~ /the (.*) page/
|
18
18
|
path_components = $1.split(/\s+/)
|
19
|
-
|
19
|
+
send(path_components.push("path").join("_").to_sym)
|
20
20
|
rescue Object
|
21
21
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
22
|
-
|
22
|
+
"Now, go and add a mapping in #{__FILE__}"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/features/support/rails.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__),
|
2
|
-
APP_NAME =
|
3
|
-
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
|
4
|
-
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,
|
1
|
+
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", "..")).freeze
|
2
|
+
APP_NAME = "testapp"
|
3
|
+
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).freeze
|
4
|
+
ORIGINAL_BUNDLE_VARS = Hash[ENV.select { |key, _value| BUNDLE_ENV_VARS.include?(key) }]
|
5
5
|
|
6
|
-
ENV[
|
6
|
+
ENV["RAILS_ENV"] = "test"
|
7
7
|
|
8
8
|
Before do
|
9
|
-
gemfile = ENV[
|
10
|
-
ENV[
|
9
|
+
gemfile = ENV["BUNDLE_GEMFILE"].to_s
|
10
|
+
ENV["BUNDLE_GEMFILE"] = File.join(Dir.pwd, gemfile) unless gemfile.start_with?(Dir.pwd)
|
11
11
|
@framework_version = nil
|
12
12
|
end
|
13
13
|
|
data/gemfiles/4.2.gemfile
CHANGED
@@ -2,16 +2,19 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
|
6
5
|
gem "pry"
|
6
|
+
gem "sqlite3", "~> 1.3.8", platforms: :ruby
|
7
7
|
gem "rails", "~> 4.2.0"
|
8
8
|
|
9
9
|
group :development, :test do
|
10
10
|
gem "activerecord-import"
|
11
|
-
gem "
|
11
|
+
gem "bootsnap", require: false
|
12
12
|
gem "builder"
|
13
|
-
gem "
|
13
|
+
gem "listen", "~> 3.0.8"
|
14
|
+
gem "mime-types"
|
14
15
|
gem "rspec"
|
16
|
+
gem "rubocop", require: false
|
17
|
+
gem "sprockets", "3.7.2"
|
15
18
|
end
|
16
19
|
|
17
|
-
gemspec :
|
20
|
+
gemspec path: "../"
|
data/gemfiles/5.0.gemfile
CHANGED
@@ -2,16 +2,19 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
|
6
5
|
gem "pry"
|
6
|
+
gem "sqlite3", "~> 1.3.8", platforms: :ruby
|
7
7
|
gem "rails", "~> 5.0.0"
|
8
8
|
|
9
9
|
group :development, :test do
|
10
10
|
gem "activerecord-import"
|
11
|
-
gem "
|
11
|
+
gem "bootsnap", require: false
|
12
12
|
gem "builder"
|
13
|
-
gem "
|
13
|
+
gem "listen", "~> 3.0.8"
|
14
|
+
gem "mime-types"
|
14
15
|
gem "rspec"
|
16
|
+
gem "rubocop", require: false
|
17
|
+
gem "sprockets", "3.7.2"
|
15
18
|
end
|
16
19
|
|
17
|
-
gemspec :
|
20
|
+
gemspec path: "../"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry"
|
6
|
+
gem "sqlite3", "~> 1.3.8", platforms: :ruby
|
7
|
+
gem "rails", "~> 5.1.0"
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "activerecord-import"
|
11
|
+
gem "bootsnap", require: false
|
12
|
+
gem "builder"
|
13
|
+
gem "listen", "~> 3.0.8"
|
14
|
+
gem "mime-types"
|
15
|
+
gem "rspec"
|
16
|
+
gem "rubocop", require: false
|
17
|
+
gem "sprockets", "3.7.2"
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec path: "../"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry"
|
6
|
+
gem "sqlite3", "~> 1.3.8", platforms: :ruby
|
7
|
+
gem "rails", "~> 5.2.0"
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "activerecord-import"
|
11
|
+
gem "bootsnap", require: false
|
12
|
+
gem "builder"
|
13
|
+
gem "listen", "~> 3.0.8"
|
14
|
+
gem "mime-types"
|
15
|
+
gem "rspec"
|
16
|
+
gem "rubocop", require: false
|
17
|
+
gem "sprockets", "3.7.2"
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec path: "../"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry"
|
6
|
+
gem "sqlite3", "~> 1.4", platforms: :ruby
|
7
|
+
gem "rails", "~> 6.0.0"
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "activerecord-import"
|
11
|
+
gem "bootsnap", require: false
|
12
|
+
gem "builder"
|
13
|
+
gem "listen", "~> 3.0.8"
|
14
|
+
gem "mime-types"
|
15
|
+
gem "rspec"
|
16
|
+
gem "rubocop", require: false
|
17
|
+
gem "sprockets", "3.7.2"
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec path: "../"
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "rails/generators/active_record"
|
2
2
|
|
3
3
|
class PaperclipGenerator < ActiveRecord::Generators::Base
|
4
4
|
desc "Create a migration to add paperclip-specific fields to your model. " +
|
5
5
|
"The NAME argument is the name of your model, and the following " +
|
6
6
|
"arguments are the name of the attachments"
|
7
7
|
|
8
|
-
argument :attachment_names, :
|
9
|
-
|
8
|
+
argument :attachment_names, required: true, type: :array, desc: "The names of the attachment(s) to add.",
|
9
|
+
banner: "attachment_one attachment_two attachment_three ..."
|
10
10
|
|
11
11
|
def self.source_root
|
12
|
-
@source_root ||= File.expand_path(
|
12
|
+
@source_root ||= File.expand_path("templates", __dir__)
|
13
13
|
end
|
14
14
|
|
15
15
|
def generate_migration
|
@@ -19,7 +19,7 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def migration_name
|
22
|
-
"add_attachment_#{attachment_names.join(
|
22
|
+
"add_attachment_#{attachment_names.join('_')}_to_#{name.underscore.pluralize}"
|
23
23
|
end
|
24
24
|
|
25
25
|
def migration_file_name
|
@@ -31,8 +31,6 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def migration_version
|
34
|
-
if Rails.version.
|
35
|
-
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
36
|
-
end
|
34
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails.version.first.to_i > 4
|
37
35
|
end
|
38
36
|
end
|