Skip to content

Commit

Permalink
Merge pull request #1246 from MblKiTA/master
Browse files Browse the repository at this point in the history
Made filter search case-insensetive for mongoid
  • Loading branch information
mshibuya committed Jul 16, 2012
2 parents 054a537 + 7899366 commit 344432e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/rails_admin/main_controller.rb
Expand Up @@ -40,7 +40,7 @@ def list_entries(model_config = @model_config, auth_scope_key = :index, addition
end

private

def get_layout
"rails_admin/#{request.headers['X-PJAX'] ? 'pjax' : 'application'}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/adapters/mongoid.rb
Expand Up @@ -237,7 +237,7 @@ def build_statement(column, type, value, operator)
return if value.blank?
value = case operator
when 'default', 'like'
Regexp.compile(Regexp.escape(value))
Regexp.compile(Regexp.escape(value), Regexp::IGNORECASE)
when 'starts_with'
Regexp.compile("^#{Regexp.escape(value)}")
when 'ends_with'
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/adapters/mongoid_spec.rb
Expand Up @@ -686,10 +686,10 @@ class CustomValiated
it "supports string type query" do
@abstract_model.send(:build_statement, :field, :string, "", nil).should be_nil
@abstract_model.send(:build_statement, :field, :string, "foo", "was").should be_nil
@abstract_model.send(:build_statement, :field, :string, "foo", "default").should == {:field=>/foo/}
@abstract_model.send(:build_statement, :field, :string, "foo", "like").should == {:field=>/foo/}
@abstract_model.send(:build_statement, :field, :string, "foo", "starts_with").should == {:field=>/^foo/}
@abstract_model.send(:build_statement, :field, :string, "foo", "ends_with").should == {:field=>/foo$/}
@abstract_model.send(:build_statement, :field, :string, "foo", "default").should == {:field=>/foo/i}
@abstract_model.send(:build_statement, :field, :string, "foo", "like").should == {:field=>/foo/i}
@abstract_model.send(:build_statement, :field, :string, "foo", "starts_with").should == {:field=>/^foo/i}
@abstract_model.send(:build_statement, :field, :string, "foo", "ends_with").should == {:field=>/foo$/i}
@abstract_model.send(:build_statement, :field, :string, "foo", "is").should == {:field=>'foo'}
end

Expand Down

0 comments on commit 344432e

Please sign in to comment.