Skip to content

Commit

Permalink
fix: Change include to includes in tag model
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrice Clark committed Nov 13, 2017
1 parent 3483343 commit 6473cd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def self.find_top_nodes_by_type(tagname, type = 'wiki', limit = 10)
.where('term_data.name = ?', tagname)
.order('node.views DESC')
.limit(limit)
.include(:node_tag, :tag)
.includes(:node_tag, :tag)
end

# finds recent nodes - should drop "limit" and allow use of chainable .limit()
Expand Down Expand Up @@ -110,7 +110,7 @@ def self.find_popular_notes(tagname, views = 20, limit = 10)
.where('term_data.name = ? AND node.views > (?)', tagname, views)
.order('node.nid DESC')
.limit(limit)
.include(:node_tag, :tag)
.includes(:node_tag, :tag)
end

def self.exists?(tagname, nid)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/tag_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,14 @@ class TagTest < ActiveSupport::TestCase
assert !trending_tags.empty?
assert_not_nil Tag.trending(2, Time.now - 1.year, Time.now - 1.month)
end

test 'Tag.find_popular_notes returns most viewed notes with specified tag' do
popular_notes = Tag.find_popular_notes('test')
assert_not_nil popular_notes
end

test 'Tag.top_nodes returns most viewed nodes with specified tag and node type' do
top_nodes = Tag.find_top_nodes_by_type(tagname:'awesome2', type:'page')
assert_not_nil top_nodes
end
end

0 comments on commit 6473cd1

Please sign in to comment.