rails_admin 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. data/Gemfile +18 -20
  2. data/README.md +8 -1
  3. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +5 -4
  4. data/app/assets/stylesheets/rails_admin/base/theming.css.scss +4 -4
  5. data/app/controllers/rails_admin/main_controller.rb +11 -2
  6. data/app/helpers/rails_admin/application_helper.rb +1 -1
  7. data/app/helpers/rails_admin/form_builder.rb +3 -3
  8. data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +4 -4
  9. data/app/views/rails_admin/main/_form_filtering_select.html.haml +2 -2
  10. data/app/views/rails_admin/main/_form_nested_one.html.haml +1 -1
  11. data/app/views/rails_admin/main/_form_text.html.haml +2 -1
  12. data/app/views/rails_admin/main/export.html.haml +2 -2
  13. data/app/views/rails_admin/main/index.html.haml +5 -5
  14. data/app/views/rails_admin/main/show.html.haml +1 -1
  15. data/lib/generators/rails_admin/templates/initializer.erb +5 -5
  16. data/lib/rails_admin/abstract_model.rb +1 -0
  17. data/lib/rails_admin/config.rb +1 -1
  18. data/lib/rails_admin/config/actions/base.rb +1 -1
  19. data/lib/rails_admin/config/actions/edit.rb +5 -4
  20. data/lib/rails_admin/config/actions/new.rb +5 -4
  21. data/lib/rails_admin/config/fields/association.rb +10 -10
  22. data/lib/rails_admin/config/fields/base.rb +10 -4
  23. data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
  24. data/lib/rails_admin/config/fields/types/boolean.rb +4 -4
  25. data/lib/rails_admin/config/fields/types/bson_object_id.rb +4 -4
  26. data/lib/rails_admin/config/fields/types/carrierwave.rb +3 -3
  27. data/lib/rails_admin/config/fields/types/datetime.rb +5 -5
  28. data/lib/rails_admin/config/fields/types/enum.rb +5 -5
  29. data/lib/rails_admin/config/fields/types/file_upload.rb +10 -6
  30. data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -1
  31. data/lib/rails_admin/config/fields/types/has_one_association.rb +3 -3
  32. data/lib/rails_admin/config/fields/types/integer.rb +1 -1
  33. data/lib/rails_admin/config/fields/types/paperclip.rb +2 -2
  34. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +8 -4
  35. data/lib/rails_admin/config/fields/types/serialized.rb +2 -2
  36. data/lib/rails_admin/config/fields/types/string.rb +3 -3
  37. data/lib/rails_admin/config/fields/types/text.rb +22 -15
  38. data/lib/rails_admin/config/fields/types/time.rb +1 -1
  39. data/lib/rails_admin/config/hideable.rb +1 -1
  40. data/lib/rails_admin/config/model.rb +4 -0
  41. data/lib/rails_admin/config/sections/modal.rb +1 -1
  42. data/lib/rails_admin/engine.rb +1 -1
  43. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -1
  44. data/lib/rails_admin/support/csv_converter.rb +1 -1
  45. data/lib/rails_admin/version.rb +2 -2
  46. data/lib/rails_admin/version.rbc +582 -0
  47. data/lib/tasks/rails_admin.rake +2 -2
  48. data/spec/controllers/main_controller_spec.rb +113 -45
  49. data/spec/dummy_app/Gemfile +11 -25
  50. data/spec/dummy_app/Gemfile.lock +214 -0
  51. data/spec/dummy_app/app/active_record/comment.rb +1 -1
  52. data/spec/dummy_app/app/active_record/field_test.rb +0 -1
  53. data/spec/dummy_app/config/initializers/strong_parameters.rb +2 -0
  54. data/spec/dummy_app/db/test.sqlite3 +0 -0
  55. data/spec/dummy_app/log/test.log +97612 -0
  56. data/spec/helpers/application_helper_spec.rb +24 -24
  57. data/spec/helpers/form_builder_spec.rb +4 -4
  58. data/spec/integration/authorization/cancan_spec.rb +3 -3
  59. data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +2 -2
  60. data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +2 -2
  61. data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +9 -9
  62. data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -1
  63. data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +4 -4
  64. data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +9 -9
  65. data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +10 -10
  66. data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +5 -5
  67. data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +32 -25
  68. data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +8 -8
  69. data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +3 -3
  70. data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +6 -6
  71. data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +13 -13
  72. data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +97 -76
  73. data/spec/integration/config/list/rails_admin_config_list_spec.rb +32 -32
  74. data/spec/integration/config/show/rails_admin_config_show_spec.rb +23 -23
  75. data/spec/integration/history/rails_admin_history_spec.rb +6 -6
  76. data/spec/integration/rails_admin_spec.rb +17 -17
  77. data/spec/integration/relation_spec.rb +7 -7
  78. data/spec/unit/abstract_model_spec.rb +11 -5
  79. data/spec/unit/active_record_extension_spec.rb +2 -2
  80. data/spec/unit/adapters/active_record/abstract_object_spec.rb +8 -8
  81. data/spec/unit/adapters/active_record_spec.rb +6 -6
  82. data/spec/unit/adapters/mongoid/abstract_object_spec.rb +1 -1
  83. data/spec/unit/adapters/mongoid_spec.rb +12 -12
  84. data/spec/unit/config/actions/base_spec.rb +2 -2
  85. data/spec/unit/config/actions_spec.rb +16 -16
  86. data/spec/unit/config/fields/base_spec.rb +61 -49
  87. data/spec/unit/config/fields/date_spec.rb +4 -4
  88. data/spec/unit/config/fields/datetime_spec.rb +4 -4
  89. data/spec/unit/config/fields/file_upload_spec.rb +21 -0
  90. data/spec/unit/config/fields/time_spec.rb +3 -3
  91. data/spec/unit/config/fields/timestamp_spec.rb +1 -1
  92. data/spec/unit/config/model_spec.rb +10 -10
  93. data/spec/unit/config/sections_spec.rb +4 -4
  94. data/spec/unit/config_spec.rb +9 -9
  95. metadata +17 -218
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "RailsAdmin" do
3
+ describe RailsAdmin do
4
4
 
