docbrown/spec/requests/follows_show_spec.rb
Ben Halpern c76abbbdb3
Allow users to follow podcasts (#2690)
* Allow users to follow podcasts

* Only display podcasts user follows

* Add main_color_hex to factory

* Fix podcast test and modify styles

* Fix tests

* Remove weird test
2019-05-04 15:30:40 -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 { login_as 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
logout
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