Commit 4199280abd7e6dd5c6f11f0926a017e1a619dce5
1 parent
8dfeff6c
Exists in
web_steps_improvements
and in
9 other branches
Refactor ProductsBlock footer into helper/view
Showing
3 changed files
with
26 additions
and
31 deletions
Show diff stats
app/models/products_block.rb
| ... | ... | @@ -19,10 +19,6 @@ class ProductsBlock < Block |
| 19 | 19 | _('This block presents a list of your products.') |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | - def footer | |
| 23 | - link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) | |
| 24 | - end | |
| 25 | - | |
| 26 | 22 | settings_items :product_ids, type: Array |
| 27 | 23 | def product_ids=(array) |
| 28 | 24 | self.settings[:product_ids] = array | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= link_to(_('View all products'), block.owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) %> | ... | ... |
test/unit/products_block_test.rb
| ... | ... | @@ -20,18 +20,6 @@ class ProductsBlockTest < ActiveSupport::TestCase |
| 20 | 20 | assert_not_equal Block.description, ProductsBlock.description |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | - should 'point to all products in footer' do | |
| 24 | - enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | |
| 25 | - create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | |
| 26 | - create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | |
| 27 | - | |
| 28 | - block.stubs(:owner).returns(enterprise) | |
| 29 | - | |
| 30 | - footer = block.footer | |
| 31 | - | |
| 32 | - assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | |
| 33 | - end | |
| 34 | - | |
| 35 | 23 | should 'list 4 random products by default' do |
| 36 | 24 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') |
| 37 | 25 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) |
| ... | ... | @@ -105,21 +93,6 @@ class ProductsBlockTest < ActiveSupport::TestCase |
| 105 | 93 | assert_equivalent [p1, p2, p3, p4], block.products |
| 106 | 94 | end |
| 107 | 95 | end |
| 108 | - | |
| 109 | - should 'generate footer when enterprise has own hostname' do | |
| 110 | - enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | |
| 111 | - enterprise.domains << Domain.new(:name => 'sometest.com'); enterprise.save! | |
| 112 | - create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | |
| 113 | - create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | |
| 114 | - | |
| 115 | - block.stubs(:owner).returns(enterprise) | |
| 116 | - | |
| 117 | - footer = block.footer | |
| 118 | - | |
| 119 | - assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | |
| 120 | - end | |
| 121 | - | |
| 122 | - | |
| 123 | 96 | end |
| 124 | 97 | |
| 125 | 98 | require 'boxes_helper' |
| ... | ... | @@ -174,4 +147,29 @@ class ProductsBlockViewTest < ActionView::TestCase |
| 174 | 147 | content = render_block_content(block) |
| 175 | 148 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /rails_minor.png/ } |
| 176 | 149 | end |
| 150 | + | |
| 151 | + should 'point to all products in footer' do | |
| 152 | + enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | |
| 153 | + create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | |
| 154 | + create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | |
| 155 | + | |
| 156 | + block.stubs(:owner).returns(enterprise) | |
| 157 | + | |
| 158 | + footer = render_block_footer(block) | |
| 159 | + | |
| 160 | + assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | |
| 161 | + end | |
| 162 | + | |
| 163 | + should 'generate footer when enterprise has own hostname' do | |
| 164 | + enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | |
| 165 | + enterprise.domains << Domain.new(:name => 'sometest.com'); enterprise.save! | |
| 166 | + create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | |
| 167 | + create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | |
| 168 | + | |
| 169 | + block.stubs(:owner).returns(enterprise) | |
| 170 | + | |
| 171 | + footer = render_block_footer(block) | |
| 172 | + | |
| 173 | + assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | |
| 174 | + end | |
| 177 | 175 | end | ... | ... |