5
5
  subject { page }
6
6
 
7
7
  describe "authentication" do
8
- it "should be disableable" do
8
+ it "is disableable" do
9
9
  logout
10
10
  RailsAdmin.config do |config|
11
11
  config.authenticate_with {}
@@ -18,7 +18,7 @@ describe "RailsAdmin" do
18
18
  # root key from en to their own locale (as people tend to use the English
19
19
  # file as template for a new translation).
20
20
  describe "localization" do
21
- it "should default to English" do
21
+ it "defaults to English" do
22
22
  visit dashboard_path
23
23
 
24
24
  should have_content("Site administration")
@@ -31,16 +31,16 @@ describe "RailsAdmin" do
31
31
 
32
32
  # Note: the [href^="/asset... syntax matches the start of a value. The reason
33
33
  # we just do that is to avoid being confused by rails' asset_ids.
34
- it "should load stylesheets in header" do
34
+ it "loads stylesheets in header" do
35
35
  should have_selector('head link[href^="/assets/rails_admin/rails_admin.css"]')
36
36
  end
37
37
 
38
- it "should load javascript files in body" do
38
+ it "loads javascript files in body" do
39
39
  should have_selector('head script[src^="/assets/rails_admin/rails_admin.js"]')
40
40
  end
41
41
  end
42
42
 
43
- describe 'hidden fields with default values' do
43
+ describe "hidden fields with default values" do
44
44
 
45
45
  before (:each) do
46
46
  RailsAdmin.config Player do
@@ -55,24 +55,24 @@ describe "RailsAdmin" do
55
55
  end
56
56
  end
57
57
 
58
- it "should show up with default value, hidden" do
58
+ it "shows up with default value, hidden" do
59
59
  visit new_path(:model_name => "player")
60
60
  should have_selector("#player_name[type=hidden][value='username@example.com']")
61
61
  should_not have_selector("#player_name[type=hidden][value='toto@example.com']")
62
62
  end
63
63
 
64
- it "should not show label" do
64
+ it "does not show label" do
65
65
  should_not have_selector("label", :text => "Name")
66
66
  end
