Commit 70d490bb by Tute Costa

Remove Rails 3 snippets

Rails 3 is not supported anymore. We can safely remove mentions and
snippets for it.

Drop unused variable definition (`options`).
parent 16491494
...@@ -189,18 +189,6 @@ Quick Start ...@@ -189,18 +189,6 @@ Quick Start
### Models ### Models
**Rails 3**
```ruby
class User < ActiveRecord::Base
attr_accessible :avatar
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
end
```
**Rails 4**
```ruby ```ruby
class User < ActiveRecord::Base class User < ActiveRecord::Base
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png" has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
...@@ -241,16 +229,6 @@ end ...@@ -241,16 +229,6 @@ end
### Controller ### Controller
**Rails 3**
```ruby
def create
@user = User.create( params[:user] )
end
```
**Rails 4**
```ruby ```ruby
def create def create
@user = User.create( user_params ) @user = User.create( user_params )
......
...@@ -68,27 +68,3 @@ Feature: Migration ...@@ -68,27 +68,3 @@ Feature: Migration
When I rollback a migration When I rollback a migration
Then I should not have attachment columns for "avatar" Then I should not have attachment columns for "avatar"
Scenario: Rails 3.2 change method
Given I am using Rails newer than 3.1
When I write to "db/migrate/01_create_users.rb" with:
"""
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users
end
end
"""
When I write to "db/migrate/02_add_attachment_to_users.rb" with:
"""
class AddAttachmentToUsers < ActiveRecord::Migration
def change
add_attachment :users, :avatar
end
end
"""
And I run a migration
Then I should have attachment columns for "avatar"
When I rollback a migration
Then I should not have attachment columns for "avatar"
...@@ -190,12 +190,6 @@ When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname| ...@@ -190,12 +190,6 @@ When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
comment_out_gem_in_gemfile gemname comment_out_gem_in_gemfile gemname
end end
Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
if framework_version < version
pending "Not supported in Rails < #{version}"
end
end
Given(/^I add a "(.*?)" processor in "(.*?)"$/) do |processor, directory| Given(/^I add a "(.*?)" processor in "(.*?)"$/) do |processor, directory|
filename = "#{directory}/#{processor}.rb" filename = "#{directory}/#{processor}.rb"
cd(".") do cd(".") do
......
...@@ -12,10 +12,7 @@ module Paperclip ...@@ -12,10 +12,7 @@ module Paperclip
ActiveRecord::ConnectionAdapters::Table.send :include, TableDefinition ActiveRecord::ConnectionAdapters::Table.send :include, TableDefinition
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, TableDefinition ActiveRecord::ConnectionAdapters::TableDefinition.send :include, TableDefinition
ActiveRecord::ConnectionAdapters::AbstractAdapter.send :include, Statements ActiveRecord::ConnectionAdapters::AbstractAdapter.send :include, Statements
ActiveRecord::Migration::CommandRecorder.send :include, CommandRecorder
if defined?(ActiveRecord::Migration::CommandRecorder) # Rails 3.1+
ActiveRecord::Migration::CommandRecorder.send :include, CommandRecorder
end
end end
module Statements module Statements
...@@ -35,8 +32,6 @@ module Paperclip ...@@ -35,8 +32,6 @@ module Paperclip
def remove_attachment(table_name, *attachment_names) def remove_attachment(table_name, *attachment_names)
raise ArgumentError, "Please specify attachment name in your remove_attachment call in your migration." if attachment_names.empty? raise ArgumentError, "Please specify attachment name in your remove_attachment call in your migration." if attachment_names.empty?
options = attachment_names.extract_options!
attachment_names.each do |attachment_name| attachment_names.each do |attachment_name|
COLUMNS.keys.each do |column_name| COLUMNS.keys.each do |column_name|
remove_column(table_name, "#{attachment_name}_#{column_name}") remove_column(table_name, "#{attachment_name}_#{column_name}")
......
...@@ -222,9 +222,6 @@ describe Paperclip::Attachment do ...@@ -222,9 +222,6 @@ describe Paperclip::Attachment do
dummy.avatar_file_name = "fake.jpg" dummy.avatar_file_name = "fake.jpg"
dummy.stubs(:new_record?).returns(false) dummy.stubs(:new_record?).returns(false)
expected_string = '{"avatar":"/system/dummies/avatars/000/001/234/original/fake.jpg"}' expected_string = '{"avatar":"/system/dummies/avatars/000/001/234/original/fake.jpg"}'
if ActiveRecord::Base.include_root_in_json # This is true by default in Rails 3, and false in 4
expected_string = %({"dummy":#{expected_string}})
end
# active_model pre-3.2 checks only by calling any? on it, thus it doesn't work if it is empty # active_model pre-3.2 checks only by calling any? on it, thus it doesn't work if it is empty
assert_equal expected_string, dummy.to_json(only: [:dummy_key_for_old_active_model], methods: [:avatar]) assert_equal expected_string, dummy.to_json(only: [:dummy_key_for_old_active_model], methods: [:avatar])
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment