Skip to content

Commit

Permalink
Add onboarding information to user serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKing0126 committed May 1, 2024
1 parent 11ac1c3 commit e08cd89
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/serializers/user_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UserSerializer < ActiveModel::Serializer

attributes :services, :account, :profile, :va_profile, :veteran_status,
:in_progress_forms, :prefills_available, :vet360_contact_information,
:session
:session, :onboarding

def id
nil
Expand All @@ -23,4 +23,5 @@ def id
delegate :prefills_available, to: :object
delegate :services, to: :object
delegate :session, to: :object
delegate :onboarding, to: :object
end
7 changes: 7 additions & 0 deletions app/services/users/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def fetch_and_serialize_profile
scaffold.prefills_available = prefills_available
scaffold.services = services
scaffold.session = session_data
scaffold.onboarding = onboarding if Flipper.enabled?(:veteran_onboarding_beta_flow, @user)
end

def account
Expand Down Expand Up @@ -215,5 +216,11 @@ def session_data
transactionid: @session[:ssoe_transactionid]
}
end

def onboarding
{
show: user.show_onboarding_flow_on_login
}
end
end
end
3 changes: 2 additions & 1 deletion app/services/users/scaffold.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module Users
#
# rubocop:disable Style/StructInheritance
class Scaffold < Struct.new(:errors, :status, :services, :account, :profile, :va_profile, :veteran_status,
:in_progress_forms, :prefills_available, :vet360_contact_information, :session)
:in_progress_forms, :prefills_available, :vet360_contact_information, :session,
:onboarding)
end
# rubocop:enable Style/StructInheritance
end
20 changes: 20 additions & 0 deletions spec/controllers/v0/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@
expect(claims).to be(nil)
end

context 'onboarding' do
it 'returns a JSON user with onboarding information when the feature toggle is enabled' do
Flipper.enable(:veteran_onboarding_beta_flow, user)
get :show
json = json_body_for(response)
expect(response).to be_successful
onboarding = json.dig('attributes', 'onboarding')
expect(onboarding['show']).to be(true)
end

it 'returns a JSON user without onboarding information when the feature toggle is disabled' do
Flipper.disable(:veteran_onboarding_beta_flow)
get :show
json = json_body_for(response)
expect(response).to be_successful
onboarding = json.dig('attributes', 'onboarding')
expect(onboarding).to be(nil)
end
end

context 'when profile claims enabled' do
before do
Flipper.enable(:profile_user_claims)
Expand Down

0 comments on commit e08cd89

Please sign in to comment.