Commit 7d200d67bfeb7c009be02acbced473303da6c1c2
1 parent
4d184a76
Exists in
master
and in
23 other branches
Rename enterprise variables to profile
Conflicts: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb
Showing
9 changed files
with
63 additions
and
64 deletions
Show diff stats
app/controllers/public/catalog_controller.rb
| ... | ... | @@ -11,7 +11,7 @@ class CatalogController < PublicController |
| 11 | 11 | protected |
| 12 | 12 | |
| 13 | 13 | def check_enterprise_and_environment |
| 14 | - unless profile.kind_of?(Enterprise) && @profile.environment.enabled?('products_for_enterprises') | |
| 14 | + unless profile.enterprise? && @profile.environment.enabled?('products_for_enterprises') | |
| 15 | 15 | redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index' |
| 16 | 16 | end |
| 17 | 17 | end | ... | ... |
plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
| ... | ... | @@ -28,8 +28,8 @@ class ShoppingCartPluginController < PublicController |
| 28 | 28 | |
| 29 | 29 | def add |
| 30 | 30 | product = find_product(params[:id]) |
| 31 | - if product && enterprise = validate_same_enterprise(product) | |
| 32 | - self.cart = { :profile_id => enterprise.id, :items => {} } if self.cart.nil? | |
| 31 | + if product && profile = validate_same_profile(product) | |
| 32 | + self.cart = { :profile_id => profile.id, :items => {} } if self.cart.nil? | |
| 33 | 33 | self.cart[:items][product.id] = 0 if self.cart[:items][product.id].nil? |
| 34 | 34 | self.cart[:items][product.id] += 1 |
| 35 | 35 | render :text => { |
| ... | ... | @@ -38,7 +38,7 @@ class ShoppingCartPluginController < PublicController |
| 38 | 38 | :products => [{ |
| 39 | 39 | :id => product.id, |
| 40 | 40 | :name => product.name, |
| 41 | - :price => get_price(product, enterprise.environment), | |
| 41 | + :price => get_price(product, profile.environment), | |
| 42 | 42 | :description => product.description, |
| 43 | 43 | :picture => product.default_image(:minor), |
| 44 | 44 | :quantity => self.cart[:items][product.id] |
| ... | ... | @@ -96,8 +96,8 @@ class ShoppingCartPluginController < PublicController |
| 96 | 96 | def buy |
| 97 | 97 | if validate_cart_presence |
| 98 | 98 | @cart = cart |
| 99 | - @enterprise = environment.enterprises.find(cart[:profile_id]) | |
| 100 | - @settings = Noosfero::Plugin::Settings.new(@enterprise, ShoppingCartPlugin) | |
| 99 | + @profile = environment.profiles.find(cart[:profile_id]) | |
| 100 | + @settings = Noosfero::Plugin::Settings.new(@profile, ShoppingCartPlugin) | |
| 101 | 101 | render :layout => false |
| 102 | 102 | end |
| 103 | 103 | end |
| ... | ... | @@ -105,9 +105,9 @@ class ShoppingCartPluginController < PublicController |
| 105 | 105 | def send_request |
| 106 | 106 | register_order(params[:customer], self.cart[:items]) |
| 107 | 107 | begin |
| 108 | - enterprise = environment.enterprises.find(cart[:profile_id]) | |
| 109 | - ShoppingCartPlugin::Mailer.deliver_customer_notification(params[:customer], enterprise, self.cart[:items], params[:delivery_option]) | |
| 110 | - ShoppingCartPlugin::Mailer.deliver_supplier_notification(params[:customer], enterprise, self.cart[:items], params[:delivery_option]) | |
| 108 | + profile = environment.profiles.find(cart[:profile_id]) | |
| 109 | + ShoppingCartPlugin::Mailer.deliver_customer_notification(params[:customer], profile, self.cart[:items], params[:delivery_option]) | |
| 110 | + ShoppingCartPlugin::Mailer.deliver_supplier_notification(params[:customer], profile, self.cart[:items], params[:delivery_option]) | |
| 111 | 111 | self.cart = nil |
| 112 | 112 | render :text => { |
| 113 | 113 | :ok => true, |
| ... | ... | @@ -168,8 +168,8 @@ class ShoppingCartPluginController < PublicController |
| 168 | 168 | end |
| 169 | 169 | |
| 170 | 170 | def update_delivery_option |
| 171 | - enterprise = environment.enterprises.find(cart[:profile_id]) | |
| 172 | - settings = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin) | |
| 171 | + profile = environment.profiles.find(cart[:profile_id]) | |
| 172 | + settings = Noosfero::Plugin::Settings.new(profile, ShoppingCartPlugin) | |
| 173 | 173 | delivery_price = settings.delivery_options[params[:delivery_option]] |
| 174 | 174 | delivery = Product.new(:name => params[:delivery_option], :price => delivery_price) |
| 175 | 175 | delivery.save(false) |
| ... | ... | @@ -188,7 +188,7 @@ class ShoppingCartPluginController < PublicController |
| 188 | 188 | |
| 189 | 189 | private |
| 190 | 190 | |
| 191 | - def validate_same_enterprise(product) | |
| 191 | + def validate_same_profile(product) | |
| 192 | 192 | if self.cart && self.cart[:profile_id] && product.profile_id != self.cart[:profile_id] |
| 193 | 193 | render :text => { |
| 194 | 194 | :ok => false, |
| ... | ... | @@ -199,7 +199,7 @@ class ShoppingCartPluginController < PublicController |
| 199 | 199 | }.to_json |
| 200 | 200 | return nil |
| 201 | 201 | end |
| 202 | - product.enterprise | |
| 202 | + product.profile | |
| 203 | 203 | end |
| 204 | 204 | |
| 205 | 205 | def validate_cart_presence |
| ... | ... | @@ -268,7 +268,7 @@ class ShoppingCartPluginController < PublicController |
| 268 | 268 | new_items[id] = {:quantity => quantity, :price => price, :name => product.name} |
| 269 | 269 | end |
| 270 | 270 | ShoppingCartPlugin::PurchaseOrder.create!( |
| 271 | - :seller => Enterprise.find(cart[:profile_id]), | |
| 271 | + :seller => environment.profiles.find(cart[:profile_id]), | |
| 272 | 272 | :customer => user, |
| 273 | 273 | :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED, |
| 274 | 274 | :products_list => new_items, |
| ... | ... | @@ -325,7 +325,7 @@ class ShoppingCartPluginController < PublicController |
| 325 | 325 | if product |
| 326 | 326 | { :id => product.id, |
| 327 | 327 | :name => product.name, |
| 328 | - :price => get_price(product, product.enterprise.environment), | |
| 328 | + :price => get_price(product, product.profile.environment), | |
| 329 | 329 | :description => product.description, |
| 330 | 330 | :picture => product.default_image(:minor), |
| 331 | 331 | :quantity => quantity | ... | ... |
plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb
| 1 | -include ShoppingCartPlugin::CartHelper | |
| 2 | - | |
| 3 | 1 | class ShoppingCartPluginMyprofileController < MyProfileController |
| 4 | - append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
| 2 | + | |
| 3 | + include ShoppingCartPlugin::CartHelper | |
| 5 | 4 | |
| 6 | 5 | def edit |
| 7 | 6 | params[:settings] = treat_cart_options(params[:settings]) | ... | ... |
plugins/shopping_cart/lib/shopping_cart_plugin.rb
| ... | ... | @@ -23,8 +23,8 @@ class ShoppingCartPlugin < Noosfero::Plugin |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | def add_to_cart_button(item) |
| 26 | - enterprise = item.enterprise | |
| 27 | - settings = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin) | |
| 26 | + profile = item.profile | |
| 27 | + settings = Noosfero::Plugin::Settings.new(profile, ShoppingCartPlugin) | |
| 28 | 28 | if settings.enabled && item.available |
| 29 | 29 | lambda { |
| 30 | 30 | link_to(_('Add to basket'), "add:#{item.name}", | ... | ... |
plugins/shopping_cart/public/buy.js
| ... | ... | @@ -11,7 +11,7 @@ jQuery(document).ready(function(){ |
| 11 | 11 | jQuery('#delivery_option').change(function(){ |
| 12 | 12 | jQuery('#cboxLoadingGraphic').show(); |
| 13 | 13 | me = this; |
| 14 | - enterprise = jQuery(me).attr('data-profile-identifier'); | |
| 14 | + profile = jQuery(me).attr('data-profile-identifier'); | |
| 15 | 15 | option = jQuery(me).val(); |
| 16 | 16 | jQuery.ajax({ |
| 17 | 17 | url: '/plugin/shopping_cart/update_delivery_option', | ... | ... |
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
| ... | ... | @@ -10,10 +10,10 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 10 | 10 | @controller = ShoppingCartPluginController.new |
| 11 | 11 | @request = ActionController::TestRequest.new |
| 12 | 12 | @response = ActionController::TestResponse.new |
| 13 | - @enterprise = fast_create(Enterprise) | |
| 14 | - @product = fast_create(Product, :profile_id => @enterprise.id) | |
| 13 | + @profile = fast_create(Enterprise) | |
| 14 | + @product = fast_create(Product, :profile_id => @profile.id) | |
| 15 | 15 | end |
| 16 | - attr_reader :enterprise | |
| 16 | + attr_reader :profile | |
| 17 | 17 | attr_reader :product |
| 18 | 18 | |
| 19 | 19 | should 'force cookie expiration with explicit path for an empty cart' do |
| ... | ... | @@ -62,7 +62,7 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | 64 | should 'just remove product if there are other products on cart' do |
| 65 | - another_product = fast_create(Product, :profile_id => enterprise.id) | |
| 65 | + another_product = fast_create(Product, :profile_id => profile.id) | |
| 66 | 66 | get :add, :id => product.id |
| 67 | 67 | get :add, :id => another_product.id |
| 68 | 68 | |
| ... | ... | @@ -135,7 +135,7 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 135 | 135 | end |
| 136 | 136 | |
| 137 | 137 | should 'clean the cart' do |
| 138 | - another_product = fast_create(Product, :profile_id => enterprise.id) | |
| 138 | + another_product = fast_create(Product, :profile_id => profile.id) | |
| 139 | 139 | get :add, :id => product.id |
| 140 | 140 | get :add, :id => another_product.id |
| 141 | 141 | |
| ... | ... | @@ -150,9 +150,9 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 150 | 150 | end |
| 151 | 151 | |
| 152 | 152 | should 'register order on send request' do |
| 153 | - product1 = fast_create(Product, :profile_id => enterprise.id, :price => 1.99) | |
| 154 | - product2 = fast_create(Product, :profile_id => enterprise.id, :price => 2.23) | |
| 155 | - @controller.stubs(:cart).returns({ :profile_id => enterprise.id, :items => {product1.id => 1, product2.id => 2}}) | |
| 153 | + product1 = fast_create(Product, :profile_id => profile.id, :price => 1.99) | |
| 154 | + product2 = fast_create(Product, :profile_id => profile.id, :price => 2.23) | |
| 155 | + @controller.stubs(:cart).returns({ :profile_id => profile.id, :items => {product1.id => 1, product2.id => 2}}) | |
| 156 | 156 | assert_difference ShoppingCartPlugin::PurchaseOrder, :count, 1 do |
| 157 | 157 | post :send_request, |
| 158 | 158 | :customer => {:name => "Manuel", :email => "manuel@ceu.com"} |
| ... | ... | @@ -168,8 +168,8 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 168 | 168 | end |
| 169 | 169 | |
| 170 | 170 | should 'register order on send request and not crash if product is not defined' do |
| 171 | - product1 = fast_create(Product, :profile_id => enterprise.id) | |
| 172 | - @controller.stubs(:cart).returns({ :profile_id => enterprise.id, :items => {product1.id => 1}}) | |
| 171 | + product1 = fast_create(Product, :profile_id => profile.id) | |
| 172 | + @controller.stubs(:cart).returns({ :profile_id => profile.id, :items => {product1.id => 1}}) | |
| 173 | 173 | assert_difference ShoppingCartPlugin::PurchaseOrder, :count, 1 do |
| 174 | 174 | post :send_request, |
| 175 | 175 | :customer => {:name => "Manuel", :email => "manuel@ceu.com"} |
| ... | ... | @@ -181,7 +181,7 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 181 | 181 | end |
| 182 | 182 | |
| 183 | 183 | should 'clean the cart after placing the order' do |
| 184 | - product1 = fast_create(Product, :profile_id => enterprise.id) | |
| 184 | + product1 = fast_create(Product, :profile_id => profile.id) | |
| 185 | 185 | post :add, :id => product1.id |
| 186 | 186 | post :send_request, :customer => { :name => "Manuel", :email => "manuel@ceu.com" } |
| 187 | 187 | assert !cart?, "cart expected to be empty!" | ... | ... |
plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb
| ... | ... | @@ -5,17 +5,17 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 5 | 5 | TIME_FORMAT = '%Y-%m-%d' |
| 6 | 6 | |
| 7 | 7 | def setup |
| 8 | - @enterprise = fast_create(Enterprise) | |
| 8 | + @profile = fast_create(Enterprise) | |
| 9 | 9 | @admin = create_user('admin').person |
| 10 | - @enterprise.add_admin(@admin) | |
| 10 | + @profile.add_admin(@admin) | |
| 11 | 11 | login_as(@admin.identifier) |
| 12 | 12 | end |
| 13 | - attr_reader :enterprise | |
| 13 | + attr_reader :profile | |
| 14 | 14 | |
| 15 | 15 | should 'be able to enable shopping cart' do |
| 16 | 16 | settings.enabled = false |
| 17 | 17 | settings.save! |
| 18 | - post :edit, :profile => enterprise.identifier, :settings => {:enabled => '1'} | |
| 18 | + post :edit, :profile => profile.identifier, :settings => {:enabled => '1'} | |
| 19 | 19 | |
| 20 | 20 | assert settings.enabled |
| 21 | 21 | end |
| ... | ... | @@ -23,7 +23,7 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 23 | 23 | should 'be able to disable shopping cart' do |
| 24 | 24 | settings.enabled = true |
| 25 | 25 | settings.save! |
| 26 | - post :edit, :profile => enterprise.identifier, :settings => {:enabled => '0'} | |
| 26 | + post :edit, :profile => profile.identifier, :settings => {:enabled => '0'} | |
| 27 | 27 | |
| 28 | 28 | assert !settings.enabled |
| 29 | 29 | end |
| ... | ... | @@ -31,7 +31,7 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 31 | 31 | should 'be able to enable shopping cart delivery' do |
| 32 | 32 | settings.delivery = false |
| 33 | 33 | settings.save! |
| 34 | - post :edit, :profile => enterprise.identifier, :settings => {:delivery => '1'} | |
| 34 | + post :edit, :profile => profile.identifier, :settings => {:delivery => '1'} | |
| 35 | 35 | |
| 36 | 36 | assert settings.delivery |
| 37 | 37 | end |
| ... | ... | @@ -39,37 +39,37 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 39 | 39 | should 'be able to disable shopping cart delivery' do |
| 40 | 40 | settings.delivery = true |
| 41 | 41 | settings.save! |
| 42 | - post :edit, :profile => enterprise.identifier, :settings => {:delivery => '0'} | |
| 42 | + post :edit, :profile => profile.identifier, :settings => {:delivery => '0'} | |
| 43 | 43 | |
| 44 | 44 | assert !settings.delivery |
| 45 | 45 | end |
| 46 | 46 | |
| 47 | 47 | should 'be able to choose the delivery price' do |
| 48 | 48 | price = 4.35 |
| 49 | - post :edit, :profile => enterprise.identifier, :settings => {:delivery_price => price} | |
| 49 | + post :edit, :profile => profile.identifier, :settings => {:delivery_price => price} | |
| 50 | 50 | |
| 51 | 51 | assert settings.delivery_price == price |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | 54 | should 'be able to choose delivery_options' do |
| 55 | 55 | delivery_options = {:options => ['car', 'bike'], :prices => ['20', '5']} |
| 56 | - post :edit, :profile => enterprise.identifier, :settings => {:delivery_options => delivery_options} | |
| 56 | + post :edit, :profile => profile.identifier, :settings => {:delivery_options => delivery_options} | |
| 57 | 57 | |
| 58 | 58 | assert_equal '20', settings.delivery_options['car'] |
| 59 | 59 | assert_equal '5', settings.delivery_options['bike'] |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | should 'filter the reports correctly' do |
| 63 | - another_enterprise = fast_create(Enterprise) | |
| 64 | - po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 65 | - po2 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::SHIPPED) | |
| 66 | - po3 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 63 | + another_profile = fast_create(Enterprise) | |
| 64 | + po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 65 | + po2 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :status => ShoppingCartPlugin::PurchaseOrder::Status::SHIPPED) | |
| 66 | + po3 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 67 | 67 | po3.created_at = 1.year.ago |
| 68 | 68 | po3.save! |
| 69 | - po4 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => another_enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 69 | + po4 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => another_profile, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 70 | 70 | |
| 71 | 71 | post :reports, |
| 72 | - :profile => enterprise.identifier, | |
| 72 | + :profile => profile.identifier, | |
| 73 | 73 | :from => (Time.now - 1.day).strftime(TIME_FORMAT), |
| 74 | 74 | :to => (Time.now + 1.day).strftime(TIME_FORMAT), |
| 75 | 75 | :filter_status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED |
| ... | ... | @@ -81,16 +81,16 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 81 | 81 | end |
| 82 | 82 | |
| 83 | 83 | should 'group filtered orders products and quantities' do |
| 84 | - p1 = fast_create(Product, :profile_id => enterprise.id, :price => 1, :name => 'p1') | |
| 85 | - p2 = fast_create(Product, :profile_id => enterprise.id, :price => 2, :name => 'p2') | |
| 86 | - p3 = fast_create(Product, :profile_id => enterprise.id, :price => 3) | |
| 84 | + p1 = fast_create(Product, :profile_id => profile.id, :price => 1, :name => 'p1') | |
| 85 | + p2 = fast_create(Product, :profile_id => profile.id, :price => 2, :name => 'p2') | |
| 86 | + p3 = fast_create(Product, :profile_id => profile.id, :price => 3) | |
| 87 | 87 | po1_products = {p1.id => {:quantity => 1, :price => p1.price, :name => p1.name}, p2.id => {:quantity => 2, :price => p2.price, :name => p2.name }} |
| 88 | 88 | po2_products = {p2.id => {:quantity => 1, :price => p2.price, :name => p2.name }, p3.id => {:quantity => 2, :price => p3.price, :name => p3.name}} |
| 89 | - po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :products_list => po1_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 90 | - po2 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :products_list => po2_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 89 | + po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :products_list => po1_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 90 | + po2 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :products_list => po2_products, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 91 | 91 | |
| 92 | 92 | post :reports, |
| 93 | - :profile => enterprise.identifier, | |
| 93 | + :profile => profile.identifier, | |
| 94 | 94 | :from => (Time.now - 1.day).strftime(TIME_FORMAT), |
| 95 | 95 | :to => (Time.now + 1.day).strftime(TIME_FORMAT), |
| 96 | 96 | :filter_status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED |
| ... | ... | @@ -107,10 +107,10 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 107 | 107 | end |
| 108 | 108 | |
| 109 | 109 | should 'be able to update the order status' do |
| 110 | - po = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 110 | + po = ShoppingCartPlugin::PurchaseOrder.create!(:seller => profile, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) | |
| 111 | 111 | |
| 112 | 112 | post :update_order_status, |
| 113 | - :profile => enterprise.identifier, | |
| 113 | + :profile => profile.identifier, | |
| 114 | 114 | :order_id => po.id, |
| 115 | 115 | :order_status => ShoppingCartPlugin::PurchaseOrder::Status::CONFIRMED |
| 116 | 116 | po.reload |
| ... | ... | @@ -120,7 +120,7 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase |
| 120 | 120 | private |
| 121 | 121 | |
| 122 | 122 | def settings |
| 123 | - @enterprise.reload | |
| 124 | - Noosfero::Plugin::Settings.new(@enterprise, ShoppingCartPlugin) | |
| 123 | + @profile.reload | |
| 124 | + Noosfero::Plugin::Settings.new(@profile, ShoppingCartPlugin) | |
| 125 | 125 | end |
| 126 | 126 | end | ... | ... |
plugins/shopping_cart/test/unit/shopping_cart_plugin_test.rb
| ... | ... | @@ -19,16 +19,16 @@ class ShoppingCartPluginTest < ActiveSupport::TestCase |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | should 'not add button if product unavailable' do |
| 22 | - enterprise = fast_create(:enterprise) | |
| 23 | - product = fast_create(Product, :available => false, :profile_id => enterprise.id) | |
| 24 | - enterprise.stubs(:shopping_cart).returns(true) | |
| 22 | + profile = fast_create(:enterprise) | |
| 23 | + product = fast_create(Product, :available => false, :profile_id => profile.id) | |
| 24 | + profile.stubs(:shopping_cart).returns(true) | |
| 25 | 25 | |
| 26 | 26 | assert_nil shopping_cart.add_to_cart_button(product) |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | 29 | should 'be disabled by default on the enterprise' do |
| 30 | - enterprise = fast_create(Enterprise) | |
| 31 | - settings = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin) | |
| 30 | + profile = fast_create(Enterprise) | |
| 31 | + settings = Noosfero::Plugin::Settings.new(profile, ShoppingCartPlugin) | |
| 32 | 32 | assert !settings.enabled |
| 33 | 33 | end |
| 34 | 34 | end | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | <%= labelled_form_field('* ' + _("Name"), f.text_field(:name, :class => 'required') ) %> |
| 7 | 7 | <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> |
| 8 | 8 | <%= labelled_form_field('* ' + _("Contact phone"), f.text_field(:contact_phone, :class => 'required') ) %> |
| 9 | - <%= labelled_form_field(_('Delivery option'), select_tag(:delivery_option, options_for_select(select_delivery_options(@settings.delivery_options, environment)), 'data-profile-identifier' => @enterprise.identifier)) unless !@settings.delivery || (@settings.free_delivery_price && get_total(@cart[:items]) >= @settings.free_delivery_price) %> | |
| 9 | + <%= labelled_form_field(_('Delivery option'), select_tag(:delivery_option, options_for_select(select_delivery_options(@settings.delivery_options, environment)), 'data-profile-identifier' => @profile.identifier)) unless !@settings.delivery || (@settings.free_delivery_price && get_total(@cart[:items]) >= @settings.free_delivery_price) %> | |
| 10 | 10 | <%= labelled_form_field(_('Payment'), select_tag('customer[payment]', options_for_select([[_("Money"), :money],[_('shopping_cart|Check'), :check]]))) %> |
| 11 | 11 | <%= labelled_form_field(s_('shopping_cart|Change'), text_field_tag('customer[change]')) %> |
| 12 | 12 | </div> |
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | </div> |
| 25 | 25 | <% end %> |
| 26 | 26 | <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %> |
| 27 | - <%= items_table(@cart[:items], @enterprise, delivery_option) %> | |
| 27 | + <%= items_table(@cart[:items], @profile, delivery_option) %> | |
| 28 | 28 | <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %> |
| 29 | 29 | </div> |
| 30 | 30 | ... | ... |