Welcome to the Pro Dashboard, the home of in-depth user metrics so that authors can make data-driven decisions about the <%= SiteConfig.community_member_label %> ecosystem.
+
Analytics Dashboard for <%= @user_or_org.name %>
+
Welcome to the Analytics Dashboard, the home of in-depth user metrics so that authors can make data-driven decisions about the <%= SiteConfig.community_member_label %> ecosystem.
This dashboard highlights deep insights especially relevant to <%= SiteConfig.community_member_label %> relations, authors, and serious bloggers.
diff --git a/config/elasticsearch/mappings/feed_content.json b/config/elasticsearch/mappings/feed_content.json
index b578cf084..04124a792 100644
--- a/config/elasticsearch/mappings/feed_content.json
+++ b/config/elasticsearch/mappings/feed_content.json
@@ -170,9 +170,6 @@
},
"profile_image_90": {
"type": "keyword"
- },
- "pro": {
- "type": "boolean"
}
}
},
diff --git a/config/elasticsearch/mappings/reactions.json b/config/elasticsearch/mappings/reactions.json
index 89cfe8f0d..30dab30fd 100644
--- a/config/elasticsearch/mappings/reactions.json
+++ b/config/elasticsearch/mappings/reactions.json
@@ -78,9 +78,6 @@
},
"profile_image_90": {
"type": "keyword"
- },
- "pro": {
- "type": "boolean"
}
}
}
diff --git a/config/routes.rb b/config/routes.rb
index 6f9ae884e..52a01b75a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -557,8 +557,8 @@ Rails.application.routes.draw do
get "/settings/:tab/:id", to: "users#edit", constraints: { tab: /response-templates/ }
get "/signout_confirm", to: "users#signout_confirm"
get "/dashboard", to: "dashboards#show"
- get "/dashboard/pro", to: "dashboards#pro"
- get "dashboard/pro/org/:org_id", to: "dashboards#pro", as: :dashboard_pro_org
+ get "/dashboard/analytics", to: "dashboards#analytics"
+ get "dashboard/analytics/org/:org_id", to: "dashboards#analytics", as: :dashboard_analytics_org
get "dashboard/following", to: "dashboards#following_tags"
get "dashboard/following_tags", to: "dashboards#following_tags"
get "dashboard/following_users", to: "dashboards#following_users"
diff --git a/docs/backend/roles.md b/docs/backend/roles.md
index 2d5fba0bc..b35a756ec 100644
--- a/docs/backend/roles.md
+++ b/docs/backend/roles.md
@@ -33,21 +33,21 @@ at the console.
rails console
```
-- after verifying the user `test_user_name` is missing the `pro` role we proceed
- to add it and then verify the role has been added:
+- after verifying the user `test_user_name` is missing the `trusted` role we
+ proceed to add it and then verify the role has been added:
```ruby
> user = User.find_by(username: "test_user_name")
-> user.has_role? :pro
+> user.has_role? :trusted
=> false
-> user.add_role(:pro)
+> user.add_role(:trusted)
=> #
-> user.has_role? :pro
+> user.has_role? :trusted
=> true
```
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index f0d11159c..cae7781da 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -99,10 +99,6 @@ FactoryBot.define do
end
end
- trait :pro do
- after(:build) { |user| user.add_role(:pro) }
- end
-
trait :org_member do
after(:create) do |user|
org = create(:organization)
diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb
index eba0db7d2..50d990932 100644
--- a/spec/models/role_spec.rb
+++ b/spec/models/role_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Role, type: :model do
describe "::ROLES" do
it "contains the correct values" do
expected_roles = %w[
- admin banned chatroom_beta_tester codeland_admin comment_banned podcast_admin pro restricted_liquid_tag
+ admin banned chatroom_beta_tester codeland_admin comment_banned podcast_admin restricted_liquid_tag
single_resource_admin super_admin tag_moderator mod_relations_admin support_admin tech_admin trusted
warned workshop_pass
]
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index f3c2398bb..7536603ee 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -759,17 +759,6 @@ RSpec.describe User, type: :model do
end
end
- describe "#pro?" do
- it "returns false if the user is not a pro" do
- expect(user.pro?).to be(false)
- end
-
- it "returns true if the user has the pro role" do
- user.add_role(:pro)
- expect(user.pro?).to be(true)
- end
- end
-
describe "#enough_credits?" do
it "returns false if the user has less unspent credits than neeed" do
expect(user.enough_credits?(1)).to be(false)
diff --git a/spec/requests/api/v0/analytics_spec.rb b/spec/requests/api/v0/analytics_spec.rb
index f03c9e40e..c772721d6 100644
--- a/spec/requests/api/v0/analytics_spec.rb
+++ b/spec/requests/api/v0/analytics_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "Api::V0::Analytics", type: :request do
include_examples "GET /api/analytics/:endpoint authorization examples", "historical", "&start=2019-03-29"
context "when the start parameter is not included" do
- before { get "/api/analytics/historical", headers: { "api-key" => pro_api_token.secret } }
+ before { get "/api/analytics/historical", headers: { "api-key" => api_token.secret } }
it "fails with an unprocessable entity HTTP error" do
expect(response).to have_http_status(:unprocessable_entity)
@@ -22,7 +22,7 @@ RSpec.describe "Api::V0::Analytics", type: :request do
end
context "when the start parameter has the incorrect format" do
- before { get "/api/analytics/historical?start=2019/2/2", headers: { "api-key" => pro_api_token.secret } }
+ before { get "/api/analytics/historical?start=2019/2/2", headers: { "api-key" => api_token.secret } }
it "fails with an unprocessable entity HTTP error" do
expect(response).to have_http_status(:unprocessable_entity)
diff --git a/spec/requests/articles/articles_spec.rb b/spec/requests/articles/articles_spec.rb
index b3706ca25..9cb400c8c 100644
--- a/spec/requests/articles/articles_spec.rb
+++ b/spec/requests/articles/articles_spec.rb
@@ -301,13 +301,7 @@ RSpec.describe "Articles", type: :request do
expect { get "#{article.path}/stats" }.to raise_error(Pundit::NotAuthorizedError)
end
- it "returns unauthorized if the user is not pro" do
- article = create(:article, user: user)
- expect { get "#{article.path}/stats" }.to raise_error(Pundit::NotAuthorizedError)
- end
-
it "works successfully" do
- user.add_role(:pro)
article = create(:article, user: user)
get "#{article.path}/stats"
expect(response).to have_http_status(:ok)
diff --git a/spec/requests/dashboard_spec.rb b/spec/requests/dashboard_spec.rb
index dbb552c66..2b6a3c7fd 100644
--- a/spec/requests/dashboard_spec.rb
+++ b/spec/requests/dashboard_spec.rb
@@ -4,7 +4,6 @@ RSpec.describe "Dashboards", type: :request do
let(:user) { create(:user) }
let(:second_user) { create(:user) }
let(:super_admin) { create(:user, :super_admin) }
- let(:pro_user) { create(:user, :pro) }
let(:article) { create(:article, user: user) }
let(:unpublished_article) { create(:article, user: user, published: false) }
let(:organization) { create(:organization) }
@@ -28,9 +27,12 @@ RSpec.describe "Dashboards", type: :request do
expect(response.body).to include(CGI.escapeHTML(article.title))
end
- it 'does not show "STATS" for articles' do
+ it 'shows "STATS" for articles' do
+ article = create(:article, user: user)
+
get "/dashboard"
- expect(response.body).not_to include("Stats")
+ expect(response.body).to include("Stats")
+ expect(response.body).to include("#{article.path}/stats")
end
it "renders the delete button for drafts" do
@@ -66,18 +68,18 @@ RSpec.describe "Dashboards", type: :request do
expect(response.body).not_to include "pagination"
end
- it "does not render a link to pro analytics" do
+ it "renders a link to analytics dashboard" do
get dashboard_path
- expect(response.body).not_to include("Pro Analytics")
+ expect(response.body).to include("Analytics")
end
- it "does not render a link to pro analytics for the org" do
+ it "renders a link to analytics for the org" do
create(:organization_membership, type_of_user: :admin, organization: organization, user: user)
get dashboard_path
- expect(response.body).not_to include("Pro Analytics for #{organization.name}")
+ expect(response.body).to include("Analytics for #{organization.name}")
end
it "does not render a link to upload a video when enable_video_upload is false" do
@@ -105,32 +107,6 @@ RSpec.describe "Dashboards", type: :request do
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
-
- it "renders a link to pro analytics" do
- sign_in pro_user
- get dashboard_path
-
- expect(response.body).to include("Pro Analytics")
- end
-
- it "renders a link to pro analytics for the org" do
- create(:organization_membership, type_of_user: :admin, organization: organization, user: pro_user)
-
- sign_in pro_user
- get dashboard_path
-
- expect(response.body).to include("Pro Analytics for #{CGI.escapeHTML(organization.name)}")
- end
- end
-
context "when logged in as a non recent user with enable_video_upload set to true on the Forem" do
it "renders a link to upload a video" do
Timecop.freeze(Time.current) do
@@ -278,49 +254,41 @@ RSpec.describe "Dashboards", type: :request do
end
end
- describe "GET /dashboard/pro" do
+ describe "GET /dashboard/analytics" do
context "when not logged in" do
it "raises unauthorized" do
- get "/dashboard/pro"
+ get "/dashboard/analytics"
expect(response).to redirect_to("/enter")
end
end
- context "when user does not have permission" do
- it "raises unauthorized" do
- sign_in user
- expect { get "/dashboard/pro" }.to raise_error(Pundit::NotAuthorizedError)
- end
- end
-
- context "when user has pro permission" do
+ context "when user is signed in" do
it "shows page properly" do
- user.add_role(:pro)
sign_in user
- get "/dashboard/pro"
- expect(response.body).to include("pro")
+ get "/dashboard/analytics"
+ expect(response.body).to include("Analytics")
end
end
- context "when user has pro permission and is an org admin" do
+ context "when user is an org admin" do
it "shows page properly" do
org = create :organization
create(:organization_membership, user: user, organization: org, type_of_user: "admin")
- user.add_role(:pro)
+
sign_in user
- get "/dashboard/pro/org/#{org.id}"
- expect(response.body).to include("pro")
+ get "/dashboard/analytics/org/#{org.id}"
+ expect(response.body).to include("Analytics")
end
end
- context "when user has pro permission and is an org member" do
+ context "when user has is an org member" do
it "shows page properly" do
org = create :organization
create(:organization_membership, user: user, organization: org)
- user.add_role(:pro)
+
sign_in user
- get "/dashboard/pro/org/#{org.id}"
- expect(response.body).to include("pro")
+ get "/dashboard/analytics/org/#{org.id}"
+ expect(response.body).to include("Analytics")
end
end
end
diff --git a/spec/support/api_analytics_shared_examples.rb b/spec/support/api_analytics_shared_examples.rb
index b12b10ca7..d891b2971 100644
--- a/spec/support/api_analytics_shared_examples.rb
+++ b/spec/support/api_analytics_shared_examples.rb
@@ -1,14 +1,12 @@
RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |endpoint, params|
let(:user) { create(:user) }
let(:api_token) { create(:api_secret, user: user) }
- let(:pro_user) { create(:user, :pro) }
- let(:pro_api_token) { create(:api_secret, user: pro_user) }
- let(:pro_org_member) { create(:user, :pro, :org_member) }
- let(:org_member_token) { create(:api_secret, user: pro_org_member) }
- let(:org) { pro_org_member.organizations.first }
+ let(:org_member) { create(:user, :org_member) }
+ let(:org_member_token) { create(:api_secret, user: org_member) }
+ let(:org) { org_member.organizations.first }
let(:article) { create(:article, user: user) }
- let(:pro_user_article) { create(:article, user: pro_user) }
- let(:pro_org_article) { create(:article, user: pro_user, organization: org) }
+ let(:user_article) { create(:article, user: user) }
+ let(:org_article) { create(:article, user: user, organization: org) }
context "when an invalid token is given" do
before { get "/api/analytics/#{endpoint}?#{params}", headers: { "api-key" => "abadskajdlsak" } }
@@ -22,21 +20,9 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
end
end
- context "when a valid token is given but the user is not a pro" do
+ context "when a valid token is given" do
before { get "/api/analytics/#{endpoint}?#{params}", headers: { "api-key" => api_token.secret } }
- it "renders an error message: 'unauthorized' in JSON" do
- expect(response.parsed_body).to include("error" => "unauthorized")
- end
-
- it "has a status 401" do
- expect(response).to have_http_status(:unauthorized)
- end
- end
-
- context "when a valid token is given and the user is a pro" do
- before { get "/api/analytics/#{endpoint}?#{params}", headers: { "api-key" => pro_api_token.secret } }
-
it "renders JSON as the content type" do
expect(response.media_type).to eq "application/json"
end
@@ -44,7 +30,7 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
context "when attempting to view organization analytics without belonging to the organization" do
before do
- headers = { "api-key" => pro_api_token.secret }
+ headers = { "api-key" => api_token.secret }
get "/api/analytics/#{endpoint}?organization_id=#{org.id}#{params}", headers: headers
end
@@ -59,7 +45,7 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
context "when attempting to view organization analytics and being a member of the organization" do
before do
- path = "/api/analytics/#{endpoint}?organization_id=#{pro_org_member.organization_ids.first}#{params}"
+ path = "/api/analytics/#{endpoint}?organization_id=#{org_member.organization_ids.first}#{params}"
get path, headers: { "api-key" => org_member_token.secret }
end
@@ -86,7 +72,7 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
context "when viewing as current user" do
it "responds with status 200 OK" do
- sign_in pro_user
+ sign_in user
get "/api/analytics/#{endpoint}?#{params}"
expect(response).to have_http_status(:ok)
end
@@ -94,18 +80,18 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
context "when viewing your own single article's analytics" do
it "responds with status 200 OK" do
- sign_in pro_user
- get "/api/analytics/#{endpoint}?article_id=#{pro_user_article.id}#{params}"
+ sign_in user
+ get "/api/analytics/#{endpoint}?article_id=#{user_article.id}#{params}"
expect(response).to have_http_status(:ok)
end
end
context "when viewing your own organizaiton's single article's analytics" do
it "responds with status 200 OK" do
- org_param = "&organization_id=#{pro_org_article.organization.id}"
+ org_param = "&organization_id=#{org_article.organization.id}"
- sign_in pro_org_member
- get "/api/analytics/#{endpoint}?article_id=#{pro_org_article.id}#{params}#{org_param}"
+ sign_in org_member
+ get "/api/analytics/#{endpoint}?article_id=#{org_article.id}#{params}#{org_param}"
expect(response).to have_http_status(:ok)
end
end
diff --git a/spec/system/articles/user_visits_article_stats_spec.rb b/spec/system/articles/user_visits_article_stats_spec.rb
index 61d7c5863..106d60698 100644
--- a/spec/system/articles/user_visits_article_stats_spec.rb
+++ b/spec/system/articles/user_visits_article_stats_spec.rb
@@ -4,9 +4,8 @@ RSpec.describe "Viewing an article stats", type: :system, js: true do
let(:user) { create(:user) }
let(:article) { create(:article, user: user) }
- it "shows stats for pro users by clicking on the stats button" do
+ it "shows stats for a user by clicking on the stats button" do
path = "/#{user.username}/#{article.slug}/stats"
- allow(user).to receive(:pro?).and_return(true)
sign_in user
visit path