rails_admin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_admin might be problematic. Click here for more details.

Files changed (55) hide show
  1. data/README.md +8 -57
  2. data/app/assets/stylesheets/rails_admin/base/{README → README.txt} +1 -1
  3. data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +4 -2
  4. data/app/assets/stylesheets/rails_admin/themes/cerulean/theming.css.scss +2 -2
  5. data/app/helpers/rails_admin/application_helper.rb +22 -28
  6. data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -1
  7. data/app/views/rails_admin/main/_form_filtering_select.html.haml +1 -1
  8. data/lib/generators/rails_admin/install_generator.rb +4 -3
  9. data/lib/rails_admin/adapters/mongoid.rb +2 -1
  10. data/lib/rails_admin/engine.rb +1 -0
  11. data/lib/rails_admin/version.rb +1 -1
  12. data/spec/controllers/application_controller_spec.rb +4 -4
  13. data/spec/controllers/main_controller_spec.rb +26 -26
  14. data/spec/dummy_app/config/routes.rb +1 -1
  15. data/spec/dummy_app/db/test.sqlite3 +0 -0
  16. data/spec/dummy_app/log/test.log +161818 -0
  17. data/spec/helpers/application_helper_spec.rb +46 -46
  18. data/spec/helpers/form_builder_spec.rb +2 -2
  19. data/spec/integration/authorization/cancan_spec.rb +22 -22
  20. data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +6 -6
  21. data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +16 -16
  22. data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +1 -1
  23. data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +6 -6
  24. data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +8 -8
  25. data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +10 -10
  26. data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +16 -16
  27. data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +3 -3
  28. data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +2 -2
  29. data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +1 -2
  30. data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +27 -27
  31. data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +45 -45
  32. data/spec/integration/config/list/rails_admin_config_list_spec.rb +35 -38
  33. data/spec/integration/config/show/rails_admin_config_show_spec.rb +2 -2
  34. data/spec/integration/history/rails_admin_history_spec.rb +9 -9
  35. data/spec/integration/rails_admin_spec.rb +4 -4
  36. data/spec/integration/relation_spec.rb +3 -3
  37. data/spec/spec_helper.rb +3 -1
  38. data/spec/unit/abstract_model_spec.rb +10 -10
  39. data/spec/unit/active_record_extension_spec.rb +1 -1
  40. data/spec/unit/adapters/active_record/abstract_object_spec.rb +24 -24
  41. data/spec/unit/adapters/active_record_spec.rb +131 -132
  42. data/spec/unit/adapters/mongoid/abstract_object_spec.rb +5 -5
  43. data/spec/unit/adapters/mongoid_spec.rb +180 -180
  44. data/spec/unit/config/actions/base_spec.rb +6 -6
  45. data/spec/unit/config/actions_spec.rb +31 -32
  46. data/spec/unit/config/fields/base_spec.rb +69 -70
  47. data/spec/unit/config/fields/date_spec.rb +5 -5
  48. data/spec/unit/config/fields/datetime_spec.rb +4 -4
  49. data/spec/unit/config/fields/time_spec.rb +3 -3
  50. data/spec/unit/config/fields/timestamp_spec.rb +1 -1
  51. data/spec/unit/config/model_spec.rb +12 -12
  52. data/spec/unit/config/sections_spec.rb +17 -17
  53. data/spec/unit/config_spec.rb +23 -24
  54. data/spec/unit/support/csv_converter_spec.rb +2 -2
  55. metadata +19 -3
@@ -50,115 +50,114 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
50
50
  end
51
51
 
52
52
  it 'lists associations' do
53
- @post.associations.map{|a|a[:name].to_s}.should =~ ['a_r_blog', 'a_r_categories', 'a_r_comments']
53
+ expect(@post.associations.map{|a|a[:name].to_s}).to match_array ['a_r_blog', 'a_r_categories', 'a_r_comments']
54
54
  end
55
55
 
56
56
  it 'list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
