Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[REVERT][FIX] Fix the URL-incompatible translation of namespaced mode…

…ls into `document_type`

Revert "[ACTIVEMODEL][FIX] Fix the incorrect translation of namespaced models into `document_type`".

The "proper" translation translates `MyNamespace::MyModel` to `my_namespace/my_model`, which
allows proper loading of namespaced models, but fucks up the encoded URL, because of something like:
http://.../indexname/my_namespace/my_model/_search?...

This reverts commit 89bc663.

See #189.
  • Loading branch information...
commit 1d6b2678be47accecef5bc1c0efbb19f041daced 1 parent b20997a
@karmi karmi authored
View
2  lib/tire/model/naming.rb
@@ -74,7 +74,7 @@ def index_prefix(*args)
#
def document_type name=nil
@document_type = name if name
- @document_type || klass.model_name.underscore
+ @document_type || klass.model_name.singular
end
end
View
8 test/models/namespaced_model.rb
@@ -1,8 +0,0 @@
-# Example ActiveModel class with custom document type
-
-require File.expand_path('../active_model_article', __FILE__)
-
-module MyNamespace
- class ModelInNamespace < ActiveModelArticle
- end
-end
View
7 test/unit/model_search_test.rb
@@ -100,13 +100,6 @@ class SearchTest < Test::Unit::TestCase
end
end
- should "properly translate namespaced model into document_type" do
- # Watch out for <https://github.com/rails/rails/blob/v3.1.3/activemodel/lib/active_model/naming.rb#L50-52>
- t = MyNamespace::ModelInNamespace.document_type
- assert_equal 'my_namespace/model_in_namespace', t
- assert defined?(t), "Cannot infer class from document type: #{t}"
- end
-
should "allow to refresh index" do
Index.any_instance.expects(:refresh)
Please sign in to comment.
Something went wrong with that request. Please try again.