rails_admin 0.1.1 → 0.1.2
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.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- data/README.md +8 -57
- data/app/assets/stylesheets/rails_admin/base/{README → README.txt} +1 -1
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +4 -2
- data/app/assets/stylesheets/rails_admin/themes/cerulean/theming.css.scss +2 -2
- data/app/helpers/rails_admin/application_helper.rb +22 -28
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -1
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +1 -1
- data/lib/generators/rails_admin/install_generator.rb +4 -3
- data/lib/rails_admin/adapters/mongoid.rb +2 -1
- data/lib/rails_admin/engine.rb +1 -0
- data/lib/rails_admin/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +4 -4
- data/spec/controllers/main_controller_spec.rb +26 -26
- data/spec/dummy_app/config/routes.rb +1 -1
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +161818 -0
- data/spec/helpers/application_helper_spec.rb +46 -46
- data/spec/helpers/form_builder_spec.rb +2 -2
- data/spec/integration/authorization/cancan_spec.rb +22 -22
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +6 -6
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +16 -16
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +1 -1
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +6 -6
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +8 -8
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +10 -10
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +16 -16
- data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +3 -3
- data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +2 -2
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +1 -2
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +27 -27
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +45 -45
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +35 -38
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +2 -2
- data/spec/integration/history/rails_admin_history_spec.rb +9 -9
- data/spec/integration/rails_admin_spec.rb +4 -4
- data/spec/integration/relation_spec.rb +3 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/unit/abstract_model_spec.rb +10 -10
- data/spec/unit/active_record_extension_spec.rb +1 -1
- data/spec/unit/adapters/active_record/abstract_object_spec.rb +24 -24
- data/spec/unit/adapters/active_record_spec.rb +131 -132
- data/spec/unit/adapters/mongoid/abstract_object_spec.rb +5 -5
- data/spec/unit/adapters/mongoid_spec.rb +180 -180
- data/spec/unit/config/actions/base_spec.rb +6 -6
- data/spec/unit/config/actions_spec.rb +31 -32
- data/spec/unit/config/fields/base_spec.rb +69 -70
- data/spec/unit/config/fields/date_spec.rb +5 -5
- data/spec/unit/config/fields/datetime_spec.rb +4 -4
- data/spec/unit/config/fields/time_spec.rb +3 -3
- data/spec/unit/config/fields/timestamp_spec.rb +1 -1
- data/spec/unit/config/model_spec.rb +12 -12
- data/spec/unit/config/sections_spec.rb +17 -17
- data/spec/unit/config_spec.rb +23 -24
- data/spec/unit/support/csv_converter_spec.rb +2 -2
- metadata +19 -3
@@ -45,8 +45,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
45
45
|
|
46
46
|
it "should show all by default" do
|
47
47
|
visit index_path(:model_name => "fan")
|
48
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
49
|
-
|
48
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
49
|
+
to match_array ["Id", "Created at", "Updated at", "His Name", "Teams"]
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should hide some fields on demand with a block" do
|
@@ -58,8 +58,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
visit index_path(:model_name => "fan")
|
61
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
62
|
-
|
61
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
62
|
+
to match_array ["Id", "His Name", "Teams"]
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should hide some fields on demand with fields list" do
|
@@ -69,8 +69,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
visit index_path(:model_name => "fan")
|
72
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
73
|
-
|
72
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
73
|
+
to match_array ["Id", "His Name", "Teams"]
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should add some fields on demand with a block" do
|
@@ -82,8 +82,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
visit index_path(:model_name => "fan")
|
85
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
86
|
-
|
85
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
86
|
+
to match_array ["Id", "His Name", "Teams"]
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should show some fields on demand with fields list, respect ordering and configure them" do
|
@@ -97,9 +97,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
visit index_path(:model_name => "fan")
|
100
|
-
|
101
|
-
|
102
|
-
should =~ ["Modified Id", "Modified His Name"]
|
100
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
101
|
+
to match_array ["Modified Id", "Modified His Name"]
|
103
102
|
end
|
104
103
|
|
105
104
|
it "should show all fields if asked" do
|
@@ -111,9 +110,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
111
110
|
end
|
112
111
|
end
|
113
112
|
visit index_path(:model_name => "fan")
|
114
|
-
|
115
|
-
|
116
|
-
should =~ ["Id", "Created at", "Updated at", "His Name", "Teams"]
|
113
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
114
|
+
to match_array ["Id", "Created at", "Updated at", "His Name", "Teams"]
|
117
115
|
end
|
118
116
|
|
119
117
|
it "should appear in order defined" do
|
@@ -126,9 +124,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
126
124
|
end
|
127
125
|
end
|
128
126
|
visit index_path(:model_name => "fan")
|
129
|
-
|
130
|
-
|
131
|
-
should == ["Updated at", "His Name", "Id", "Created at"]
|
127
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
128
|
+
to eq(["Updated at", "His Name", "Id", "Created at"])
|
132
129
|
end
|
133
130
|
|
134
131
|
it "should only list the defined fields if some fields are defined" do
|
@@ -139,8 +136,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
139
136
|
end
|
140
137
|
end
|
141
138
|
visit index_path(:model_name => "fan")
|
142
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
143
|
-
|
139
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
140
|
+
to eq(["Id", "His Name"])
|
144
141
|
should have_no_selector("th:nth-child(4).header")
|
145
142
|
end
|
146
143
|
|
@@ -151,7 +148,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
151
148
|
end
|
152
149
|
end
|
153
150
|
visit index_path(:model_name => "fan")
|
154
|
-
find("th:nth-child(2)").
|
151
|
+
expect(find("th:nth-child(2)")).to have_content("His Name")
|
155
152
|
end
|
156
153
|
|
157
154
|
it "should be renameable" do
|
@@ -164,8 +161,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
164
161
|
end
|
165
162
|
end
|
166
163
|
visit index_path(:model_name => "fan")
|
167
|
-
find("th:nth-child(2)").
|
168
|
-
find("th:nth-child(3)").
|
164
|
+
expect(find("th:nth-child(2)")).to have_content("Identifier")
|
165
|
+
expect(find("th:nth-child(3)")).to have_content("His Name")
|
169
166
|
end
|
170
167
|
|
171
168
|
it "should be renameable by type" do
|
@@ -177,8 +174,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
177
174
|
end
|
178
175
|
end
|
179
176
|
visit index_path(:model_name => "fan")
|
180
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
181
|
-
|
177
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
178
|
+
to match_array ["Id", "Created at (datetime)", "Updated at (datetime)", "His Name", "Teams"]
|
182
179
|
end
|
183
180
|
|
184
181
|
it "should be globally renameable by type" do
|
@@ -190,8 +187,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
190
187
|
end
|
191
188
|
end
|
192
189
|
visit index_path(:model_name => "fan")
|
193
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
194
|
-
|
190
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
191
|
+
to match_array ["Id", "Created at (datetime)", "Updated at (datetime)", "His Name", "Teams"]
|
195
192
|
end
|
196
193
|
|
197
194
|
it "should be sortable by default" do
|
@@ -263,8 +260,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
263
260
|
end
|
264
261
|
end
|
265
262
|
visit index_path(:model_name => "fan")
|
266
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
267
|
-
|
263
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
264
|
+
to match_array ["Id", "His Name", "Teams"]
|
268
265
|
end
|
269
266
|
|
270
267
|
it "should have option to hide fields by type globally" do
|
@@ -276,8 +273,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
276
273
|
end
|
277
274
|
end
|
278
275
|
visit index_path(:model_name => "fan")
|
279
|
-
all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }.
|
280
|
-
|
276
|
+
expect(all("th").map(&:text).delete_if{|t| /^\n*$/ =~ t }).
|
277
|
+
to match_array ["Id", "His Name", "Teams"]
|
281
278
|
end
|
282
279
|
|
283
280
|
it "should have option to customize column width" do
|
@@ -293,8 +290,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
293
290
|
end
|
294
291
|
@fans = 2.times.map { FactoryGirl.create :fan }
|
295
292
|
visit index_path(:model_name => "fan")
|
296
|
-
find('style').
|
297
|
-
find('style').
|
293
|
+
expect(find('style')).to have_content("#list th.#{PK_COLUMN}_field")
|
294
|
+
expect(find('style')).to have_content("#list td.#{PK_COLUMN}_field")
|
298
295
|
end
|
299
296
|
|
300
297
|
it "should have option to customize output formatting" do
|
@@ -312,8 +309,8 @@ describe "RailsAdmin Config DSL List Section" do
|
|
312
309
|
end
|
313
310
|
@fans = 2.times.map { FactoryGirl.create :fan }
|
314
311
|
visit index_path(:model_name => "fan")
|
315
|
-
find('tbody tr:nth-child(1) td:nth-child(3)').
|
316
|
-
find('tbody tr:nth-child(2) td:nth-child(3)').
|
312
|
+
expect(find('tbody tr:nth-child(1) td:nth-child(3)')).to have_content(@fans[1].name.upcase)
|
313
|
+
expect(find('tbody tr:nth-child(2) td:nth-child(3)')).to have_content(@fans[0].name.upcase)
|
317
314
|
end
|
318
315
|
|
319
316
|
it "should have a simple option to customize output formatting of date fields" do
|
@@ -359,7 +356,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
359
356
|
@team = FactoryGirl.create :team
|
360
357
|
@players = 2.times.map { FactoryGirl.create :player, :team => @team }
|
361
358
|
visit index_path(:model_name => "team")
|
362
|
-
find('tbody tr:nth-child(1) td:nth-child(4)').
|
359
|
+
expect(find('tbody tr:nth-child(1) td:nth-child(4)')).to have_content(@players.collect(&:name).join(", "))
|
363
360
|
end
|
364
361
|
end
|
365
362
|
|
@@ -395,7 +392,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
395
392
|
end
|
396
393
|
visit index_path(:model_name => "player")
|
397
394
|
player_names_by_date.reverse.each_with_index do |name, i|
|
398
|
-
find("tbody tr:nth-child(#{i + 1})").
|
395
|
+
expect(find("tbody tr:nth-child(#{i + 1})")).to have_content(name)
|
399
396
|
end
|
400
397
|
end
|
401
398
|
end
|
@@ -408,7 +405,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
408
405
|
end
|
409
406
|
visit index_path(:model_name => "player")
|
410
407
|
player_names_by_date.reverse.each_with_index do |name, i|
|
411
|
-
find("tbody tr:nth-child(#{i + 1})").
|
408
|
+
expect(find("tbody tr:nth-child(#{i + 1})")).to have_content(name)
|
412
409
|
end
|
413
410
|
end
|
414
411
|
|
@@ -421,7 +418,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
421
418
|
end
|
422
419
|
visit index_path(:model_name => "player")
|
423
420
|
player_names_by_date.each_with_index do |name, i|
|
424
|
-
find("tbody tr:nth-child(#{i + 1})").
|
421
|
+
expect(find("tbody tr:nth-child(#{i + 1})")).to have_content(name)
|
425
422
|
end
|
426
423
|
end
|
427
424
|
end
|
@@ -23,11 +23,11 @@ describe "RailsAdmin Config DSL Show Section" do
|
|
23
23
|
let(:body) { page.body }
|
24
24
|
|
25
25
|
it 'should create a JSON uri' do
|
26
|
-
uri.
|
26
|
+
expect(uri).to eq("/admin/player/#{@player.id}.json")
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should contain the JSONified object' do
|
30
|
-
body.
|
30
|
+
expect(body).to include(@player.to_json)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -14,15 +14,15 @@ describe "RailsAdmin History", :active_record => true do
|
|
14
14
|
|
15
15
|
it "should fetch one page of history" do
|
16
16
|
histories = RailsAdmin::History.history_for_model @model, nil, false, false, false, nil, 20
|
17
|
-
histories.total_count.
|
18
|
-
histories.count.
|
17
|
+
expect(histories.total_count).to eq(30)
|
18
|
+
expect(histories.count).to eq(20)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should respect RailsAdmin::Config.default_items_per_page" do
|
22
22
|
RailsAdmin.config.default_items_per_page = 15
|
23
23
|
histories = RailsAdmin::History.history_for_model @model, nil, false, false, false, nil
|
24
|
-
histories.total_count.
|
25
|
-
histories.count.
|
24
|
+
expect(histories.total_count).to eq(30)
|
25
|
+
expect(histories.count).to eq(15)
|
26
26
|
end
|
27
27
|
|
28
28
|
context "with Kaminari" do
|
@@ -55,8 +55,8 @@ describe "RailsAdmin History", :active_record => true do
|
|
55
55
|
# test that no link uses the "wildcard route" with the history
|
56
56
|
# controller and for_model method
|
57
57
|
it "should not use the 'wildcard route'" do
|
58
|
-
page.
|
59
|
-
page.
|
58
|
+
expect(page).to have_selector("a[href*='all=true']") # make sure we're fully testing pagination
|
59
|
+
expect(page).to have_no_selector("a[href^='/rails_admin/history/for_model']")
|
60
60
|
end
|
61
61
|
|
62
62
|
context "with a lot of histories" do
|
@@ -69,13 +69,13 @@ describe "RailsAdmin History", :active_record => true do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should get latest ones' do
|
72
|
-
RailsAdmin::History.latest.count.
|
72
|
+
expect(RailsAdmin::History.latest.count).to eq(100)
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should get latest ones orderly' do
|
76
76
|
latest = RailsAdmin::History.latest
|
77
|
-
latest.first.message.
|
78
|
-
latest.last.message.
|
77
|
+
expect(latest.first.message).to eq("change 100")
|
78
|
+
expect(latest.last.message).to eq("change 1")
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should render a XHR request successfully" do
|
@@ -41,7 +41,7 @@ describe "RailsAdmin" do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'hidden fields with default values' do
|
44
|
-
|
44
|
+
|
45
45
|
before (:each) do
|
46
46
|
RailsAdmin.config Player do
|
47
47
|
include_all_fields
|
@@ -54,17 +54,17 @@ describe "RailsAdmin" do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "should show 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
64
|
it "should not show label" do
|
65
65
|
should_not have_selector("label", :text => "Name")
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should not show help block" do
|
69
69
|
should_not have_xpath("id('player_name')/../p[@class='help-block']")
|
70
70
|
end
|
@@ -17,19 +17,19 @@ describe 'table relations' do
|
|
17
17
|
|
18
18
|
describe 'column with nullable fk and no model validations' do
|
19
19
|
it 'should be optional' do
|
20
|
-
@fields.find{ |f| f.name == :league }.required
|
20
|
+
expect(@fields.find{ |f| f.name == :league }.required?).to be_false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'column with non-nullable fk and no model validations' do
|
25
25
|
it 'should not be required' do
|
26
|
-
@fields.find{ |f| f.name == :division }.required
|
26
|
+
expect(@fields.find{ |f| f.name == :division }.required?).to be_false
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'column with nullable fk and a numericality model validation' do
|
31
31
|
it 'should be required' do
|
32
|
-
@fields.find{ |f| f.name == :player }.required
|
32
|
+
expect(@fields.find{ |f| f.name == :player }.required?).to be_true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,11 +14,11 @@ describe RailsAdmin::AbstractModel do
|
|
14
14
|
FactoryGirl.create(:field_test, :date_field => Date.strptime("01/02/2012", date_format))
|
15
15
|
FactoryGirl.create(:field_test, :date_field => Date.strptime("01/03/2012", date_format))
|
16
16
|
FactoryGirl.create(:field_test, :date_field => Date.strptime("01/04/2012", date_format))
|
17
|
-
@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } ).count.
|
18
|
-
@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/02/2012"], :o => 'between' } } } ).count.
|
19
|
-
@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).count.
|
20
|
-
@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).count.
|
21
|
-
@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).count.
|
17
|
+
expect(@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } ).count).to eq(2)
|
18
|
+
expect(@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/02/2012"], :o => 'between' } } } ).count).to eq(1)
|
19
|
+
expect(@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).count).to eq(2)
|
20
|
+
expect(@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).count).to eq(2)
|
21
|
+
expect(@abstract_model.all(:filters => { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).count).to eq(1)
|
22
22
|
|
23
23
|
end
|
24
24
|
end
|
@@ -34,11 +34,11 @@ describe RailsAdmin::AbstractModel do
|
|
34
34
|
else
|
35
35
|
FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 4, 0, 0, 0))
|
36
36
|
end
|
37
|
-
@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } ).count.
|
38
|
-
@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/02/2012"], :o => 'between' } } } ).count.
|
39
|
-
@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).count.
|
40
|
-
@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).count.
|
41
|
-
@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).count.
|
37
|
+
expect(@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } ).count).to eq(2)
|
38
|
+
expect(@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/02/2012"], :o => 'between' } } } ).count).to eq(1)
|
39
|
+
expect(@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } ).count).to eq(2)
|
40
|
+
expect(@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } ).count).to eq(2)
|
41
|
+
expect(@abstract_model.all(:filters => { "datetime_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } ).count).to eq(1)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -10,7 +10,7 @@ describe 'ActiveRecord::Base', :active_record => true do
|
|
10
10
|
@player.should_receive(:read_attribute).exactly(1).times do |*args|
|
11
11
|
original_method.call(*args)
|
12
12
|
end
|
13
|
-
@player.safe_send(:number).
|
13
|
+
expect(@player.safe_send(:number)).to eq(23)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -25,15 +25,15 @@ describe "AbstractObject", :active_record => true do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should create a Player with given attributes" do
|
28
|
-
object.save.
|
28
|
+
expect(object.save).to be_true
|
29
29
|
|
30
30
|
player.reload
|
31
|
-
player.name.
|
32
|
-
player.number.
|
33
|
-
player.position.
|
34
|
-
player.suspended.
|
35
|
-
player.draft.
|
36
|
-
player.team.
|
31
|
+
expect(player.name).to eq(name)
|
32
|
+
expect(player.number).to eq(number)
|
33
|
+
expect(player.position).to eq(position)
|
34
|
+
expect(player.suspended).to be_false
|
35
|
+
expect(player.draft).to be_nil
|
36
|
+
expect(player.team).to be_nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -46,15 +46,15 @@ describe "AbstractObject", :active_record => true do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should create a Player with given attributes" do
|
49
|
-
object.save.
|
49
|
+
expect(object.save).to be_true
|
50
50
|
|
51
51
|
player.reload
|
52
|
-
player.name.
|
53
|
-
player.number.
|
54
|
-
player.position.
|
55
|
-
player.suspended.
|
56
|
-
player.draft.
|
57
|
-
player.team.
|
52
|
+
expect(player.name).to eq(name)
|
53
|
+
expect(player.number).to eq(number)
|
54
|
+
expect(player.position).to eq(position)
|
55
|
+
expect(player.suspended).to be_false
|
56
|
+
expect(player.draft).to eq(draft.reload)
|
57
|
+
expect(player.team).to be_nil
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -70,10 +70,10 @@ describe "AbstractObject", :active_record => true do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should create a League with given attributes and associations" do
|
73
|
-
object.save.
|
73
|
+
expect(object.save).to be_true
|
74
74
|
league.reload
|
75
|
-
league.name.
|
76
|
-
league.divisions.
|
75
|
+
expect(league.name).to eq(name)
|
76
|
+
expect(league.divisions).to eq(divisions)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -96,11 +96,11 @@ describe "AbstractObject", :active_record => true do
|
|
96
96
|
|
97
97
|
it "should update a record and associations" do
|
98
98
|
object.reload
|
99
|
-
object.number.
|
100
|
-
object.name.
|
101
|
-
object.draft.
|
102
|
-
object.suspended.
|
103
|
-
object.team.
|
99
|
+
expect(object.number).to eq(new_number)
|
100
|
+
expect(object.name).to eq(name)
|
101
|
+
expect(object.draft).to be_nil
|
102
|
+
expect(object.suspended).to be_true
|
103
|
+
expect(object.team).to eq(new_team)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -114,7 +114,7 @@ describe "AbstractObject", :active_record => true do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should delete the record" do
|
117
|
-
Player.exists?(player.id).
|
117
|
+
expect(Player.exists?(player.id)).to be_false
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -126,7 +126,7 @@ describe "AbstractObject", :active_record => true do
|
|
126
126
|
|
127
127
|
@league = FactoryGirl.create :league
|
128
128
|
|
129
|
-
RailsAdmin.config('League').with(:object => @league).object_label.
|
129
|
+
expect(RailsAdmin.config('League').with(:object => @league).object_label).to eq("League '#{@league.name}'")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|