<commit_before>require 'spec_helper'

describe ApiController do

  let(:user)  { FactoryGirl.create(:user) }
  let(:feed) { FactoryGirl.create(:feed) }
  let(:paper) { FactoryGirl.create(:paper) }

  before { sign_in user }

  describe "sciting a paper" do
    it "should increment the Scite count" do
      expect do
        xhr :post, :scite, paper_id: paper.id
      end.to change(Scite, :count).by(1)
    end

    it "should respond with success" do
      xhr :post, :scite, paper_id: paper.id
      response.should be_success
    end
  end

  describe "unsciting a paper" do
    before do
      user.scite!(paper)
    end

    it "should decrement the Scite count" do
      expect do
        xhr :post, :unscite, paper_id: paper.id
      end.to change(Scite, :count).by(-1)
    end

    it "should respond with success" do
      xhr :post, :unscite, paper_id: paper.id
      response.should be_success
    end
  end

  describe "subscribing to a feed" do
    before do
      xhr :post, :subscribe, feed_id: feed.id
    end

    it "should subscribe" do
      user.feeds.should include(feed)
    end
  end

  describe "unsubscribing from a feed" do
    before do
      xhr :post, :subscribe, feed_id: feed.id
      xhr :post, :unsubscribe, feed_id: feed.id
    end

    it "should unsubscribe" do
      user.feeds.should_not include(feed)
    end
  end
end<commit_msg>Fix API spec to use uids<commit_after>require 'spec_helper'

describe ApiController do

  let(:user)  { FactoryGirl.create(:user) }
  let(:feed) { FactoryGirl.create(:feed) }
  let(:paper) { FactoryGirl.create(:paper) }

  before { sign_in user }

  describe "sciting a paper" do
    it "should increment the Scite count" do
      expect do
        xhr :post, :scite, paper_id: paper.id
      end.to change(Scite, :count).by(1)
    end

    it "should respond with success" do
      xhr :post, :scite, paper_id: paper.id
      response.should be_success
    end
  end

  describe "unsciting a paper" do
    before do
      user.scite!(paper)
    end

    it "should decrement the Scite count" do
      expect do
        xhr :post, :unscite, paper_id: paper.id
      end.to change(Scite, :count).by(-1)
    end

    it "should respond with success" do
      xhr :post, :unscite, paper_id: paper.id
      response.should be_success
    end
  end

  describe "subscribing to a feed" do
    before do
      xhr :post, :subscribe, feed_uid: feed.uid
    end

    it "should subscribe" do
      user.feeds.should include(feed)
    end
  end

  describe "unsubscribing from a feed" do
    before do
      xhr :post, :subscribe, feed_uid: feed.uid
      xhr :post, :unsubscribe, feed_uid: feed.uid
    end

    it "should unsubscribe" do
      user.feeds.should_not include(feed)
    end
  end
end
{'fraction_non_alphanumeric': 0.0919956537486418, 'fraction_numerical': 0.0014487504527345165, 'mean_word_length': 2.587012987012987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3818359', 'n_tokens_mistral': 949, 'n_tokens_neox': 918, 'n_words': 292}