paperclip 3.0.3 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- checksums.yaml +15 -0
- data/.gitignore +2 -1
- data/.travis.yml +3 -0
- data/Appraisals +8 -3
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/NEWS +198 -35
- data/README.md +332 -113
- data/features/basic_integration.feature +24 -12
- data/features/migration.feature +94 -0
- data/features/rake_tasks.feature +2 -3
- data/features/step_definitions/attachment_steps.rb +28 -0
- data/features/step_definitions/rails_steps.rb +94 -8
- data/features/step_definitions/s3_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +3 -3
- data/features/support/fakeweb.rb +4 -1
- data/features/support/file_helpers.rb +10 -0
- data/features/support/rails.rb +18 -2
- data/gemfiles/3.0.gemfile +2 -2
- data/gemfiles/3.1.gemfile +2 -2
- data/gemfiles/3.2.gemfile +2 -2
- data/gemfiles/4.0.gemfile +11 -0
- data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +4 -8
- data/lib/paperclip/attachment.rb +96 -43
- data/lib/paperclip/attachment_registry.rb +57 -0
- data/lib/paperclip/callbacks.rb +2 -2
- data/lib/paperclip/content_type_detector.rb +78 -0
- data/lib/paperclip/file_command_content_type_detector.rb +32 -0
- data/lib/paperclip/filename_cleaner.rb +16 -0
- data/lib/paperclip/geometry.rb +66 -30
- data/lib/paperclip/geometry_detector_factory.rb +41 -0
- data/lib/paperclip/geometry_parser_factory.rb +31 -0
- data/lib/paperclip/glue.rb +2 -8
- data/lib/paperclip/has_attached_file.rb +99 -0
- data/lib/paperclip/helpers.rb +12 -15
- data/lib/paperclip/interpolations/plural_cache.rb +17 -0
- data/lib/paperclip/interpolations.rb +15 -5
- data/lib/paperclip/io_adapters/abstract_adapter.rb +45 -0
- data/lib/paperclip/io_adapters/attachment_adapter.rb +14 -49
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +27 -0
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +18 -0
- data/lib/paperclip/io_adapters/file_adapter.rb +8 -69
- data/lib/paperclip/io_adapters/identity_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/nil_adapter.rb +2 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +16 -45
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +17 -40
- data/lib/paperclip/io_adapters/uri_adapter.rb +44 -0
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +1 -5
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +36 -17
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +5 -1
- data/lib/paperclip/matchers.rb +3 -3
- data/lib/paperclip/missing_attachment_styles.rb +11 -16
- data/lib/paperclip/processor.rb +12 -0
- data/lib/paperclip/railtie.rb +5 -1
- data/lib/paperclip/schema.rb +59 -23
- data/lib/paperclip/storage/filesystem.rb +23 -5
- data/lib/paperclip/storage/fog.rb +64 -25
- data/lib/paperclip/storage/s3.rb +93 -52
- data/lib/paperclip/style.rb +2 -2
- data/lib/paperclip/tempfile_factory.rb +21 -0
- data/lib/paperclip/thumbnail.rb +18 -3
- data/lib/paperclip/validators/attachment_content_type_validator.rb +38 -10
- data/lib/paperclip/validators/attachment_presence_validator.rb +8 -8
- data/lib/paperclip/validators/attachment_size_validator.rb +12 -7
- data/lib/paperclip/validators.rb +21 -2
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +15 -44
- data/lib/tasks/paperclip.rake +26 -7
- data/paperclip.gemspec +11 -7
- data/test/attachment_definitions_test.rb +12 -0
- data/test/attachment_processing_test.rb +83 -0
- data/test/attachment_registry_test.rb +77 -0
- data/test/attachment_test.rb +253 -44
- data/test/content_type_detector_test.rb +50 -0
- data/test/file_command_content_type_detector_test.rb +25 -0
- data/test/filename_cleaner_test.rb +14 -0
- data/test/fixtures/animated +0 -0
- data/test/fixtures/animated.unknown +0 -0
- data/test/fixtures/rotated.jpg +0 -0
- data/test/generator_test.rb +26 -24
- data/test/geometry_detector_test.rb +24 -0
- data/test/geometry_parser_test.rb +73 -0
- data/test/geometry_test.rb +55 -4
- data/test/has_attached_file_test.rb +125 -0
- data/test/helper.rb +38 -7
- data/test/integration_test.rb +105 -89
- data/test/interpolations_test.rb +12 -0
- data/test/io_adapters/abstract_adapter_test.rb +58 -0
- data/test/io_adapters/attachment_adapter_test.rb +120 -33
- data/test/io_adapters/data_uri_adapter_test.rb +60 -0
- data/test/io_adapters/empty_string_adapter_test.rb +17 -0
- data/test/io_adapters/file_adapter_test.rb +32 -1
- data/test/io_adapters/stringio_adapter_test.rb +29 -10
- data/test/io_adapters/uploaded_file_adapter_test.rb +53 -5
- data/test/io_adapters/uri_adapter_test.rb +102 -0
- data/test/matchers/validate_attachment_presence_matcher_test.rb +22 -0
- data/test/meta_class_test.rb +32 -0
- data/test/paperclip_missing_attachment_styles_test.rb +4 -8
- data/test/paperclip_test.rb +27 -51
- data/test/plural_cache_test.rb +36 -0
- data/test/processor_test.rb +16 -0
- data/test/rake_test.rb +103 -0
- data/test/schema_test.rb +179 -77
- data/test/storage/filesystem_test.rb +26 -3
- data/test/storage/fog_test.rb +181 -3
- data/test/storage/s3_test.rb +239 -4
- data/test/style_test.rb +18 -14
- data/test/tempfile_factory_test.rb +13 -0
- data/test/thumbnail_test.rb +96 -16
- data/test/validators/attachment_content_type_validator_test.rb +181 -55
- data/test/validators/attachment_size_validator_test.rb +10 -0
- data/test/validators_test.rb +8 -1
- metadata +126 -92
- data/Gemfile.lock +0 -157
- data/features/support/fixtures/.boot_config.rb.swo +0 -0
- data/images.rake +0 -21
- data/lib/.DS_Store +0 -0
- data/lib/paperclip/.DS_Store +0 -0
- data/lib/paperclip/attachment_options.rb +0 -9
- data/lib/paperclip/instance_methods.rb +0 -35
- data/test/attachment_options_test.rb +0 -27
@@ -7,13 +7,27 @@ Feature: Rails integration
|
|
7
7
|
And I run a migration
|
8
8
|
And I update my new user view to include the file upload field
|
9
9
|
And I update my user view to include the attachment
|
10
|
+
And I allow the attachment to be submitted
|
11
|
+
|
12
|
+
Scenario: Configure defaults for all attachments through Railtie
|
13
|
+
Given I add this snippet to config/application.rb:
|
14
|
+
"""
|
15
|
+
config.paperclip_defaults = {:url => "/paperclip/custom/:attachment/:style/:filename"}
|
16
|
+
"""
|
17
|
+
And I attach :attachment
|
18
|
+
And I start the rails application
|
19
|
+
When I go to the new user page
|
20
|
+
And I fill in "Name" with "something"
|
21
|
+
And I attach the file "test/fixtures/5k.png" to "Attachment"
|
22
|
+
And I press "Submit"
|
23
|
+
Then I should see "Name: something"
|
24
|
+
And I should see an image with a path of "/paperclip/custom/attachments/original/5k.png"
|
25
|
+
And the file at "/paperclip/custom/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
|
10
26
|
|
11
27
|
Scenario: Filesystem integration test
|
12
|
-
Given I
|
28
|
+
Given I attach :attachment with:
|
13
29
|
"""
|
14
|
-
|
15
|
-
has_attached_file :attachment, :url => "/system/:attachment/:style/:filename",
|
16
|
-
:styles => { :square => "100x100#" }
|
30
|
+
:url => "/system/:attachment/:style/:filename"
|
17
31
|
"""
|
18
32
|
And I start the rails application
|
19
33
|
When I go to the new user page
|
@@ -25,14 +39,12 @@ Feature: Rails integration
|
|
25
39
|
And the file at "/system/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
|
26
40
|
|
27
41
|
Scenario: S3 Integration test
|
28
|
-
Given I
|
29
|
-
"""
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:s3_credentials => Rails.root.join("config/s3.yml"),
|
35
|
-
:styles => { :square => "100x100#" }
|
42
|
+
Given I attach :attachment with:
|
43
|
+
"""
|
44
|
+
:storage => :s3,
|
45
|
+
:path => "/:attachment/:style/:filename",
|
46
|
+
:s3_credentials => Rails.root.join("config/s3.yml"),
|
47
|
+
:styles => { :square => "100x100#" }
|
36
48
|
"""
|
37
49
|
And I write to "config/s3.yml" with:
|
38
50
|
"""
|
@@ -0,0 +1,94 @@
|
|
1
|
+
Feature: Migration
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I generate a new rails application
|
5
|
+
And I write to "app/models/user.rb" with:
|
6
|
+
"""
|
7
|
+
class User < ActiveRecord::Base; end
|
8
|
+
"""
|
9
|
+
|
10
|
+
Scenario: Vintage syntax
|
11
|
+
When I write to "db/migrate/01_add_attachment_to_users.rb" with:
|
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
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_attached_file :users, :avatar
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And I run a migration
|
26
|
+
Then I should have attachment columns for "avatar"
|
27
|
+
|
28
|
+
When I rollback a migration
|
29
|
+
Then I should not have attachment columns for "avatar"
|
30
|
+
|
31
|
+
Scenario: New syntax with create_table
|
32
|
+
When I write to "db/migrate/01_add_attachment_to_users.rb" with:
|
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
|
+
"""
|
42
|
+
And I run a migration
|
43
|
+
Then I should have attachment columns for "avatar"
|
44
|
+
|
45
|
+
Scenario: New syntax outside of create_table
|
46
|
+
When I write to "db/migrate/01_create_users.rb" with:
|
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
|
60
|
+
|
61
|
+
def self.down
|
62
|
+
remove_attachment :users, :avatar
|
63
|
+
end
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
And I run a migration
|
67
|
+
Then I should have attachment columns for "avatar"
|
68
|
+
|
69
|
+
When I rollback a migration
|
70
|
+
Then I should not have attachment columns for "avatar"
|
71
|
+
|
72
|
+
Scenario: Rails 3.2 change method
|
73
|
+
Given I am using Rails newer than 3.1
|
74
|
+
When I write to "db/migrate/01_create_users.rb" with:
|
75
|
+
"""
|
76
|
+
class CreateUsers < ActiveRecord::Migration
|
77
|
+
def self.up
|
78
|
+
create_table :users
|
79
|
+
end
|
80
|
+
end
|
81
|
+
"""
|
82
|
+
When I write to "db/migrate/02_add_attachment_to_users.rb" with:
|
83
|
+
"""
|
84
|
+
class AddAttachmentToUsers < ActiveRecord::Migration
|
85
|
+
def change
|
86
|
+
add_attachment :users, :avatar
|
87
|
+
end
|
88
|
+
end
|
89
|
+
"""
|
90
|
+
And I run a migration
|
91
|
+
Then I should have attachment columns for "avatar"
|
92
|
+
|
93
|
+
When I rollback a migration
|
94
|
+
Then I should not have attachment columns for "avatar"
|
data/features/rake_tasks.feature
CHANGED
@@ -5,10 +5,9 @@ Feature: Rake tasks
|
|
5
5
|
And I run a rails generator to generate a "User" scaffold with "name:string"
|
6
6
|
And I run a paperclip generator to add a paperclip "attachment" to the "User" model
|
7
7
|
And I run a migration
|
8
|
-
And I
|
8
|
+
And I attach :attachment with:
|
9
9
|
"""
|
10
|
-
|
11
|
-
has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
|
10
|
+
:path => ":rails_root/public/system/:attachment/:style/:filename"
|
12
11
|
"""
|
13
12
|
|
14
13
|
Scenario: Paperclip refresh thumbnails task
|
@@ -72,3 +72,31 @@ Then /^the attachment file "([^"]*)" should (not )?exist$/ do |filename, not_exi
|
|
72
72
|
check_file_presence([attachment_path(filename)], !not_exist)
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name|
|
77
|
+
in_current_dir do
|
78
|
+
columns = eval(`bundle exec #{runner_command} "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
|
79
|
+
expect_columns = [
|
80
|
+
["#{attachment_name}_file_name", :string],
|
81
|
+
["#{attachment_name}_content_type", :string],
|
82
|
+
["#{attachment_name}_file_size", :integer],
|
83
|
+
["#{attachment_name}_updated_at", :datetime]
|
84
|
+
]
|
85
|
+
|
86
|
+
expect_columns.all?{ |column| columns.include? column }.should be_true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name|
|
91
|
+
in_current_dir do
|
92
|
+
columns = eval(`bundle exec #{runner_command} "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
|
93
|
+
expect_columns = [
|
94
|
+
["#{attachment_name}_file_name", :string],
|
95
|
+
["#{attachment_name}_content_type", :string],
|
96
|
+
["#{attachment_name}_file_size", :integer],
|
97
|
+
["#{attachment_name}_updated_at", :datetime]
|
98
|
+
]
|
99
|
+
|
100
|
+
expect_columns.none?{ |column| columns.include? column }.should be_true
|
101
|
+
end
|
102
|
+
end
|
@@ -3,6 +3,7 @@ Given /^I generate a new rails application$/ do
|
|
3
3
|
When I run `bundle exec #{new_application_command} #{APP_NAME} --skip-bundle`
|
4
4
|
And I cd to "#{APP_NAME}"
|
5
5
|
And I turn off class caching
|
6
|
+
And I fix the application.rb for 3.0.12
|
6
7
|
And I write to "Gemfile" with:
|
7
8
|
"""
|
8
9
|
source "http://rubygems.org"
|
@@ -14,12 +15,75 @@ Given /^I generate a new rails application$/ do
|
|
14
15
|
gem "gherkin"
|
15
16
|
gem "aws-sdk"
|
16
17
|
"""
|
18
|
+
And I remove turbolinks
|
19
|
+
And I empty the application.js file
|
17
20
|
And I configure the application to use "paperclip" from this project
|
18
21
|
And I reset Bundler environment variable
|
19
22
|
And I successfully run `bundle install --local`
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
26
|
+
Given "I fix the application.rb for 3.0.12" do
|
27
|
+
in_current_dir do
|
28
|
+
File.open("config/application.rb", "a") do |f|
|
29
|
+
f << "ActionController::Base.config.relative_url_root = ''"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Given "I allow the attachment to be submitted" do
|
35
|
+
in_current_dir do
|
36
|
+
transform_file("app/controllers/users_controller.rb") do |content|
|
37
|
+
content.gsub("params.require(:user).permit(:name)",
|
38
|
+
"params.require(:user).permit!")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Given "I remove turbolinks" do
|
44
|
+
in_current_dir do
|
45
|
+
transform_file("app/assets/javascripts/application.js") do |content|
|
46
|
+
content.gsub("//= require turbolinks", "")
|
47
|
+
end
|
48
|
+
transform_file("app/views/layouts/application.html.erb") do |content|
|
49
|
+
content.gsub(', "data-turbolinks-track" => true', "")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Given /^I attach :attachment$/ do
|
55
|
+
attach_attachment("attachment")
|
56
|
+
end
|
57
|
+
|
58
|
+
Given /^I attach :attachment with:$/ do |definition|
|
59
|
+
attach_attachment("attachment", definition)
|
60
|
+
end
|
61
|
+
|
62
|
+
def attach_attachment(name, definition = nil)
|
63
|
+
snippet = ""
|
64
|
+
if using_protected_attributes?
|
65
|
+
snippet += "attr_accessible :name, :#{name}\n"
|
66
|
+
end
|
67
|
+
snippet += "has_attached_file :#{name}"
|
68
|
+
if definition
|
69
|
+
snippet += ", \n"
|
70
|
+
snippet += definition
|
71
|
+
end
|
72
|
+
in_current_dir do
|
73
|
+
transform_file("app/models/user.rb") do |content|
|
74
|
+
content.sub(/end\Z/, "#{snippet}\nend")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Given "I empty the application.js file" do
|
80
|
+
in_current_dir do
|
81
|
+
transform_file("app/assets/javascripts/application.js") do |content|
|
82
|
+
""
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
23
87
|
Given /^I run a rails generator to generate a "([^"]*)" scaffold with "([^"]*)"$/ do |model_name, attributes|
|
24
88
|
step %[I successfully run `bundle exec #{generator_command} scaffold #{model_name} #{attributes}`]
|
25
89
|
end
|
@@ -29,7 +93,11 @@ Given /^I run a paperclip generator to add a paperclip "([^"]*)" to the "([^"]*)
|
|
29
93
|
end
|
30
94
|
|
31
95
|
Given /^I run a migration$/ do
|
32
|
-
step %[I successfully run `bundle exec rake db:migrate`]
|
96
|
+
step %[I successfully run `bundle exec rake db:migrate --trace`]
|
97
|
+
end
|
98
|
+
|
99
|
+
When /^I rollback a migration$/ do
|
100
|
+
step %[I successfully run `bundle exec rake db:rollback STEPS=1 --trace`]
|
33
101
|
end
|
34
102
|
|
35
103
|
Given /^I update my new user view to include the file upload field$/ do
|
@@ -65,6 +133,14 @@ Given /^I add this snippet to the User model:$/ do |snippet|
|
|
65
133
|
end
|
66
134
|
end
|
67
135
|
|
136
|
+
Given /^I add this snippet to config\/application.rb:$/ do |snippet|
|
137
|
+
file_name = "config/application.rb"
|
138
|
+
in_current_dir do
|
139
|
+
content = File.read(file_name)
|
140
|
+
File.open(file_name, 'w') {|f| f << content.sub(/class Application < Rails::Application.*$/, "class Application < Rails::Application\n#{snippet}\n")}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
68
144
|
Given /^I start the rails application$/ do
|
69
145
|
in_current_dir do
|
70
146
|
require "./config/environment"
|
@@ -88,13 +164,7 @@ end
|
|
88
164
|
|
89
165
|
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
|
90
166
|
expected = IO.read(path)
|
91
|
-
actual =
|
92
|
-
Net::HTTP.get(URI.parse(web_file))
|
93
|
-
else
|
94
|
-
visit(web_file)
|
95
|
-
page.source
|
96
|
-
end
|
97
|
-
actual.force_encoding("UTF-8") if actual.respond_to?(:force_encoding)
|
167
|
+
actual = read_from_web(web_file)
|
98
168
|
actual.should == expected
|
99
169
|
end
|
100
170
|
|
@@ -118,3 +188,19 @@ end
|
|
118
188
|
When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
|
119
189
|
comment_out_gem_in_gemfile gemname
|
120
190
|
end
|
191
|
+
|
192
|
+
Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
|
193
|
+
if framework_version < version
|
194
|
+
pending "Not supported in Rails < #{version}"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def transform_file(filename)
|
199
|
+
if File.exists?(filename)
|
200
|
+
content = File.read(filename)
|
201
|
+
File.open(filename, "w") do |f|
|
202
|
+
content = yield(content)
|
203
|
+
f.write(content)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field|
|
2
|
-
definition = User
|
2
|
+
definition = Paperclip::AttachmentRegistry.definitions_for(User)[field.downcase.to_sym]
|
3
3
|
path = "https://paperclip.s3.amazonaws.com#{definition[:path]}"
|
4
4
|
path.gsub!(':filename', File.basename(file_path))
|
5
5
|
path.gsub!(/:([^\/\.]+)/) do |match|
|
@@ -181,7 +181,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label
|
|
181
181
|
end
|
182
182
|
end
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
186
186
|
current_path = URI.parse(current_url).path
|
187
187
|
if current_path.respond_to? :should
|
@@ -195,8 +195,8 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
195
195
|
query = URI.parse(current_url).query
|
196
196
|
actual_params = query ? CGI.parse(query) : {}
|
197
197
|
expected_params = {}
|
198
|
-
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
199
|
-
|
198
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
199
|
+
|
200
200
|
if actual_params.respond_to? :should
|
201
201
|
actual_params.should == expected_params
|
202
202
|
else
|
data/features/support/fakeweb.rb
CHANGED
@@ -19,6 +19,16 @@ module FileHelpers
|
|
19
19
|
File.open("Gemfile", 'w'){ |file| file.write(gemfile) }
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
def read_from_web(url)
|
24
|
+
file = if url.match %r{^https?://}
|
25
|
+
Net::HTTP.get(URI.parse(url))
|
26
|
+
else
|
27
|
+
visit(url)
|
28
|
+
page.source
|
29
|
+
end
|
30
|
+
file.force_encoding("UTF-8") if file.respond_to?(:force_encoding)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
World(FileHelpers)
|
data/features/support/rails.rb
CHANGED
@@ -31,16 +31,32 @@ module RailsCommandHelpers
|
|
31
31
|
@framework_version ||= `rails -v`[/^Rails (.+)$/, 1]
|
32
32
|
end
|
33
33
|
|
34
|
+
def framework_major_version
|
35
|
+
framework_version.split(".").first.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
def using_protected_attributes?
|
39
|
+
framework_major_version < 4
|
40
|
+
end
|
41
|
+
|
34
42
|
def new_application_command
|
35
43
|
"rails new"
|
36
44
|
end
|
37
45
|
|
38
46
|
def generator_command
|
39
|
-
|
47
|
+
if framework_major_version >= 4
|
48
|
+
"rails generate"
|
49
|
+
else
|
50
|
+
"script/rails generate"
|
51
|
+
end
|
40
52
|
end
|
41
53
|
|
42
54
|
def runner_command
|
43
|
-
|
55
|
+
if framework_major_version >= 4
|
56
|
+
"rails runner"
|
57
|
+
else
|
58
|
+
"script/rails runner"
|
59
|
+
end
|
44
60
|
end
|
45
61
|
end
|
46
62
|
World(RailsCommandHelpers)
|
data/gemfiles/3.0.gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "jruby-openssl", :platform=>:jruby
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
|
7
7
|
gem "sqlite3", :platform=>:ruby
|
8
|
-
gem "rails", "~> 3.0.
|
8
|
+
gem "rails", "~> 3.0.15"
|
9
9
|
gem "paperclip", :path=>"../"
|
10
10
|
|
11
11
|
gemspec :path=>"../"
|
data/gemfiles/3.1.gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "jruby-openssl", :platform=>:jruby
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
|
7
7
|
gem "sqlite3", :platform=>:ruby
|
8
|
-
gem "rails", "~> 3.1.
|
8
|
+
gem "rails", "~> 3.1.6"
|
9
9
|
gem "paperclip", :path=>"../"
|
10
10
|
|
11
11
|
gemspec :path=>"../"
|
data/gemfiles/3.2.gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "jruby-openssl", :platform=>:jruby
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
|
7
7
|
gem "sqlite3", :platform=>:ruby
|
8
|
-
gem "rails", "~> 3.2.
|
8
|
+
gem "rails", "~> 3.2.6"
|
9
9
|
gem "paperclip", :path=>"../"
|
10
10
|
|
11
11
|
gemspec :path=>"../"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "jruby-openssl", :platform=>:jruby
|
6
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
|
7
|
+
gem "sqlite3", :platform=>:ruby
|
8
|
+
gem "rails", "~> 4.0.0"
|
9
|
+
gem "paperclip", :path=>"../"
|
10
|
+
|
11
|
+
gemspec :path=>"../"
|
@@ -1,19 +1,15 @@
|
|
1
1
|
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
+
change_table :<%= table_name %> do |t|
|
3
4
|
<% attachment_names.each do |attachment| -%>
|
4
|
-
|
5
|
-
add_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
|
6
|
-
add_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
|
7
|
-
add_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
|
5
|
+
t.attachment :<%= attachment %>
|
8
6
|
<% end -%>
|
7
|
+
end
|
9
8
|
end
|
10
9
|
|
11
10
|
def self.down
|
12
11
|
<% attachment_names.each do |attachment| -%>
|
13
|
-
|
14
|
-
remove_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
|
15
|
-
remove_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
|
16
|
-
remove_column :<%= name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
|
12
|
+
drop_attached_file :<%= table_name %>, :<%= attachment %>
|
17
13
|
<% end -%>
|
18
14
|
end
|
19
15
|
end
|