Skip to content

Commit

Permalink
fix for issue_31
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Apr 2, 2010
1 parent b12e17d commit f7d5c5c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/admin_data/helpers.rb
Expand Up @@ -113,7 +113,7 @@ def admin_data_form_field(klass, model, col, f)
if col.primary
html << model.new_record? ? '(auto)' : model.id

elsif get_reflection_for_column(klass, col)
elsif get_reflection_for_column(klass, col) && AdminDataConfig.setting[:drop_down_for_associations]
admin_data_form_field_for_association_records(klass, col, f, html)
else
admin_data_handle_column_type(col, html, model, column_value, f)
Expand Down
3 changes: 3 additions & 0 deletions lib/admin_data/settings.rb
Expand Up @@ -18,6 +18,7 @@ def self.set=(input = {})
columns_order
use_google_hosting_for_jquery
rake_options
drop_down_for_associations
).collect(&:intern)

extra_keys = input.keys - valid_keys
Expand Down Expand Up @@ -58,6 +59,8 @@ def self.initialize_defaults

:rake_command => 'rake',

:drop_down_for_associations => true,

:columns_order => nil

}
Expand Down
36 changes: 29 additions & 7 deletions test/functional/main_controller_test.rb
Expand Up @@ -319,15 +319,37 @@ def setup
end

context 'get edit comment' do
setup do
@comment = Factory(:comment, :article => @article)
get :edit, {:id => @comment.id, :klass => @comment.class.name.underscore }
context 'without drop down for associations' do
setup do
AdminDataConfig.set = ({:drop_down_for_associations => false})
@comment = Factory(:comment, :article => @article)
get :edit, {:id => @comment.id, :klass => @comment.class.name.underscore }
show_response
end
teardown do
AdminDataConfig.set = ({:drop_down_for_associations => true})
end

should_respond_with :success

should "have input text field for belongs_to article" do
assert_select 'form' do
assert_tag(:tag => 'input', :attributes => {:id => 'comment_article_id', :name => 'comment[article_id]'})
end
end
end
should_respond_with :success
context 'with drop down for associations' do
setup do
@comment = Factory(:comment, :article => @article)
get :edit, {:id => @comment.id, :klass => @comment.class.name.underscore }
end

should "have dropdowns for belongs_to article" do
assert_select 'form' do
assert_select "select[name='comment[article_id]']"
should_respond_with :success

should "have dropdowns for belongs_to article" do
assert_select 'form' do
assert_select "select[name='comment[article_id]']"
end
end
end
end
Expand Down

0 comments on commit f7d5c5c

Please sign in to comment.