From 9b39bfdc5bb9c351595d9b9dda3a29505876efbb Mon Sep 17 00:00:00 2001 From: Aurelio A. Heckert Date: Wed, 11 Jan 2012 19:03:48 -0200 Subject: [PATCH] Tests for Gravatar Support --- features/gravatar_support.feature | 30 ++++++++++++++++++++++++++++++ features/support/paths.rb | 3 +++ test/unit/application_helper_test.rb | 7 ++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 features/gravatar_support.feature diff --git a/features/gravatar_support.feature b/features/gravatar_support.feature new file mode 100644 index 0000000..f16c158 --- /dev/null +++ b/features/gravatar_support.feature @@ -0,0 +1,30 @@ +Feature: Gravatar Support + Unauthenticated users may comment content and are displayed with Gravatar + pictures. The commenter with registered Gravatar image will have a link to + his/her Gravatar profile, others will have a link to the Gravatar homepage. + + Background: + Given the following users + | login | name | + | manuel | Manuel Silva | + And the following articles + | owner | name | + | manuel | My Article | + And the following comments + | article | author | name | email | title | body | + | My Article | manuel | | | 1 | Hi! | + | My Article | | Aurium | aurium@gmail.com | 2 | Hello! | + | My Article | | NoOne | nobody@colivre.coop.br | 3 | Bye! | + + @selenium + Scenario: The Aurium's gravatar picture must link to his gravatar profile + # because Aurium has his picture registered at garvatar.com. + When I go to article "My Article" + Then I should see "Aurium" linking to "http://www.gravatar.com/24a625896a07aa37fdb2352e302e96de" + + @selenium + Scenario: The NoOne's gravatar picture must link to Gravatar homepage + # because NoOne has no picture registered. + When I go to article "My Article" + Then I should see "NoOne" linking to "http://www.gravatar.com" + diff --git a/features/support/paths.rb b/features/support/paths.rb index a292fca..2afb346 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -14,6 +14,9 @@ module NavigationHelpers when /^\// page_name + when /article "([^"]+)"\s*$/ + url_for( Article.find_by_name($1).url ) + when /edit "(.+)" by (.+)/ article_id = Person[$2].articles.find_by_slug($1.to_slug).id "/myprofile/#{$2}/cms/edit/#{article_id}" diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index b463a69..f71e117 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -467,7 +467,7 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_match(/Community nick/, page_title) end - should 'generate a gravatar url' do + should 'generate a gravatar image url' do with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) @@ -477,6 +477,11 @@ class ApplicationHelperTest < Test::Unit::TestCase end end + should 'generate a gravatar profile url' do + url = gravatar_profile_url( 'rms@gnu.org' ) + assert_equal('http://www.gravatar.com/ed5214d4b49154ba0dc397a28ee90eb7', url) + end + should 'use theme passed via param when in development mode' do stubs(:environment).returns(Environment.new(:theme => 'environment-theme')) ENV.stubs(:[]).with('RAILS_ENV').returns('development') -- libgit2 0.21.2