fix synapse/mapping spec

This commit is contained in:
Devin Howard 2017-02-11 19:56:07 -08:00
parent bfdce21a66
commit 4ee4aeaad2
2 changed files with 30 additions and 29 deletions

View file

@ -1,8 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class FollowService 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)
@ -12,11 +11,11 @@ class FollowService
end end
end end
def self.unfollow(entity, user) def unfollow(entity, user)
Follow.where(followed: entity, user: user).destroy_all Follow.where(followed: entity, user: user).destroy_all
end end
def self.remove_reason(entity, user, reason) def remove_reason(entity, user, reason)
return unless FollowReason::REASONS.include?(reason) return unless FollowReason::REASONS.include?(reason)
follow = Follow.where(followed: entity, user: user).first follow = Follow.where(followed: entity, user: user).first
if follow if follow
@ -32,4 +31,5 @@ class FollowService
def is_tester(user) def is_tester(user)
%w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email) %w(connorturland@gmail.com devin@callysto.com chessscholar@gmail.com solaureum@gmail.com ishanshapiro@gmail.com).include?(user.email)
end end
end
end end

View file

@ -2,11 +2,12 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe SynapsesController, type: :controller do 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(:valid_attributes) { synapse.attributes.except('id') }
let(:invalid_attributes) { { permission: :invalid_lol } } let(:invalid_attributes) { { permission: :invalid_lol } }
before :each do before :each do
sign_in create(:user) sign_in(user)
end end
describe 'POST #create' do describe 'POST #create' do