Skip to content

Commit

Permalink
[Outreachy] Dashboard Redesign URL (#8886)
Browse files Browse the repository at this point in the history
* dashboard redesign

* rename dashboard2 to dashboard_v2

* add subscription test and dashboard_v2 query

* add limit to query
  • Loading branch information
RuthNjeri authored Dec 23, 2020
1 parent 309500e commit cd59bfc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def dashboard
end
end

def dashboard_v2
# The new dashboard displays the blog and topics list
if current_user
@blog = Tag.find_nodes_by_type('blog', 'note', 1).limit(1).first
@tags = current_user.subscriptions(:tag).includes(:tag)
render template: 'dashboard/dashboard_v2'
else
redirect_to '/research'
end
end

def research
if current_user
redirect_to '/dashboard'
Expand Down
3 changes: 3 additions & 0 deletions app/views/dashboard/dashboard_v2.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


<h1><%= raw translation('dashboard_v2.view') %></h2>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ en:
first_time_post: "Moderate first-time post:"
_comment_moderate:
first_time_post: "Moderate first-time comment:"
dashboard_v2:
view: "This is the dashboard redesign page"
like:
index:
recent_likes: "Recent Likes"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
get 'feed/liked' => 'notes#liked_rss'

get 'dashboard' => 'home#dashboard'
get 'v2/dashboard' => 'home#dashboard_v2'
get 'comments' => 'comment#index'
get 'profile/comments/:id' => 'users#comments'
get 'profile/comments/:id/tag/:tagname' => 'users#comments_by_tagname'
Expand Down
15 changes: 15 additions & 0 deletions test/functional/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,19 @@ def setup
assert_template 'home/home'
end
end

# dashboard_v2 tests
test 'should get research if not logged by v2/dashboard' do
get :dashboard_v2
assert_redirected_to :research
get :research
assert_response :success
end

test 'get v2/dashboard' do
UserSession.create(users(:bob))
get :dashboard_v2
assert_includes response.body, "This is the dashboard redesign page"
end

end
2 changes: 1 addition & 1 deletion test/unit/node_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def setup
assert nodes.include?(node2), "Should include note tagged with sunny-day for sun*"
end

test 'for hidden_response_node_ids' do
test 'for_hidden_response_node_ids' do
node = nodes(:hidden_response_note)

hidden_nids = Node.hidden_response_node_ids
Expand Down
4 changes: 4 additions & 0 deletions test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,8 @@ class UserTest < ActiveSupport::TestCase
end
end

test 'for_subscriptions' do
user = users(:bob)
assert_equal user.subscriptions(:tag).size, 3
end
end

0 comments on commit cd59bfc

Please sign in to comment.