Skip to content

Commit

Permalink
Rename answered to recently commented (publiclab#7257)
Browse files Browse the repository at this point in the history
* Rename answered to recently commented

* Update config/routes.rb

Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
  • Loading branch information
2 people authored and Piyush Swain committed Oct 22, 2020
1 parent 91b02dc commit 0c60539
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def show
set_sidebar :tags, @tagnames
end

def answered
def recently_commented
@title = 'Recently Commented'
@questions = Node.questions
.where(status: 1)
Expand Down
4 changes: 2 additions & 2 deletions app/views/questions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="col-lg-12">

<% if params[:action] == 'answered' %>
<% if params[:action] == 'recently_commented' %>
<h2>Recently Commented <small class="d-md-none d-lg-inline">Recently commented questions</small></h2>
<% elsif params[:action] == 'popular' %>
<h2>Popular Questions <small class="d-md-none d-lg-inline">Most viewed questions</small></h2>
Expand Down Expand Up @@ -54,7 +54,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link <% if params[:action] == "answered" %> active <% end %>" href="/questions/answered/">
<a class="nav-link <% if params[:action] == "recently_commented" %> active <% end %>" href="/questions/recently_commented/">
<i class="fa fa-check"></i> <span class="d-none d-lg-inline"> Recently Commented</span>
</a>
</li>
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@
get 'questions/:author/:date/:id' => 'questions#show'
get 'questions/show/:id' => 'questions#show'
get 'q/:id' => 'questions#shortlink'
get 'questions/answered(/:tagnames)' => 'questions#answered'
get 'questions/answered(/:tagnames)', to: redirect('questions#recently_commented')
get 'questions/recently_commented(/:tagnames)' => 'questions#recently_commented'
get 'questions/popular(/:tagnames)' => 'questions#popular'
get 'questions/unanswered(/:tagnames)' => 'questions#unanswered'
get 'questions/liked(/:tagnames)' => 'questions#liked'
Expand Down
6 changes: 3 additions & 3 deletions test/functional/questions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setup

test 'should get show' do
note = nodes(:question)

get :show, params: { author: note.author.name, date: Time.at(note.created).strftime('%m-%d-%Y'), id: note.title.parameterize }

assert_response :success
Expand Down Expand Up @@ -88,7 +88,7 @@ def setup
end

test 'should get answered' do
get :answered
get :recently_commented
assert_response :success
assert_equal assigns(:title), 'Recently Commented'
assert_not_nil assigns(:questions)
Expand Down Expand Up @@ -144,7 +144,7 @@ def setup
end

test 'should list only answered questions in answered' do
get :answered
get :recently_commented
questions = assigns(:questions)
expected = [nodes(:question)]
assert (questions & expected).present?
Expand Down

0 comments on commit 0c60539

Please sign in to comment.