Commit 8a59c91b92cc2ba54664cd2509f393b2e2aaddc9
Committed by
Antonio Terceiro
1 parent
ae1b444d
Exists in
master
and in
22 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,8 +34,7 @@ module CategoriesHelper | ||
| 34 | 34 | ||
| 35 | def select_category_type(field) | 35 | def select_category_type(field) |
| 36 | value = params[field] | 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 | end | 38 | end |
| 40 | 39 | ||
| 41 | end | 40 | end |
app/models/environment.rb
| @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base | @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base | ||
| 207 | settings_items :layout_template, :type => String, :default => 'default' | 207 | settings_items :layout_template, :type => String, :default => 'default' |
| 208 | settings_items :homepage, :type => String | 208 | settings_items :homepage, :type => String |
| 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>' | 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 | settings_items :enable_ssl | 210 | settings_items :enable_ssl |
| 212 | settings_items :local_docs, :type => Array, :default => [] | 211 | settings_items :local_docs, :type => Array, :default => [] |
| 213 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 | 212 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 |
app/views/categories/_form.rhtml
| @@ -9,11 +9,7 @@ | @@ -9,11 +9,7 @@ | ||
| 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> | 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> |
| 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> | 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> |
| 11 | <% else %> | 11 | <% else %> |
| 12 | - <% if environment.category_types.length > 1 %> | ||
| 13 | <%= select_category_type :type %> | 12 | <%= select_category_type :type %> |
| 14 | - <% else %> | ||
| 15 | - <%= hidden_field_tag('type', @category.class.name) %> | ||
| 16 | - <% end%> | ||
| 17 | <% end %> | 13 | <% end %> |
| 18 | <% end %> | 14 | <% end %> |
| 19 | 15 |
test/unit/categories_helper_test.rb
| @@ -11,7 +11,6 @@ class CategoriesHelperTest < Test::Unit::TestCase | @@ -11,7 +11,6 @@ class CategoriesHelperTest < Test::Unit::TestCase | ||
| 11 | def _(s); s; end | 11 | def _(s); s; end |
| 12 | 12 | ||
| 13 | should 'generate list of category types for selection' do | 13 | should 'generate list of category types for selection' do |
| 14 | - environment.category_types = ['Category', 'ProductCategory', 'Region'] | ||
| 15 | expects(:params).returns({'fieldname' => 'fieldvalue'}) | 14 | expects(:params).returns({'fieldname' => 'fieldvalue'}) |
| 16 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') | 15 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') |
| 17 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') | 16 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') |
| @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase | @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase | ||
| 20 | assert_equal 'RESULT', select_category_type('fieldname') | 19 | assert_equal 'RESULT', select_category_type('fieldname') |
| 21 | end | 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 | end | 22 | end |
test/unit/environment_test.rb
| @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase | ||
| 731 | assert_equal ['contact_email'], env.required_community_fields | 731 | assert_equal ['contact_email'], env.required_community_fields |
| 732 | end | 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 | should 'has tasks' do | 734 | should 'has tasks' do |
| 746 | e = Environment.default | 735 | e = Environment.default |
| 747 | assert_nothing_raised do | 736 | assert_nothing_raised do |