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

Fixes #11379: Made the subtopics method #11380

Closed
wants to merge 12 commits into from
9 changes: 9 additions & 0 deletions app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,13 @@ def fetch_counts
end

def topic_tree; end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body end.

def subtopics
# here, we look for this special tag marking a node as having a parent
# collect the "slugs" i.e. the unique part of the URL, which should correspond to a tagname
subtopic_names = Tag.find_by(name: "parent:#{params[:topic]}")
.nodes
.collect(&:slug)
@subtopics = Tag.find_by(name: subtopic_names)
render "tags/subtopics", layout: false
KarishmaVanwari marked this conversation as resolved.
Show resolved Hide resolved
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@
post 'comment/react/update/:id' => 'comment#react_update'

get 'topic-tree' => 'tag#topic_tree'
get 'tags/subtopic/:topic' => 'tag#subtopics'

# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
Expand Down
9 changes: 9 additions & 0 deletions test/functional/tag_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ def setup
assert_not_nil assigns(:notes)
assert (notes & expected).present?
end

test 'subtopics partial' do
get :subtopics,
params: {
topic: 'test'
}
assert :success
assert_not_nil assigns(:subtopics)
end

test 'shows suggested tags' do
get :suggested, params: { id: 'spectr' }
Expand Down