67
67
 
68
- it "should not show help block" do
68
+ it "does not show help block" do
69
69
  should_not have_xpath("id('player_name')/../p[@class='help-block']")
70
70
  end
71
71
  end
72
72
 
73
- describe '_current_user' do # https://github.com/sferik/rails_admin/issues/549
73
+ describe "_current_user" do # https://github.com/sferik/rails_admin/issues/549
74
74
 
75
- it 'should be accessible from the list view' do
75
+ it "is accessible from the list view" do
76
76
  RailsAdmin.config Player do
77
77
  list do
78
78
  field :name do
@@ -101,20 +101,20 @@ describe "RailsAdmin" do
101
101
  @comment = FactoryGirl.create :comment, :commentable => @team
102
102
  end
103
103
 
104
- it "should work like belongs to associations in the list view" do
104
+ it "works like belongs to associations in the list view" do
105
105
  visit index_path(:model_name => "comment")
106
106
 
107
107
  should have_content(@team.name)
108
108
  end
109
109
 
110
- it "should be editable" do
110
+ it "is editable" do
111
111
  visit edit_path(:model_name => "comment", :id => @comment.id)
112
112
 
113
113
  should have_selector("select#comment_commentable_type")
114
114
  should have_selector("select#comment_commentable_id")
115
115
  end
116
116
 
117
- it "should be visible in the owning end" do
117
+ it "is visible in the owning end" do
118
118
  visit edit_path(:model_name => "team", :id => @team.id)
119
119
 
120
120
  should have_selector("select#team_comment_ids")
@@ -122,18 +122,18 @@ describe "RailsAdmin" do
122
122
  end
123
123
 
124
124
  describe "secondary navigation" do
125
- it "should have Gravatar image" do
125
+ it "has Gravatar image" do
126
126
  visit dashboard_path
127
127
  should have_selector("ul.nav.pull-right li img")
128
128
  end
129
129
 
130
- it "should not show Gravatar when user doesn't have email method" do
130
+ it "does not show Gravatar when user doesn't have email method" do
131
131
  User.any_instance.stub(:respond_to?).with(:email).and_return(false)
132
132
  visit dashboard_path
133
133
  should_not have_selector("ul.nav.pull-right li img")
134
134
  end
135
135
 
136
- it "should not cause error when email is nil" do
136
+ it "does not cause error when email is nil" do
137
137
  User.any_instance.stub(:email).and_return(nil)
138
138
  visit dashboard_path
139
139
  should have_selector("body.rails_admin")
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'table relations' do
3
+ describe "table relations" do
4
4
 
5
5
  before(:each) do
6
6
  class RelTest < Tableless
@@ -15,20 +15,20 @@ describe 'table relations' do
15
15
  @fields = RailsAdmin.config(RelTest).create.fields
16
16
  end
17
17
 
18
- describe 'column with nullable fk and no model validations' do
19
- it 'should be optional' do
18
+ describe "column with nullable fk and no model validations" do
19
+ it "is optional" do
20
20
  expect(@fields.find{ |f| f.name == :league }.required?).to be_false
21
21
  end
22
22
  end
23
23
 
24
- describe 'column with non-nullable fk and no model validations' do
25
- it 'should not be required' do
24
+ describe "column with non-nullable fk and no model validations" do
25
+ it "is not required" do
26
26
  expect(@fields.find{ |f| f.name == :division }.required?).to be_false
27
27
  end
28
28
  end
29
29
 
30
- describe 'column with nullable fk and a numericality model validation' do
31
- it 'should be required' do
30
+ describe "column with nullable fk and a numericality model validation" do
31
+ it "is required" do
32
32
  expect(@fields.find{ |f| f.name == :player }.required?).to be_true
33
33
  end
34
34
  end
@@ -1,13 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RailsAdmin::AbstractModel do
4
- describe 'filters' do
4
+ describe "filters" do
5
5
  before do
6
6
  @abstract_model = RailsAdmin::AbstractModel.new('FieldTest')
7
7
  end
8
+
9
+ context "ActiveModel::ForbiddenAttributesProtection" do
10
+ it "is present" do
11
+ @abstract_model.model.ancestors.map(&:to_s).include?('ActiveModel::ForbiddenAttributesProtection')
12
+ end
13
+ end
8
14
 
