File tree 2 files changed +9
-1
lines changed
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ def event_type(options={})
403
403
end
404
404
405
405
def topic_ids
406
- self . taggings . joins ( 'inner join tags on taggings.tag_id = tags.id' ) . select ( 'tags.id' ) . map ( & :id )
406
+ topics_tags . pluck ( :id )
407
407
end
408
408
409
409
def to_indexed_json
Original file line number Diff line number Diff line change 126
126
expect ( protip . topics ) . to eq ( %w( ruby python heroku ) )
127
127
expect ( protip . topics . count ) . to eq ( 3 )
128
128
end
129
+
130
+ it '#topic_ids should return ids of topics only' do
131
+ protip = Fabricate ( :protip , topics : 'ruby python' , user : Fabricate ( :user ) )
132
+ protip . save!
133
+ ruby_id = Tag . find_by_name ( "ruby" ) . id
134
+ python_id = Tag . find_by_name ( "python" ) . id
135
+ expect ( protip . topic_ids ) . to match_array ( [ ruby_id , python_id ] )
136
+ end
129
137
end
130
138
131
139
describe 'linking and featuring an image' do
You can’t perform that action at this time.
0 commit comments