Add list of followed organizations to dashboard (#2157)
This commit is contained in:
parent
953c555c36
commit
937bc63bbb
3 changed files with 28 additions and 6 deletions
|
|
@ -15,6 +15,8 @@ class DashboardsController < ApplicationController
|
|||
order("created_at DESC").includes(:followable).limit(80)
|
||||
@followed_tags = @user.follows_by_type("ActsAsTaggableOn::Tag").
|
||||
order("points DESC").includes(:followable).limit(80)
|
||||
@followed_organizations = @user.follows_by_type("Organization").
|
||||
order("created_at DESC").includes(:followable).limit(80)
|
||||
elsif params[:which] == "user_followers"
|
||||
@follows = Follow.where(followable_id: @user.id, followable_type: "User").
|
||||
includes(:follower).order("created_at DESC").limit(80)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,21 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @followed_organizations %>
|
||||
<h2>Followed organizations (<%= @followed_organizations.count %>)</h2>
|
||||
<% @followed_organizations.each do |follow| %>
|
||||
<% organization = follow.followable %>
|
||||
<div class="single-article">
|
||||
<a href="<%= organization.path %>" class="block-link">
|
||||
<h2>
|
||||
<img alt="<%= organization.name %> profile image" src="<%= ProfileImage.new(organization).get(60) %>" />
|
||||
<%= organization.name %>
|
||||
<span class="dashboard-username">@<%= organization.name %></span>
|
||||
</h2>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif @articles.any? %>
|
||||
<%= render "analytics" %>
|
||||
<% if current_user.created_at < 2.weeks.ago %>
|
||||
|
|
|
|||
|
|
@ -64,20 +64,25 @@ RSpec.describe "Dashboards", type: :request do
|
|||
end
|
||||
|
||||
context "when logged in" do
|
||||
it "renders the current user's followings" do
|
||||
before { login_as user }
|
||||
|
||||
it "renders users that current user follows" do
|
||||
user.follow second_user
|
||||
login_as user
|
||||
get "/dashboard/following_users"
|
||||
expect(response.body).to include CGI.escapeHTML(second_user.name)
|
||||
end
|
||||
it "renders the current user's tag followings" do
|
||||
user.follow second_user
|
||||
it "renders tags that current user follows" do
|
||||
tag = create(:tag)
|
||||
user.follow tag
|
||||
login_as user
|
||||
get "/dashboard/following"
|
||||
get "/dashboard/following_users"
|
||||
expect(response.body).to include CGI.escapeHTML(tag.name)
|
||||
end
|
||||
it "renders organizations that current user follows" do
|
||||
organization = create(:organization)
|
||||
user.follow organization
|
||||
get "/dashboard/following_users"
|
||||
expect(response.body).to include CGI.escapeHTML(organization.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue