diff --git a/app/models/topic.rb b/app/models/topic.rb index 9255625c541..af5c6c521c1 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -453,14 +453,6 @@ class Topic < ActiveRecord::Base ((Time.zone.now - created_at) / 1.minute).round end - def has_meta_data_boolean?(key) - meta_data_string(key) == 'true' - end - - def meta_data_string(key) - custom_fields[key.to_s] - end - def self.listable_count_per_day(start_date, end_date, category_id = nil) result = listable_topics.where('created_at >= ? and created_at <= ?', start_date, end_date) result = result.where(category_id: category_id) if category_id diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb index a364423fb96..81eb95f9f0e 100644 --- a/lib/guardian/post_guardian.rb +++ b/lib/guardian/post_guardian.rb @@ -46,10 +46,7 @@ module PostGuardian not(post.trashed?) && # don't like your own stuff - not(action_key == :like && is_my_own?(post)) && - - # no voting more than once on single vote topics - not(action_key == :vote && opts[:voted_in_topic] && post.topic.has_meta_data_boolean?(:single_vote)) + not(action_key == :like && is_my_own?(post)) end !!result @@ -75,11 +72,6 @@ module PostGuardian return can_see_flags?(topic) if PostActionType.is_flag?(type_symbol) - if type_symbol == :vote - # We can see votes if the topic allows for public voting - return false if topic.has_meta_data_boolean?(:private_poll) - end - true end @@ -207,10 +199,6 @@ module PostGuardian can_see_post?(post) end - def can_vote?(post, opts = {}) - post_can_act?(post, :vote, opts: opts) - end - def can_change_post_owner? is_admin? end diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index e6e05828f61..4603b006ef4 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -346,11 +346,6 @@ describe Guardian do expect(Guardian.new(moderator).can_see_post_actors?(topic, PostActionType.types[:notify_user])).to be_truthy end - it 'returns false for private votes' do - topic.expects(:has_meta_data_boolean?).with(:private_poll).returns(true) - expect(Guardian.new(user).can_see_post_actors?(topic, PostActionType.types[:vote])).to be_falsey - end - end describe 'can_impersonate?' do @@ -986,19 +981,6 @@ describe Guardian do topic.archived = true expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey end - - describe 'multiple voting' do - - it "isn't allowed if the user voted and the topic doesn't allow multiple votes" do - Topic.any_instance.expects(:has_meta_data_boolean?).with(:single_vote).returns(true) - expect(Guardian.new(user).can_vote?(post, voted_in_topic: true)).to be_falsey - end - - it "is allowed if the user voted and the topic doesn't allow multiple votes" do - expect(Guardian.new(user).can_vote?(post, voted_in_topic: false)).to be_truthy - end - end - end end