diff --git a/app/helpers/article_helper.rb b/app/helpers/article_helper.rb index 2b3a4c4..861ce0b 100644 --- a/app/helpers/article_helper.rb +++ b/app/helpers/article_helper.rb @@ -187,9 +187,9 @@ module ArticleHelper def following_button(page, user) if !user.blank? and user != page.author if page.is_followed_by? user - button :cancel, unfollow_button_text(page), {:controller => 'profile', :action => 'unfollow_article', :article_id => page.id} + button :cancel, unfollow_button_text(page), {:controller => 'profile', :action => 'unfollow_article', :article_id => page.id, :profile => page.profile.identifier} else - button :add, follow_button_text(page), {:controller => 'profile', :action => 'follow_article', :article_id => page.id} + button :add, follow_button_text(page), {:controller => 'profile', :action => 'follow_article', :article_id => page.id, :profile => page.profile.identifier} end end end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 9b85802..bdf2dc6 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -1631,4 +1631,22 @@ class ContentViewerControllerTest < ActionController::TestCase assert_select '.article-body-img > img', 0 end + should 'render follow article button in another domain' do + d = Domain.new + d.name = "theresourcebasedeconomy.com" + d.save! + profile = fast_create(Community) + profile.domains << d + + page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text') + page.save! + + login_as(create_user.login) + ActionController::TestRequest.any_instance.expects(:host).returns('theresourcebasedeconomy.com').at_least_once + get :view_page, :page => 'myarticle' + + assert_equal profile, assigns(:profile) + assert_tag tag: 'a', attributes: {'title' => 'Follow'} + end + end diff --git a/test/unit/article_helper_test.rb b/test/unit/article_helper_test.rb new file mode 100644 index 0000000..508879b --- /dev/null +++ b/test/unit/article_helper_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' + +class ArticleHelperTest < ActionView::TestCase + include ArticleHelper + include ButtonsHelper + + should 'render follow article button' do + environment = Environment.default + person = fast_create(Person) + profile = fast_create(Profile, :environment_id => environment) + article = fast_create(Article, :profile_id => profile) + link = following_button article, person + assert_tag_in_string link, tag: 'a', attributes: {'title' => 'Follow'} + end + +end -- libgit2 0.21.2