Skip to content
This repository
  • 12 commits
  • 15 files changed
  • 0 comments
  • 6 contributors
Jul 16, 2012
MblKiTA Fixed: Failure/Error: @abstract_model.send(:build_statement, :field, …
…:string, "foo", "default").should == {:field=>/foo/}

expected: {:field=>/foo/}
got: {:field=>/foo/i} (using ==)
481a8da
MblKiTA Failures:
1) RailsAdmin::Adapters::Mongoid#build_statement supports string type query
Failure/Error: @abstract_model.send(:build_statement, :field, :string, "foo", "like").should == {:field=>/foo/}
expected: {:field=>/foo/}
got: {:field=>/foo/i} (using ==)
Diff:
@@ -1,2 +1,2 @@
-:field => /foo/
+:field => /foo/i
./spec/unit/adapters/mongoid_spec.rb:690
7899366
Mitsuhiro Shibuya Merge pull request #1246 from MblKiTA/master
Made filter search case-insensetive for mongoid
344432e
Jul 17, 2012
Mitsuhiro Shibuya Make Mongoid regexps' case sensitivity consistent d21edff
Daniel Hedlund Change paper_trail audit extension to use ::Version. Fixes #1234 c08fa22
Mitsuhiro Shibuya Merge pull request #1250 from dhedlund/paper_trail_version_fix
Change paper_trail audit extension to use ::Version. Fixes #1234
523f8e1
Mitsuhiro Shibuya Allow failures in jruby until intermittent segfaults are resolved ec06754
Jul 18, 2012
Carlo Scortegagna charset forced to utf-8 in css 1a416b6
Erik Michaels-Ober Merge pull request #1252 from carloscortegagna/master
Utf-8 problem with asset precompile
2f04eb7
Jul 20, 2012
Mitsuhiro Shibuya Prevent upward recursive inspection in console/debugger session acd3918
Mitsuhiro Shibuya Merge remote-tracking branch 'upstream/master' f8d58f7
Mitsuhiro Shibuya Nested model's field gets ignored when inverse_of name matches with n…
…ested_in field. Closes #1255
37e927c
1  .travis.yml
@@ -36,6 +36,7 @@ matrix:
36 36
       env: "CI_ORM=mongoid CI_ORM_VERSION=head"
37 37
   allow_failures:
38 38
     - env: "CI_ORM=mongoid CI_ORM_VERSION=head"
  39
+    - rvm: jruby-19mode
39 40
     - rvm: rbx-19mode
40 41
 notifications:
41 42
   irc: "irc.freenode.org#railsadmin"
2  app/assets/stylesheets/rails_admin/imports.css.scss.erb
... ...
@@ -1,3 +1,5 @@
  1
+@charset "UTF-8";
  2
+
1 3
 <%
2 4
   theme = ENV['RAILS_ADMIN_THEME'] || :default
3 5
 %>
3  app/helpers/rails_admin/form_builder.rb
@@ -43,7 +43,8 @@ def fieldset_for fieldset, nested_in
43 43
     def field_wrapper_for field, nested_in
44 44
       if field.label
45 45
         # do not show nested field if the target is the origin
46  
-        unless field.inverse_of.presence && field.inverse_of == nested_in
  46
+        unless field.inverse_of.presence && field.inverse_of == nested_in &&
  47
+          @template.instance_variable_get(:@model_config).abstract_model == field.associated_model_config.abstract_model
47 48
           @template.content_tag(:div, :class => "control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => "#{dom_id(field)}_field") do
48 49
             label(field.method_name, field.label, :class => 'control-label') +
49 50
             (field.nested_form ? field_for(field) : input_for(field))
4  lib/rails_admin/adapters/mongoid.rb
@@ -239,9 +239,9 @@ def build_statement(column, type, value, operator)
239 239
           when 'default', 'like'
240 240
             Regexp.compile(Regexp.escape(value), Regexp::IGNORECASE)
241 241
           when 'starts_with'
242  
-            Regexp.compile("^#{Regexp.escape(value)}")
  242
+            Regexp.compile("^#{Regexp.escape(value)}", Regexp::IGNORECASE)
243 243
           when 'ends_with'
244  
-            Regexp.compile("#{Regexp.escape(value)}$")
  244
+            Regexp.compile("#{Regexp.escape(value)}$", Regexp::IGNORECASE)
245 245
           when 'is', '='
246 246
             value.to_s
247 247
           else
3  lib/rails_admin/config/fields/base.rb
@@ -280,7 +280,8 @@ def inspect
280 280
           "#<#{self.class.name}[#{name}] #{
281 281
             instance_variables.map do |v|
282 282
               value = instance_variable_get(v)
283  
-              if [:@parent, :@root, :@section].include? v
  283
+              if [:@parent, :@root, :@section, :@children_fields_registered,
  284
+                  :@associated_model_config, :@group, :@bindings].include? v
284 285
                 if value.respond_to? :name
285 286
                   "#{v}=#{value.name.inspect}"
286 287
                 else
17  lib/rails_admin/config/model.rb
@@ -83,6 +83,23 @@ def object_label
83 83
       def method_missing(m, *args, &block)
84 84
         self.send(:base).send(m, *args, &block)
85 85
       end
  86
+
  87
+      def inspect
  88
+        "#<#{self.class.name}[#{abstract_model.model.name}] #{
  89
+          instance_variables.map do |v|
  90
+            value = instance_variable_get(v)
  91
+            if [:@parent, :@root].include? v
  92
+              if value.respond_to? :name
  93
+                "#{v}=#{value.name.inspect}"
  94
+              else
  95
+                "#{v}=#{value.class.name}"
  96
+              end
  97
+            else
  98
+              "#{v}=#{value.inspect}"
  99
+            end
  100
+          end.join(", ")
  101
+        }>"
  102
+      end
86 103
     end
87 104
   end
88 105
 end
17  lib/rails_admin/config/sections/base.rb
@@ -23,6 +23,23 @@ def initialize(parent)
23 23
 
24 24
           @abstract_model = root.abstract_model
25 25
         end
  26
+
  27
+        def inspect
  28
+          "#<#{self.class.name} #{
  29
+            instance_variables.map do |v|
  30
+              value = instance_variable_get(v)
  31
+              if [:@parent, :@root, :@abstract_model].include? v
  32
+                if value.respond_to? :name
  33
+                  "#{v}=#{value.name.inspect}"
  34
+                else
  35
+                  "#{v}=#{value.class.name}"
  36
+                end
  37
+              else
  38
+                "#{v}=#{value.inspect}"
  39
+              end
  40
+            end.join(", ")
  41
+          }>"
  42
+        end
26 43
       end
27 44
     end
28 45
   end
6  lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
@@ -44,7 +44,7 @@ def initialize(controller, user_class = User)
44 44
         end
45 45
 
46 46
         def latest
47  
-          Version.limit(100).map{|version| VersionProxy.new(version, @user_class)}
  47
+          ::Version.limit(100).map{|version| VersionProxy.new(version, @user_class)}
48 48
         end
49 49
 
50 50
         def delete_object(message, object, model, user)
