docbrown/spec/requests/follows_show_spec.rb
Mac Siri 6d1638ed68 Unskip all skipped specs (#2941)
* Change all login_as to sign_in

* Unskip comment spec

* Create new specs

* Turn on Webdriver caching

* Set logger for Omniauth in test

* Update editor system spec

* Fix editor approval file

* Update video_controller

* Update TagAdjustmentUpdateService's spec

* Update users api spec

* Update stories_index_spec

* Remove redundant spec file

* Remove residual code

* Change ClassifiedListing spec

* Update NotificationsIndex spec
2019-05-25 11:04:38 -04:00

38 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "Follows #show", type: :request do
let(:current_user) { create(:user) }
let(:user) { create(:user) }
let(:tag) { create(:tag) }
let(:organization) { create(:organization) }
let(:podcast) { create(:podcast) }
before { sign_in current_user }
def get_following_status
%w[User Organization Tag Podcast].map do |type|
get "/follows/#{send(type.downcase).id}", params: { followable_type: type }
response.body
end
end
it "rejects unless logged-in" do
sign_out(user)
get "/follows/#{user.id}"
expect(response.body).to eq("not-logged-in")
end
it "returns false when not following" do
expect(get_following_status.uniq[0]).to eq("false")
end
it "returns true when is following" do
%w[user organization tag].each { |followable| current_user.follow(send(followable)) }
expect(get_following_status.uniq[0]).to eq("true")
end
it "return self if current_user try to follow themself" do
get "/follows/#{current_user.id}", params: { followable_type: "User" }
expect(response.body).to eq("self")
end
end