9
- context 'on dates' do
10
- it 'lists elements within outbound limits' do
15
+ context "on dates" do
16
+ it "lists elements within outbound limits" do
11
17
  date_format = I18n.t("admin.misc.filter_date_format", :default => I18n.t("admin.misc.filter_date_format", :locale => :en)).gsub('dd', '%d').gsub('mm', '%m').gsub('yy', '%Y')
12
18
 
13
19
  FactoryGirl.create(:field_test, :date_field => Date.strptime("01/01/2012", date_format))
@@ -23,8 +29,8 @@ describe RailsAdmin::AbstractModel do
23
29
  end
24
30
  end
25
31
 
26
- context 'on datetimes' do
27
- it 'lists elements within outbound limits' do
32
+ context "on datetimes" do
33
+ it "lists elements within outbound limits" do
28
34
  FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 1, 23, 59, 59))
29
35
  FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 2, 0, 0, 0))
30
36
  FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 3, 23, 59, 59))
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require File.expand_path('../../../config/initializers/active_record_extensions', __FILE__)
3
3
 
4
- describe 'ActiveRecord::Base', :active_record => true do
5
- describe '#safe_send' do
4
+ describe "ActiveRecord::Base", :active_record => true do
5
+ describe "#safe_send" do
6
6
  it "only calls #read_attribute once" do
7
7
  @player = Player.new
8
8
  @player.number = 23
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "AbstractObject", :active_record => true do
3
+ describe "RailsAdmin::Adapters::ActiveRecord::AbstractObject", :active_record => true do
4
4
  describe "proxy" do
5
5
  let(:object) { mock("object") }
6
6
  let(:abstract_object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new(object) }
7
7
 
8
- it "should act like a proxy" do
8
+ it "acts like a proxy" do
9
9
  object.should_receive(:method_call)
10
10
  abstract_object.method_call
11
11
  end
@@ -24,7 +24,7 @@ describe "AbstractObject", :active_record => true do
24
24
  object.set_attributes({ :name => name, :number => number, :position => position, :suspended => suspended, :team_id => nil })
25
25
  end
26
26
 
27
- it "should create a Player with given attributes" do
27
+ it "creates a Player with given attributes" do
28
28
  expect(object.save).to be_true
29
29
 
30
30
  player.reload
@@ -45,7 +45,7 @@ describe "AbstractObject", :active_record => true do
45
45
  object.set_attributes({ :name => name, :number => number, :position => position, :suspended => suspended, :team_id => nil, :draft_id => draft.id })
46
46
  end
47
47
 
48
- it "should create a Player with given attributes" do
48
+ it "creates a Player with given attributes" do
49
49
  expect(object.save).to be_true
50
50
 
51
51
  player.reload
@@ -69,7 +69,7 @@ describe "AbstractObject", :active_record => true do
69
69
  object.set_attributes({ :name => name, :division_ids => divisions.map(&:id) })
70
70
  end
71
71
 
72
- it "should create a League with given attributes and associations" do
72
+ it "creates a League with given attributes and associations" do
73
73
  expect(object.save).to be_true
74
74
  league.reload
75
75
  expect(league.name).to eq(name)
@@ -94,7 +94,7 @@ describe "AbstractObject", :active_record => true do
94
94
  object.save
95
95
  end
96
96
 
97
- it "should update a record and associations" do
97
+ it "updates a record and associations" do
98
98
  object.reload
99
99
  expect(object.number).to eq(new_number)
100
100
  expect(object.name).to eq(name)
@@ -113,13 +113,13 @@ describe "AbstractObject", :active_record => true do
113
113
  object.destroy
114
114
  end
115
115
 
116
- it "should delete the record" do
116
+ it "deletes the record" do
117
117
  expect(Player.exists?(player.id)).to be_false
118
118
  end
119
119
  end
120
120
 
121
121
  describe "object_label_method" do
122
- it 'should be configurable' do
122
+ it "is configurable" do
123
123
  RailsAdmin.config League do
124
124
  object_label_method { :custom_name }
