<commit_before>require 'spec_helper'

describe 'articles/show', type: :view do
  before :each do
    @user = build_stubbed(:user, first_name: 'Thomas')
    @author = @user
    @article = build_stubbed(:article,
              	   id: 555,
		   slug: 'friendly_id',
		   title: "Ruby article",
		   tag_list: ["Ruby", "Rails"],
		   user: @user,
		   created_at: Time.now,
		   updated_at: Time.now
		   )
  end

  context 'user is not signed in' do
    before :each do
      allow(view).to receive(:user_signed_in?).and_return(false)
    end

    it 'should show article content' do
      render
      expect(rendered).to have_css('div#doc-box')
      expect(rendered).to have_text(@article.title)
      expect(rendered).to have_content("Created on #{@article.created_at.strftime('%d %B %y')}")
      expect(rendered).to have_content("Last updated #{time_ago_in_words(@article.updated_at)}")
      expect(rendered).to have_text(@article.tag_list.join(', '))
      expect(rendered).not_to have_link('edit article')
    end

    if 'should show article vote content' do
        render
        rendered.should have_content("Vote value: #{@article.votevalue}"
# test for vote up/down links
    end

  end

  context 'user is signed in' do
    before :each do
      allow(view).to receive(:current_user).and_return(@user)
      allow(view).to receive(:user_signed_in?).and_return(true)
    end

    it 'renders a edit button' do
      render
      expect(rendered).to have_link('edit article')
    end
  end

  describe 'renders Disqus section' do
    it_behaves_like 'commentable with Disqus' do
      let(:entity) { @article }
    end
  end
end
<commit_msg>votes stub and vote link test for view spec<commit_after>require 'spec_helper'

describe 'articles/show', type: :view do
  before :each do
    @user = build_stubbed(:user, first_name: 'Thomas')
    @author = @user
    @article = build_stubbed(:article,
              	   id: 555,
		   slug: 'friendly_id',
		   title: "Ruby article",
		   tag_list: ["Ruby", "Rails"],
		   user: @user,
		   created_at: Time.now,
		   updated_at: Time.now
		   )
    downvotes = [stub_model(ActsAsVotable::Vote),stub_model(ActsAsVotable::Vote)]
    upvotes = [stub_model(ActsAsVotable::Vote)]
    allow(@article).to recieve(:upvotes).and_return(upvotes)
    allow(@article).to recieve(:downvotes).and_return(downvotes)
  end

  context 'user is not signed in' do
    before :each do
      allow(view).to receive(:user_signed_in?).and_return(false)
    end

    it 'should show article content' do
      render
      expect(rendered).to have_css('div#doc-box')
      expect(rendered).to have_text(@article.title)
      expect(rendered).to have_content("Created on #{@article.created_at.strftime('%d %B %y')}")
      expect(rendered).to have_content("Last updated #{time_ago_in_words(@article.updated_at)}")
      expect(rendered).to have_text(@article.tag_list.join(', '))
      expect(rendered).not_to have_link('edit article')
    end

    it 'should show article vote content' do
        render
        rendered.should have_content("Vote value: #{@article.upvotes.size-@article.downvotes.size}")
# test for vote up/down links
    end

  end

  context 'user is signed in' do
    before :each do
      allow(view).to receive(:current_user).and_return(@user)
      allow(view).to receive(:user_signed_in?).and_return(true)
    end

    it 'renders a edit button' do
      render
      expect(rendered).to have_link('edit article')
    end

    it 'renders the vote links' do
      render
      rendered.should have_link('Vote up')
      rendered.should have_link('Vote down')
    end

  end

  describe 'renders Disqus section' do
    it_behaves_like 'commentable with Disqus' do
      let(:entity) { @article }
    end
  end
end

{'fraction_non_alphanumeric': 0.12028677642060542, 'fraction_numerical': 0.0015932023366967605, 'mean_word_length': 3.2468996617812853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920729', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1216, 'n_words': 300}