Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add is_question? method to node #8748

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def setup

is_impressionable counter_cache: true, column_name: :views, unique: :ip_address

def is_question?
has_power_tag('question')
end

def self.weekly_tallies(type = 'note', span = 52, time = Time.now)
weeks = {}
(0..span).each do |week|
Expand Down
2 changes: 2 additions & 0 deletions test/unit/node_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def setup

test 'adding a question:FOO style tag adds FOO tag as well; also for subtags' do
node = nodes(:one)
assert !node.is_question?
assert_difference 'node.tags.count', 2 do
node.add_tag('question:kites', users(:bob))
end
assert node.is_question?
assert node.has_tag('kites')
assert_difference 'node.tags.count', 2 do
node.add_tag('pm', users(:bob))
Expand Down