docbrown/spec/requests/follows_show_spec.rb
Keshav Biswa 8d57d45ecc Rubocop Style cops enabled (#2056)
* Rubocop enabled style/alias

* Enabled Style/ArrayJoin Cop

* Enabled Style/Attr

* Enabled Case Equality

* Enabled CharacterLiteral

*  Enabled ColonMethodCall Cop

* Enabled CommentAnnotation cop

* Enabled PreferredHashMethods Cop

*  Enabled DoubleNegation Cop

* Enabled EachWithObject Cop

* Enabled EmptyLiteral Cop

* Enabled EvenOdd Cop

* Enabled IfWithSemicolon Cop

* Enabled Lambda and LambdaCall Cop

* Enabled LineEndConcatenation Cop

* Enabled ModuleFunction Cop;

* Enable NegatedIf and NegatedWhile Cop

* Enabled NilComparison Cop

* Enabled Not Cop

* Enabled NumericLiterals Cop

* Enabled OneLineConditional Cop

* Enabled PercentLiteralDelimiters Cop

* Excluded internal/users_controller from negated_if cop

* Reverted the double negation change from github_issue_tag and github_issue.rb"

* Enabled PerlBackrefs Cop

* Changed Regexp.last_match(1) to Regexp.last_match(0)

* Enabled proc cop

* Enabled RaiseArgs Cop

* Reverted Regexp.last_match(0) to Regexp.last_match(1)

* Enabled SelfAssignment Cop

* Enabled SingleLineMethods Cop

* Enabled SpecialGlobalVars Cop

* Enabled VariableInterpolation Cop

* Enabled WhenThen Cop

* Enabled WhileUntilModifier Cop

* Enabled WordArray Cop

* Enabled IfUnlessModifier Cop

* Enabled GuardClause Cop
2019-03-15 18:33:54 -04:00

37 lines
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) }
before { login_as current_user }
def get_following_status
%w[User Organization Tag].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