57
- (@post.associations + @blog.associations + @user.associations).map{|a|a[:type]}.uniq.map(&:to_s).should =~ ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
57
+ expect((@post.associations + @blog.associations + @user.associations).map{|a|a[:type]}.uniq.map(&:to_s)).to match_array ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
58
58
  end
59
59
 
60
60
  it "has correct parameter of belongs_to association" do
61
61
  param = @post.associations.select{|a| a[:name] == :a_r_blog}.first
62
- param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }.should == {
63
- :name=>:a_r_blog,
64
- :pretty_name=>"A r blog",
65
- :type=>:belongs_to,
66
- :foreign_key=>:a_r_blog_id,
67
- :foreign_type=>nil,
68
- :as=>nil,
69
- :polymorphic=>false,
70
- :inverse_of=>nil,
71
- :read_only=>nil,
72
- :nested_form=>nil
73
- }
74
- param[:primary_key_proc].call.should == 'id'
75
- param[:model_proc].call.should == ARBlog
62
+ expect(param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }).to eq({
63
+ :name => :a_r_blog,
64
+ :pretty_name => "A r blog",
65
+ :type => :belongs_to,
66
+ :foreign_key => :a_r_blog_id,
67
+ :foreign_type => nil,
68
+ :as => nil,
69
+ :polymorphic => false,
70
+ :inverse_of => nil,
71
+ :read_only => nil,
72
+ :nested_form => nil,
73
+ })
74
+ expect(param[:primary_key_proc].call).to eq('id')
75
+ expect(param[:model_proc].call).to eq(ARBlog)
76
76
  end
77
77
 
78
78
  it "has correct parameter of has_many association" do
79
79
  param = @blog.associations.select{|a| a[:name] == :a_r_posts}.first
80
- param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }.should == {
81
- :name=>:a_r_posts,
82
- :pretty_name=>"A r posts",
83
- :type=>:has_many,
84
- :foreign_key=>:ar_blog_id,
85
- :foreign_type=>nil,
86
- :as=>nil,
87
- :polymorphic=>false,
88
- :inverse_of=>nil,
89
- :read_only=>nil,
90
- :nested_form=>nil
91
- }
92
- param[:primary_key_proc].call.should == 'id'
93
- param[:model_proc].call.should == ARPost
80
+ expect(param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }).to eq({
81
+ :name => :a_r_posts,
82
+ :pretty_name => "A r posts",
83
+ :type => :has_many,
84
+ :foreign_key => :ar_blog_id,
85
+ :foreign_type => nil,
86
+ :as => nil,
87
+ :polymorphic => false,
88
+ :inverse_of => nil,
89
+ :read_only => nil,
90
+ :nested_form => nil,
91
+ })
92
+ expect(param[:primary_key_proc].call).to eq('id')
93
+ expect(param[:model_proc].call).to eq(ARPost)
94
94
  end
95
95
 
96
96
  it "has correct parameter of has_and_belongs_to_many association" do
97
97
  param = @post.associations.select{|a| a[:name] == :a_r_categories}.first
98
- param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }.should == {
99
- :name=>:a_r_categories,
100
- :pretty_name=>"A r categories",
101
- :type=>:has_and_belongs_to_many,
102
- :foreign_key=>:ar_post_id,
103
- :foreign_type=>nil,
104
- :as=>nil,
105
- :polymorphic=>false,
106
- :inverse_of=>nil,
107
- :read_only=>nil,
108
- :nested_form=>nil
109
- }
110
- param[:primary_key_proc].call.should == 'id'
111
- param[:model_proc].call.should == ARCategory
98
+ expect(param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }).to eq({
99
+ :name => :a_r_categories,
100
+ :pretty_name => "A r categories",
101
+ :type => :has_and_belongs_to_many,
102
+ :foreign_key => :ar_post_id,
103
+ :foreign_type => nil,
104
+ :as => nil,
105
+ :polymorphic => false,
106
+ :inverse_of => nil,
107
+ :read_only => nil,
108
+ :nested_form => nil
109
+ })
110
+ expect(param[:primary_key_proc].call).to eq('id')
111
+ expect(param[:model_proc].call).to eq(ARCategory)
112
112
  end
113
113
 
114
114
  it "has correct parameter of polymorphic belongs_to association" do
115
115
  RailsAdmin::Config.stub!(:models_pool).and_return(["ARBlog", "ARPost", "ARCategory", "ARUser", "ARProfile", "ARComment"])
116
116
  param = @comment.associations.select{|a| a[:name] == :commentable}.first
117
- param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }.should == {
118
- :name=>:commentable,
119
- :pretty_name=>"Commentable",
120
- :type=>:belongs_to,
121
- :foreign_key=>:commentable_id,
122
- :foreign_type=>:commentable_type,
123
- :as=>nil,
124
- :polymorphic=>true,
125
- :inverse_of=>nil,
126
- :read_only=>nil,
127
- :nested_form=>nil
128
- }
129
- # param[:primary_key_proc].call.should == 'id' Should not be called for polymorphic relations. Todo, Handle this niver
130
- param[:model_proc].call.should == [ARBlog, ARPost]
117
+ expect(param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }).to eq({
118
+ :name => :commentable,
119
+ :pretty_name => "Commentable",
120
+ :type => :belongs_to,
121
+ :foreign_key => :commentable_id,
122
+ :foreign_type => :commentable_type,
123
+ :as => nil,
124
+ :polymorphic => true,
125
+ :inverse_of => nil,
126
+ :read_only => nil,
127
+ :nested_form => nil
128
+ })
129
+ # Should not be called for polymorphic relations.
130
+ # TODO: Handle this case
131
+ # expect(param[:primary_key_proc].call).to eq('id')
132
+ expect(param[:model_proc].call).to eq([ARBlog, ARPost])
131
133
  end
132
134
 
133
135
  it "has correct parameter of polymorphic inverse has_many association" do
134
136
  param = @blog.associations.select{|a| a[:name] == :a_r_comments}.first
135
- param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }.should == {
136
- :name=>:a_r_comments,
137
- :pretty_name=>"A r comments",
138
- :type=>:has_many,
139
- :foreign_key=>:commentable_id,
140
- :foreign_type=>nil,
141
- :as=>:commentable,
142
- :polymorphic=>false,
143
- :inverse_of=>nil,
144
- :read_only=>nil,
145
- :nested_form=>nil
146
- }
147
- param[:primary_key_proc].call.should == 'id'
148
- param[:model_proc].call.should == ARComment
137
+ expect(param.reject{|k, v| [:primary_key_proc, :model_proc].include? k }).to eq({
138
+ :name => :a_r_comments,
139
+ :pretty_name => "A r comments",
140
+ :type => :has_many,
141
+ :foreign_key => :commentable_id,
142
+ :foreign_type => nil,
143
+ :as => :commentable,
144
+ :polymorphic => false,
145
+ :inverse_of => nil,
146
+ :read_only => nil,
147
+ :nested_form => nil
148
+ })
149
+ expect(param[:primary_key_proc].call).to eq('id')
150
+ expect(param[:model_proc].call).to eq(ARComment)
149
151
  end
150
152
  end
151
-
152
153
 
153
154
  describe "#properties" do
154
155
  it "returns parameters of string-type field" do
155
- RailsAdmin::AbstractModel.new('Player').properties.select{|f| f[:name] == :name}.should ==
156
- [{:name => :name, :pretty_name => "Name", :type => :string, :length => 100, :nullable? => false, :serial? => false}]
156
+ expect(RailsAdmin::AbstractModel.new('Player').properties.select{|f| f[:name] == :name}).to eq([{:name => :name, :pretty_name => "Name", :type => :string, :length => 100, :nullable? => false, :serial? => false}])
157
157
  end
158
158
 
159
159
  it "maps serialized attribute to :serialized field type" do
160
- RailsAdmin::AbstractModel.new('User').properties.find{|f| f[:name] == :roles}.should ==
161
- {:name => :roles, :pretty_name => "Roles", :length => 255, :nullable? => true, :serial? => false, :type => :serialized}
160
+ expect(RailsAdmin::AbstractModel.new('User').properties.find{|f| f[:name] == :roles}).to eq({:name => :roles, :pretty_name => "Roles", :length => 255, :nullable? => true, :serial? => false, :type => :serialized})
162
161
  end
