obitum-rails_admin 0.0.1 → 0.0.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.
Files changed (232) hide show
  1. data/Gemfile +1 -8
  2. data/README.md +6 -2
  3. data/app/assets/javascripts/rails_admin/custom/ui.js +5 -5
  4. data/app/assets/javascripts/rails_admin/jquery-ui-1.8.16.custom.js +4727 -4727
  5. data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -484
  6. data/app/assets/javascripts/rails_admin/jquery.pjax.js +250 -85
  7. data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1371 -1219
  8. data/app/assets/javascripts/rails_admin/ra.filter-box.js +30 -30
  9. data/app/assets/javascripts/rails_admin/ra.filtering-select.js +11 -11
  10. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +40 -0
  11. data/app/assets/javascripts/rails_admin/ra.remote-form.js +41 -39
  12. data/app/assets/javascripts/rails_admin/rails_admin.js.erb +4 -3
  13. data/app/assets/javascripts/rails_admin/themes/default/ui.js +6 -6
  14. data/app/assets/javascripts/rails_admin/ui.js.coffee +44 -16
  15. data/app/assets/stylesheets/rails_admin/base/README +2 -2
  16. data/app/assets/stylesheets/rails_admin/base/theming.css.scss +226 -113
  17. data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +1 -1
  18. data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +2 -2
  19. data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +3 -3
  20. data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +36 -1
  21. data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +16 -0
  22. data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +2 -2
  23. data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +1 -1
  24. data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +2 -2
  25. data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +3 -3
  26. data/app/controllers/rails_admin/application_controller.rb +13 -18
  27. data/app/controllers/rails_admin/main_controller.rb +15 -16
  28. data/app/helpers/rails_admin/application_helper.rb +67 -41
  29. data/app/helpers/rails_admin/form_builder.rb +31 -29
  30. data/app/helpers/rails_admin/main_helper.rb +4 -4
  31. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +12 -11
  32. data/app/views/layouts/rails_admin/application.html.haml +29 -29
  33. data/app/views/rails_admin/main/_dashboard_history.html.haml +1 -1
  34. data/app/views/rails_admin/main/_delete_notice.html.haml +4 -5
  35. data/app/views/rails_admin/main/_form_colorpicker.html.haml +2 -1
  36. data/app/views/rails_admin/main/_form_datetime.html.haml +1 -1
  37. data/app/views/rails_admin/main/_form_enumeration.html.haml +1 -1
  38. data/app/views/rails_admin/main/_form_field.html.haml +1 -1
  39. data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -2
  40. data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +6 -4
  41. data/app/views/rails_admin/main/_form_filtering_select.html.haml +6 -5
  42. data/app/views/rails_admin/main/_form_nested_many.html.haml +41 -6
  43. data/app/views/rails_admin/main/_form_nested_one.html.haml +34 -5
  44. data/app/views/rails_admin/main/_form_text.html.haml +3 -3
  45. data/app/views/rails_admin/main/_submit_buttons.html.haml +6 -4
  46. data/app/views/rails_admin/main/bulk_delete.html.haml +7 -3
  47. data/app/views/rails_admin/main/dashboard.html.haml +4 -4
  48. data/app/views/rails_admin/main/delete.html.haml +7 -3
  49. data/app/views/rails_admin/main/edit.html.haml +1 -1
  50. data/app/views/rails_admin/main/export.html.haml +57 -53
  51. data/app/views/rails_admin/main/history.html.haml +8 -8
  52. data/app/views/rails_admin/main/index.html.haml +22 -21
  53. data/app/views/rails_admin/main/new.html.haml +1 -1
  54. data/app/views/rails_admin/main/show.html.haml +2 -2
  55. data/config/initializers/active_record_extensions.rb +2 -2
  56. data/config/initializers/haml.rb +0 -1
  57. data/config/locales/rails_admin.en.yml +5 -5
  58. data/lib/generators/rails_admin/templates/initializer.erb +7 -7
  59. data/lib/rails_admin/abstract_model.rb +36 -53
  60. data/lib/rails_admin/adapters/active_record/abstract_object.rb +32 -0
  61. data/lib/rails_admin/adapters/active_record.rb +56 -137
  62. data/lib/rails_admin/config/actions/base.rb +40 -28
  63. data/lib/rails_admin/config/actions/bulk_delete.rb +10 -11
  64. data/lib/rails_admin/config/actions/dashboard.rb +9 -5
  65. data/lib/rails_admin/config/actions/delete.rb +12 -9
  66. data/lib/rails_admin/config/actions/edit.rb +13 -9
  67. data/lib/rails_admin/config/actions/export.rb +9 -6
  68. data/lib/rails_admin/config/actions/history_index.rb +9 -5
  69. data/lib/rails_admin/config/actions/history_show.rb +9 -5
  70. data/lib/rails_admin/config/actions/index.rb +23 -13
  71. data/lib/rails_admin/config/actions/new.rb +14 -10
  72. data/lib/rails_admin/config/actions/show.rb +10 -5
  73. data/lib/rails_admin/config/actions/show_in_app.rb +9 -4
  74. data/lib/rails_admin/config/actions.rb +16 -16
  75. data/lib/rails_admin/config/configurable.rb +92 -0
  76. data/lib/rails_admin/config/fields/association.rb +6 -23
  77. data/lib/rails_admin/config/fields/base.rb +58 -40
  78. data/lib/rails_admin/config/fields/factories/belongs_to_association.rb +26 -0
  79. data/lib/rails_admin/config/fields/factories/carrierwave.rb +21 -2
  80. data/lib/rails_admin/config/fields/factories/devise.rb +9 -12
  81. data/lib/rails_admin/config/fields/factories/dragonfly.rb +13 -7
  82. data/lib/rails_admin/config/fields/factories/paperclip.rb +14 -15
  83. data/lib/rails_admin/config/fields/group.rb +16 -3
  84. data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
  85. data/lib/rails_admin/config/fields/types/carrierwave.rb +0 -9
  86. data/lib/rails_admin/config/fields/types/color.rb +3 -3
  87. data/lib/rails_admin/config/fields/types/dragonfly.rb +1 -19
  88. data/lib/rails_admin/config/fields/types/file_upload.rb +7 -11
  89. data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -6
  90. data/lib/rails_admin/config/fields/types/has_one_association.rb +4 -4
  91. data/lib/rails_admin/config/fields/types/paperclip.rb +0 -18
  92. data/lib/rails_admin/config/fields/types/password.rb +2 -2
  93. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +2 -2
  94. data/lib/rails_admin/config/fields/types/text.rb +2 -2
  95. data/lib/rails_admin/config/fields.rb +7 -17
  96. data/lib/rails_admin/config/has_fields.rb +9 -9
  97. data/lib/rails_admin/config/has_groups.rb +2 -2
  98. data/lib/rails_admin/config/hideable.rb +2 -2
  99. data/lib/rails_admin/config/model.rb +23 -17
  100. data/lib/rails_admin/config/proxyable/proxy.rb +43 -0
  101. data/lib/rails_admin/config/proxyable.rb +12 -0
  102. data/lib/rails_admin/config/sections/base.rb +14 -4
  103. data/lib/rails_admin/config.rb +38 -9
  104. data/lib/rails_admin/extension.rb +1 -1
  105. data/lib/rails_admin/extensions/history/auditing_adapter.rb +6 -6
  106. data/lib/rails_admin/extensions/history/history.rb +2 -1
  107. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +13 -13
  108. data/lib/rails_admin/support/csv_converter.rb +6 -6
  109. data/lib/rails_admin/version.rb +1 -1
  110. data/lib/rails_admin.rb +0 -5
  111. data/spec/controllers/main_controller_spec.rb +7 -7
  112. data/spec/dummy_app/Gemfile +10 -7
  113. data/spec/dummy_app/Rakefile +1 -1
  114. data/spec/dummy_app/app/assets/images/rails.png +0 -0
  115. data/spec/dummy_app/app/assets/javascripts/application.js +15 -0
  116. data/spec/dummy_app/app/assets/stylesheets/application.css +13 -0
  117. data/spec/dummy_app/app/controllers/players_controller.rb +1 -1
  118. data/spec/dummy_app/app/models/cms/basic_page.rb +1 -1
  119. data/spec/dummy_app/app/models/division.rb +5 -1
  120. data/spec/dummy_app/app/models/field_test.rb +4 -4
  121. data/spec/dummy_app/app/models/nested_field_test.rb +3 -0
  122. data/spec/dummy_app/app/models/player.rb +3 -3
  123. data/spec/dummy_app/app/views/layouts/application.html.erb +3 -2
  124. data/spec/dummy_app/app/views/players/show.html.haml +1 -1
  125. data/spec/dummy_app/config/application.rb +20 -5
  126. data/spec/dummy_app/config/database.yml +5 -2
  127. data/spec/dummy_app/config/environments/development.rb +11 -1
  128. data/spec/dummy_app/config/environments/production.rb +19 -3
  129. data/spec/dummy_app/config/environments/test.rb +5 -7
  130. data/spec/dummy_app/config/initializers/devise.rb +6 -0
  131. data/spec/dummy_app/config/initializers/inflections.rb +5 -0
  132. data/spec/dummy_app/config/initializers/secret_token.rb +1 -1
  133. data/spec/dummy_app/{foo/test/dummy/config → config}/initializers/wrap_parameters.rb +1 -1
  134. data/spec/dummy_app/config/routes.rb +1 -1
  135. data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +35 -5
  136. data/spec/dummy_app/db/migrate/20120118122004_add_categories.rb +1 -1
  137. data/spec/dummy_app/doc/README_FOR_APP +2 -0
  138. data/spec/dummy_app/public/404.html +26 -0
  139. data/spec/dummy_app/{foo/test/dummy/public → public}/422.html +0 -0
  140. data/spec/dummy_app/{foo/test/dummy/public → public}/500.html +0 -1
  141. data/spec/dummy_app/public/favicon.ico +0 -0
  142. data/spec/dummy_app/public/robots.txt +5 -0
  143. data/spec/helpers/application_helper_spec.rb +107 -42
  144. data/spec/{requests → integration}/authorization/cancan_spec.rb +4 -5
  145. data/spec/{requests → integration}/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +0 -0
  146. data/spec/{requests → integration}/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +3 -16
  147. data/spec/{requests → integration}/basic/create/rails_admin_basic_create_spec.rb +0 -2
  148. data/spec/{requests → integration}/basic/create/rails_admin_namespaced_model_create_spec.rb +0 -16
  149. data/spec/{requests → integration}/basic/delete/rails_admin_basic_delete_spec.rb +0 -0
  150. data/spec/{requests → integration}/basic/destroy/rails_admin_basic_destroy_spec.rb +0 -0
  151. data/spec/{requests → integration}/basic/edit/rails_admin_basic_edit_spec.rb +2 -2
  152. data/spec/{requests → integration}/basic/export/rails_admin_basic_export_spec.rb +1 -1
  153. data/spec/{requests → integration}/basic/list/rails_admin_basic_list_spec.rb +12 -38
  154. data/spec/{requests → integration}/basic/new/rails_admin_basic_new_spec.rb +0 -0
  155. data/spec/{requests → integration}/basic/new/rails_admin_namespaced_model_new_spec.rb +0 -0
  156. data/spec/{requests → integration}/basic/show/rails_admin_basic_show_spec.rb +1 -2
  157. data/spec/{requests → integration}/basic/update/rails_admin_basic_update_spec.rb +2 -2
  158. data/spec/{requests → integration}/config/edit/rails_admin_config_edit_spec.rb +65 -24
  159. data/spec/{requests → integration}/config/list/rails_admin_config_list_spec.rb +2 -2
  160. data/spec/{requests → integration}/config/show/rails_admin_config_show_spec.rb +20 -0
  161. data/spec/{requests → integration}/history/rails_admin_history_spec.rb +3 -3
  162. data/spec/{requests → integration}/rails_admin_spec.rb +8 -41
  163. data/spec/{requests → integration}/relation_spec.rb +0 -0
  164. data/spec/spec_helper.rb +13 -31
  165. data/spec/{lib → unit/adapters/active_record}/abstract_object_spec.rb +17 -5
  166. data/spec/unit/adapters/active_record_spec.rb +53 -0
  167. data/spec/{requests/actions.rb → unit/config/actions_spec.rb} +47 -31
  168. data/spec/unit/config/fields/base_spec.rb +291 -0
  169. data/spec/unit/config/model_spec.rb +75 -0
  170. data/spec/unit/config/sections_spec.rb +123 -0
  171. data/spec/{lib/rails_admin_spec.rb → unit/config_spec.rb} +65 -93
  172. metadata +127 -223
  173. data/app/assets/javascripts/rails_admin/jquery_nested_form.js +0 -58
  174. data/app/views/layouts/rails_admin/_navigation.html.haml +0 -17
  175. data/lib/rails_admin/abstract_object.rb +0 -28
  176. data/lib/rails_admin/config/base.rb +0 -111
  177. data/lib/rails_admin/config/proxy.rb +0 -40
  178. data/lib/rails_admin/generic_support.rb +0 -18
  179. data/spec/dummy_app/config/initializers/quiet_assets.rb +0 -10
  180. data/spec/dummy_app/foo/Gemfile +0 -17
  181. data/spec/dummy_app/foo/MIT-LICENSE +0 -20
  182. data/spec/dummy_app/foo/README.rdoc +0 -3
  183. data/spec/dummy_app/foo/Rakefile +0 -39
  184. data/spec/dummy_app/foo/app/assets/javascripts/foo/application.js +0 -9
  185. data/spec/dummy_app/foo/app/assets/stylesheets/foo/application.css +0 -7
  186. data/spec/dummy_app/foo/app/controllers/foo/application_controller.rb +0 -4
  187. data/spec/dummy_app/foo/app/helpers/foo/application_helper.rb +0 -4
  188. data/spec/dummy_app/foo/app/models/foo/bar.rb +0 -4
  189. data/spec/dummy_app/foo/app/views/layouts/foo/application.html.erb +0 -14
  190. data/spec/dummy_app/foo/config/routes.rb +0 -2
  191. data/spec/dummy_app/foo/foo.gemspec +0 -23
  192. data/spec/dummy_app/foo/lib/foo/engine.rb +0 -5
  193. data/spec/dummy_app/foo/lib/foo/version.rb +0 -3
  194. data/spec/dummy_app/foo/lib/foo.rb +0 -4
  195. data/spec/dummy_app/foo/lib/tasks/foo_tasks.rake +0 -4
  196. data/spec/dummy_app/foo/script/rails +0 -6
  197. data/spec/dummy_app/foo/test/dummy/Rakefile +0 -7
  198. data/spec/dummy_app/foo/test/dummy/app/assets/javascripts/application.js +0 -9
  199. data/spec/dummy_app/foo/test/dummy/app/assets/stylesheets/application.css +0 -7
  200. data/spec/dummy_app/foo/test/dummy/app/controllers/application_controller.rb +0 -3
  201. data/spec/dummy_app/foo/test/dummy/app/helpers/application_helper.rb +0 -2
  202. data/spec/dummy_app/foo/test/dummy/app/views/layouts/application.html.erb +0 -14
  203. data/spec/dummy_app/foo/test/dummy/config/application.rb +0 -45
  204. data/spec/dummy_app/foo/test/dummy/config/boot.rb +0 -10
  205. data/spec/dummy_app/foo/test/dummy/config/database.yml +0 -25
  206. data/spec/dummy_app/foo/test/dummy/config/environment.rb +0 -5
  207. data/spec/dummy_app/foo/test/dummy/config/environments/development.rb +0 -30
  208. data/spec/dummy_app/foo/test/dummy/config/environments/production.rb +0 -60
  209. data/spec/dummy_app/foo/test/dummy/config/environments/test.rb +0 -39
  210. data/spec/dummy_app/foo/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  211. data/spec/dummy_app/foo/test/dummy/config/initializers/inflections.rb +0 -10
  212. data/spec/dummy_app/foo/test/dummy/config/initializers/mime_types.rb +0 -5
  213. data/spec/dummy_app/foo/test/dummy/config/initializers/secret_token.rb +0 -7
  214. data/spec/dummy_app/foo/test/dummy/config/initializers/session_store.rb +0 -8
  215. data/spec/dummy_app/foo/test/dummy/config/locales/en.yml +0 -5
  216. data/spec/dummy_app/foo/test/dummy/config/routes.rb +0 -4
  217. data/spec/dummy_app/foo/test/dummy/config.ru +0 -4
  218. data/spec/dummy_app/foo/test/dummy/db/schema.rb +0 -21
  219. data/spec/dummy_app/foo/test/dummy/public/404.html +0 -26
  220. data/spec/dummy_app/foo/test/dummy/public/favicon.ico +0 -0
  221. data/spec/dummy_app/foo/test/dummy/script/rails +0 -6
  222. data/spec/dummy_app/foo/test/fixtures/foo/bars.yml +0 -11
  223. data/spec/dummy_app/foo/test/foo_test.rb +0 -7
  224. data/spec/dummy_app/foo/test/integration/navigation_test.rb +0 -10
  225. data/spec/dummy_app/foo/test/test_helper.rb +0 -10
  226. data/spec/dummy_app/foo/test/unit/foo/bar_test.rb +0 -9
  227. data/spec/generator_helpers.rb +0 -30
  228. data/spec/generators/install_generator_spec.rb +0 -85
  229. data/spec/generators/uninstall_generator_spec.rb +0 -35
  230. data/spec/lib/custom_field.rb +0 -7
  231. data/spec/requests/config/navigation/rails_admin_config_navigation_spec.rb +0 -107
  232. data/spec/requests/config/rails_admin_config_spec.rb +0 -227
