From d11f3923dd3d047a67b0e2a15e29540b707add30 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 14 Mar 2016 14:34:36 +0800 Subject: [PATCH] remove unused has_viewable_synapses function --- app/models/topic.rb | 11 ---------- spec/models/topic_spec.rb | 42 --------------------------------------- 2 files changed, 53 deletions(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index 0f312823..aef72b74 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -83,15 +83,4 @@ class Topic < ActiveRecord::Base def mk_permission Perm.short(permission) end - - # has no viewable synapses helper function - def has_viewable_synapses(current) - result = false - synapses.each do |synapse| - if synapse.authorize_to_show(current) - result = true - end - end - result - end end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index ef8f0b7a..dbaac86d 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -7,46 +7,4 @@ RSpec.describe Topic, type: :model do it { is_expected.to have_many :mappings } it { is_expected.to validate_presence_of :permission } it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) } - - context 'has_viewable_synapses function' do - let (:user) { create(:user) } - let (:other_user) { create(:user) } - - context 'topic with no synapses' do - let (:topic) { create(:topic) } - - it 'returns false' do - expect(topic.has_viewable_synapses(user)).to eq false - end - end - - context 'topic with one unpermitted synapse' do - let (:synapse) { create(:synapse, permission: :private, user: other_user) } - let (:topic) { create(:topic, synapses1: [synapse]) } - - it 'returns false' do - expect(topic.has_viewable_synapses(user)).to eq false - end - end - - context 'topic with one permitted synapse' do - let (:synapse) { create(:synapse, permission: :private, user: user) } - let(:topic) { create(:topic, synapses1: [synapse]) } - - it 'returns true' do - expect(topic.has_viewable_synapses(user)).to eq true - end - end - - context 'topic with one unpermitted, one permitted synapse' do - let (:synapse1) { create(:synapse, permission: :private, user: other_user) } - let (:synapse2) { create(:synapse, permission: :private, user: user) } - let (:topic) { create(:topic, synapses1: [synapse1, synapse2]) } - - it 'returns true' do - expect(topic.synapses.count).to eq 2 - expect(topic.has_viewable_synapses(user)).to eq true - end - end - end end