Commit 7d64d3eabf29c24454850f50d80d32e0bd0f4809

Authored by Antonio Terceiro
1 parent 5bf7a6e2

Block, Article: test per-language fragment caching in unit tests

The cucumber tests would depend on having the translations compiled,
which takes quite a while (more than 1 minute on my tests). You don't
want an extra full minute on every CI run.
features/caching.feature
@@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
1 -Feature: caching  
2 - As a user  
3 - I want to see the contents according with my language  
4 - Even with the contents being cached  
5 -  
6 - Background:  
7 - Given the cache is turned on  
8 - And the following user  
9 - | login | name |  
10 - | mario | Mario |  
11 - And I am logged in as "mario"  
12 -  
13 - Scenario: blog view page  
14 - Given the following blogs  
15 - | owner | name | display_posts_in_current_language | visualization_format |  
16 - | mario | Sample Blog | false | short |  
17 - And the following articles  
18 - | owner | name | parent |  
19 - | mario | Post1 | Sample Blog |  
20 - | mario | Post2 | Sample Blog |  
21 - When I go to article "Sample Blog"  
22 - Then I should see "no comments yet"  
23 - When I follow "Português"  
24 - Then I should see "sem comentários ainda"  
25 -  
26 - Scenario: blocks  
27 - Given I am on Mario's homepage  
28 - Then I should see "Recent content"  
29 - When I follow "Português"  
30 - Then I should see "Conteúdo recente"  
test/unit/article_test.rb
@@ -759,6 +759,11 @@ class ArticleTest < ActiveSupport::TestCase @@ -759,6 +759,11 @@ class ArticleTest < ActiveSupport::TestCase
759 assert_match(/-version-2/,a.cache_key(:version => 2)) 759 assert_match(/-version-2/,a.cache_key(:version => 2))
760 end 760 end
761 761
  762 + should 'use language in cache key' do
  763 + a = Article.new
  764 + assert_not_equal a.cache_key({}, nil, ''), a.cache_key({}, nil, 'pt')
  765 + end
  766 +
762 should 'not be highlighted by default' do 767 should 'not be highlighted by default' do
763 a = Article.new 768 a = Article.new
764 refute a.highlighted 769 refute a.highlighted
test/unit/block_test.rb
@@ -303,6 +303,11 @@ class BlockTest < ActiveSupport::TestCase @@ -303,6 +303,11 @@ class BlockTest < ActiveSupport::TestCase
303 assert_equal block.cache_key('en'), block.cache_key('en', person) 303 assert_equal block.cache_key('en'), block.cache_key('en', person)
304 end 304 end
305 305
  306 + should 'use language in cache key' do
  307 + block = Block.new
  308 + assert_not_equal block.cache_key('en'), block.cache_key('pt')
  309 + end
  310 +
306 should 'display block to members of community for display_user = members' do 311 should 'display block to members of community for display_user = members' do
307 community = fast_create(Community) 312 community = fast_create(Community)
308 user = create_user('testinguser') 313 user = create_user('testinguser')