Skip to content

Commit

Permalink
removed useless binding in applicative sanity check
Browse files Browse the repository at this point in the history
fixes #549
  • Loading branch information
bbenezech committed Jan 3, 2012
1 parent 297c61c commit b4649f3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/rails_admin/main_controller.rb
Expand Up @@ -276,7 +276,7 @@ def back_or_index

def get_sort_hash(model_config)
abstract_model = model_config.abstract_model
params[:sort] = params[:sort_reverse] = nil unless model_config.list.with(:view => self, :object => abstract_model.model.new).visible_fields.map {|f| f.name.to_s}.include? params[:sort]
params[:sort] = params[:sort_reverse] = nil unless model_config.list.fields.map {|f| f.name.to_s}.include? params[:sort]

params[:sort] ||= model_config.list.sort_by.to_s
params[:sort_reverse] ||= 'false'
Expand Down
25 changes: 25 additions & 0 deletions spec/requests/rails_admin_spec.rb
Expand Up @@ -59,6 +59,31 @@
should_not have_selector("#player_name[type=hidden][value='toto@example.com']")
end
end

describe '_current_user should be accessible from the list view' do # https://github.com/sferik/rails_admin/issues/549

it 'should work' do
RailsAdmin.config Player do
list do
field :name do
visible do
bindings[:view]._current_user.email == 'username@example.com'
end
end

field :team do
visible do
bindings[:view]._current_user.email == 'foo@example.com'
end
end
end
end

visit index_path(:model_name => "player")
should have_selector(".header.name_field")
should_not have_selector(".header.team_field")
end
end

describe "polymorphic associations" do
before :each do
Expand Down

0 comments on commit b4649f3

Please sign in to comment.