diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 82ea72acb..9570bcdd3 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -8,8 +8,6 @@ class ApplicationController < ActionController::Base
# before_action :require_http_auth if ENV["APP_NAME"] == "dev_stage"
- before_action :ensure_signup_complete
-
#before_action :customize_params
def require_http_auth
@@ -22,15 +20,6 @@ class ApplicationController < ActionController::Base
raise ActionController::RoutingError.new("Not Found")
end
- def ensure_signup_complete
- return if controller_name == "users" || controller_name == "onboarding" || params[:confirmation_token].present?
- return if !request.get?
- if current_user && current_user.email.blank?
- redirect_to "/getting-started"
- return
- end
- end
-
def efficient_current_user_id
if session["warden.user.user.key"].present?
session["warden.user.user.key"].flatten[0]
diff --git a/app/controllers/async_info_controller.rb b/app/controllers/async_info_controller.rb
index f7b0a3911..c606c9ede 100644
--- a/app/controllers/async_info_controller.rb
+++ b/app/controllers/async_info_controller.rb
@@ -1,5 +1,4 @@
class AsyncInfoController < ApplicationController
- skip_before_action :ensure_signup_complete
include Devise::Controllers::Rememberable
def base_data
diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb
index 24c715ed3..6373c59d6 100644
--- a/app/controllers/dashboards_controller.rb
+++ b/app/controllers/dashboards_controller.rb
@@ -17,8 +17,6 @@ class DashboardsController < ApplicationController
@articles = @user.organization.articles.order("created_at DESC").decorate
elsif @user
@articles = @user.articles.order("created_at DESC").decorate
- else
- redirect_to "/enter"
end
end
end
diff --git a/app/controllers/feedback_messages_controller.rb b/app/controllers/feedback_messages_controller.rb
index 7e1207661..497b32b2a 100644
--- a/app/controllers/feedback_messages_controller.rb
+++ b/app/controllers/feedback_messages_controller.rb
@@ -43,7 +43,7 @@ class FeedbackMessagesController < ApplicationController
#{generate_user_detail}
Category: #{feedback_message_params[:category]}
Message: #{feedback_message_params[:message]}
- URL: #{params[:url]}
+ URL: #{params[:reported_url]}
HEREDOC
end
diff --git a/app/controllers/followed_articles_controller.rb b/app/controllers/followed_articles_controller.rb
index 5921a4ced..be7a64013 100644
--- a/app/controllers/followed_articles_controller.rb
+++ b/app/controllers/followed_articles_controller.rb
@@ -1,5 +1,4 @@
class FollowedArticlesController < ApplicationController
- skip_before_action :ensure_signup_complete
caches_action :index,
:cache_path => Proc.new { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?.to_s}" },
diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb
index 1a3f3de43..5b4c1c8d6 100644
--- a/app/controllers/follows_controller.rb
+++ b/app/controllers/follows_controller.rb
@@ -1,5 +1,4 @@
class FollowsController < ApplicationController
- skip_before_action :ensure_signup_complete
def show
unless current_user
diff --git a/app/controllers/giveaways_controller.rb b/app/controllers/giveaways_controller.rb
index ee7e2e2a0..e77ad854e 100644
--- a/app/controllers/giveaways_controller.rb
+++ b/app/controllers/giveaways_controller.rb
@@ -1,6 +1,5 @@
class GiveawaysController < ApplicationController
# GET /giveaways/new
- skip_before_action :ensure_signup_complete
def new
@user = current_user
diff --git a/app/controllers/notifications/counts_controller.rb b/app/controllers/notifications/counts_controller.rb
index e5dc0e785..41acab1db 100644
--- a/app/controllers/notifications/counts_controller.rb
+++ b/app/controllers/notifications/counts_controller.rb
@@ -1,5 +1,4 @@
class Notifications::CountsController < ApplicationController
- skip_before_action :ensure_signup_complete
def index
count = GetUnseenNotificationsService.new(current_user).get
render plain: count.to_s
diff --git a/app/controllers/notifications/reads_controller.rb b/app/controllers/notifications/reads_controller.rb
index 09c870dcc..a905fd0c7 100644
--- a/app/controllers/notifications/reads_controller.rb
+++ b/app/controllers/notifications/reads_controller.rb
@@ -1,5 +1,5 @@
class Notifications::ReadsController < ApplicationController
- skip_before_action :ensure_signup_complete
+
def create
result = ""
result = ReadNotificationsService.new(current_user).mark_as_read if current_user
diff --git a/app/controllers/onboarding_controller.rb b/app/controllers/onboarding_controller.rb
deleted file mode 100644
index 0aad60981..000000000
--- a/app/controllers/onboarding_controller.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class OnboardingController < ApplicationController
-
- def index
- if Rails.env.test?
- redirect_to "/"
- elsif current_user.email.blank? && current_user.unconfirmed_email.blank?
- basic_info
- else
- redirect_to "/settings"
- end
- end
-
- def basic_info
- @user = current_user
- render :basic_info
- end
-end
diff --git a/app/controllers/reading_list_items_controller.rb b/app/controllers/reading_list_items_controller.rb
index d42d19cbf..1646bd37e 100644
--- a/app/controllers/reading_list_items_controller.rb
+++ b/app/controllers/reading_list_items_controller.rb
@@ -1,6 +1,6 @@
class ReadingListItemsController < ApplicationController
before_action :set_cache_control_headers, only: [:index]
- skip_before_action :ensure_signup_complete
+
def index
@reading_list_items_index = true
set_surrogate_key_header "reading-list-index"
diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb
index 1b454512d..18ac217d6 100644
--- a/app/controllers/stories_controller.rb
+++ b/app/controllers/stories_controller.rb
@@ -2,8 +2,6 @@ class StoriesController < ApplicationController
before_action :authenticate_user!, except: [:index,:search,:show, :feed, :new]
before_action :set_cache_control_headers, only: [:index, :search, :show]
- skip_before_action :ensure_signup_complete
-
def index
return handle_user_or_organization_or_podcast_index if params[:username]
return handle_tag_index if params[:tag]
diff --git a/app/views/onboarding/basic_info.html.erb b/app/views/onboarding/basic_info.html.erb
deleted file mode 100644
index 99efd3c3a..000000000
--- a/app/views/onboarding/basic_info.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
Thanks for signing up
- A couple things to get started
- <%= form_for @user do |f| %>
- <%= f.email_field :email, placeholder: "Email Address" %>
- <%= f.text_area :summary,
- placeholder: "Short personal summary: Job, programming languages, etc.",
- maxlength: 200 %>
- <%= f.submit "SUBMIT", class: "cta" %>
- <% end %>
-
-
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 98c45a4a6..dd44ecfc6 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -21,9 +21,14 @@
<% end %>
<% if current_user.email.blank? %>
- Provide email to complete your profile
+ Confirm your email to complete your profile
- while you're at it, go ahead and fill everything out.
connect your <%= (@user.twitter_username.blank?) ? "twitter":"github" %> account as well to complete your identity.
+ while you're at it, go ahead and fill everything out.
+ <% if @user.twitter_username.blank? %>
+ connect your twitter account as well to complete your identity.
+ <% elsif @user.github_username.blank? %>
+ connect your github account as well to complete your identity.
+ <% end %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 64ee9e0e2..867caf147 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -232,8 +232,6 @@ Rails.application.routes.draw do
get "/badge/:slug" => "badges#show"
- get "/getting-started" => "onboarding#index"
-
get "/top/:timeframe" => "stories#index"
get "/:timeframe" => "stories#index", constraints: { timeframe: /latest/}
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 1ddc75c69..b5166f923 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -26,6 +26,10 @@ FactoryBot.define do
after(:build) { |user| user.add_role(:banned) }
end
+ trait :video_permission do
+ after(:build) { |user| user.add_role :video_permission }
+ end
+
trait :ignore_after_callback do
after(:build) do |user|
user.define_singleton_method(:subscribe_to_mailchimp_newsletter) {}
diff --git a/spec/requests/dashboard_spec.rb b/spec/requests/dashboard_spec.rb
index 7b448d96a..6198f3254 100644
--- a/spec/requests/dashboard_spec.rb
+++ b/spec/requests/dashboard_spec.rb
@@ -1,33 +1,94 @@
require "rails_helper"
RSpec.describe "Dashboards", type: :request do
- let(:user) { create(:user) }
- let(:article) { create(:article, user_id: user.id) }
+ let(:user) { create(:user) }
+ let(:second_user) { create(:user) }
+ let(:super_admin) { create(:user, :super_admin) }
+ let(:article) { create(:article, user_id: user.id) }
describe "GET /dashboard" do
- context "when logged-in" do
- before do
- article
- login_as user
+ context "when not logged in" do
+ it "redirects to /enter" do
+ get "/dashboard"
+ is_expected.to redirect_to("/enter")
end
+ end
+ context "when logged in" do
it "renders user's articles" do
+ login_as user
+ article
get "/dashboard"
expect(response.body).to include CGI.escapeHTML(article.title)
end
+ end
+ context "when logged in as a super admin" do
+ it "renders the specified user's articles" do
+ article
+ user
+ login_as super_admin
+ get "/dashboard/#{user.username}"
+ expect(response.body).to include CGI.escapeHTML(article.title)
+ end
+ end
+ end
+
+ describe "GET /dashboard/organization" do
+ let(:organization) { create(:organization) }
+
+ context "when not logged in" do
+ it "redirects to /enter" do
+ get "/dashboard/organization"
+ is_expected.to redirect_to("/enter")
+ end
+ end
+
+ context "when logged in" do
it "renders user's organization articles" do
organization = create(:organization)
user.update(organization_id: organization.id, org_admin: true)
article.update(organization_id: organization.id)
+ login_as user
get "/dashboard/organization"
expect(response.body).to include CGI.escapeHTML(organization.name.upcase)
end
end
+ end
- it "redirects to /enter if no current_user" do
- get "/dashboard/organization"
- expect(response.body).to redirect_to("/enter")
+ describe "GET /dashboard/following_users" do
+ context "when not logged in" do
+ it "redirects to /enter" do
+ get "/dashboard/following_users"
+ is_expected.to redirect_to("/enter")
+ end
+ end
+
+ context "when logged in" do
+ it "renders the current user's followings" do
+ user.follow second_user
+ login_as user
+ get "/dashboard/following_users"
+ expect(response.body).to include second_user.name
+ end
+ end
+ end
+
+ describe "GET /dashboard/user_followers" do
+ context "when not logged in" do
+ it "redirects to /enter" do
+ get "/dashboard/user_followers"
+ is_expected.to redirect_to("/enter")
+ end
+ end
+
+ context "when logged in" do
+ it "renders the current user's followers" do
+ second_user.follow user
+ login_as user
+ get "/dashboard/user_followers"
+ expect(response.body).to include second_user.name
+ end
end
end
end
diff --git a/spec/requests/feedback_messages_create_spec.rb b/spec/requests/feedback_messages_create_spec.rb
index 903e81b29..3dc8ba3d4 100644
--- a/spec/requests/feedback_messages_create_spec.rb
+++ b/spec/requests/feedback_messages_create_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "feedback_messages", type: :request do
end
context "when a logged in user submits report" do
- let!(:user) { create(:user) }
+ let(:user) { create(:user) }
let(:mail_message) { instance_double(Mail::Message, deliver: true) }
before do
diff --git a/spec/requests/registration_spec.rb b/spec/requests/registration_spec.rb
new file mode 100644
index 000000000..2e875fce9
--- /dev/null
+++ b/spec/requests/registration_spec.rb
@@ -0,0 +1,22 @@
+require "rails_helper"
+
+RSpec.describe "Registrations", type: :request do
+ let(:user) { create(:user) }
+
+ describe "GET /enter" do
+ context "when not logged in" do
+ it "shows the sign in page" do
+ get "/enter"
+ expect(response.body).to include "Sign In or Create Your Account"
+ end
+ end
+
+ context "when logged in" do
+ it "redirects to /dashboard" do
+ login_as user
+ get "/enter"
+ is_expected.to redirect_to("/dashboard?signed-in-already&t=#{Time.now.to_i}")
+ end
+ end
+ end
+end
diff --git a/spec/requests/videos_spec.rb b/spec/requests/videos_spec.rb
index 649feafd2..2cbd2c668 100644
--- a/spec/requests/videos_spec.rb
+++ b/spec/requests/videos_spec.rb
@@ -1,22 +1,60 @@
-# http://localhost:3000/api/comments?a_id=23
require "rails_helper"
RSpec.describe "Videos", type: :request do
- before do
- @user = create(:user)
- login_as @user
- end
+ let(:unauthorized_user) { create(:user) }
+ let(:authorized_user) { create(:user, :video_permission) }
describe "GET /videos/new" do
- it "redirects if non permission" do
- get "/videos/new"
- expect(response.body).to include("You are being")
+ context "when not authorized" do
+ it "redirects non-logged in users" do
+ get "/videos/new"
+ is_expected.to redirect_to("/enter")
+ end
+
+ it "redirects logged in users" do
+ login_as unauthorized_user
+ get "/videos/new"
+ is_expected.to redirect_to("/enter")
+ end
end
- it "renders video page if has permission" do
- @user.add_role(:video_permission)
- get "/videos/new"
- expect(response.body).to include("Upload Video File")
+ context "when authorized" do
+ it "allows authorized users" do
+ login_as authorized_user
+ get "/videos/new"
+ expect(response.body).to include "Upload Video File"
+ end
+ end
+ end
+
+ describe "POST /videos" do
+ context "when not authorized" do
+ it "redirects non-logged in users" do
+ post "/videos"
+ is_expected.to redirect_to("/enter")
+ end
+
+ it "redirects logged in users" do
+ login_as unauthorized_user
+ post "/videos"
+ is_expected.to redirect_to("/enter")
+ end
+ end
+
+ context "when authorized" do
+ before do
+ login_as authorized_user
+ end
+
+ valid_params = {
+ article: {
+ video: "something.mp4"
+ }
+ }
+
+ xit "creates an article for the logged in user" do
+ post "/videos", params: valid_params
+ end
end
end
end