Show getting_started only if user has made no profile changes on the page

closes #6456
This commit is contained in:
Faldrian 2015-10-04 18:19:33 +02:00 committed by Jonne Haß
parent 517cd56f21
commit a946251a9e
4 changed files with 39 additions and 3 deletions

View file

@ -4,6 +4,7 @@
* Improve infinite scroll triggering [#6451](https://github.com/diaspora/diaspora/pull/6451) * Improve infinite scroll triggering [#6451](https://github.com/diaspora/diaspora/pull/6451)
## Bug fixes ## Bug fixes
* Skip first getting started step if it looks done already [#6456](https://github.com/diaspora/diaspora/pull/6456)
## Features ## Features
* Show spinner on initial stream load [#6384](https://github.com/diaspora/diaspora/pull/6384) * Show spinner on initial stream load [#6384](https://github.com/diaspora/diaspora/pull/6384)

View file

@ -138,7 +138,12 @@ class ApplicationController < ActionController::Base
end end
def current_user_redirect_path 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 end
def gon_set_current_user def gon_set_current_user

View file

@ -416,6 +416,10 @@ class User < ActiveRecord::Base
Postzord::Dispatcher.build(self, profile).post Postzord::Dispatcher.build(self, profile).post
end end
def basic_profile_present?
tag_followings.any? || profile[:image_url]
end
###Helpers############ ###Helpers############
def self.build(opts = {}) def self.build(opts = {})
u = User.new(opts.except(:person, :id)) u = User.new(opts.except(:person, :id))

View file

@ -20,7 +20,7 @@ describe ApplicationController, :type => :controller do
get :index get :index
expect(response.headers['X-Diaspora-Version']).to include AppConfig.version.number.get expect(response.headers['X-Diaspora-Version']).to include AppConfig.version.number.get
end end
context 'with git info' do context 'with git info' do
before do before do
allow(AppConfig).to receive(:git_available?).and_return(true) allow(AppConfig).to receive(:git_available?).and_return(true)
@ -86,10 +86,36 @@ describe ApplicationController, :type => :controller do
alice.update_attribute(:getting_started, true) alice.update_attribute(:getting_started, true)
end 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) expect(@controller.send(:after_sign_in_path_for, alice)).to eq(getting_started_path)
end end
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 end
describe "#after_sign_out_path_for" do describe "#after_sign_out_path_for" do