163
162
  end
164
163
 
@@ -169,66 +168,66 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
169
168
  end
170
169
 
171
170
  it "#new returns instance of AbstractObject" do
172
- @abstract_model.new.object.should be_instance_of(Player)
171
+ expect(@abstract_model.new.object).to be_instance_of(Player)
173
172
  end
174
173
 
175
174
  it "#get returns instance of AbstractObject" do
176
- @abstract_model.get(@players.first.id).object.should == @players.first
175
+ expect(@abstract_model.get(@players.first.id).object).to eq(@players.first)
177
176
  end
178
177
 
179
178
  it "#get returns nil when id does not exist" do
180
- @abstract_model.get('abc').should be_nil
179
+ expect(@abstract_model.get('abc')).to be_nil
181
180
  end
182
181
 
183
182
  it "#first returns a player" do
184
- @players.should include @abstract_model.first
183
+ expect(@players).to include @abstract_model.first
185
184
  end
186
185
 
187
186
  it "#count returns count of items" do
188
- @abstract_model.count.should == @players.count
187
+ expect(@abstract_model.count).to eq(@players.count)
189
188
  end
190
189
 
191
190
  it "#destroy destroys multiple items" do
192
191
  @abstract_model.destroy(@players[0..1])
193
- Player.all.should == @players[2..2]
192
+ expect(Player.all).to eq(@players[2..2])
194
193
  end
195
194
 
196
195
  it "#where returns filtered results" do
197
- @abstract_model.where(:name => @players.first.name).should == [@players.first]
196
+ expect(@abstract_model.where(:name => @players.first.name)).to eq([@players.first])
198
197
  end
199
198
 
200
199
  describe "#all" do
201
200
  it "works without options" do
202
- @abstract_model.all.should =~ @players
201
+ expect(@abstract_model.all).to match_array @players
203
202
  end
204
203
 
205
204
  it "supports eager loading" do
206
- @abstract_model.all(:include => :team).includes_values.should == [:team]
205
+ expect(@abstract_model.all(:include => :team).includes_values).to eq([:team])
207
206
  end
208
207
 
209
208
  it "supports limiting" do
210
- @abstract_model.all(:limit => 2).should have(2).items
209
+ expect(@abstract_model.all(:limit => 2)).to have(2).items
211
210
  end
212
211
 
213
212
  it "supports retrieval by bulk_ids" do
214
- @abstract_model.all(:bulk_ids => @players[0..1].map(&:id)).should =~ @players[0..1]
213
+ expect(@abstract_model.all(:bulk_ids => @players[0..1].map(&:id))).to match_array @players[0..1]
215
214
  end
216
215
 
217
216
  it "supports pagination" do
218
- @abstract_model.all(:sort => "id", :page => 2, :per => 1).should == @players[1..1]
219
- @abstract_model.all(:sort => "id", :page => 1, :per => 2).should == @players[1..2].reverse
217
+ expect(@abstract_model.all(:sort => "id", :page => 2, :per => 1)).to eq(@players[1..1])
218
+ expect(@abstract_model.all(:sort => "id", :page => 1, :per => 2)).to eq(@players[1..2].reverse)
220
219
  end
221
220
 
222
221
  it "supports ordering" do
223
- @abstract_model.all(:sort => "id", :sort_reverse => true).should == @players.sort
222
+ expect(@abstract_model.all(:sort => "id", :sort_reverse => true)).to eq(@players.sort)
224
223
  end
225
224
 
226
225
  it "supports querying" do
227
- @abstract_model.all(:query => @players[1].name).should == @players[1..1]
226
+ expect(@abstract_model.all(:query => @players[1].name)).to eq(@players[1..1])
228
227
  end
229
228
 
230
229
  it "supports filtering" do