125
125
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
  require 'timecop'
3
3
 
4
- describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
4
+ describe "RailsAdmin::Adapters::ActiveRecord", :active_record => true do
5
5
  before do
6
6
  @like = ::ActiveRecord::Base.configurations[Rails.env]['adapter'] == "postgresql" ? 'ILIKE' : 'LIKE'
7
7
  end
8
8
 
9
- describe '#associations' do
9
+ describe "#associations" do
10
10
  before :all do
11
11
  RailsAdmin::AbstractModel.reset_polymorphic_parents
12
12
 
@@ -49,11 +49,11 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
49
49
  RailsAdmin::AbstractModel.reset_polymorphic_parents
50
50
  end
51
51
 
52
- it 'lists associations' do
52
+ it "lists associations" do
53
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
- it 'list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
56
+ it "list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]" do
57
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
 
@@ -339,14 +339,14 @@ describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
339
339
  end
340
340
 
341
341
 
342
- it 'supports date type query' do
342
+ it "supports date type query" do
343
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
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
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
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)])
347
347
  end
348
348
 
349
- it 'supports datetime type query' do
349
+ it "supports datetime type query" do
350
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
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
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])
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'rails_admin/adapters/mongoid/abstract_object'
3
3
 
4
- describe "Mongoid::AbstractObject", :mongoid => true do
4
+ describe "RailsAdmin::Adapters::Mongoid::AbstractObject", :mongoid => true do
5
5
  before(:each) do
6
6
  @players = FactoryGirl.create_list :player, 3
7
7
  @team = RailsAdmin::Adapters::Mongoid::AbstractObject.new FactoryGirl.create :team
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'timecop'
3
3
 
4
- describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
5
- describe '#associations' do
4
+ describe "RailsAdmin::Adapters::Mongoid", :mongoid => true do
5
+ describe "#associations" do
6
6
  before :all do
7
7
  RailsAdmin::AbstractModel.reset_polymorphic_parents
8
8
 
@@ -67,11 +67,11 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
67
67
  RailsAdmin::AbstractModel.reset_polymorphic_parents
68
68
  end
69
69
 
70
- it 'lists associations' do
70
+ it "lists associations" do
71
71
  expect(@post.associations.map{|a| a[:name]}).to match_array [:mongo_blog, :mongo_categories, :mongo_comments, :mongo_note]
72
72
  end
73
73
 
74
- it 'reads correct and know types in [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
74
+ it "reads correct and know types in [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]" do
75
75
  expect((@post.associations + @blog.associations + @user.associations).map{|a|a[:type].to_s}.uniq).to match_array ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
76
76
  end
77
77
 
@@ -114,7 +114,7 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
114
114
  expect(@post.properties.find{|f| f[:name] == :mongo_blog_id}[:type]).to eq(:bson_object_id)
115
115
  end
116
116
 
117
- it "should not confuse foreign_key column which belongs to associated model" do
117
+ it "does not confuse foreign_key column which belongs to associated model" do
118
118
  expect(@blog.properties.find{|f| f[:name] == :mongo_blog_id}[:type]).to eq(:string)
119
119
  end
120
120
 
@@ -215,7 +215,7 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
215
215
  expect(param[:model_proc].call).to eq(MongoNote)
216
216
  end
217
217
 
218
- it "should raise error when embeds_* is used without accepts_nested_attributes_for" do
218
+ it "raises error when embeds_* is used without accepts_nested_attributes_for" do
219
219
  class MongoEmbedsOne
220
220
  include Mongoid::Document
221
221
  embeds_one :mongo_embedded
@@ -240,7 +240,7 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
240
240
  )
241
241
  end
242
242
 
243
- it "should work with inherited embeds_many model" do
243
+ it "works with inherited embeds_many model" do
244
244
  class MongoEmbedsParent
245
245
  include Mongoid::Document
246
246
  embeds_many :mongo_embeddeds
@@ -407,7 +407,7 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
407
407
  expect(RailsAdmin::AbstractModel.new('LengthValiated').send(:length_validation_lookup, :text)).to eq(50)
408
408
  end
409
409
 
