Commit 2b14720c07af8a2ef8b778dd56ff6b7ad11b6cd6

Authored by Evandro Junior
1 parent 27f11bf7

Fix error accessing community with own domain

app/helpers/article_helper.rb
... ... @@ -187,9 +187,9 @@ module ArticleHelper
187 187 def following_button(page, user)
188 188 if !user.blank? and user != page.author
189 189 if page.is_followed_by? user
190   - button :cancel, unfollow_button_text(page), {:controller => 'profile', :action => 'unfollow_article', :article_id => page.id}
  190 + button :cancel, unfollow_button_text(page), {:controller => 'profile', :action => 'unfollow_article', :article_id => page.id, :profile => page.profile.identifier}
191 191 else
192   - button :add, follow_button_text(page), {:controller => 'profile', :action => 'follow_article', :article_id => page.id}
  192 + button :add, follow_button_text(page), {:controller => 'profile', :action => 'follow_article', :article_id => page.id, :profile => page.profile.identifier}
193 193 end
194 194 end
195 195 end
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -1631,4 +1631,22 @@ class ContentViewerControllerTest < ActionController::TestCase
1631 1631 assert_select '.article-body-img > img', 0
1632 1632 end
1633 1633  
  1634 + should 'render follow article button in another domain' do
  1635 + d = Domain.new
  1636 + d.name = "theresourcebasedeconomy.com"
  1637 + d.save!
  1638 + profile = fast_create(Community)
  1639 + profile.domains << d
  1640 +
  1641 + page = profile.articles.build(:name => 'myarticle', :body => 'the body of the text')
  1642 + page.save!
  1643 +
  1644 + login_as(create_user.login)
  1645 + ActionController::TestRequest.any_instance.expects(:host).returns('theresourcebasedeconomy.com').at_least_once
  1646 + get :view_page, :page => 'myarticle'
  1647 +
  1648 + assert_equal profile, assigns(:profile)
  1649 + assert_tag tag: 'a', attributes: {'title' => 'Follow'}
  1650 + end
  1651 +
1634 1652 end
... ...
test/unit/article_helper_test.rb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +require 'test_helper'
  2 +
  3 +class ArticleHelperTest < ActionView::TestCase
  4 + include ArticleHelper
  5 + include ButtonsHelper
  6 +
  7 + should 'render follow article button' do
  8 + environment = Environment.default
  9 + person = fast_create(Person)
  10 + profile = fast_create(Profile, :environment_id => environment)
  11 + article = fast_create(Article, :profile_id => profile)
  12 + link = following_button article, person
  13 + assert_tag_in_string link, tag: 'a', attributes: {'title' => 'Follow'}
  14 + end
  15 +
  16 +end
... ...