Commit 8a59c91b92cc2ba54664cd2509f393b2e2aaddc9
Committed by
Antonio Terceiro
1 parent
ae1b444d
Exists in
staging
and in
42 other branches
Removing category_types method from environment. It's not needed anymore.
(ActionItem1729)
Showing
5 changed files
with
1 additions
and
29 deletions
Show diff stats
app/helpers/categories_helper.rb
| ... | ... | @@ -34,8 +34,7 @@ module CategoriesHelper |
| 34 | 34 | |
| 35 | 35 | def select_category_type(field) |
| 36 | 36 | value = params[field] |
| 37 | - types = TYPES.select { |title,typename| environment.category_types.include?(typename) } | |
| 38 | - labelled_form_field(_('Type of category'), select_tag('type', options_for_select(types, value))) | |
| 37 | + labelled_form_field(_('Type of category'), select_tag('type', options_for_select(TYPES, value))) | |
| 39 | 38 | end |
| 40 | 39 | |
| 41 | 40 | end | ... | ... |
app/models/environment.rb
| ... | ... | @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base |
| 207 | 207 | settings_items :layout_template, :type => String, :default => 'default' |
| 208 | 208 | settings_items :homepage, :type => String |
| 209 | 209 | settings_items :description, :type => String, :default => '<div style="text-align: center"><a href="http://noosfero.org/"><img src="/images/noosfero-network.png" alt="Noosfero"/></a></div>' |
| 210 | - settings_items :category_types, :type => Array, :default => ['Category'] | |
| 211 | 210 | settings_items :enable_ssl |
| 212 | 211 | settings_items :local_docs, :type => Array, :default => [] |
| 213 | 212 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 | ... | ... |
app/views/categories/_form.rhtml
| ... | ... | @@ -9,11 +9,7 @@ |
| 9 | 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> |
| 10 | 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> |
| 11 | 11 | <% else %> |
| 12 | - <% if environment.category_types.length > 1 %> | |
| 13 | 12 | <%= select_category_type :type %> |
| 14 | - <% else %> | |
| 15 | - <%= hidden_field_tag('type', @category.class.name) %> | |
| 16 | - <% end%> | |
| 17 | 13 | <% end %> |
| 18 | 14 | <% end %> |
| 19 | 15 | ... | ... |
test/unit/categories_helper_test.rb
| ... | ... | @@ -11,7 +11,6 @@ class CategoriesHelperTest < Test::Unit::TestCase |
| 11 | 11 | def _(s); s; end |
| 12 | 12 | |
| 13 | 13 | should 'generate list of category types for selection' do |
| 14 | - environment.category_types = ['Category', 'ProductCategory', 'Region'] | |
| 15 | 14 | expects(:params).returns({'fieldname' => 'fieldvalue'}) |
| 16 | 15 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') |
| 17 | 16 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') |
| ... | ... | @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase |
| 20 | 19 | assert_equal 'RESULT', select_category_type('fieldname') |
| 21 | 20 | end |
| 22 | 21 | |
| 23 | - should 'only list the available types' do | |
| 24 | - environment.category_types = ['Category'] | |
| 25 | - expects(:params).returns({'fieldname' => 'fieldvalue'}) | |
| 26 | - expects(:options_for_select).with([['General Category', 'Category']], 'fieldvalue').returns('OPTIONS') | |
| 27 | - expects(:select_tag).with('type', 'OPTIONS').returns('TAG') | |
| 28 | - expects(:labelled_form_field).with(anything, 'TAG').returns('RESULT') | |
| 29 | - | |
| 30 | - assert_equal 'RESULT', select_category_type('fieldname') | |
| 31 | - end | |
| 32 | - | |
| 33 | 22 | end | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase |
| 731 | 731 | assert_equal ['contact_email'], env.required_community_fields |
| 732 | 732 | end |
| 733 | 733 | |
| 734 | - should 'set category_types' do | |
| 735 | - env = Environment.new | |
| 736 | - env.category_types = ['Category', 'ProductCategory'] | |
| 737 | - | |
| 738 | - assert_equal ['Category', 'ProductCategory'], env.category_types | |
| 739 | - end | |
| 740 | - | |
| 741 | - should 'have type /Category/ on category_types by default' do | |
| 742 | - assert_equal ['Category'], Environment.new.category_types | |
| 743 | - end | |
| 744 | - | |
| 745 | 734 | should 'has tasks' do |
| 746 | 735 | e = Environment.default |
| 747 | 736 | assert_nothing_raised do | ... | ... |