@@ -1,18 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RailsAdmin::ApplicationHelper do
4
-
5
- subject { page }
6
-
4
+
5
+ before do
6
+ controller.stub(:authorized?).and_return(true)
7
+ end
8
+
7
9
  describe '#current_action?' do
8
10
  it 'should return true if current_action, false otherwise' do
9
11
  @action = RailsAdmin::Config::Actions.find(:index)
10
-
12
+
11
13
  helper.current_action?(RailsAdmin::Config::Actions.find(:index)).should be_true
12
14
  helper.current_action?(RailsAdmin::Config::Actions.find(:show)).should_not be_true
13
15
  end
14
16
  end
15
-
17
+
16
18
  describe '#action' do
17
19
  it 'should return action by :custom_key' do
18
20
  RailsAdmin.config do |config|
@@ -22,10 +24,9 @@ describe RailsAdmin::ApplicationHelper do
22
24
  end
23
25
  end
24
26
  end
25
-
26
- helper.action(:my_custom_dashboard_key).should == RailsAdmin::Config::Actions.find(:my_custom_dashboard_key)
27
+ helper.action(:my_custom_dashboard_key).should be
27
28
  end
28
-
29
+
29
30
  it 'should return only visible actions' do
30
31
  RailsAdmin.config do |config|
31
32
  config.actions do
