require 'rails_helper'
require 'features_helper'

feature 'users relationships' do

  let(:user_with_posts) {FactoryGirl.create(:user_with_posts, posts_count: 2)}
  let(:other_user_with_posts) {FactoryGirl.create(:other_user_with_posts, posts_count: 2)}

  before do
    form_login user_with_posts
  end

  scenario 'with other_user mBlog in Feed' do
    visit user_path(other_user_with_posts)
    click_button 'Follow'
    visit '/'

    expect(page).to have_content 'mBlog by Other User', count: 2

  end

  scenario 'with other_user in Following' do
    visit user_path(other_user_with_posts)
    click_button 'Follow'
    visit user_path(user_with_posts)
    click_link 'Following'

    within '.thumbnail' do
      expect(page).to have_link 'Other User'
    end

  end

  scenario 'with user in Follower' do
    visit user_path(other_user_with_posts)
    click_button 'Follow'
    click_link 'Follower'

    within '.thumbnail' do
      expect(page).to have_link 'User'
    end
  end

end