231
- @abstract_model.all(:filters => {"name" => {"0000" => {:o=>"is", :v=>@players[1].name}}}).should == @players[1..1]
230
+ expect(@abstract_model.all(:filters => {"name" => {"0000" => {:o => "is", :v => @players[1].name}}})).to eq(@players[1..1])
232
231
  end
233
232
  end
234
233
  end
@@ -236,12 +235,12 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
236
235
  describe "#query_conditions" do
237
236
  before do
238
237
  @abstract_model = RailsAdmin::AbstractModel.new('Team')
239
- @teams = [{}, {:name=>'somewhere foos'}, {:manager=>'foo junior'}].
238
+ @teams = [{}, {:name => 'somewhere foos'}, {:manager => 'foo junior'}].
240
239
  map{|h| FactoryGirl.create :team, h}
241
240
  end
242
241
 
243
242
  it "makes conrrect query" do
244
- @abstract_model.all(:query => "foo").should =~ @teams[1..2]
243
+ expect(@abstract_model.all(:query => "foo")).to match_array @teams[1..2]
245
244
  end
246
245
  end
247
246
 
@@ -249,16 +248,16 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
249
248
  before do
250
249
  @abstract_model = RailsAdmin::AbstractModel.new('Team')
251
250
  @division = FactoryGirl.create :division, :name => 'bar division'
252
- @teams = [{}, {:division=>@division}, {:name=>'somewhere foos', :division=>@division}, {:name=>'nowhere foos'}].
251
+ @teams = [{}, {:division => @division}, {:name => 'somewhere foos', :division => @division}, {:name => 'nowhere foos'}].
253
252
  map{|h| FactoryGirl.create :team, h}
254
253
  end
255
254
 
256
255
  it "makes conrrect query" do
257
- @abstract_model.all(
258
- :filters => {"name" => {"0000" => {:o=>"like", :v=>"foo"}},
259
- "division" => {"0001" => {:o=>"like", :v=>"bar"}}},
256
+ expect(@abstract_model.all(
257
+ :filters => {"name" => {"0000" => {:o => "like", :v => "foo"}},
258
+ "division" => {"0001" => {:o => "like", :v => "bar"}}},
260
259
  :include => :division
261
- ).should == [@teams[2]]
260
+ )).to eq([@teams[2]])
262
261
  end
263
262
  end
264
263
 
@@ -269,93 +268,93 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
269
268
 
270
269
  it "ignores '_discard' operator or value" do
271
270
  [["_discard", ""], ["", "_discard"]].each do |value, operator|
272
- @abstract_model.send(:build_statement, :name, :string, value, operator).should be_nil
271
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to be_nil
273
272
  end
274
273
  end
275
274
 
276
275
  it "supports '_blank' operator" do
277
276
  [["_blank", ""], ["", "_blank"]].each do |value, operator|
278
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name IS NULL OR name = '')"]
277
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name IS NULL OR name = '')"])
279
278
  end
280
279
  end
281
280
 
282
281
  it "supports '_present' operator" do
283
282
  [["_present", ""], ["", "_present"]].each do |value, operator|
284
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name IS NOT NULL AND name != '')"]
283
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name IS NOT NULL AND name != '')"])
285
284
  end
286
285
  end
287
286
 
288
287
  it "supports '_null' operator" do
289
288
  [["_null", ""], ["", "_null"]].each do |value, operator|
290
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name IS NULL)"]
289
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name IS NULL)"])
291
290
  end
292
291
  end
293
292
 
294
293
  it "supports '_not_null' operator" do
295
294
  [["_not_null", ""], ["", "_not_null"]].each do |value, operator|
296
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name IS NOT NULL)"]
295
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name IS NOT NULL)"])
297
296
  end
298
297
  end
299
298
 
300
299
  it "supports '_empty' operator" do
301
300
  [["_empty", ""], ["", "_empty"]].each do |value, operator|
302
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name = '')"]
301
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name = '')"])
303
302
  end
304
303
  end
305
304
 
306
305
  it "supports '_not_empty' operator" do
307
306
  [["_not_empty", ""], ["", "_not_empty"]].each do |value, operator|
