diff --git a/app/models/block.rb b/app/models/block.rb index 6a9c70b..7f22724 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -185,12 +185,12 @@ class Block < ActiveRecord::Base 'never' => __('Don\'t display'), } - def display_options + def display_options_available DISPLAY_OPTIONS.keys end - def display_option_label(option) - DISPLAY_OPTIONS[option] + def display_options + DISPLAY_OPTIONS.slice(*display_options_available) end def display_user_options diff --git a/app/models/main_block.rb b/app/models/main_block.rb index 8e2ed59..f1537e6 100644 --- a/app/models/main_block.rb +++ b/app/models/main_block.rb @@ -24,7 +24,7 @@ class MainBlock < Block false end - def display_options + def display_options_available ['always', 'except_home_page'] end diff --git a/app/views/box_organizer/edit.rhtml b/app/views/box_organizer/edit.rhtml index 530de37..95bd893 100644 --- a/app/views/box_organizer/edit.rhtml +++ b/app/views/box_organizer/edit.rhtml @@ -7,13 +7,10 @@ <%= render :partial => partial_for_class(@block.class) %> - <%= labelled_form_field _('Display this block:'), '' %> -
- <% @block.display_options.each do |option| %> - <%= radio_button(:block, :display, option) %> - <%= label_tag("block_display_#{option}", _(@block.display_option_label(option))) %> -
- <% end %> +
+ <%= labelled_form_field _('Display this block:'), + select_tag('block[display]', options_from_collection_for_select(@block.display_options, :first, :last, @block.display)) + %>
<%= labelled_form_field _('Display to users:'), '' %> diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index 173b613..aa7582b 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -173,7 +173,8 @@ class ProfileDesignControllerTest < ActionController::TestCase should 'have options to display blocks' do get :edit, :profile => 'designtestuser', :id => @b1.id %w[always home_page_only except_home_page never].each do |option| - assert_tag :input, :attributes => { :type => 'radio', :value => option} + assert_tag :select, :attributes => {:name => 'block[display]'}, + :descendant => {:tag => 'option', :attributes => {:value => option}} end end @@ -302,22 +303,26 @@ class ProfileDesignControllerTest < ActionController::TestCase should 'not edit main block with never option' do get :edit, :profile => 'designtestuser', :id => @b4.id - assert_no_tag :input, :attributes => { :type => 'radio', :value => 'never'} + assert_no_tag :select, :attributes => {:name => 'block[display]'}, + :descendant => {:tag => 'option', :attributes => {:value => 'never'}} end should 'not edit main block with home_page_only option' do get :edit, :profile => 'designtestuser', :id => @b4.id - assert_no_tag :input, :attributes => { :type => 'radio', :value => 'home_page_only'} + assert_no_tag :select, :attributes => {:name => 'block[display]'}, + :descendant => {:tag => 'option', :attributes => {:value => 'home_page_only'}} end should 'edit main block with always option' do get :edit, :profile => 'designtestuser', :id => @b4.id - assert_tag :input, :attributes => { :type => 'radio', :value => 'always'} + assert_tag :select, :attributes => {:name => 'block[display]'}, + :descendant => {:tag => 'option', :attributes => {:value => 'always'}} end should 'edit main block with except_home_page option' do get :edit, :profile => 'designtestuser', :id => @b4.id - assert_tag :input, :attributes => { :type => 'radio', :value => 'except_home_page'} + assert_tag :select, :attributes => {:name=> 'block[display]'}, + :descendant => {:tag => 'option', :attributes => {:value => 'except_home_page'}} end -- libgit2 0.21.2