diff --git a/Changelog.md b/Changelog.md index 9c1a61080..10326903f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -87,6 +87,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure. * Improve infinite scroll triggering [#6451](https://github.com/diaspora/diaspora/pull/6451) ## Bug fixes +* Skip first getting started step if it looks done already [#6456](https://github.com/diaspora/diaspora/pull/6456) ## Features * Show spinner on initial stream load [#6384](https://github.com/diaspora/diaspora/pull/6384) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 19010ca93..ebd5b0343 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -139,7 +139,12 @@ class ApplicationController < ActionController::Base end def current_user_redirect_path - current_user.getting_started? ? getting_started_path : stream_path + # If getting started is active AND the user has not completed the getting_started page + if current_user.getting_started? && !current_user.basic_profile_present? + getting_started_path + else + stream_path + end end def gon_set_appconfig diff --git a/app/models/user.rb b/app/models/user.rb index a7ed430fb..cc0dd2331 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -422,6 +422,10 @@ class User < ActiveRecord::Base Postzord::Dispatcher.build(self, profile).post end + def basic_profile_present? + tag_followings.any? || profile[:image_url] + end + ###Helpers############ def self.build(opts = {}) u = User.new(opts.except(:person, :id)) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 3910e9461..7b23695ac 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -20,7 +20,7 @@ describe ApplicationController, :type => :controller do get :index expect(response.headers['X-Diaspora-Version']).to include AppConfig.version.number.get end - + context 'with git info' do before do allow(AppConfig).to receive(:git_available?).and_return(true) @@ -86,10 +86,36 @@ describe ApplicationController, :type => :controller do alice.update_attribute(:getting_started, true) end - it "redirects to getting started if the user has getting started set to true" do + it "redirects to getting started if the user has getting started set to true and a blank profile" do expect(@controller.send(:after_sign_in_path_for, alice)).to eq(getting_started_path) end end + + context "getting started true and one tag present on user" do + before do + alice.update_attribute(:getting_started, true) + @tag = ActsAsTaggableOn::Tag.create!(name: "partytimeexcellent") + allow(@controller).to receive(:current_user).and_return(alice) + TagFollowing.create!(tag: @tag, user: alice) + end + + it "redirects to stream if the user has getting started set to true and has already added tags" do + expect(@controller.send(:after_sign_in_path_for, alice)).to eq(stream_path) + end + end + + context "getting started true and user image present on user" do + before do + alice.update_attribute(:getting_started, true) + # Just set the image url... + alice.profile.image_url = "something not nil" + allow(@controller).to receive(:current_user).and_return(alice) + end + + it "redirects to stream if the user has getting started set to true and has already added a photo" do + expect(@controller.send(:after_sign_in_path_for, alice)).to eq(stream_path) + end + end end describe "#after_sign_out_path_for" do