<commit_before>require 'spec_helper'

describe HeartablesController do
  let(:news_feed_item) { NewsFeedItem.make! }
  let(:user) { User.make! }
  let(:user2) { User.make! }

  before do
    sign_in user
  end

  it 'loves a heartable' do
    post :love,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(assigns(:heart).heartable).to eq(news_feed_item)
  end

  it 'returns errors when the item has had too much love' do
    news_feed_item.hearts.create!(user_id: user.id)

    post :love,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(JSON.parse(response.body)).to eq({
      "heartable_id" => ["has already been taken"]
    })
  end

  it 'can be unloved' do
    heart = news_feed_item.hearts.create!(user_id: user.id)

    post :unlove,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(response.status).to eq(200)
  end

  it 'returns hearts without current user' do
    news_feed_item.hearts.create!(user_id: user.id)
    heart = news_feed_item.hearts.create!(user_id: user2.id)

    get :hearts,
      heartable_ids: [news_feed_item.id]

    expect(JSON.parse(response.body)).to eq(
      [JSON.parse(HeartSerializer.new(heart).to_json)]
    )
  end
end<commit_msg>Remove bogus test<commit_after>require 'spec_helper'

describe HeartablesController do
  let(:news_feed_item) { NewsFeedItem.make! }
  let(:user) { User.make! }
  let(:user2) { User.make! }

  before do
    sign_in user
  end

  it 'loves a heartable' do
    post :love,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(assigns(:heart).heartable).to eq(news_feed_item)
  end

  it 'returns errors when the item has had too much love' do
    news_feed_item.hearts.create!(user_id: user.id)

    post :love,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(JSON.parse(response.body)).to eq({
      "heartable_id" => ["has already been taken"]
    })
  end

  it 'can be unloved' do
    heart = news_feed_item.hearts.create!(user_id: user.id)

    post :unlove,
      type: NewsFeedItem.to_s,
      id: news_feed_item.id

    expect(response.status).to eq(200)
  end
end
{'fraction_non_alphanumeric': 0.11395348837209303, 'fraction_numerical': 0.004186046511627907, 'mean_word_length': 3.160541586073501, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '7651410', 'n_tokens_mistral': 800, 'n_tokens_neox': 769, 'n_words': 173}