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:
Rob Biedenharn 2017-04-28 14:06:30 -04:00
parent 35ee9e823d
commit ee2d770442
4 changed files with 35 additions and 28 deletions

View File

@ -2,34 +2,34 @@ PATH
remote: . remote: .
specs: specs:
simple_form (3.4.0) simple_form (3.4.0)
actionpack (> 4, < 5.1) actionpack (> 4, < 5.2)
activemodel (> 4, < 5.1) activemodel (> 4, < 5.2)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionpack (5.0.1) actionpack (5.1.0)
actionview (= 5.0.1) actionview (= 5.1.0)
activesupport (= 5.0.1) activesupport (= 5.1.0)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.1) actionview (5.1.0)
activesupport (= 5.0.1) activesupport (= 5.1.0)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activemodel (5.0.1) activemodel (5.1.0)
activesupport (= 5.0.1) activesupport (= 5.1.0)
activesupport (5.0.1) activesupport (5.1.0)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
builder (3.2.2) builder (3.2.3)
concurrent-ruby (1.0.4) concurrent-ruby (1.0.5)
countries (1.2.5) countries (1.2.5)
currencies (~> 0.4.2) currencies (~> 0.4.2)
i18n_data (~> 0.7.0) i18n_data (~> 0.7.0)
@ -37,16 +37,16 @@ GEM
countries (~> 1.2.0) countries (~> 1.2.0)
sort_alphabetical (~> 1.0) sort_alphabetical (~> 1.0)
currencies (0.4.2) currencies (0.4.2)
erubis (2.7.0) erubi (1.6.0)
ffi2-generators (0.1.1) ffi2-generators (0.1.1)
i18n (0.7.0) i18n (0.8.1)
i18n_data (0.7.0) i18n_data (0.7.0)
loofah (2.0.3) loofah (2.0.3)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
method_source (0.8.2) method_source (0.8.2)
mini_portile2 (2.1.0) mini_portile2 (2.1.0)
minitest (5.10.1) minitest (5.10.1)
nokogiri (1.7.0.1) nokogiri (1.7.1)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
rack (2.0.1) rack (2.0.1)
rack-test (0.6.3) rack-test (0.6.3)
@ -56,9 +56,9 @@ GEM
nokogiri (~> 1.6) nokogiri (~> 1.6)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.3)
loofah (~> 2.0) loofah (~> 2.0)
railties (5.0.1) railties (5.1.0)
actionpack (= 5.0.1) actionpack (= 5.1.0)
activesupport (= 5.0.1) activesupport (= 5.1.0)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
@ -248,7 +248,7 @@ GEM
rubysl-set (2.0.1) rubysl-set (2.0.1)
rubysl-shellwords (2.0.0) rubysl-shellwords (2.0.0)
rubysl-singleton (2.0.0) rubysl-singleton (2.0.0)
rubysl-socket (2.2) rubysl-socket (2.2.1)
rubysl-fcntl (~> 2.0) rubysl-fcntl (~> 2.0)
rubysl-stringio (2.1.0) rubysl-stringio (2.1.0)
rubysl-strscan (2.0.0) rubysl-strscan (2.0.0)
@ -275,8 +275,8 @@ GEM
sort_alphabetical (1.1.0) sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2) unicode_utils (>= 1.2.2)
thor (0.19.4) thor (0.19.4)
thread_safe (0.3.5) thread_safe (0.3.6)
tzinfo (1.2.2) tzinfo (1.2.3)
thread_safe (~> 0.1) thread_safe (~> 0.1)
unicode_utils (1.4.0) unicode_utils (1.4.0)
@ -292,4 +292,4 @@ DEPENDENCIES
simple_form! simple_form!
BUNDLED WITH BUNDLED WITH
1.14.0.pre.1 1.14.6

View File

@ -20,6 +20,6 @@ Gem::Specification.new do |s|
s.rubyforge_project = "simple_form" s.rubyforge_project = "simple_form"
s.add_dependency('activemodel', '> 4', '< 5.1') s.add_dependency('activemodel', '> 4', '< 5.2')
s.add_dependency('actionpack', '> 4', '< 5.1') s.add_dependency('actionpack', '> 4', '< 5.2')
end end

View File

@ -9,7 +9,7 @@ class MockController
defined?(@action_name) ? @action_name : "edit" defined?(@action_name) ? @action_name : "edit"
end end
def url_for(*args) def url_for(*)
"http://example.com" "http://example.com"
end end
@ -17,6 +17,8 @@ class MockController
{} {}
end end
def polymorphic_mappings(*); {}; end
def hash_for_user_path(*); end def hash_for_user_path(*); end
def hash_for_validating_user_path(*); end def hash_for_validating_user_path(*); end
def hash_for_other_validating_user_path(*); end def hash_for_other_validating_user_path(*); end

View File

@ -128,6 +128,7 @@ class User
begin begin
require 'active_model/type' require 'active_model/type'
require 'active_record/type'
def type_for_attribute(attribute) def type_for_attribute(attribute)
column_type, limit = case attribute column_type, limit = case attribute
when 'name', 'status', 'password' then [:string, 100] when 'name', 'status', 'password' then [:string, 100]
@ -148,7 +149,11 @@ class User
when 'uuid' then :string when 'uuid' then :string
end 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 end
rescue LoadError rescue LoadError
end end