fix synapse/mapping spec
This commit is contained in:
parent
bfdce21a66
commit
4ee4aeaad2
2 changed files with 30 additions and 29 deletions
|
@ -1,35 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
class FollowService
|
||||
|
||||
class << self
|
||||
def follow(entity, user, reason)
|
||||
|
||||
def self.follow(entity, user, reason)
|
||||
return unless is_tester(user)
|
||||
|
||||
return unless is_tester(user)
|
||||
|
||||
follow = Follow.where(followed: entity, user: user).first_or_create
|
||||
if FollowReason::REASONS.include?(reason) && !follow.follow_reason.read_attribute(reason)
|
||||
follow.follow_reason.update_attribute(reason, true)
|
||||
end
|
||||
end
|
||||
|
||||
def self.unfollow(entity, user)
|
||||
Follow.where(followed: entity, user: user).destroy_all
|
||||
end
|
||||
|
||||
def self.remove_reason(entity, user, reason)
|
||||
return unless FollowReason::REASONS.include?(reason)
|
||||
follow = Follow.where(followed: entity, user: user).first
|
||||
if follow
|
||||
follow.follow_reason.update_attribute(reason, false)
|
||||
if !follow.follow_reason.has_reason
|
||||
follow.destroy
|
||||
follow = Follow.where(followed: entity, user: user).first_or_create
|
||||
if FollowReason::REASONS.include?(reason) && !follow.follow_reason.read_attribute(reason)
|
||||
follow.follow_reason.update_attribute(reason, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def is_tester(user)
|
||||
%w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email)
|
||||
|
||||
def unfollow(entity, user)
|
||||
Follow.where(followed: entity, user: user).destroy_all
|
||||
end
|
||||
|
||||
def remove_reason(entity, user, reason)
|
||||
return unless FollowReason::REASONS.include?(reason)
|
||||
follow = Follow.where(followed: entity, user: user).first
|
||||
if follow
|
||||
follow.follow_reason.update_attribute(reason, false)
|
||||
if !follow.follow_reason.has_reason
|
||||
follow.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def is_tester(user)
|
||||
%w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SynapsesController, type: :controller do
|
||||
let(:synapse) { create(:synapse) }
|
||||
let(:user) { create(:user) }
|
||||
let(:synapse) { create(:synapse, user: user, updated_by: user) }
|
||||
let(:valid_attributes) { synapse.attributes.except('id') }
|
||||
let(:invalid_attributes) { { permission: :invalid_lol } }
|
||||
before :each do
|
||||
sign_in create(:user)
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
|
|
Loading…
Reference in a new issue