@@ -34,10 +35,10 @@ describe RailsAdmin::ApplicationHelper do
34
35
  end
35
36
  end
36
37
  end
37
-
38
+
38
39
  helper.action(:dashboard).should == nil
39
40
  end
40
-
41
+
41
42
  it 'should return only visible actions, passing all bindings' do
42
43
  RailsAdmin.config do |config|
43
44
  config.actions do
@@ -50,25 +51,22 @@ describe RailsAdmin::ApplicationHelper do
50
51
  end
51
52
  end
52
53
  end
53
-
54
- helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Team.new).should == RailsAdmin::Config::Actions.find(:test_bindings)
55
- helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Player.new).should == nil
56
- helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new).should == nil
54
+ helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Team.new).should be
55
+ helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Player.new).should be_nil
56
+ helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new).should be_nil
57
57
  end
58
58
  end
59
-
59
+
60
60
  describe "#actions" do
61
61
  it 'should return actions by type' do
62
62
  abstract_model = RailsAdmin::AbstractModel.new(Player)
63
63
  object = FactoryGirl.create :player
64
64
  helper.actions(:all, abstract_model, object).map(&:custom_key).should == [:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app]
65
- helper.actions(:all).map(&:custom_key).should == [:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index]
66
- helper.actions.map(&:custom_key).should == [:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index]
67
- helper.actions(:root).map(&:custom_key).should == [:dashboard]
68
- helper.actions(:collection).map(&:custom_key).should == [:index, :new, :export, :bulk_delete, :history_index]
69
- helper.actions(:member).map(&:custom_key).should == [:show, :edit, :delete, :history_show]
65
+ helper.actions(:root, abstract_model, object).map(&:custom_key).should == [:dashboard]
66
+ helper.actions(:collection, abstract_model, object).map(&:custom_key).should == [:index, :new, :export, :bulk_delete, :history_index]
67
+ helper.actions(:member, abstract_model, object).map(&:custom_key).should == [:show, :edit, :delete, :history_show, :show_in_app]
70
68
  end
