Remove ancient votes code that is no longer used.
This commit is contained in:
parent
764b6c005c
commit
e7a7356986
|
@ -453,14 +453,6 @@ class Topic < ActiveRecord::Base
|
||||||
((Time.zone.now - created_at) / 1.minute).round
|
((Time.zone.now - created_at) / 1.minute).round
|
||||||
end
|
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)
|
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 = listable_topics.where('created_at >= ? and created_at <= ?', start_date, end_date)
|
||||||
result = result.where(category_id: category_id) if category_id
|
result = result.where(category_id: category_id) if category_id
|
||||||
|
|
|
@ -46,10 +46,7 @@ module PostGuardian
|
||||||
not(post.trashed?) &&
|
not(post.trashed?) &&
|
||||||
|
|
||||||
# don't like your own stuff
|
# don't like your own stuff
|
||||||
not(action_key == :like && is_my_own?(post)) &&
|
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))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
!!result
|
!!result
|
||||||
|
@ -75,11 +72,6 @@ module PostGuardian
|
||||||
|
|
||||||
return can_see_flags?(topic) if PostActionType.is_flag?(type_symbol)
|
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
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -207,10 +199,6 @@ module PostGuardian
|
||||||
can_see_post?(post)
|
can_see_post?(post)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_vote?(post, opts = {})
|
|
||||||
post_can_act?(post, :vote, opts: opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_change_post_owner?
|
def can_change_post_owner?
|
||||||
is_admin?
|
is_admin?
|
||||||
end
|
end
|
||||||
|
|
|
@ -346,11 +346,6 @@ describe Guardian do
|
||||||
expect(Guardian.new(moderator).can_see_post_actors?(topic, PostActionType.types[:notify_user])).to be_truthy
|
expect(Guardian.new(moderator).can_see_post_actors?(topic, PostActionType.types[:notify_user])).to be_truthy
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'can_impersonate?' do
|
describe 'can_impersonate?' do
|
||||||
|
@ -986,19 +981,6 @@ describe Guardian do
|
||||||
topic.archived = true
|
topic.archived = true
|
||||||
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
|
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue