docbrown/spec/requests/followed_articles_spec.rb
Abraham Williams 9cb40e546b Enables Rails cops (#2186)
* Enable Rails cops

* Fix Rails/DynamicFindBy

* Fix Rails/HttpStatus

* Fix Rails/Blank

* Fix Rails/RequestReferer

* Fix Rails/ActiveRecordAliases

* Fix Rails/FindBy

* Fix Rails/Presence

* Fix Rails/Delegate

* Fix Rails/Validation

* Fix Rails/PluralizationGrammar

* Fix Rails/Present

* Fix Rails/Output

* Fix Rails/Blank

* Fix Rails/FilePath

* Fix Rails/InverseOf

* Fix Rails/LexicallyScopedActionFilter

* Add Rails/OutputSafety to TODO

* Add Rails/HasManyOrHasOneDependent to TODO

* Add Rails/SkipsModelValidations to TODO
2019-03-25 09:25:55 -04:00

23 lines
641 B
Ruby

require "rails_helper"
RSpec.describe "FollowedArticles", type: :request do
describe "GET followed articles index" do
let(:user) { create(:user) }
before do
login_as user
end
it "returns empty articles array if not following anyone" do
get "/followed_articles"
expect(JSON.parse(response.body)["articles"]).to eq([])
end
it "returns articles of tag I follow" do
article = create(:article)
user.follow(Tag.find_by(name: article.tag_list.first))
get "/followed_articles"
expect(JSON.parse(response.body)["articles"].first["title"]).to eq(article.title)
end
end
end