rails_admin 0.4.6 → 0.4.7
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.tar.gz.sig +0 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +222 -218
- data/app/assets/javascripts/rails_admin/ui.coffee +7 -0
- data/app/assets/stylesheets/rails_admin/base/theming.scss +2 -1
- data/app/controllers/rails_admin/main_controller.rb +1 -1
- data/app/helpers/rails_admin/application_helper.rb +2 -1
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -1
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +2 -2
- data/app/views/rails_admin/main/_form_nested_many.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +6 -1
- data/lib/rails_admin/adapters/active_record.rb +4 -0
- data/lib/rails_admin/adapters/mongoid.rb +14 -6
- data/lib/rails_admin/config.rb +1 -1
- data/lib/rails_admin/config/fields/base.rb +20 -2
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +8 -0
- data/lib/rails_admin/config/fields/types/has_many_association.rb +4 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +9 -0
- data/lib/rails_admin/config/fields/types/serialized.rb +3 -1
- data/lib/rails_admin/config/model.rb +4 -0
- data/lib/rails_admin/version.rb +1 -1
- data/spec/controllers/rails_admin/main_controller_spec.rb +18 -0
- data/spec/dummy_app/app/mongoid/field_test.rb +2 -1
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +74 -0
- data/spec/rails_admin/adapters/mongoid_spec.rb +16 -4
- data/spec/rails_admin/config/fields/base_spec.rb +12 -0
- data/spec/rails_admin/config_spec.rb +15 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
@@ -68,3 +68,10 @@ $(document).on 'rails_admin.dom_ready', ->
|
|
68
68
|
$(this).siblings('.control-group').hide()
|
69
69
|
|
70
70
|
$(".table").tooltip selector: "th[rel=tooltip]"
|
71
|
+
|
72
|
+
$(document).on 'click', '#fields_to_export label input#check_all', () ->
|
73
|
+
elems = $('#fields_to_export label input')
|
74
|
+
if $('#fields_to_export label input#check_all').is ':checked'
|
75
|
+
$(elems).prop('checked', true)
|
76
|
+
else
|
77
|
+
$(elems).prop('checked',false)
|
@@ -62,7 +62,7 @@ module RailsAdmin
|
|
62
62
|
"#{abstract_model.table_name}.#{params[:sort]}"
|
63
63
|
elsif field.sortable == false # use default sort, asked field is not sortable
|
64
64
|
"#{abstract_model.table_name}.#{model_config.list.sort_by}"
|
65
|
-
elsif field.sortable.is_a?(String) && field.sortable.include?('.') # just provide sortable, don't do anything smart
|
65
|
+
elsif (field.sortable.is_a?(String) || field.sortable.is_a?(Symbol)) && field.sortable.to_s.include?('.') # just provide sortable, don't do anything smart
|
66
66
|
field.sortable
|
67
67
|
elsif field.sortable.is_a?(Hash) # just join sortable hash, don't do anything smart
|
68
68
|
"#{field.sortable.keys.first}.#{field.sortable.values.first}"
|
@@ -79,9 +79,10 @@ module RailsAdmin
|
|
79
79
|
model_param = node.abstract_model.to_param
|
80
80
|
url = url_for(:action => :index, :controller => 'rails_admin/main', :model_name => model_param)
|
81
81
|
level_class = " nav-level-#{level}" if level > 0
|
82
|
+
nav_icon = node.navigation_icon ? %{<i class="#{node.navigation_icon}"></i>}.html_safe : ''
|
82
83
|
|
83
84
|
li = content_tag :li, "data-model"=>model_param do
|
84
|
-
link_to node.label_plural, url, :class => "pjax#{level_class}"
|
85
|
+
link_to nav_icon + node.label_plural, url, :class => "pjax#{level_class}"
|
85
86
|
end
|
86
87
|
li + navigation(nodes_stack, nodes_stack.select{ |n| n.parent.to_s == node.abstract_model.model_name}, level+1)
|
87
88
|
end.join.html_safe
|
@@ -41,7 +41,7 @@
|
|
41
41
|
|
42
42
|
- selected_ids = (hdv = field.html_default_value).nil? ? selected_ids : hdv
|
43
43
|
= form.select field.method_name, collection, { :selected => selected_ids, :object => form.object }, field.html_attributes.reverse_merge({:data => { :filteringmultiselect => true, :options => js_data.to_json }, :multiple => true})
|
44
|
-
- if authorized?
|
44
|
+
- if authorized?(:new, config.abstract_model) && field.inline_add
|
45
45
|
- path_hash = { :model_name => config.abstract_model.to_param, :modal => true }
|
46
46
|
- path_hash.merge!({ :associations => { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of
|
47
47
|
= link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe + wording_for(:link, :new, config.abstract_model), '#', :data => { :link => new_path(path_hash) }, :class => "create btn btn-info", :style => 'margin-left:10px'
|
@@ -28,10 +28,10 @@
|
|
28
28
|
- selected_id = (hdv = field.html_default_value).nil? ? selected_id : hdv
|
29
29
|
= form.select field.method_name, collection, { :selected => selected_id, :include_blank => true }, field.html_attributes.reverse_merge({ :data => { :filteringselect => true, :options => js_data.to_json }, :placeholder => t('admin.misc.search') })
|
30
30
|
|
31
|
-
- if authorized?
|
31
|
+
- if authorized?(:new, config.abstract_model) && field.inline_add
|
32
32
|
- path_hash = { :model_name => config.abstract_model.to_param, :modal => true }
|
33
33
|
- path_hash.merge!({ :associations => { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of
|
34
34
|
= link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe + wording_for(:link, :new, config.abstract_model), '#', :data => { :link => new_path(path_hash) }, :class => "btn btn-info create", :style => 'margin-left:10px'
|
35
35
|
|
36
|
-
- if edit_url.present?
|
36
|
+
- if edit_url.present? && field.inline_edit
|
37
37
|
= link_to "<i class=\"icon-pencil icon-white\"></i> ".html_safe + wording_for(:link, :edit, config.abstract_model), '#', :data => { :link => edit_url }, :class => "btn btn-info update #{field.value.nil? && 'disabled'}", :style => 'margin-left:10px'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
.btn-group
|
3
3
|
%a.btn.btn-info.toggler{:'data-toggle' => "button", :'data-target' => "#{form.jquery_namespace(field)} > .tab-content, #{form.jquery_namespace(field)} > .controls > .nav", :class => (field.active? ? 'active' : '')}
|
4
4
|
%i.icon-white
|
5
|
-
- unless field.nested_form[:update_only]
|
5
|
+
- unless field.nested_form[:update_only] || !field.inline_add
|
6
6
|
= form.link_to_add "<i class=\"icon-plus icon-white\"></i> #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { :class => 'btn btn-info' }
|
7
7
|
= form.errors_for(field)
|
8
8
|
= form.help_for(field)
|
@@ -4,7 +4,12 @@
|
|
4
4
|
= form_tag export_path(params.merge(:all => true)), :method => 'post', :class => 'form-horizontal denser' do
|
5
5
|
|
6
6
|
%input{:name => "send_data", :type => "hidden", :value => "true"}/
|
7
|
-
%fieldset
|
7
|
+
%fieldset{:id => 'fields_to_export'}
|
8
|
+
%div.control-group
|
9
|
+
%div.controls
|
10
|
+
%label.checkbox{:for => 'check_all'}
|
11
|
+
= 'Select All Fields'
|
12
|
+
= check_box_tag 'all', 'all', true, { :id => 'check_all' }
|
8
13
|
%legend
|
9
14
|
%i.icon-chevron-down
|
10
15
|
= t('admin.export.select')
|
@@ -6,7 +6,7 @@ module RailsAdmin
|
|
6
6
|
module Adapters
|
7
7
|
module Mongoid
|
8
8
|
STRING_TYPE_COLUMN_NAMES = [:name, :title, :subject]
|
9
|
-
DISABLED_COLUMN_TYPES = ['Range']
|
9
|
+
DISABLED_COLUMN_TYPES = ['Range', 'Moped::BSON::Binary']
|
10
10
|
ObjectId = (::Mongoid::VERSION >= '3' ? ::Moped::BSON::ObjectId : ::BSON::ObjectId)
|
11
11
|
|
12
12
|
def new(params = {})
|
@@ -105,6 +105,10 @@ module RailsAdmin
|
|
105
105
|
@embedded ||= !!model.associations.values.find{|a| a.macro.to_sym == :embedded_in }
|
106
106
|
end
|
107
107
|
|
108
|
+
def cyclic?
|
109
|
+
@cyclic ||= !!model.cyclic?
|
110
|
+
end
|
111
|
+
|
108
112
|
def object_id_from_string(str)
|
109
113
|
ObjectId.from_string(str)
|
110
114
|
end
|
@@ -327,7 +331,7 @@ module RailsAdmin
|
|
327
331
|
|
328
332
|
def association_nested_attributes_options_lookup(association)
|
329
333
|
nested = model.nested_attributes_options.try { |o| o[association.name.to_sym] }
|
330
|
-
if !nested && [:embeds_one, :embeds_many].include?(association.macro.to_sym)
|
334
|
+
if !nested && [:embeds_one, :embeds_many].include?(association.macro.to_sym) && !association.cyclic
|
331
335
|
raise <<-MSG.gsub(/^\s+/, '')
|
332
336
|
Embbeded association without accepts_nested_attributes_for can't be handled by RailsAdmin,
|
333
337
|
because embedded model doesn't have top-level access.
|
@@ -426,10 +430,14 @@ module RailsAdmin
|
|
426
430
|
def sort_by(options, scope)
|
427
431
|
return scope unless options[:sort]
|
428
432
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
+
case options[:sort]
|
434
|
+
when String
|
435
|
+
field_name, collection_name = options[:sort].split('.').reverse
|
436
|
+
if collection_name && collection_name != table_name
|
437
|
+
raise "sorting by associated model column is not supported in Non-Relational databases"
|
438
|
+
end
|
439
|
+
when Symbol
|
440
|
+
field_name = options[:sort].to_s
|
433
441
|
end
|
434
442
|
if options[:sort_reverse]
|
435
443
|
scope.asc field_name
|
data/lib/rails_admin/config.rb
CHANGED
@@ -315,7 +315,7 @@ module RailsAdmin
|
|
315
315
|
# @see RailsAdmin::Config::Hideable
|
316
316
|
|
317
317
|
def visible_models(bindings)
|
318
|
-
models.map{|m| m.with(bindings) }.select{|m| m.visible? && bindings[:controller].authorized?(:index, m.abstract_model) && !m.abstract_model.embedded?}.sort do |a, b|
|
318
|
+
models.map{|m| m.with(bindings) }.select{|m| m.visible? && bindings[:controller].authorized?(:index, m.abstract_model) && (!m.abstract_model.embedded? || m.abstract_model.cyclic?)}.sort do |a, b|
|
319
319
|
(weight_order = a.weight <=> b.weight) == 0 ? a.label.downcase <=> b.label.downcase : weight_order
|
320
320
|
end
|
321
321
|
end
|
@@ -215,10 +215,28 @@ module RailsAdmin
|
|
215
215
|
|
216
216
|
def editable?
|
217
217
|
return false if @properties && @properties[:read_only]
|
218
|
-
|
218
|
+
role = bindings[:view].controller.send(:_attr_accessible_role)
|
219
|
+
active_model_attr_accessible = !bindings[:object].class.active_authorizer[role].deny?(self.method_name)
|
220
|
+
|
219
221
|
return true if active_model_attr_accessible
|
220
222
|
if RailsAdmin::Config.yell_for_non_accessible_fields
|
221
|
-
|
223
|
+
accessible = "attr_accessible :#{self.method_name}#{role == :default ? '' : ", :as => :#{role}"}"
|
224
|
+
|
225
|
+
Rails.logger.debug <<-MESSAGE.strip_heredoc
|
226
|
+
|
227
|
+
|
228
|
+
[RailsAdmin] Please add '#{accessible}' in your '#{bindings[:object].class}' model definition if you want to make it editable.
|
229
|
+
You can also explicitely mark this field as read-only:
|
230
|
+
|
231
|
+
config.model #{bindings[:object].class} do
|
232
|
+
field :#{self.name} do
|
233
|
+
read_only true
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
Add 'config.yell_for_non_accessible_fields = false' in your 'rails_admin.rb' initializer if you do not want to see these warnings
|
238
|
+
|
239
|
+
MESSAGE
|
222
240
|
end
|
223
241
|
false
|
224
242
|
end
|
@@ -23,6 +23,14 @@ module RailsAdmin
|
|
23
23
|
nested_form ? :form_nested_one : :form_filtering_select
|
24
24
|
end
|
25
25
|
|
26
|
+
register_instance_option :inline_add do
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
register_instance_option :inline_edit do
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
26
34
|
def selected_id
|
27
35
|
bindings[:object].send(foreign_key)
|
28
36
|
end
|
@@ -17,6 +17,15 @@ module RailsAdmin
|
|
17
17
|
(o = value) && o.send(associated_model_config.object_label_method)
|
18
18
|
end
|
19
19
|
|
20
|
+
register_instance_option :inline_add do
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
register_instance_option :inline_edit do
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
|
20
29
|
def editable?
|
21
30
|
(nested_form || abstract_model.model.new.respond_to?("#{self.name}_id=")) && super
|
22
31
|
end
|
@@ -13,7 +13,9 @@ module RailsAdmin
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def parse_input(params)
|
16
|
-
|
16
|
+
if params[name].is_a?(::String)
|
17
|
+
params[name] = (params[name].blank? ? nil : (YAML.safe_load(params[name]) || nil))
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -82,6 +82,10 @@ module RailsAdmin
|
|
82
82
|
@navigation_label ||= (parent_module = abstract_model.model.parent) != Object ? parent_module.to_s : nil
|
83
83
|
end
|
84
84
|
|
85
|
+
register_instance_option :navigation_icon do
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
|
85
89
|
# Act as a proxy for the base section configuration that actually
|
86
90
|
# store the configurations.
|
87
91
|
def method_missing(m, *args, &block)
|
data/lib/rails_admin/version.rb
CHANGED
@@ -38,6 +38,24 @@ describe RailsAdmin::MainController do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#get_sort_hash" do
|
41
|
+
context "options sortable is a hash" do
|
42
|
+
before do
|
43
|
+
RailsAdmin.config('Player') do
|
44
|
+
configure :team do
|
45
|
+
sortable do
|
46
|
+
:'team.name'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns the option with no changes" do
|
53
|
+
controller.params = { :sort => "team", :model_name =>"players" }
|
54
|
+
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq({:sort=>:"team.name", :sort_reverse=>true})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
41
59
|
it "works with belongs_to associations with label method virtual" do
|
42
60
|
controller.params = { :sort => "parent_category", :model_name =>"categories" }
|
43
61
|
expect(controller.send(:get_sort_hash, RailsAdmin.config(Category))).to eq({:sort=>"categories.parent_category_id", :sort_reverse=>true})
|
@@ -11,6 +11,7 @@ class FieldTest
|
|
11
11
|
field :big_decimal_field, :type => BigDecimal
|
12
12
|
field :boolean_field, :type => Boolean
|
13
13
|
field :bson_object_id_field, :type => RailsAdmin::Adapters::Mongoid::ObjectId
|
14
|
+
field :bson_binary_field, :type => Moped::BSON::Binary
|
14
15
|
field :date_field, :type => Date
|
15
16
|
field :datetime_field, :type => DateTime
|
16
17
|
field :time_with_zone_field, :type => ActiveSupport::TimeWithZone
|
@@ -30,7 +31,7 @@ class FieldTest
|
|
30
31
|
field :protected_field, :type => String
|
31
32
|
has_mongoid_attached_file :paperclip_asset, :styles => { :thumb => "100x100>" }
|
32
33
|
|
33
|
-
basic_accessible_fields = [:comment_attributes, :nested_field_tests_attributes, :embed_attributes, :embeds_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :name, :array_field, :big_decimal_field, :boolean_field, :bson_object_id_field, :date_field, :datetime_field, :time_with_zone_field, :default_field, :float_field, :hash_field, :integer_field, :object_field, :range_field, :string_field, :symbol_field, :text_field, :time_field, :created_at, :updated_at, :format]
|
34
|
+
basic_accessible_fields = [:comment_attributes, :nested_field_tests_attributes, :embed_attributes, :embeds_attributes, :dragonfly_asset, :remove_dragonfly_asset, :retained_dragonfly_asset, :carrierwave_asset, :carrierwave_asset_cache, :remove_carrierwave_asset, :paperclip_asset, :delete_paperclip_asset, :comment_id, :name, :array_field, :big_decimal_field, :boolean_field, :bson_object_id_field, :bson_binary_field, :date_field, :datetime_field, :time_with_zone_field, :default_field, :float_field, :hash_field, :integer_field, :object_field, :range_field, :string_field, :symbol_field, :text_field, :time_field, :created_at, :updated_at, :format]
|
34
35
|
attr_accessible *basic_accessible_fields
|
35
36
|
attr_accessible *(basic_accessible_fields + [:restricted_field, {:as => :custom_role}])
|
36
37
|
attr_accessible *(basic_accessible_fields + [:protected_field, {:as => :extra_safe_role}])
|
@@ -593,6 +593,79 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
593
593
|
expect(find("#team_division_id_field .help-block")).to have_content("Optional")
|
594
594
|
expect(find("#team_name_field .help-block")).to have_content("Required")
|
595
595
|
end
|
596
|
+
|
597
|
+
it "can hide the add button on an associated field" do
|
598
|
+
RailsAdmin.config Player do
|
599
|
+
edit do
|
600
|
+
field :team do
|
601
|
+
inline_add false
|
602
|
+
end
|
603
|
+
field :draft do
|
604
|
+
inline_add false
|
605
|
+
end
|
606
|
+
field :comments do
|
607
|
+
inline_add false
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
visit new_path(:model_name => "player")
|
612
|
+
should have_no_selector('a', :text => 'Add a new Team')
|
613
|
+
should have_no_selector('a', :text => 'Add a new Draft')
|
614
|
+
should have_no_selector('a', :text => 'Add a new Comment')
|
615
|
+
end
|
616
|
+
|
617
|
+
it "can show the add button on an associated field" do
|
618
|
+
RailsAdmin.config Player do
|
619
|
+
edit do
|
620
|
+
field :team do
|
621
|
+
inline_add true
|
622
|
+
end
|
623
|
+
field :draft do
|
624
|
+
inline_add true
|
625
|
+
end
|
626
|
+
field :comments do
|
627
|
+
inline_add true
|
628
|
+
end
|
629
|
+
end
|
630
|
+
end
|
631
|
+
visit new_path(:model_name => "player")
|
632
|
+
should have_selector('a', :text => 'Add a new Team')
|
633
|
+
should have_selector('a', :text => 'Add a new Draft')
|
634
|
+
should have_selector('a', :text => 'Add a new Comment')
|
635
|
+
end
|
636
|
+
|
637
|
+
it "can hide the edit button on an associated field" do
|
638
|
+
RailsAdmin.config Player do
|
639
|
+
edit do
|
640
|
+
field :team do
|
641
|
+
inline_edit false
|
642
|
+
end
|
643
|
+
field :draft do
|
644
|
+
inline_edit false
|
645
|
+
end
|
646
|
+
end
|
647
|
+
end
|
648
|
+
visit new_path(:model_name => "player")
|
649
|
+
should have_no_selector('a', :text => 'Edit this Team')
|
650
|
+
should have_no_selector('a', :text => 'Edit this Draft')
|
651
|
+
end
|
652
|
+
|
653
|
+
it "can show the edit button on an associated field" do
|
654
|
+
RailsAdmin.config Player do
|
655
|
+
edit do
|
656
|
+
field :team do
|
657
|
+
inline_edit true
|
658
|
+
end
|
659
|
+
field :draft do
|
660
|
+
inline_edit true
|
661
|
+
end
|
662
|
+
end
|
663
|
+
end
|
664
|
+
visit new_path(:model_name => "player")
|
665
|
+
should have_selector('a', :text => 'Edit this Team')
|
666
|
+
should have_selector('a', :text => 'Edit this Draft')
|
667
|
+
end
|
668
|
+
|
596
669
|
end
|
597
670
|
|
598
671
|
describe "bindings" do
|
@@ -1023,4 +1096,5 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
1023
1096
|
should have_selector(".color_type input")
|
1024
1097
|
end
|
1025
1098
|
end
|
1099
|
+
|
1026
1100
|
end
|
@@ -243,12 +243,24 @@ describe "RailsAdmin::Adapters::Mongoid", :mongoid => true do
|
|
243
243
|
embedded_in :mongo_embeds_many
|
244
244
|
end
|
245
245
|
|
246
|
+
class MongoRecursivelyEmbedsOne
|
247
|
+
include Mongoid::Document
|
248
|
+
recursively_embeds_one
|
249
|
+
end
|
250
|
+
|
251
|
+
class MongoRecursivelyEmbedsMany
|
252
|
+
include Mongoid::Document
|
253
|
+
recursively_embeds_many
|
254
|
+
end
|
255
|
+
|
246
256
|
expect(lambda{ RailsAdmin::AbstractModel.new(MongoEmbedsOne).associations }).to raise_error(RuntimeError,
|
247
257
|
"Embbeded association without accepts_nested_attributes_for can't be handled by RailsAdmin,\nbecause embedded model doesn't have top-level access.\nPlease add `accepts_nested_attributes_for :mongo_embedded' line to `MongoEmbedsOne' model.\n"
|
248
258
|
)
|
249
259
|
expect(lambda{ RailsAdmin::AbstractModel.new(MongoEmbedsMany).associations }).to raise_error(RuntimeError,
|
250
260
|
"Embbeded association without accepts_nested_attributes_for can't be handled by RailsAdmin,\nbecause embedded model doesn't have top-level access.\nPlease add `accepts_nested_attributes_for :mongo_embeddeds' line to `MongoEmbedsMany' model.\n"
|
251
261
|
)
|
262
|
+
expect(lambda{ RailsAdmin::AbstractModel.new(MongoRecursivelyEmbedsOne).associations }).not_to raise_error
|
263
|
+
expect(lambda{ RailsAdmin::AbstractModel.new(MongoRecursivelyEmbedsMany).associations }).not_to raise_error
|
252
264
|
end
|
253
265
|
|
254
266
|
it "works with inherited embeds_many model" do
|
@@ -276,10 +288,10 @@ describe "RailsAdmin::Adapters::Mongoid", :mongoid => true do
|
|
276
288
|
|
277
289
|
it "maps Mongoid column types to RA types" do
|
278
290
|
expect(@abstract_model.properties.select{|p| %w(_id array_field big_decimal_field
|
279
|
-
boolean_field bson_object_id_field date_field datetime_field
|
280
|
-
hash_field integer_field name
|
281
|
-
symbol_field text_field
|
282
|
-
include? p[:name].to_s}).to match_array [
|
291
|
+
boolean_field bson_object_id_field bson_binary_field date_field datetime_field
|
292
|
+
time_with_zone_field default_field float_field hash_field integer_field name
|
293
|
+
object_field range_field short_text string_field subject symbol_field text_field
|
294
|
+
time_field title).include? p[:name].to_s}).to match_array [
|
283
295
|
{ :name => :_id,
|
284
296
|
:pretty_name => "Id",
|
285
297
|
:nullable? => true,
|
@@ -394,6 +394,18 @@ describe RailsAdmin::Config::Fields::Base do
|
|
394
394
|
expect(editable).to be_false
|
395
395
|
end
|
396
396
|
|
397
|
+
it "yells for non attr_accessible fields specified role if config.yell_for_non_accessible_fields is true" do
|
398
|
+
RailsAdmin.config do |config|
|
399
|
+
config.yell_for_non_accessible_fields = true
|
400
|
+
config.model FieldTest do
|
401
|
+
field :protected_field
|
402
|
+
end
|
403
|
+
end
|
404
|
+
Rails.logger.should_receive(:debug).with {|msg| msg =~ /Please add 'attr_accessible :protected_field, :as => :admin'/ }
|
405
|
+
editable = RailsAdmin.config(FieldTest).field(:protected_field).with(:object => FactoryGirl.create(:field_test), :view => double(:controller => double(:_attr_accessible_role => :admin))).editable?
|
406
|
+
expect(editable).to be_false
|
407
|
+
end
|
408
|
+
|
397
409
|
it "does not yell for non attr_accessible fields if config.yell_for_non_accessible_fields is false" do
|
398
410
|
RailsAdmin.config do |config|
|
399
411
|
config.yell_for_non_accessible_fields = false
|