summaryrefslogtreecommitdiff
path: root/vendor/plugins/paperclip/test/helper.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
commite0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch)
treed0cf745592a46aee4d4913911fd34c7c24515220 /vendor/plugins/paperclip/test/helper.rb
parent6424e10be5a89f175a74c71c55660412a169b8b8 (diff)
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs
Diffstat (limited to 'vendor/plugins/paperclip/test/helper.rb')
-rw-r--r--vendor/plugins/paperclip/test/helper.rb82
1 files changed, 0 insertions, 82 deletions
diff --git a/vendor/plugins/paperclip/test/helper.rb b/vendor/plugins/paperclip/test/helper.rb
deleted file mode 100644
index 3e7e6a1c..00000000
--- a/vendor/plugins/paperclip/test/helper.rb
+++ /dev/null
@@ -1,82 +0,0 @@
1require 'rubygems'
2require 'test/unit'
3gem 'thoughtbot-shoulda', ">= 2.9.0"
4require 'shoulda'
5require 'mocha'
6require 'tempfile'
7
8gem 'sqlite3-ruby'
9
10require 'active_record'
11require 'active_support'
12begin
13 require 'ruby-debug'
14rescue LoadError
15 puts "ruby-debug not loaded"
16end
17
18ROOT = File.join(File.dirname(__FILE__), '..')
19RAILS_ROOT = ROOT
20
21$LOAD_PATH << File.join(ROOT, 'lib')
22$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
23
24require File.join(ROOT, 'lib', 'paperclip.rb')
25
26require 'shoulda_macros/paperclip'
27
28ENV['RAILS_ENV'] ||= 'test'
29
30FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
31config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
32ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
33ActiveRecord::Base.establish_connection(config['test'])
34
35def reset_class class_name
36 ActiveRecord::Base.send(:include, Paperclip)
37 Object.send(:remove_const, class_name) rescue nil
38 klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
39 klass.class_eval{ include Paperclip }
40 klass
41end
42
43def reset_table table_name, &block
44 block ||= lambda{ true }
45 ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block
46end
47
48def modify_table table_name, &block
49 ActiveRecord::Base.connection.change_table :dummies, &block
50end
51
52def rebuild_model options = {}
53 ActiveRecord::Base.connection.create_table :dummies, :force => true do |table|
54 table.column :other, :string
55 table.column :avatar_file_name, :string
56 table.column :avatar_content_type, :string
57 table.column :avatar_file_size, :integer
58 table.column :avatar_updated_at, :datetime
59 end
60 rebuild_class options
61end
62
63def rebuild_class options = {}
64 ActiveRecord::Base.send(:include, Paperclip)
65 Object.send(:remove_const, "Dummy") rescue nil
66 Object.const_set("Dummy", Class.new(ActiveRecord::Base))
67 Dummy.class_eval do
68 include Paperclip
69 has_attached_file :avatar, options
70 end
71end
72
73def temporary_rails_env(new_env)
74 old_env = defined?(RAILS_ENV) ? RAILS_ENV : nil
75 silence_warnings do
76 Object.const_set("RAILS_ENV", new_env)
77 end
78 yield
79 silence_warnings do
80 Object.const_set("RAILS_ENV", old_env)
81 end
82end