Commit 5b1eb2d2059b02737ba945629bce1496d2bcfc78

Authored by Joenio Costa
2 parents ddc0af11 070dfc09

Merge branch 'stable'

Conflicts:
	app/helpers/application_helper.rb
	app/helpers/manage_products_helper.rb
app/helpers/application_helper.rb
... ... @@ -981,4 +981,8 @@ module ApplicationHelper
981 981 javascript_tag('render_jquery_ui_buttons()')
982 982 end
983 983  
  984 + def float_to_currency(value)
  985 + number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :format => "%u %n")
  986 + end
  987 +
984 988 end
... ...
app/helpers/display_helper.rb
... ... @@ -2,12 +2,16 @@ module DisplayHelper
2 2  
3 3 def link_to_product(product, opts={})
4 4 return _('No product') unless product
5   - target = product.enterprise.enabled? ? product.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => product) : product.enterprise.url
  5 + target = product_path(product)
6 6 link_to content_tag( 'span', product.name ),
7 7 target,
8 8 opts
9 9 end
10 10  
  11 + def product_path(product)
  12 + product.enterprise.enabled? ? product.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => product) : product.enterprise.url
  13 + end
  14 +
11 15 def link_to_category(category, full = true)
12 16 return _('Uncategorized product') unless category
13 17 name = full ? category.full_name(' → ') : category.name
... ...
app/helpers/manage_products_helper.rb
... ... @@ -158,8 +158,10 @@ module ManageProductsHelper
158 158 end
159 159 end
160 160  
161   - def float_to_currency(value)
162   - number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :format => "%u %n")
  161 + def edit_product_category_link(product, html_options = {})
  162 + return '' unless (user && user.has_permission?('manage_products', profile))
  163 + options = html_options.merge(:id => 'link-edit-product-category')
  164 + link_to(_('Change category'), { :action => 'edit_category', :id => product.id}, options)
163 165 end
164 166  
165 167 def display_value(product)
... ...
app/views/blocks/featured_products.rhtml
... ... @@ -9,13 +9,13 @@
9 9 <ul>
10 10 <% group.reject{ |x| x.nil? }.each_with_index do |p, i| %>
11 11 <li class="featured-product-item">
12   - <%= link_to content_tag(:img, nil, :src => p.image.public_filename(:thumb), :alt => p.name, :class => ('reflect' if block.reflect)), product_path(p.enterprise.identifier, p), :class => 'featured-product-image' %>
  12 + <%= link_to content_tag(:img, nil, :src => p.image.public_filename(:thumb), :alt => p.name, :class => ('reflect' if block.reflect)), product_path(p), :class => 'featured-product-image' %>
13 13 <div class="featured-product-info position-<%= i + 1 %>" style="display: none">
14 14 <div class="featured-product-text">
15 15 <h3><%= p.name %></h3>
16 16 <p class="featured-product-price"><%= float_to_currency(p.price) %></p>
17 17 <p class="featured-product-desc"><%= p.description.chars[0...50].to_s + '...' %></p>
18   - <p><%= link_to _('See More'), product_path(p.enterprise.identifier, p), :class => 'featured-product-link' %></p>
  18 + <p><%= link_to _('See More'), product_path(p), :class => 'featured-product-link' %></p>
19 19 </div>
20 20 </div>
21 21 </li>
... ...
features/featured_products_block.feature 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +Feature: featured_products_block
  2 + As a profile owner
  3 + I want to edit the featured block
  4 +
  5 + Background:
  6 + Given I am on the homepage
  7 + And the following users
  8 + | login | name |
  9 + | eddievedder | Eddie Vedder |
  10 + And the following enterprises
  11 + | identifier | owner | name | enabled |
  12 + | redemoinho | eddievedder | Rede Moinho | true |
  13 + And the following blocks
  14 + | owner | type |
  15 + | redemoinho | FeaturedProductsBlock |
  16 + And the following product_category
  17 + | name |
  18 + | automobile |
  19 + And the following products
  20 + | owner | category | name | description | highlighted |
  21 + | redemoinho | automobile | Car | Red Car | true |
  22 + | redemoinho | automobile | Truck | Blue Truck | true |
  23 + And I am logged in as "eddievedder"
  24 +
  25 + @selenium
  26 + Scenario: select a product to be featured
  27 + And I follow "Manage my groups"
  28 + And I follow "Control panel of this group"
  29 + And I follow "Edit sideboxes"
  30 + Given I follow "Edit" within ".featured-products-block"
  31 + And I select "Car"
  32 + When I press "Save"
  33 + Then I should see "Car"
  34 + And I should not see "float_to_currency"
  35 + And I should not see "product_path"
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -62,7 +62,8 @@ Given /^the following products$/ do |table|
62 62 data = item.dup
63 63 owner = Enterprise[data.delete("owner")]
64 64 category = Category.find_by_slug(data.delete("category"))
65   - Product.create!(data.merge(:enterprise => owner, :product_category => category))
  65 + product = Product.create!(data.merge(:enterprise => owner, :product_category => category))
  66 + image = Image.create!(:owner => product, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
66 67 end
67 68 end
68 69  
... ...