410
- it "should not cause problem with custom validators" do
410
+ it "does not cause problem with custom validators" do
411
411
  class MyCustomValidator < ActiveModel::Validator
412
412
  def validate(r); end
413
413
  end
@@ -693,14 +693,14 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
693
693
  expect(@abstract_model.send(:build_statement, :field, :string, "foo", "is")).to eq({:field => 'foo'})
694
694
  end
695
695
 
696
- it 'supports date type query' do
696
+ it "supports date type query" do
697
697
  expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } })).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,2), "$lte" => Date.new(2012,1,3)}}]})
698
698
  expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,3)}}]})
699
699
  expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq({"$and" => [{"date_field" => {"$lte" => Date.new(2012,1,2)}}]})
700
700
  expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } )).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,2), "$lte" => Date.new(2012,1,2)}}]})
701
701
  end
702
702
 
703
- it 'supports datetime type query' do
703
+ it "supports datetime type query" do
704
704
  expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$gte" => Time.local(2012,1,2), "$lte" => Time.local(2012,1,3).end_of_day}}]})
705
705
  expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$gte" => Time.local(2012,1,3)}}]})
706
706
  expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$lte" => Time.local(2012,1,2).end_of_day}}]})
@@ -733,13 +733,13 @@ describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
733
733
  end
734
734
 
735
735
  it "accepts array value" do
736
- params = {:array_field => '[1, 3]'}
736
+ params = HashWithIndifferentAccess.new({:array_field => '[1, 3]'})
737
737
  @controller.send(:sanitize_params_for!, 'create', @abstract_model.config, params)
738
738
  expect(params[:array_field]).to eq([1, 3])
739
739
  end
740
740
 
741
741
  it "accepts hash value" do
742
- params = {:hash_field => '{a: 1, b: 3}'}
742
+ params = HashWithIndifferentAccess.new({:hash_field => '{a: 1, b: 3}'})
743
743
  @controller.send(:sanitize_params_for!, 'create', @abstract_model.config, params)
744
744
  expect(params[:hash_field]).to eq({"a" => 1, "b" => 3})
745
745
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe RailsAdmin::Config::Actions::Base do
4
4
 
5
5
  describe "#visible?" do
6
- it 'should exclude models not referenced in the only array' do
6
+ it "excludes models not referenced in the only array" do
7
7
  RailsAdmin.config do |config|
8
8
  config.actions do
9
9
  index do
@@ -16,7 +16,7 @@ describe RailsAdmin::Config::Actions::Base do
16
16
  expect(RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Cms::BasicPage)})).to be_visible
17
17
  end
18
18
 
19
- it 'should exclude models referenced in the except array' do
19
+ it "excludes models referenced in the except array" do
20
20
  RailsAdmin.config do |config|
21
21
  config.actions do
22
22
  index do
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe RailsAdmin::Config::Actions do
4
4
 
5
5
  describe "default" do
6
- it 'should be as before' do
6
+ it "is as before" do
7
7
  expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app])
8
8
  end
9
9
  end
10
10
 
11
- describe 'find' do
12
- it 'should find by custom key' do
11
+ describe "find" do
12
+ it "finds by custom key" do
13
13
  RailsAdmin.config do |config|
14
14
  config.actions do
15
15
  dashboard do
@@ -27,11 +27,11 @@ describe RailsAdmin::Config::Actions do
27
27
  expect(RailsAdmin::Config::Actions.find(:show)).to be_a(RailsAdmin::Config::Actions::Show)
28
28
  end
29
29
 
30
- it 'should return nil when no action is found by the custom key' do
30
+ it "returns nil when no action is found by the custom key" do
31
31
  expect(RailsAdmin::Config::Actions.find(:non_existent_action_key)).to be_nil
32
32
  end
33
33
 
34
- it 'should return visible action passing binding if controller binding is given, and pass action visible or not if no' do
34
+ it "returns visible action passing binding if controller binding is given, and pass action visible or not if no" do
35
35
  RailsAdmin.config do |config|
36
36
  config.actions do
37
37
  root :custom_root do
