Commit e7aa3273903dc2fd63309891bbea57d1f5c404f7
Exists in
staging
and in
42 other branches
Merge commit 'refs/merge-requests/328' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/328 Conflicts: app/controllers/public/catalog_controller.rb
Showing
24 changed files
with
92 additions
and
49 deletions
Show diff stats
app/controllers/my_profile/manage_products_controller.rb
| ... | ... | @@ -6,10 +6,10 @@ class ManageProductsController < ApplicationController |
| 6 | 6 | before_filter :login_required, :except => [:show] |
| 7 | 7 | before_filter :create_product?, :only => [:new] |
| 8 | 8 | |
| 9 | - protected | |
| 9 | + protected | |
| 10 | 10 | |
| 11 | 11 | def check_environment_feature |
| 12 | - if profile.environment.enabled?('disable_products_for_enterprises') | |
| 12 | + unless profile.environment.enabled?('products_for_enterprises') | |
| 13 | 13 | render_not_found |
| 14 | 14 | return |
| 15 | 15 | end | ... | ... |
app/controllers/my_profile/profile_design_controller.rb
| ... | ... | @@ -38,7 +38,7 @@ class ProfileDesignController < BoxOrganizerController |
| 38 | 38 | end |
| 39 | 39 | |
| 40 | 40 | # product block exclusive for enterprises in environments that permits it |
| 41 | - if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises') | |
| 41 | + if profile.enterprise? && profile.environment.enabled?('products_for_enterprises') | |
| 42 | 42 | blocks << ProductsBlock |
| 43 | 43 | end |
| 44 | 44 | ... | ... |
app/controllers/public/catalog_controller.rb
| ... | ... | @@ -12,7 +12,7 @@ class CatalogController < PublicController |
| 12 | 12 | protected |
| 13 | 13 | |
| 14 | 14 | def check_enterprise_and_environment |
| 15 | - unless profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') | |
| 15 | + unless profile.kind_of?(Enterprise) && @profile.environment.enabled?('products_for_enterprises') | |
| 16 | 16 | redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index' |
| 17 | 17 | end |
| 18 | 18 | end | ... | ... |
app/models/enterprise.rb
| ... | ... | @@ -134,7 +134,7 @@ class Enterprise < Organization |
| 134 | 134 | [ProfileImageBlock.new, LinkListBlock.new(:links => links)], |
| 135 | 135 | [] |
| 136 | 136 | ] |
| 137 | - if !environment.enabled?('disable_products_for_enterprises') | |
| 137 | + if environment.enabled?('products_for_enterprises') | |
| 138 | 138 | blocks[2].unshift ProductsBlock.new |
| 139 | 139 | end |
| 140 | 140 | blocks | ... | ... |
app/models/environment.rb
| ... | ... | @@ -95,7 +95,6 @@ class Environment < ActiveRecord::Base |
| 95 | 95 | 'disable_asset_communities' => __('Disable search for communities'), |
| 96 | 96 | 'disable_asset_products' => _('Disable search for products'), |
| 97 | 97 | 'disable_asset_events' => _('Disable search for events'), |
| 98 | - 'disable_products_for_enterprises' => __('Disable products for enterprises'), | |
| 99 | 98 | 'disable_categories' => _('Disable categories'), |
| 100 | 99 | 'disable_header_and_footer' => _('Disable header/footer editing by users'), |
| 101 | 100 | 'disable_gender_icon' => _('Disable gender icon'), |
| ... | ... | @@ -103,9 +102,13 @@ class Environment < ActiveRecord::Base |
| 103 | 102 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), |
| 104 | 103 | 'disable_contact_person' => _('Disable contact for people'), |
| 105 | 104 | 'disable_contact_community' => _('Disable contact for groups/communities'), |
| 106 | - 'enterprise_registration' => __('Enterprise registration'), | |
| 107 | 105 | |
| 106 | + 'products_for_enterprises' => __('Enable products for enterprises'), | |
| 107 | + 'enterprise_registration' => __('Enterprise registration'), | |
| 108 | 108 | 'enterprise_activation' => __('Enable activation of enterprises'), |
| 109 | + 'enterprises_are_disabled_when_created' => __('Enterprises are disabled when created'), | |
| 110 | + 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'), | |
| 111 | + | |
| 109 | 112 | 'media_panel' => _('Media panel in WYSIWYG editor'), |
| 110 | 113 | 'select_preferred_domain' => _('Select preferred domains per profile'), |
| 111 | 114 | 'use_portal_community' => _('Use the portal as news source for front page'), |
| ... | ... | @@ -118,8 +121,6 @@ class Environment < ActiveRecord::Base |
| 118 | 121 | 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"), |
| 119 | 122 | 'enable_organization_url_change' => _("Allow organizations to change their URL"), |
| 120 | 123 | 'admin_must_approve_new_communities' => _("Admin must approve creation of communities"), |
| 121 | - 'enterprises_are_disabled_when_created' => __('Enterprises are disabled when created'), | |
| 122 | - 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'), | |
| 123 | 124 | 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), |
| 124 | 125 | 'xmpp_chat' => _('XMPP/Jabber based chat'), |
| 125 | 126 | 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), |
| ... | ... | @@ -281,8 +282,9 @@ class Environment < ActiveRecord::Base |
| 281 | 282 | end |
| 282 | 283 | |
| 283 | 284 | # Enables a feature identified by its name |
| 284 | - def enable(feature) | |
| 285 | + def enable(feature, must_save=true) | |
| 285 | 286 | self.settings["#{feature}_enabled".to_sym] = true |
| 287 | + self.save! if must_save | |
| 286 | 288 | end |
| 287 | 289 | |
| 288 | 290 | def enable_plugin(plugin) |
| ... | ... | @@ -292,8 +294,9 @@ class Environment < ActiveRecord::Base |
| 292 | 294 | end |
| 293 | 295 | |
| 294 | 296 | # Disables a feature identified by its name |
| 295 | - def disable(feature) | |
| 297 | + def disable(feature, must_save=true) | |
| 296 | 298 | self.settings["#{feature}_enabled".to_sym] = false |
| 299 | + self.save! if must_save | |
| 297 | 300 | end |
| 298 | 301 | |
| 299 | 302 | def disable_plugin(plugin) |
| ... | ... | @@ -337,7 +340,7 @@ class Environment < ActiveRecord::Base |
| 337 | 340 | %w( |
| 338 | 341 | disable_asset_products |
| 339 | 342 | disable_gender_icon |
| 340 | - disable_products_for_enterprises | |
| 343 | + products_for_enterprises | |
| 341 | 344 | disable_select_city_for_contact |
| 342 | 345 | enterprise_registration |
| 343 | 346 | media_panel |
| ... | ... | @@ -345,7 +348,7 @@ class Environment < ActiveRecord::Base |
| 345 | 348 | show_balloon_with_profile_links_when_clicked |
| 346 | 349 | use_portal_community |
| 347 | 350 | ).each do |feature| |
| 348 | - enable(feature) | |
| 351 | + enable(feature, false) | |
| 349 | 352 | end |
| 350 | 353 | end |
| 351 | 354 | ... | ... |
app/models/price_detail.rb
| ... | ... | @@ -4,11 +4,11 @@ class PriceDetail < ActiveRecord::Base |
| 4 | 4 | validates_presence_of :product_id |
| 5 | 5 | |
| 6 | 6 | belongs_to :production_cost |
| 7 | - validates_presence_of :production_cost | |
| 7 | + # Do not validates_presence_of production_cost. We may have undefined other costs. | |
| 8 | 8 | validates_uniqueness_of :production_cost_id, :scope => :product_id |
| 9 | 9 | |
| 10 | 10 | def name |
| 11 | - production_cost.name | |
| 11 | + production_cost.nil? ? _('Other costs') : production_cost.name | |
| 12 | 12 | end |
| 13 | 13 | |
| 14 | 14 | def price | ... | ... |
app/models/product.rb
| ... | ... | @@ -191,11 +191,13 @@ class Product < ActiveRecord::Base |
| 191 | 191 | (price - total_production_cost.to_f).zero? |
| 192 | 192 | end |
| 193 | 193 | |
| 194 | - def update_price_details(price_details) | |
| 195 | - self.price_details.destroy_all | |
| 196 | - price_details.each do |price_detail| | |
| 197 | - self.price_details.create(price_detail) | |
| 194 | + def update_price_details(new_price_details) | |
| 195 | + price_details.destroy_all | |
| 196 | + new_price_details.each do |detail| | |
| 197 | + price_details.create(detail) | |
| 198 | 198 | end |
| 199 | + reload # to remove temporary duplicated price_details | |
| 200 | + price_details | |
| 199 | 201 | end |
| 200 | 202 | |
| 201 | 203 | def price_description_percentage | ... | ... |
app/views/blocks/profile_info.rhtml
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <ul class="profile-info-data" id="profile-info-data-<%= block.id %>"> |
| 18 | 18 | <li><%= link_to __('Homepage'), block.owner.url, :class => 'url' %></li> |
| 19 | 19 | <li><%= link_to _('View profile'), block.owner.public_profile_url %></li> |
| 20 | - <% if block.owner.enterprise? && !block.owner.environment.enabled?('disable_products_for_enterprises') %> | |
| 20 | + <% if block.owner.enterprise? && block.owner.environment.enabled?('products_for_enterprises') %> | |
| 21 | 21 | <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li> |
| 22 | 22 | <% end %> |
| 23 | 23 | <li id="profile-admin-url-<%= block.id %>"></li> | ... | ... |
app/views/content_viewer/_enterprise_homepage.rhtml
| 1 | 1 | <%= display_profile_info enterprise_homepage.profile %> |
| 2 | 2 | <div><%= enterprise_homepage.body %></div> |
| 3 | -<%= render :file => 'catalog/index' unless enterprise_homepage.profile.environment.enabled?('disable_products_for_enterprises') %> | |
| 3 | +<%= render :file => 'catalog/index' if enterprise_homepage.profile.environment.enabled?('products_for_enterprises') %> | ... | ... |
app/views/manage_products/_display_price_details.rhtml
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | </li> |
| 11 | 11 | <% @product.price_details.each do |price_detail| %> |
| 12 | 12 | <li> |
| 13 | - <div class='price-detail-name'><%= "%s:" % price_detail.production_cost.name %></div> | |
| 13 | + <div class='price-detail-name'><%= "%s:" % price_detail.name %></div> | |
| 14 | 14 | <div class='price-detail-price'><%= float_to_currency(price_detail.price) %></div> |
| 15 | 15 | </li> |
| 16 | 16 | <% end %> | ... | ... |
app/views/manage_products/_edit_price_details.rhtml
| 1 | 1 | <% price_details.each do |price_detail| %> |
| 2 | 2 | <tr id='<%= "price-detail-#{price_detail.id}" %>'> |
| 3 | 3 | <td><%= select_production_cost(@product, price_detail.production_cost_id) %></td> |
| 4 | - <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', price_detail.formatted_value(:price), :class => 'numbers-only price-details-price')) %></td> | |
| 4 | + <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', price_detail.formatted_value(:price), :class => 'numbers-only price-details-price', :size => 6)) %></td> | |
| 5 | 5 | <td> |
| 6 | 6 | <%= link_to_remote(_('Remove'), |
| 7 | 7 | :update => "price-detail-#{price_detail.id}", | ... | ... |
app/views/manage_products/_manage_product_details.rhtml
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | <table id='new-cost-fields'> |
| 35 | 35 | <tr> |
| 36 | 36 | <td><%= select_production_cost(@product) %></td> |
| 37 | - <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', nil, :class => 'numbers-only price-details-price')) %></td> | |
| 37 | + <td><%= labelled_form_field(environment.currency_unit, text_field_tag('price_details[][price]', nil, :class => 'numbers-only price-details-price', :size => 6)) %></td> | |
| 38 | 38 | <td><%= link_to(_('Cancel'), '#', {:class => 'cancel-new-cost'}) %></td> |
| 39 | 39 | </tr> |
| 40 | 40 | </table> | ... | ... |
app/views/profile/_organization_profile.rhtml
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | <td><%= show_date(profile.created_at) %></td> |
| 20 | 20 | </tr> |
| 21 | 21 | |
| 22 | - <% if profile.kind_of?(Enterprise) && !profile.environment.enabled?('disable_products_for_enterprises') %> | |
| 22 | + <% if profile.kind_of?(Enterprise) && profile.environment.enabled?('products_for_enterprises') %> | |
| 23 | 23 | <tr> |
| 24 | 24 | <td></td> |
| 25 | 25 | <td> | ... | ... |
app/views/profile_editor/index.rhtml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | |
| 46 | 46 | <%= control_panel_button(_('Manage Members'), 'members', :controller => 'profile_members') if profile.organization? && user.has_permission?(:manage_memberships, profile) %> |
| 47 | 47 | |
| 48 | - <%= control_panel_button(_('Manage Products and Services'), 'products', :controller => 'manage_products') if profile.enterprise? && !environment.enabled?('disable_products_for_enterprises') %> | |
| 48 | + <%= control_panel_button(_('Manage Products and Services'), 'products', :controller => 'manage_products') if profile.enterprise? && environment.enabled?('products_for_enterprises') %> | |
| 49 | 49 | |
| 50 | 50 | <% if !environment.enabled?('disable_asset_enterprises') %> |
| 51 | 51 | <% if profile.is_validation_entity? %> | ... | ... |
db/migrate/20130529155000_rename_environment_setting_disable_products.rb
0 → 100644
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +class RenameEnvironmentSettingDisableProducts < ActiveRecord::Migration | |
| 2 | + def self.up | |
| 3 | + select_all("select id from environments").each do |environment| | |
| 4 | + env = Environment.find(environment['id']) | |
| 5 | + env.settings[:products_for_enterprises_enabled] = | |
| 6 | + !env.settings[:disable_products_for_enterprises_enabled] | |
| 7 | + env.settings.delete :disable_products_for_enterprises_enabled | |
| 8 | + env.save! | |
| 9 | + end | |
| 10 | + end | |
| 11 | + | |
| 12 | + def self.down | |
| 13 | + select_all("select id from environments").each do |environment| | |
| 14 | + env = Environment.find(environment['id']) | |
| 15 | + env.settings[:disable_products_for_enterprises_enabled] = | |
| 16 | + !env.settings[:products_for_enterprises_enabled] | |
| 17 | + env.settings.delete :products_for_enterprises_enabled | |
| 18 | + env.save! | |
| 19 | + end | |
| 20 | + end | |
| 21 | +end | ... | ... |
public/javascripts/manage-products.js
| ... | ... | @@ -23,13 +23,24 @@ |
| 23 | 23 | return false; |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - $("#manage-product-details-form").live('submit', function(data) { | |
| 26 | + $('#manage-product-details-form').live('submit', function(data) { | |
| 27 | 27 | var form = this; |
| 28 | 28 | $(form).find('.loading-area').addClass('small-loading'); |
| 29 | 29 | $(form).css('cursor', 'progress'); |
| 30 | - $.post(form.action, $(form).serialize(), function(data) { | |
| 31 | - $("#display-manage-price-details").html(data); | |
| 32 | - $("#manage-product-details-button").show(); | |
| 30 | + var request = $.ajax(form.action, { | |
| 31 | + type: 'POST', | |
| 32 | + dataType: 'html', | |
| 33 | + data: $(form).serialize() | |
| 34 | + }); | |
| 35 | + request.done(function(data, textStatus, jqXHR) { | |
| 36 | + $('#display-manage-price-details').html(data); | |
| 37 | + $('#manage-product-details-button').show(); | |
| 38 | + }); | |
| 39 | + request.fail(function(jqXHR, textStatus, errorThrown) { | |
| 40 | + log.error('manage_product_details', 'Request failed', errorThrown); | |
| 41 | + alert('manage_product_details\nRequest failed: '+ errorThrown + | |
| 42 | + '\n\nPlease, contact the site administrator.'); | |
| 43 | + $('#display-manage-price-details .loading-area').hide(); | |
| 33 | 44 | }); |
| 34 | 45 | if ($('#progressbar-icon').hasClass('ui-icon-check')) { |
| 35 | 46 | display_notice($('#progressbar-icon').attr('data-price-described-notice')); | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -3038,6 +3038,10 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation |
| 3038 | 3038 | display: inline-block; |
| 3039 | 3039 | } |
| 3040 | 3040 | |
| 3041 | +#manage-product-details-form .formfieldline { | |
| 3042 | + white-space: nowrap; | |
| 3043 | +} | |
| 3044 | + | |
| 3041 | 3045 | #manage-product-details-form .formlabel, |
| 3042 | 3046 | #manage-product-details-form .formfield { |
| 3043 | 3047 | display: inline-block; | ... | ... |
test/functional/catalog_controller_test.rb
| ... | ... | @@ -10,6 +10,7 @@ class CatalogControllerTest < ActionController::TestCase |
| 10 | 10 | @request = ActionController::TestRequest.new |
| 11 | 11 | @response = ActionController::TestResponse.new |
| 12 | 12 | |
| 13 | + Environment.default.enable('products_for_enterprises') | |
| 13 | 14 | @enterprise = fast_create(Enterprise, :name => 'My enterprise', :identifier => 'testent') |
| 14 | 15 | @product_category = fast_create(ProductCategory) |
| 15 | 16 | end |
| ... | ... | @@ -52,7 +53,7 @@ class CatalogControllerTest < ActionController::TestCase |
| 52 | 53 | |
| 53 | 54 | should 'not give access if environment do not let' do |
| 54 | 55 | env = Environment.default |
| 55 | - env.enable('disable_products_for_enterprises') | |
| 56 | + env.disable('products_for_enterprises') | |
| 56 | 57 | env.save! |
| 57 | 58 | ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) |
| 58 | 59 | get :index, :profile => ent.identifier | ... | ... |
test/functional/manage_products_controller_test.rb
| ... | ... | @@ -13,6 +13,7 @@ class ManageProductsControllerTest < ActionController::TestCase |
| 13 | 13 | @enterprise = fast_create(Enterprise, :name => 'teste', :identifier => 'test_ent') |
| 14 | 14 | @user = create_user_with_permission('test_user', 'manage_products', @enterprise) |
| 15 | 15 | @environment = @enterprise.environment |
| 16 | + @environment.enable('products_for_enterprises') | |
| 16 | 17 | @product_category = fast_create(ProductCategory) |
| 17 | 18 | login_as :test_user |
| 18 | 19 | end |
| ... | ... | @@ -191,7 +192,7 @@ class ManageProductsControllerTest < ActionController::TestCase |
| 191 | 192 | |
| 192 | 193 | should 'not let users in if environment do not let' do |
| 193 | 194 | env = Environment.default |
| 194 | - env.enable('disable_products_for_enterprises') | |
| 195 | + env.disable('products_for_enterprises') | |
| 195 | 196 | env.save! |
| 196 | 197 | @enterprise.environment = env |
| 197 | 198 | @enterprise.save! | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -9,7 +9,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 9 | 9 | @controller = ProfileController.new |
| 10 | 10 | @request = ActionController::TestRequest.new |
| 11 | 11 | @response = ActionController::TestResponse.new |
| 12 | - | |
| 12 | + Environment.default.enable('products_for_enterprises') | |
| 13 | 13 | @profile = create_user('testuser').person |
| 14 | 14 | end |
| 15 | 15 | attr_reader :profile |
| ... | ... | @@ -263,8 +263,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 263 | 263 | |
| 264 | 264 | should 'not display "Products" link for enterprise if environment do not let' do |
| 265 | 265 | env = Environment.default |
| 266 | - env.enable('disable_products_for_enterprises') | |
| 267 | - env.save! | |
| 266 | + env.disable('products_for_enterprises') | |
| 268 | 267 | ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false, :environment_id => env.id) |
| 269 | 268 | |
| 270 | 269 | get :index, :profile => 'my-test-enterprise' | ... | ... |
test/functional/profile_design_controller_test.rb
| ... | ... | @@ -395,7 +395,7 @@ class ProfileDesignControllerTest < ActionController::TestCase |
| 395 | 395 | |
| 396 | 396 | should 'not allow products block if environment do not let' do |
| 397 | 397 | env = Environment.default |
| 398 | - env.enable('disable_products_for_enterprises') | |
| 398 | + env.disable('products_for_enterprises') | |
| 399 | 399 | env.save! |
| 400 | 400 | ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent', :environment_id => env.id) |
| 401 | 401 | person = create_user_with_permission('test_user', 'edit_profile_design', ent) |
| ... | ... | @@ -530,6 +530,7 @@ class ProfileDesignControllerTest < ActionController::TestCase |
| 530 | 530 | environment = mock |
| 531 | 531 | profile.stubs(:environment).returns(environment) |
| 532 | 532 | environment.stubs(:enabled?).returns(true) |
| 533 | + environment.stubs(:enabled?).with('products_for_enterprises').returns(false) | |
| 533 | 534 | @controller.stubs(:profile).returns(profile) |
| 534 | 535 | @controller.stubs(:user).returns(profile) |
| 535 | 536 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) |
| ... | ... | @@ -546,7 +547,7 @@ class ProfileDesignControllerTest < ActionController::TestCase |
| 546 | 547 | profile.stubs(:is_admin?).with(anything).returns(false) |
| 547 | 548 | environment = mock |
| 548 | 549 | profile.stubs(:environment).returns(environment) |
| 549 | - environment.stubs(:enabled?).returns(false) | |
| 550 | + environment.stubs(:enabled?).returns(true) | |
| 550 | 551 | @controller.stubs(:profile).returns(profile) |
| 551 | 552 | @controller.stubs(:user).returns(profile) |
| 552 | 553 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) | ... | ... |
test/functional/profile_editor_controller_test.rb
| ... | ... | @@ -559,7 +559,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 559 | 559 | |
| 560 | 560 | should 'not list the manage products button if the environment disabled it' do |
| 561 | 561 | env = Environment.default |
| 562 | - env.enable('disable_products_for_enterprises') | |
| 562 | + env.disable('products_for_enterprises') | |
| 563 | 563 | env.save! |
| 564 | 564 | ent = fast_create(Enterprise) |
| 565 | 565 | ... | ... |
test/unit/enterprise_test.rb
| ... | ... | @@ -5,6 +5,7 @@ class EnterpriseTest < ActiveSupport::TestCase |
| 5 | 5 | |
| 6 | 6 | def setup |
| 7 | 7 | super |
| 8 | + Environment.default.enable('products_for_enterprises') | |
| 8 | 9 | @product_category = fast_create(ProductCategory, :name => 'Products') |
| 9 | 10 | end |
| 10 | 11 | |
| ... | ... | @@ -80,9 +81,9 @@ class EnterpriseTest < ActiveSupport::TestCase |
| 80 | 81 | should 'create default set of blocks' do |
| 81 | 82 | e = Enterprise.create(:name => 'my new community', :identifier => 'mynewcommunity') |
| 82 | 83 | |
| 83 | - assert !e.boxes[0].blocks.empty?, 'person must have blocks in area 1' | |
| 84 | - assert !e.boxes[1].blocks.empty?, 'person must have blocks in area 2' | |
| 85 | - assert !e.boxes[2].blocks.empty?, 'person must have blocks in area 3' | |
| 84 | + assert !e.boxes[0].blocks.empty?, 'enterprise must have blocks in area 1' | |
| 85 | + assert !e.boxes[1].blocks.empty?, 'enterprise must have blocks in area 2' | |
| 86 | + assert !e.boxes[2].blocks.empty?, 'enterprise must have blocks in area 3' | |
| 86 | 87 | end |
| 87 | 88 | |
| 88 | 89 | should 'allow to add new members if has no members' do |
| ... | ... | @@ -242,8 +243,7 @@ class EnterpriseTest < ActiveSupport::TestCase |
| 242 | 243 | |
| 243 | 244 | should 'not create a products block for enterprise if environment do not let' do |
| 244 | 245 | env = Environment.default |
| 245 | - env.enable('disable_products_for_enterprises') | |
| 246 | - env.save! | |
| 246 | + env.disable('products_for_enterprises') | |
| 247 | 247 | ent = fast_create(Enterprise, :name => 'test ent', :identifier => 'test_ent') |
| 248 | 248 | assert_not_includes ent.blocks.map(&:class), ProductsBlock |
| 249 | 249 | end | ... | ... |
test/unit/price_detail_test.rb
| ... | ... | @@ -50,14 +50,14 @@ class PriceDetailTest < ActiveSupport::TestCase |
| 50 | 50 | assert_equal cost, PriceDetail.find(detail.id).production_cost |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | - should 'production cost be mandatory' do | |
| 54 | - p = PriceDetail.new | |
| 55 | - p.valid? | |
| 56 | - | |
| 57 | - assert p.errors.invalid?(:production_cost) | |
| 53 | + should 'production cost not be mandatory' do | |
| 54 | + product = fast_create(Product) | |
| 55 | + price = PriceDetail.new :product=>product | |
| 56 | + price.valid? | |
| 57 | + assert price.errors.empty? | |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | - should 'th production cost be unique on scope of product' do | |
| 60 | + should 'the production cost be unique on scope of product' do | |
| 61 | 61 | product = fast_create(Product) |
| 62 | 62 | cost = fast_create(ProductionCost, :owner_id => Environment.default.id, :owner_type => 'environment') |
| 63 | 63 | ... | ... |