docbrown/spec/requests/api/v0/followings_spec.rb
John Curcio 157a6f1ef1 Add pagination to followers and following page in dashboard (#258) (#4375) [deploy]
* Add infinite scroll to followers list (#258)

* Refactor fetchNext function for clarity (#258)

* Sepparate following tab into multiple tabs to support infinite scroll (#258)

* Add infinite scroll to following pages (#258)

* Add tests to infinite scroll api

* Refactor dashboard loading text

* Refactor infine scroll function

* Fix duplicated entries problem in infinite scrolling

* Switch randomized attributes to sequential to avoid InvalidRecord error

* Add acceptance tests for infinite scroll

* Remove unused following method

* parameterize limit per page for followers and followings

* Split follows endpoint into followers and followings

* Authenticate user with api key in followers and followings

* Split followers endpoint into users and organizations

* Add redundant html to sublist partial

* Speed up infinite scroll tests

* Refactor api json responses to use partials

* Authenticate api user before follows create

* Resolve conflicts on scrolling js

* Improve partials organization and fix organization username bug

* Improve readability of unauthorized test

* Use let! to create scrolling test data

* Fix not working podcasts link

* Refactor initScrolling to remove linting errors

* Fix codeclimate coding style issue

* Test tags forms and podcasts hyperlinks

* Fix eslint issue with double equals

* Improve before_action usage and readability
2019-11-20 18:21:18 -05:00

41 lines
1 KiB
Ruby

require "rails_helper"
RSpec.describe "Api::V0::FollowingsController", type: :request do
let(:user) { create(:user) }
let(:user2) { create(:user) }
describe "GET /api/followings" do
let(:tag) { create(:tag) }
let(:podcast) { create(:podcast) }
let(:organization) { create(:organization) }
before do
sign_in user
user.follow user2
user.follow tag
user.follow organization
user.follow podcast
user.reload
end
it "returns following users list" do
get "/api/followings/users"
expect(response.body).to include user2.name
end
it "returns following tag list" do
get "/api/followings/tags"
expect(response.body).to include tag.name
end
it "returns following organization list" do
get "/api/followings/organizations"
expect(response.body).to include organization.name
end
it "returns following podcast list" do
get "/api/followings/podcasts"
expect(response.body).to include podcast.name
end
end
end