71
-
69
+
72
70
  it 'should only return visible actions, passing bindings correctly' do
73
71
  RailsAdmin.config do |config|
74
72
  config.actions do
@@ -81,13 +79,13 @@ describe RailsAdmin::ApplicationHelper do
81
79
  end
82
80
  end
83
81
  end
84
-
82
+
85
83
  helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Team.new).map(&:custom_key).should == [:test_bindings]
86
84
  helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Player.new).map(&:custom_key).should == []
87
85
  helper.actions(:all, RailsAdmin::AbstractModel.new(Player), Team.new).map(&:custom_key).should == []
88
86
  end
89
87
  end
90
-
88
+
91
89
  describe "#wording_for" do
92
90
  it "gives correct wording even if action is not visible" do
93
91
  RailsAdmin.config do |config|
@@ -97,35 +95,33 @@ describe RailsAdmin::ApplicationHelper do
97
95
  end
98
96
  end
99
97
  end
100
-
98
+
101
99
  helper.wording_for(:menu, :index).should == "List"
102
100
  end
103
-
101
+
104
102
  it "passes correct bindings" do
105
103
  helper.wording_for(:title, :edit, RailsAdmin::AbstractModel.new(Team), Team.new(:name => 'the avengers')).should == "Edit Team 'the avengers'"