@@ -66,7 +66,7 @@ def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (R
66 66
             sort = :created_at
67 67
             sort_reverse = "true"
68 68
           end
69  
-          versions = Version.where :item_type => model.model.name
  69
+          versions = ::Version.where :item_type => model.model.name
70 70
           versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
71 71
           versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
72 72
           versions = all ? versions : versions.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
@@ -80,7 +80,7 @@ def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_
80 80
             sort = :created_at
81 81
             sort_reverse = "true"
82 82
           end
83  
-          versions = Version.where :item_type => model.model.name, :item_id => object.id
  83
+          versions = ::Version.where :item_type => model.model.name, :item_id => object.id
84 84
           versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
85 85
           versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
86 86
           versions = all ? versions : versions.send(Kaminari.config.page_method_name, page.presence || "1").per(per_page)
4  spec/dummy_app/app/active_record/another_field_test.rb
... ...
@@ -0,0 +1,4 @@
  1
+class AnotherFieldTest < ActiveRecord::Base
  2
+  has_many :nested_field_tests, :inverse_of => :another_field_test
  3
+  attr_accessible :nested_field_test_ids
  4
+end
3  spec/dummy_app/app/active_record/nested_field_test.rb
... ...
@@ -1,7 +1,8 @@
1 1
 class NestedFieldTest < ActiveRecord::Base
2  
-  attr_accessible :title, :field_test_id, :comment_attributes
  2
+  attr_accessible :title, :field_test_id, :another_field_test_id, :comment_attributes
3 3
 
4 4
   belongs_to :field_test, :inverse_of => :nested_field_tests
  5
+  belongs_to :another_field_test, :inverse_of => :nested_field_tests
5 6
   has_one :comment, :as => :commentable
6 7
   accepts_nested_attributes_for :comment, :allow_destroy => true, :reject_if => proc { |attributes| attributes["content"].blank? }
7 8
 end
6  spec/dummy_app/app/mongoid/another_field_test.rb
... ...
@@ -0,0 +1,6 @@
  1
+class AnotherFieldTest
  2
+  include Mongoid::Document
  3
+
  4
+  has_many :nested_field_tests, :inverse_of => :another_field_test
  5
+  attr_accessible :nested_field_test_ids
  6
+end
3  spec/dummy_app/app/mongoid/nested_field_test.rb
@@ -3,9 +3,10 @@ class NestedFieldTest
3 3
 
4 4
   field :title, :type => String
5 5
   belongs_to :field_test, :inverse_of => :nested_field_tests
  6
+  belongs_to :another_field_test, :inverse_of => :nested_field_tests
6 7
   include Mongoid::Timestamps
7 8
 
8  
-  attr_accessible :title, :field_test_id, :comment_attributes
  9
+  attr_accessible :title, :field_test_id, :another_field_test_id, :comment_attributes
9 10
 
10 11
   has_one :comment, :as => :commentable, :autosave => true
11 12
   accepts_nested_attributes_for :comment, :allow_destroy => true, :reject_if => proc { |attributes| attributes["content"].blank? }
8  spec/dummy_app/db/migrate/20120720075608_create_another_field_tests.rb
... ...
@@ -0,0 +1,8 @@
  1
+class CreateAnotherFieldTests < ActiveRecord::Migration
  2
+  def change
  3
+    create_table :another_field_tests do |t|
  4
+      t.timestamps
  5
+    end
  6
+    add_column :nested_field_tests, :another_field_test_id, :integer
  7
+  end
  8
+end
8  spec/integration/config/edit/rails_admin_config_edit_spec.rb
@@ -853,6 +853,14 @@ class HelpTest < Tableless
853 853
         should have_selector('.fields_blueprint .remove_nested_fields')
854 854
       end
855 855
     end
  856
+
  857
+    describe "when a field which have the same name of nested_in field's" do
  858
+      it "should not hide fields which is not associated with nesting parent field's model" do
  859
+        visit new_path(:model_name => "field_test")
  860
+        should_not have_selector('select#field_test_nested_field_tests_attributes_new_nested_field_tests_field_test_id')
  861
+        should have_selector('select#field_test_nested_field_tests_attributes_new_nested_field_tests_another_field_test_id')
  862
+      end
  863
+    end
856 864
   end
857 865
 
858 866
   describe 'embedded model', :mongoid => true do
8  spec/unit/adapters/mongoid_spec.rb
@@ -686,10 +686,10 @@ class CustomValiated
686 686
     it "supports string type query" do
687 687
       @abstract_model.send(:build_statement, :field, :string, "", nil).should be_nil
688 688
       @abstract_model.send(:build_statement, :field, :string, "foo", "was").should be_nil
689  
-      @abstract_model.send(:build_statement, :field, :string, "foo", "default").should == {:field=>/foo/}
690  
-      @abstract_model.send(:build_statement, :field, :string, "foo", "like").should == {:field=>/foo/}
691  
-      @abstract_model.send(:build_statement, :field, :string, "foo", "starts_with").should == {:field=>/^foo/}
692  
-      @abstract_model.send(:build_statement, :field, :string, "foo", "ends_with").should == {:field=>/foo$/}
  689
+      @abstract_model.send(:build_statement, :field, :string, "foo", "default").should == {:field=>/foo/i}
  690
+      @abstract_model.send(:build_statement, :field, :string, "foo", "like").should == {:field=>/foo/i}
  691
+      @abstract_model.send(:build_statement, :field, :string, "foo", "starts_with").should == {:field=>/^foo/i}
  692
+      @abstract_model.send(:build_statement, :field, :string, "foo", "ends_with").should == {:field=>/foo$/i}
693 693
       @abstract_model.send(:build_statement, :field, :string, "foo", "is").should == {:field=>'foo'}
694 694
     end
695 695
 

No commit comments for this range

Something went wrong with that request. Please try again.