Add article pro stats button in dashboard (#3230)
This commit is contained in:
parent
d2a78f051f
commit
d74aa46bc5
3 changed files with 27 additions and 3 deletions
|
|
@ -6,6 +6,8 @@ class DashboardsController < ApplicationController
|
|||
def show
|
||||
fetch_and_authorize_user
|
||||
|
||||
@current_user_pro = current_user.pro?
|
||||
|
||||
target = @user
|
||||
not_authorized if params[:org_id] && !@user.org_admin?(params[:org_id] || @user.any_admin?)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
<% else %>
|
||||
<a href="<%= article.path %>/delete_confirm" data-no-instant class="cta pill black">DELETE</a>
|
||||
<% end %>
|
||||
<% if @current_user_pro %>
|
||||
<a href="<%= article.path %>/stats" data-no-instant class="cta pill blue">STATS</a>
|
||||
<% end %>
|
||||
|
||||
<% if article.published %>
|
||||
<span id="pageviews-<%= article.id %>" class="cta pill dashboard-pageviews-indicator" data-analytics-pageviews data-article-id="<%= article.id %>">
|
||||
<span class="page-views-count">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ RSpec.describe "Dashboards", type: :request do
|
|||
let(:user) { create(:user) }
|
||||
let(:second_user) { create(:user) }
|
||||
let(:super_admin) { create(:user, :super_admin) }
|
||||
let(:article) { create(:article, user_id: user.id) }
|
||||
let(:pro_user) { create(:user, :pro) }
|
||||
let(:article) { create(:article, user: user) }
|
||||
|
||||
describe "GET /dashboard" do
|
||||
context "when not logged in" do
|
||||
|
|
@ -19,7 +20,14 @@ RSpec.describe "Dashboards", type: :request do
|
|||
sign_in user
|
||||
article
|
||||
get "/dashboard"
|
||||
expect(response.body).to include CGI.escapeHTML(article.title)
|
||||
expect(response.body).to include(CGI.escapeHTML(article.title))
|
||||
end
|
||||
|
||||
it 'does not show "STATS" for articles' do
|
||||
sign_in user
|
||||
article
|
||||
get "/dashboard"
|
||||
expect(response.body).not_to include("STATS")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -29,7 +37,17 @@ RSpec.describe "Dashboards", type: :request do
|
|||
user
|
||||
sign_in super_admin
|
||||
get "/dashboard/#{user.username}"
|
||||
expect(response.body).to include CGI.escapeHTML(article.title)
|
||||
expect(response.body).to include(CGI.escapeHTML(article.title))
|
||||
end
|
||||
end
|
||||
|
||||
context "when logged in as a pro user" do
|
||||
it 'shows "STATS" for articles' do
|
||||
article = create(:article, user: pro_user)
|
||||
sign_in pro_user
|
||||
get "/dashboard"
|
||||
expect(response.body).to include("STATS")
|
||||
expect(response.body).to include("#{article.path}/stats")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue