require 'spec_helper'

# Test for #83
describe "user links" do
  let(:topic) { Factory(:topic) }
  let(:post) { Factory(:post, :topic => topic) }

  context "with user_profile_links on" do
    before { Forem.user_profile_links = true }

    it "is able to click a user link" do
      visit forum_topic_path(post.forum, post.topic)
      # There should be at least one link on the page with the user's name
      click_link post.user.to_s
      page.should have_content("A user's page!")
    end
  end

  context "with user_profile_links off" do
    before { Forem.user_profile_links = false }

    it "user name is not a link" do
      visit forum_topic_path(post.forum, post.topic)
      # There should be no links on the page with the user's name
      Nokogiri::HTML(page.body).css("a").none? { |a| a.text.include?(post.user.to_s) }
    end
  end
end

require 'spec_helper'

# Test for #83
describe "user links" do
  let(:topic) { Factory(:approved_topic) }
  let(:post) { Factory(:approved_post, :topic => topic) }

  context "with user_profile_links on" do
    before { Forem.user_profile_links = true }

    it "is able to click a user link" do
      visit forum_topic_path(post.forum, post.topic)
      # There should be at least one link on the page with the user's name
      click_link post.user.to_s
      page.should have_content("A user's page!")
    end
  end

  context "with user_profile_links off" do
    before { Forem.user_profile_links = false }

    it "user name is not a link" do
      visit forum_topic_path(post.forum, post.topic)
      # There should be no links on the page with the user's name
      Nokogiri::HTML(page.body).css("a").none? { |a| a.text.include?(post.user.to_s) }
    end
  end
end

Set approved topic + post in user link spec
Set approved topic + post in user link spec