@@ -46,7 +46,7 @@ describe RailsAdmin::Config::Actions do
46
46
  expect(RailsAdmin::Config::Actions.find(:custom_root, {:controller => "controller"})).to be_a(RailsAdmin::Config::Actions::Base)
47
47
  end
48
48
 
49
- it 'should check bindings[:abstract_model] visibility while checking action\'s visibility' do
49
+ it "checks bindings[:abstract_model] visibility while checking action\'s visibility" do
50
50
  RailsAdmin.config Team do
51
51
  hide
52
52
  end
@@ -55,7 +55,7 @@ describe RailsAdmin::Config::Actions do
55
55
  expect(RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Team)})).to be_nil
56
56
  end
57
57
 
58
- it 'should check bindings[:abstract_model] presence while checking action\'s visibility' do
58
+ it "checks bindings[:abstract_model] presence while checking action\'s visibility" do
59
59
  RailsAdmin.config do |config|
60
60
  config.excluded_models << Team
61
61
  end
@@ -64,8 +64,8 @@ describe RailsAdmin::Config::Actions do
64
64
  end
65
65
  end
66
66
 
67
- describe 'all' do
68
- it 'should return all defined actions' do
67
+ describe "all" do
68
+ it "returns all defined actions" do
69
69
  RailsAdmin.config do |config|
70
70
  config.actions do
71
71
  dashboard
@@ -76,7 +76,7 @@ describe RailsAdmin::Config::Actions do
76
76
  expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index])
77
77
  end
78
78
 
79
- it 'should restrict by scope' do
79
+ it "restricts by scope" do
80
80
  RailsAdmin.config do |config|
81
81
  config.actions do
82
82
  root :custom_root
@@ -89,7 +89,7 @@ describe RailsAdmin::Config::Actions do
89
89
  expect(RailsAdmin::Config::Actions.all(:member).map(&:key)).to eq([:custom_member])
90
90
  end
91
91
 
92
- it 'should return all visible actions passing binding if controller binding is given, and pass all actions if no' do
92
+ it "returns all visible actions passing binding if controller binding is given, and pass all actions if no" do
93
93
  RailsAdmin.config do |config|
94
94
  config.actions do
95
95
  root :custom_root do
@@ -106,7 +106,7 @@ describe RailsAdmin::Config::Actions do
106
106
  end
107
107
 
108
108
  describe "customized through DSL" do
109
- it 'should add the one asked' do
109
+ it "adds the one asked" do
110
110
  RailsAdmin.config do |config|
111
111
  config.actions do
112
112
  dashboard
@@ -118,7 +118,7 @@ describe RailsAdmin::Config::Actions do
118
118
  expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index, :show])
119
119
  end
120
120
 
121
- it 'should allow to customize the custom_key when customizing an existing action' do
121
+ it "allows to customize the custom_key when customizing an existing action" do
122
122
  RailsAdmin.config do |config|
123
123
  config.actions do
124
124
  dashboard do
@@ -130,7 +130,7 @@ describe RailsAdmin::Config::Actions do
130
130
  expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard])
131
131
  end
132
132
 
133
- it 'should allow to change the key and the custom_key when "subclassing" an existing action' do
133
+ it "allows to change the key and the custom_key when subclassing an existing action" do
134
134
  RailsAdmin.config do |config|
135
135
  config.actions do
136
136
  root :my_dashboard_key, :dashboard do
@@ -143,7 +143,7 @@ describe RailsAdmin::Config::Actions do
143
143
  expect(RailsAdmin::Config::Actions.all.map(&:class)).to eq([RailsAdmin::Config::Actions::Dashboard])
144
144
  end
145
145
 
146
- it 'should not add the same custom_key twice' do
146
+ it "does not add the same custom_key twice" do
147
147
  expect do
148
148
  RailsAdmin.config do |config|
149
149
  config.actions do
@@ -163,7 +163,7 @@ describe RailsAdmin::Config::Actions do
163
163
  end.to raise_error("Action index already exist. Please change its custom key")
164
164
  end
165
165
 
166
- it 'should add the same key with different custom key' do
166
+ it "adds the same key with different custom key" do
167
167
  RailsAdmin.config do |config|
168
168
  config.actions do
169
169
  dashboard