308
- @abstract_model.send(:build_statement, :name, :string, value, operator).should == ["(name != '')"]
307
+ expect(@abstract_model.send(:build_statement, :name, :string, value, operator)).to eq(["(name != '')"])
309
308
  end
310
309
  end
311
310
 
312
311
  it "supports boolean type query" do
313
312
  ['false', 'f', '0'].each do |value|
314
- @abstract_model.send(:build_statement, :field, :boolean, value, nil).should == ["(field IS NULL OR field = ?)", false]
313
+ expect(@abstract_model.send(:build_statement, :field, :boolean, value, nil)).to eq(["(field IS NULL OR field = ?)", false])
315
314
  end
316
315
  ['true', 't', '1'].each do |value|
317
- @abstract_model.send(:build_statement, :field, :boolean, value, nil).should == ["(field = ?)", true]
316
+ expect(@abstract_model.send(:build_statement, :field, :boolean, value, nil)).to eq(["(field = ?)", true])
318
317
  end
319
- @abstract_model.send(:build_statement, :field, :boolean, 'word', nil).should be_nil
318
+ expect(@abstract_model.send(:build_statement, :field, :boolean, 'word', nil)).to be_nil
320
319
  end
321
320
 
322
321
  it "supports integer type query" do
323
- @abstract_model.send(:build_statement, :field, :integer, "1", nil).should == ["(field = ?)", 1]
324
- @abstract_model.send(:build_statement, :field, :integer, 'word', nil).should be_nil
322
+ expect(@abstract_model.send(:build_statement, :field, :integer, "1", nil)).to eq(["(field = ?)", 1])
323
+ expect(@abstract_model.send(:build_statement, :field, :integer, 'word', nil)).to be_nil
325
324
  end
326
325
 
327
326
  it "supports decimal type query" do
328
- @abstract_model.send(:build_statement, :field, :decimal, "1.1", nil).should == ["(field = ?)", 1.1]
329
- @abstract_model.send(:build_statement, :field, :decimal, 'word', nil).should be_nil
327
+ expect(@abstract_model.send(:build_statement, :field, :decimal, "1.1", nil)).to eq(["(field = ?)", 1.1])
328
+ expect(@abstract_model.send(:build_statement, :field, :decimal, 'word', nil)).to be_nil
330
329
  end
331
330
 
332
331
  it "supports string type query" do
333
- @abstract_model.send(:build_statement, :field, :string, "", nil).should be_nil
334
- @abstract_model.send(:build_statement, :field, :string, "foo", "was").should be_nil
335
- @abstract_model.send(:build_statement, :field, :string, "foo", "default").should == ["(field #{@like} ?)", "%foo%"]
336
- @abstract_model.send(:build_statement, :field, :string, "foo", "like").should == ["(field #{@like} ?)", "%foo%"]
337
- @abstract_model.send(:build_statement, :field, :string, "foo", "starts_with").should == ["(field #{@like} ?)", "foo%"]
338
- @abstract_model.send(:build_statement, :field, :string, "foo", "ends_with").should == ["(field #{@like} ?)", "%foo"]
339
- @abstract_model.send(:build_statement, :field, :string, "foo", "is").should == ["(field #{@like} ?)", "foo"]
332
+ expect(@abstract_model.send(:build_statement, :field, :string, "", nil)).to be_nil
333
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "was")).to be_nil
334
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "default")).to eq(["(field #{@like} ?)", "%foo%"])
335
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "like")).to eq(["(field #{@like} ?)", "%foo%"])
336
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "starts_with")).to eq(["(field #{@like} ?)", "foo%"])
337
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "ends_with")).to eq(["(field #{@like} ?)", "%foo"])
338
+ expect(@abstract_model.send(:build_statement, :field, :string, "foo", "is")).to eq(["(field #{@like} ?)", "foo"])
340
339
  end
341
340
 
342
341
 
343
342
  it 'supports date type query' do