106
104
  end
107
-
105
+
108
106
  it "defaults correct bindings" do
109
107
  @action = RailsAdmin::Config::Actions.find :edit
110
108
  @abstract_model = RailsAdmin::AbstractModel.new(Team)
111
109
  @object = Team.new(:name => 'the avengers')
112
110
  helper.wording_for(:title).should == "Edit Team 'the avengers'"
113
111
  end
114
-
112
+
115
113
  it "does not try to use the wrong :label_metod" do
116
114
  @abstract_model = RailsAdmin::AbstractModel.new(Draft)
117
115
  @object = Draft.new
118
-
116
+
119
117
  helper.wording_for(:link, :new, RailsAdmin::AbstractModel.new(Team)).should == "Add a new Team"
120
118
  end
121
-
119
+
122
120
  end
123
-
121
+
124
122
  describe "#breadcrumb" do
125
- it "gives us a breadcrumb, dammit" do
126
- @action = RailsAdmin::Config::Actions.find :edit
127
- @abstract_model = RailsAdmin::AbstractModel.new(Team)
128
- @object = Team.new(:name => 'the avengers')
123
+ it "gives us a breadcrumb" do
124
+ @action = RailsAdmin::Config::Actions.find(:edit, {:abstract_model => RailsAdmin::AbstractModel.new(Team), :object => Team.new(:name => 'the avengers')})
129
125
  bc = helper.breadcrumb
130
126
  bc.should match /Dashboard/ # dashboard
131
127
  bc.should match /Teams/ # list
@@ -133,7 +129,7 @@ describe RailsAdmin::ApplicationHelper do
133
129
  bc.should match /Edit/ # current (edit)
134
130
  end
135
131
  end
136
-
132
+
137
133
  describe "#menu_for" do
138
134
  it 'passes model and object as bindings and generates a menu, excluding non-get actions' do
139
135
  RailsAdmin.config do |config|
@@ -154,7 +150,7 @@ describe RailsAdmin::ApplicationHelper do
154
150
  end
155
151
  end
156
152
  end
157
-
153
+
158
154
  @action = RailsAdmin::Config::Actions.find :show
159
155
  @abstract_model = RailsAdmin::AbstractModel.new(Team)
160
156
  @object = Team.new(:name => 'the avengers')
@@ -162,13 +158,13 @@ describe RailsAdmin::ApplicationHelper do
162
158
  helper.menu_for(:root).should match /Dashboard/
163
159
  helper.menu_for(:collection, @abstract_model).should match /List/
164
160
  helper.menu_for(:member, @abstract_model, @object).should match /Show/
165
-
161
+
166
162
  @abstract_model = RailsAdmin::AbstractModel.new(Player)
167
163
  @object = Player.new
168
164
  helper.menu_for(:collection, @abstract_model).should_not match /List/
169
165
  helper.menu_for(:member, @abstract_model, @object).should_not match /Show/
170
166
  end
171
-
167
+
172
168
  it "excludes non-get actions" do
173
169
  RailsAdmin.config do |config|
174
170
  config.actions do
@@ -177,12 +173,82 @@ describe RailsAdmin::ApplicationHelper do
177
173
  end
178
174
  end
179
175
  end
180
-
176
+
181
177
  @action = RailsAdmin::Config::Actions.find :dashboard
182
178
  helper.menu_for(:root).should_not match /Dashboard/
183
179
  end
184
180
  end
185
-
181
+
182
+ describe "#main_navigation" do
183
+ it 'should show included models' do
184
+ RailsAdmin.config do |config|
185
+ config.included_models = [Ball, Comment]
186
+ end
187
+ helper.main_navigation.should match /(nav\-header).*(Navigation).*(Balls).*(Comments)/m
188
+ end
189
+
190
+ it 'should not show unvisible models' do
191
+ RailsAdmin.config do |config|
192
+ config.included_models = [Ball, Comment]
193
+ config.model Comment do
194
+ hide
195
+ end
196
+ end
197
+ result = helper.main_navigation
198
+ result.should match /(nav\-header).*(Navigation).*(Balls)/m
199
+ result.should_not match "Comments"
200
+ end
201
+
202
+ it "should show children of hidden models" do # https://github.com/sferik/rails_admin/issues/978
203
+ RailsAdmin.config do |config|
204
+ config.included_models = [Ball, Hardball]
205
+ config.model Ball do
206
+ hide
207
+ end
208
+ end
209
+ helper.main_navigation.should match /(nav\-header).*(Navigation).*(Hardballs)/m
210
+ end
211
+
212
+ it "should show children of excluded models" do
213
+ RailsAdmin.config do |config|
214
+ config.included_models = [Hardball]
215
+ end
216
+ helper.main_navigation.should match /(nav\-header).*(Navigation).*(Hardballs)/m
217
+ end
218
+
219
+ it 'should "nest" in navigation label' do
220
+ RailsAdmin.config do |config|
221
+ config.included_models = [Comment]
222
+ config.model Comment do
223
+ navigation_label 'commentable'
224
+ end
225
+ end
226
+ helper.main_navigation.should match /(nav\-header).*(commentable).*(Comments)/m
227
+ end
228
+
229
+ it 'should "nest" in parent model' do
230
+ RailsAdmin.config do |config|
231
+ config.included_models = [Player, Comment]
232
+ config.model Comment do
233
+ parent Player
234
+ end
235
+ end
236
+ helper.main_navigation.should match /(Players).*(nav\-level\-1).*(Comments)/m
237
+ end
238
+
239
+ it 'should order' do
240
+ RailsAdmin.config do |config|
241
+ config.included_models = [Player, Comment]
242
+ end
243
+ helper.main_navigation.should match /(Comments).*(Players)/m
244
+
245
+ RailsAdmin.config(Comment) do
246
+ weight 1
247
+ end
248
+ helper.main_navigation.should match /(Players).*(Comments)/m
249
+ end
250
+ end
251
+
186
252
  describe "#bulk_menu" do
187
253
  it 'should include all visible bulkable actions' do
188
254
  RailsAdmin.config do |config|
@@ -201,7 +267,6 @@ describe RailsAdmin::ApplicationHelper do
201
267
  end
202
268
  end
203
269
  @action = RailsAdmin::Config::Actions.find :index
204
-
205
270
  result = helper.bulk_menu(RailsAdmin::AbstractModel.new(Team))
206
271
  result.should match "zorg_action"
207
272
  result.should match "blub"
@@ -209,4 +274,4 @@ describe RailsAdmin::ApplicationHelper do
209
274
  helper.bulk_menu(RailsAdmin::AbstractModel.new(Player)).should_not match "blub"
210
275
  end
211
276
  end
212
- end
277
+ end
@@ -77,7 +77,7 @@ describe "RailsAdmin CanCan Authorization" do
77
77
  ]
78
78
 
79
79
  visit index_path(:model_name => "player")
80
-
80
+
81
81
  should have_content(@players[0].name)
82
82
  should_not have_content(@players[1].name)
83
83
  should_not have_content("Add new")
@@ -112,7 +112,7 @@ describe "RailsAdmin CanCan Authorization" do
112
112
  should_not have_content("Delete")
113
113
 
114
114
  should have_content("Save and add another")
115
- fill_in "player[name]", :with => "Jackie Robinson"
115
+ fill_in "player[name]", :with => "Jackie Robinson"
116
116
  fill_in "player[number]", :with => "42"
117
117
  fill_in "player[position]", :with => "Second baseman"
118
118
  click_button "Save"
