Adjust MockController & test support for Rails 5.1
* MockController#polymorphic_mappings * Database-specific types (e.g., :text) moved from ActiveModel to ActiveRecord so the type_for_attribute helper needed adjustment.
This commit is contained in:
parent
35ee9e823d
commit
ee2d770442
48
Gemfile.lock
48
Gemfile.lock
|
@ -2,34 +2,34 @@ PATH
|
|||
remote: .
|
||||
specs:
|
||||
simple_form (3.4.0)
|
||||
actionpack (> 4, < 5.1)
|
||||
activemodel (> 4, < 5.1)
|
||||
actionpack (> 4, < 5.2)
|
||||
activemodel (> 4, < 5.2)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionpack (5.0.1)
|
||||
actionview (= 5.0.1)
|
||||
activesupport (= 5.0.1)
|
||||
actionpack (5.1.0)
|
||||
actionview (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.1)
|
||||
activesupport (= 5.0.1)
|
||||
actionview (5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activemodel (5.0.1)
|
||||
activesupport (= 5.0.1)
|
||||
activesupport (5.0.1)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activemodel (5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
activesupport (5.1.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
builder (3.2.2)
|
||||
concurrent-ruby (1.0.4)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
countries (1.2.5)
|
||||
currencies (~> 0.4.2)
|
||||
i18n_data (~> 0.7.0)
|
||||
|
@ -37,16 +37,16 @@ GEM
|
|||
countries (~> 1.2.0)
|
||||
sort_alphabetical (~> 1.0)
|
||||
currencies (0.4.2)
|
||||
erubis (2.7.0)
|
||||
erubi (1.6.0)
|
||||
ffi2-generators (0.1.1)
|
||||
i18n (0.7.0)
|
||||
i18n (0.8.1)
|
||||
i18n_data (0.7.0)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
method_source (0.8.2)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.10.1)
|
||||
nokogiri (1.7.0.1)
|
||||
nokogiri (1.7.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
rack (2.0.1)
|
||||
rack-test (0.6.3)
|
||||
|
@ -56,9 +56,9 @@ GEM
|
|||
nokogiri (~> 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.1)
|
||||
actionpack (= 5.0.1)
|
||||
activesupport (= 5.0.1)
|
||||
railties (5.1.0)
|
||||
actionpack (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
@ -248,7 +248,7 @@ GEM
|
|||
rubysl-set (2.0.1)
|
||||
rubysl-shellwords (2.0.0)
|
||||
rubysl-singleton (2.0.0)
|
||||
rubysl-socket (2.2)
|
||||
rubysl-socket (2.2.1)
|
||||
rubysl-fcntl (~> 2.0)
|
||||
rubysl-stringio (2.1.0)
|
||||
rubysl-strscan (2.0.0)
|
||||
|
@ -275,8 +275,8 @@ GEM
|
|||
sort_alphabetical (1.1.0)
|
||||
unicode_utils (>= 1.2.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
unicode_utils (1.4.0)
|
||||
|
||||
|
@ -292,4 +292,4 @@ DEPENDENCIES
|
|||
simple_form!
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.0.pre.1
|
||||
1.14.6
|
||||
|
|
|
@ -20,6 +20,6 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.rubyforge_project = "simple_form"
|
||||
|
||||
s.add_dependency('activemodel', '> 4', '< 5.1')
|
||||
s.add_dependency('actionpack', '> 4', '< 5.1')
|
||||
s.add_dependency('activemodel', '> 4', '< 5.2')
|
||||
s.add_dependency('actionpack', '> 4', '< 5.2')
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class MockController
|
|||
defined?(@action_name) ? @action_name : "edit"
|
||||
end
|
||||
|
||||
def url_for(*args)
|
||||
def url_for(*)
|
||||
"http://example.com"
|
||||
end
|
||||
|
||||
|
@ -17,6 +17,8 @@ class MockController
|
|||
{}
|
||||
end
|
||||
|
||||
def polymorphic_mappings(*); {}; end
|
||||
|
||||
def hash_for_user_path(*); end
|
||||
def hash_for_validating_user_path(*); end
|
||||
def hash_for_other_validating_user_path(*); end
|
||||
|
|
|
@ -128,6 +128,7 @@ class User
|
|||
|
||||
begin
|
||||
require 'active_model/type'
|
||||
require 'active_record/type'
|
||||
def type_for_attribute(attribute)
|
||||
column_type, limit = case attribute
|
||||
when 'name', 'status', 'password' then [:string, 100]
|
||||
|
@ -148,7 +149,11 @@ class User
|
|||
when 'uuid' then :string
|
||||
end
|
||||
|
||||
ActiveModel::Type.lookup(column_type, limit: limit)
|
||||
begin
|
||||
ActiveModel::Type.lookup(column_type, limit: limit)
|
||||
rescue ArgumentError
|
||||
ActiveRecord::Type.lookup(column_type, limit: limit)
|
||||
end
|
||||
end
|
||||
rescue LoadError
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue