Commit eb873de0fbfa6dee2df0eacebb69a93c77afec37
1 parent
45e60d94
Exists in
master
and in
29 other branches
ActionItem567: fix name of test for search_helper
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2282 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
63 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +class SearchHelperTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + include SearchHelper | ||
6 | + | ||
7 | + def _(any) | ||
8 | + any | ||
9 | + end | ||
10 | + | ||
11 | + def setup | ||
12 | + @profile = mock | ||
13 | + end | ||
14 | + attr_reader :profile | ||
15 | + | ||
16 | + include ActionView::Helpers::FormOptionsHelper | ||
17 | + include ActionView::Helpers::FormTagHelper | ||
18 | + include ActionView::Helpers::TagHelper | ||
19 | + should 'display profile info' do | ||
20 | + profile.stubs(:name).returns('Name of Profile') | ||
21 | + profile.stubs(:address).returns('Address of Profile') | ||
22 | + profile.stubs(:contact_email).returns('Email of Profile') | ||
23 | + profile.stubs(:contact_phone).returns('Phone of Profile') | ||
24 | + profile.stubs(:url).returns('') | ||
25 | + profile.stubs(:products).returns([Product.new(:name => 'product test')]) | ||
26 | + profile.stubs(:identifier).returns('name-of-profile') | ||
27 | + profile.stubs(:region).returns(Region.new(:name => 'Brazil')) | ||
28 | + | ||
29 | + self.stubs(:profile_image).returns('profileimage.png') | ||
30 | + self.stubs(:url_for).returns('merda') | ||
31 | + self.stubs(:link_to).returns('link to profile') | ||
32 | + | ||
33 | + result = self.display_profile_info(profile) | ||
34 | + assert_match /profileimage.png/, result | ||
35 | + assert_match /link to profile/, result | ||
36 | + assert_match /Email of Profile/, result | ||
37 | + assert_match /Phone of Profile/, result | ||
38 | + assert_match /Address of Profile/, result | ||
39 | + end | ||
40 | + | ||
41 | + should 'not display field if nil in profile info' do | ||
42 | + profile.stubs(:name).returns('Name of Profile') | ||
43 | + profile.stubs(:address).returns('nil') | ||
44 | + profile.stubs(:contact_email).returns('nil') | ||
45 | + profile.stubs(:contact_phone).returns('nil') | ||
46 | + profile.stubs(:url).returns('') | ||
47 | + profile.stubs(:products).returns([Product.new(:name => 'product test')]) | ||
48 | + profile.stubs(:identifier).returns('name-of-profile') | ||
49 | + profile.stubs(:region).returns(Region.new(:name => 'Brazil')) | ||
50 | + | ||
51 | + self.stubs(:profile_image).returns('profileimage.png') | ||
52 | + self.stubs(:url_for).returns('merda') | ||
53 | + self.stubs(:link_to).returns('link to profile') | ||
54 | + | ||
55 | + result = self.display_profile_info(profile) | ||
56 | + assert_match /profileimage.png/, result | ||
57 | + assert_match /link to profile/, result | ||
58 | + assert_no_match /Email of Profile/, result | ||
59 | + assert_no_match /Phone of Profile/, result | ||
60 | + assert_no_match /Address of Profile/, result | ||
61 | + end | ||
62 | + | ||
63 | +end |