@@ -141,7 +141,6 @@ describe "RailsAdmin CanCan Authorization" do
141
141
  it "GET /admin/player/1/edit should render and update record upon submission" do
142
142
  @player = FactoryGirl.create :player
143
143
  visit edit_path(:model_name => "player", :id => @player.id)
144
-
145
144
  should have_content("Save and edit")
146
145
  should_not have_content("Save and add another")
147
146
  should_not have_content("Add new")
@@ -246,7 +245,7 @@ describe "RailsAdmin CanCan Authorization" do
246
245
  visit delete_path(:model_name => "player", :id => player_id)
247
246
 
248
247
  click_button "Yes, I'm sure"
249
-
248
+
250
249
  Player.exists?(player_id).should be_false
251
250
  end
252
251
 
@@ -347,4 +346,4 @@ describe "RailsAdmin CanCan Authorization" do
347
346
  end
348
347
  end
349
348
 
350
- end
349
+ end
@@ -5,7 +5,7 @@ describe "RailsAdmin Basic Bulk Destroy" do
5
5
  subject { page }
6
6
 
7
7
  describe "successful bulk delete of records" do
8
- before(:each) do
8
+ before do
9
9
  RailsAdmin::History.destroy_all
10
10
  RailsAdmin.config { |c| c.audit_with :history }
11
11
  @players = 3.times.map { FactoryGirl.create(:player) }
@@ -17,32 +17,19 @@ describe "RailsAdmin Basic Bulk Destroy" do
17
17
 
18
18
  it "should not contain deleted records" do
19
19
  RailsAdmin::AbstractModel.new("Player").count.should == 1
20
- end
21
-
22
- it "history count should be equal to number of deleted records" do
23
20
  RailsAdmin::History.count.should == @delete_ids.count
24
- end
25
-
26
- it "history items should be for proper table" do
27
21
  RailsAdmin::History.all.each do |history|
28
22
  history.table.should == "Player"
29
23
  end
30
- end
31
-
32
- it "history items should be for proper items" do
33
24
  RailsAdmin::History.all.each do |history|
34
25
  @delete_ids.should include(history.item)
35
26
  end
36
- end
37
-
38
- it "displays a flash notice stating the number of records destroyed" do
39
- # 2 Players because @delete_ids.count == 2:
40
- page.should have_selector(".alert-message", :text => "2 Players successfully deleted")
27
+ page.should have_selector(".alert-success", :text => "2 Players successfully deleted")
41
28
  end
42
29
  end
43
30
 
44
31
  describe "cancelled bulk_deletion" do
45
- before(:each) do
32
+ before do
46
33
  RailsAdmin::History.destroy_all
47
34
  @players = 3.times.map { FactoryGirl.create(:player) }
48
35
  @delete_ids = @players[0..1].map(&:id)
@@ -6,12 +6,10 @@ describe "RailsAdmin Basic Create" do
6
6
  describe "create" do
7
7
  before(:each) do
8
8
  visit new_path(:model_name => "player")
9
-
10
9
  fill_in "player[name]", :with => "Jackie Robinson"
11
10
  fill_in "player[number]", :with => "42"
12
11
  fill_in "player[position]", :with => "Second baseman"
13
12
  click_button "Save"
14
-
15
13
  @player = RailsAdmin::AbstractModel.new("Player").first
16
14
  end
17
15
 
@@ -21,19 +21,3 @@ describe "RailsAdmin Namespaced Model Create" do
21
21
  }.to change(Cms::BasicPage, :count).by(1)
22
22
  end
23
23
  end
24
-
25
-
26
- describe "RailsAdmin Mounted Engine Model Create" do
27
-
28
- subject { page }
29
-
30
- before(:each) do
31
- visit new_path(:model_name => "foo~bar")
32
- fill_in "foo_bar[title]", :with => "Hello"
33
- click_button "Save"
34
- end
35
-
36
- it 'should be successful' do
37
- Foo::Bar.first.title.should == 'Hello'
38
- end
39
- end
@@ -95,9 +95,9 @@ describe "RailsAdmin Basic Edit" do
95
95
  end
96
96
 
97
97
  end
98
-
98
+
99
99
  describe "clicking cancel when editing an object" do
100
-
100
+
101
101
  it "should send back to previous URL" do
102
102
  @ball = FactoryGirl.create :ball
103
103
  visit '/admin/ball?sort=color'
@@ -63,7 +63,7 @@ describe "RailsAdmin Export" do
63
63
  it "should allow to export to XML" do
64
64
  visit export_path(:model_name => 'player')
65
65
  click_button 'Export to xml'
66
-
66
+
67
67
  # spec fails on non 1.9 mri rubies because of this https://github.com/rails/rails/pull/2076
68
68
  # waiting for fix (rails-3.1.4?)
69
69
  should have_content @player.team.name if RUBY_VERSION =~ /1\.9/
@@ -11,25 +11,25 @@ describe "RailsAdmin Basic List" do
11
11
  visit dashboard_path
12
12
  end
13
13
  end
14
-
14
+
15
15
  describe "GET /admin/typo" do
16
16
  it "should redirect to dashboard and inform the user the model wasn't found" do
17
17
  visit '/admin/whatever'
18
18
  page.driver.status_code.should eql(404)
19
- find('.alert-message.error').should have_content("Model 'Whatever' could not be found")
19
+ find('.alert-error').should have_content("Model 'Whatever' could not be found")
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe "GET /admin/balls/545-typo" do
24
24
  it "should redirect to balls index and inform the user the id wasn't found" do
25
25
  visit '/admin/ball/545-typo'
26
26
  page.driver.status_code.should eql(404)
27
- find('.alert-message.error').should have_content("Ball with id '545-typo' could not be found")
27
+ find('.alert-error').should have_content("Ball with id '545-typo' could not be found")
28
28
  end
29
29
  end
30
30
 
31
31
  describe "GET /admin/player as list" do
32
- before(:each) do
32
+ before do
33
33
  21.times { FactoryGirl.create :player } # two pages of players
34
34
  visit index_path(:model_name => "player")
35
35
  end
@@ -38,52 +38,26 @@ describe "RailsAdmin Basic List" do
38
38
  should have_content("List of Players")
39
39
  should have_content("Created at")
40
40
  should have_content("Updated at")
41
- end
42
41
 
43
- it "shows the show, edit and delete links" do
42
+ # it "shows the show, edit and delete links" do
44
43
  should have_selector("td a", :text => 'Show')
45
44
  should have_selector("td a", :text => 'Edit')
46
45
  should have_selector("td a", :text => 'Delete')
47
- end
48
46
 
49
- it "has the search box with some prompt text" do
47
+ # it "has the search box with some prompt text" do
50
48
  should have_selector("input[placeholder='Filter']")
51
- end
52
49
 
53
- # https://github.com/sferik/rails_admin/issues/362
54
- # test that no link uses the "wildcard route" with the main
55
- # controller and list method
56
- it "should not use the 'wildcard route'" do
50
+ # https://github.com/sferik/rails_admin/issues/362
51
+ # test that no link uses the "wildcard route" with the main
52
+ # controller and list method
53
+ # it "should not use the 'wildcard route'" do
57
54
  should have_selector("a[href*='all=true']") # make sure we're fully testing pagination
58
55
  should have_no_selector("a[href^='/rails_admin/main/list']")
59
56
  end
60
57
  end
61
58
 
62
- describe "GET /admin/player with sort" do
63
- before(:each) do
64
- @players = 2.times.map { FactoryGirl.create :player }
65
- visit index_path(:model_name => "player", :sort => "name")
66
- end
67
-
68
- it "should be sorted correctly" do
69
- 2.times { |i| should have_selector("td", :text => /#{@players[i].name}/) }
70
- end
71
- end
72
-
73
- describe "GET /admin/player with reverse sort" do
74
-
75
- before(:each) do
76
- @players = 2.times.map { FactoryGirl.create :player }
77
- visit index_path(:model_name => "player", :sort => "name", :sort_reverse => "true")
78
- end
79
-
80
- it "should be sorted correctly" do
81
- 2.times { |i| should have_selector("td", :text => /#{@players.reverse[i].name}/) }
82
- end
83
- end
84
-
85
59
  describe "GET /admin/player" do
86
- before(:each) do
60
+ before do
87
61
  @teams = 2.times.map do
88
62
  FactoryGirl.create(:team)
89
63
  end
@@ -5,7 +5,6 @@ describe "RailsAdmin Basic Show" do
5
5
 
6
6
  describe "show" do
7
7
  before(:each) do
8
-
9
8
  @player = FactoryGirl.create :player
10
9
  visit show_path(:model_name => "player", :id => @player.id)
11
10
  end
@@ -27,7 +26,7 @@ describe "RailsAdmin Basic Show" do
27
26
  should have_content(@player.number)
28
27
  end
29
28
  end
30
-
29
+
31
30
  describe "GET /admin/players/123this-id-doesnt-exist" do
32
31
  it "should raise NotFound" do
33
32
  visit '/admin/players/123this-id-doesnt-exist'
@@ -85,7 +85,7 @@ describe "RailsAdmin Basic Update" do
85
85
  RailsAdmin.config do |c|
86
86
  c.audit_with :history
87
87
  end
88
-
88
+
89
89
  @league = FactoryGirl.create :league
90
90
  @divisions = 3.times.map { Division.create!(:name => "div #{Time.now.to_f}", :league => League.create!(:name => "league #{Time.now.to_f}")) }
91
91
 
@@ -97,7 +97,7 @@ describe "RailsAdmin Basic Update" do
97
97
  @league.divisions.should include(@divisions[0])
98
98
  @league.divisions.should_not include(@divisions[1])
99
99
  @league.divisions.should_not include(@divisions[2])
100
-
100
+
101
101
  RailsAdmin::History.where(:item => @league.id).collect(&:message).should include("Added Divisions ##{@divisions[0].id} associations, Changed name")
102
102
 
103
103
  page.driver.put edit_path(:model_name => "league", :id => @league.id, :league => {:division_ids => [""]})