344
- @abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } }).should == ["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,3)]
345
- @abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).should == ["((field_tests.date_field >= ?))", Date.new(2012,1,3)]
346
- @abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).should == ["((field_tests.date_field <= ?))", Date.new(2012,1,2)]
347
- @abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).should == ["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,2)]
343
+ expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } })).to eq(["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,3)])
344
+ expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq(["((field_tests.date_field >= ?))", Date.new(2012,1,3)])
345
+ expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq(["((field_tests.date_field <= ?))", Date.new(2012,1,2)])
346
+ expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } )).to eq(["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,2)])
348
347
  end
349
348
 
350
349
  it 'supports datetime type query' do
351
- @abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } ).should == ["((field_tests.datetime_field BETWEEN ? AND ?))", Time.local(2012,1,2), Time.local(2012,1,3).end_of_day]
352
- @abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).should == ["((field_tests.datetime_field >= ?))", Time.local(2012,1,3)]
353
- @abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).should == ["((field_tests.datetime_field <= ?))", Time.local(2012,1,2).end_of_day]
354
- @abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).should == ["((field_tests.datetime_field BETWEEN ? AND ?))", Time.local(2012,1,2), Time.local(2012,1,2).end_of_day]
350
+ expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } )).to eq(["((field_tests.datetime_field BETWEEN ? AND ?))", Time.local(2012,1,2), Time.local(2012,1,3).end_of_day])
351
+ expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq(["((field_tests.datetime_field >= ?))", Time.local(2012,1,3)])
352
+ expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq(["((field_tests.datetime_field <= ?))", Time.local(2012,1,2).end_of_day])
353
+ expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } )).to eq(["((field_tests.datetime_field BETWEEN ? AND ?))", Time.local(2012,1,2), Time.local(2012,1,2).end_of_day])
355
354
  end
356
355
 
357
356
  it "supports enum type query" do
358
- @abstract_model.send(:build_statement, :field, :enum, "1", nil).should == ["(field IN (?))", ["1"]]
357
+ expect(@abstract_model.send(:build_statement, :field, :enum, "1", nil)).to eq(["(field IN (?))", ["1"]])
359
358
  end
360
359
  end
361
360
 
@@ -365,11 +364,11 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
365
364
  end
366
365
 
367
366
  it "#scoped returns relation object" do
368
- @abstract_model.scoped.should be_instance_of(ActiveRecord::Relation)
367
+ expect(@abstract_model.scoped).to be_instance_of(ActiveRecord::Relation)
369
368
  end
370
369
 
371
370
  it "#table_name works" do
372
- @abstract_model.table_name.should == 'players'
371
+ expect(@abstract_model.table_name).to eq('players')
373
372
  end
374
373
  end
375
374
  end
@@ -9,23 +9,23 @@ describe "Mongoid::AbstractObject", :mongoid => true do
9
9
 
10
10
  describe "references_many association" do
11
11
  it "supports retrieval of ids through foo_ids" do
12
- @team.player_ids.should == []
12
+ expect(@team.player_ids).to eq([])
13
13
  player = FactoryGirl.create :player, :team => @team
14
- @team.player_ids.should == [player.id]
14
+ expect(@team.player_ids).to eq([player.id])
15
15
  end
16
16
 
17
17
  it "supports assignment of items through foo_ids=" do
18
- @team.players.should == []
18
+ expect(@team.players).to eq([])
19
19
  @team.player_ids = @players.map(&:id)
20
20
  @team.reload
21
- @team.players.map(&:id).should =~ @players.map(&:id)
21
+ expect(@team.players.map(&:id)).to match_array @players.map(&:id)
22
22
  end
23
23
 
24
24
  it "skips invalid id on assignment through foo_ids=" do
25
25
  @team.player_ids = @players.map{|item| item.id.to_s }.unshift('4f431021dcf2310db7000006')
26
26
  @team.reload
27
27
  @players.each &:reload
28
- @team.players.map(&:id).should =~ @players.map(&:id)
28
+ expect(@team.players.map(&:id)).to match_array @players.map(&:id)
29
29
  end
30
30
  end
31
31
  end