Skip to content

Commit 8031ebf

Browse files
authored
Flow decorators (#1052)
* cleanup flow decorators and next step paths * remove conditional signup link * upgrade openstax_salesforce * fix school name * update complete profile handler spec * fix redirect back code * update env.sample
1 parent a11a977 commit 8031ebf

File tree

7 files changed

+24
-35
lines changed

7 files changed

+24
-35
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# This may or may not be a complete listing, but they are very useful ones.
33
#####
44

5+
ENVIRONMENT_NAME=local
6+
57
# Especially useful for debugging, learning our codebase, or development.
68
# — Whether it should take screenshots during features specs or not (see `screenshot!`)
79
SSHOTS=false

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ GEM
176176
coffee-script-source
177177
execjs
178178
coffee-script-source (1.12.2)
179-
concurrent-ruby (1.1.9)
179+
concurrent-ruby (1.1.10)
180180
crack (0.4.5)
181181
rexml
182182
crass (1.0.6)
@@ -372,7 +372,7 @@ GEM
372372
activesupport (>= 4)
373373
railties (>= 4)
374374
request_store (~> 1.0)
375-
loofah (2.14.0)
375+
loofah (2.15.0)
376376
crass (~> 1.0.2)
377377
nokogiri (>= 1.5.9)
378378
lumberjack (1.0.10)
@@ -459,7 +459,7 @@ GEM
459459
rails (>= 3.0)
460460
openstax_rescue_from (4.2.0)
461461
rails (>= 3.1, < 7.0)
462-
openstax_salesforce (7.4.2)
462+
openstax_salesforce (7.4.3)
463463
openstax_active_force
464464
rails (>= 5.0, < 7.0)
465465
restforce
@@ -582,7 +582,7 @@ GEM
582582
responders (3.0.1)
583583
actionpack (>= 5.0)
584584
railties (>= 5.0)
585-
restforce (5.2.3)
585+
restforce (5.2.4)
586586
faraday (>= 0.9.0, < 1.9.0)
587587
faraday_middleware (>= 0.8.8, <= 2.0)
588588
hashie (>= 1.2.0, < 6.0)

app/handlers/newflow/educator_signup/complete_profile.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ def handle
5656
@is_on_cs_form = signup_params.is_cs_form?
5757
outputs.is_on_cs_form = @is_on_cs_form
5858

59+
# is this user coming from the sheerid flow? there are a few things we can check...
60+
@did_use_sheerid = !(signup_params.is_school_not_supported_by_sheerid == 'true' ||
61+
signup_params.is_country_not_supported_by_sheerid == 'true' ||
62+
user.is_sheerid_unviable? || @is_on_cs_form)
63+
5964
# validate the form
6065
check_params
6166
return if errors?
6267

63-
# is this user coming from the sheerid flow? there are a few things we can check...
64-
@did_use_sheerid = !(signup_params.is_school_not_supported_by_sheerid == 'true' ||
65-
signup_params.is_country_not_supported_by_sheerid == 'true' ||
66-
user.is_sheerid_unviable? || @is_on_cs_form)
67-
6868
@user.update!(
6969
role: signup_params.educator_specific_role,
7070
other_role_name: other_role_name,
@@ -144,7 +144,7 @@ def books_of_interest
144144
def check_params
145145
role = signup_params.educator_specific_role.strip.downcase
146146

147-
if !@did_use_sheerid && signup_params.school_name.nil?
147+
if signup_params.school_name && signup_params.school_name.nil?
148148
param_error(:school_name, :school_name_must_be_entered)
149149
end
150150

app/views/newflow/educator_signup/_school_name.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<%= I18n.t(:"educator_profile_form.school_name_must_be_entered") %>
88
</div>
99
<input
10-
name="<%= :school_name %>"
10+
name="signup[school_name]"
1111
placeholder="<%= I18n.t(:"educator_profile_form.school_name") %>"
1212
autofocus
1313
data-bind="textInput: schoolName"

app/views/newflow/signup/welcome.html.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<%
2-
conditional_educator_signup_path = Settings::FeatureFlags.educator_feature_flag ? educator_signup_path : signup_path(set_param_to_permit_legacy_flow)
3-
%>
4-
51
<div id="login-signup-form">
62
<div class="content">
73
<%= render partial: 'newflow/tab_group', locals: { active_class: 'signup--active'} %>
@@ -36,7 +32,7 @@
3632
</div>
3733

3834
<div>
39-
<%= link_to conditional_educator_signup_path, data: { 'ga-category': 'Account Creation', 'ga-action': 'Click', 'ga-label': '2B-Educator' } do %>
35+
<%= link_to educator_signup_path, data: { 'ga-category': 'Account Creation', 'ga-action': 'Click', 'ga-label': '2B-Educator' } do %>
4036
<div class="join-as__role educator">
4137
<span><%= I18n.t(:"login_signup_form.educator") %></span>
4238
<%= image_tag('educator-icon.svg') %>

lib/educator_signup_flow_decorator.rb

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ def initialize(user, current_step)
1010
end
1111

1212
def newflow_edu_incomplete_step_3?
13-
if !user.is_newflow? || user.is_sheerid_unviable?
13+
if user.is_sheerid_unviable?
1414
return false
1515
elsif user.sheerid_verification_id.blank? && user.pending_faculty? && !user.is_educator_pending_cs_verification
1616
return true
1717
end
1818
end
1919

2020
def newflow_edu_incomplete_step_4?
21-
return false if !user.is_newflow?
22-
2321
return true if !user.is_profile_complete?
2422
end
2523

2624
def can_do?(action)
27-
return false if shouldnt_proceed?
25+
return false if user.student?
2826

2927
case action
3028
when 'redirect_back_upon_login'
31-
!user.is_newflow? || (user.is_newflow? && user.is_profile_complete?)
29+
user.is_profile_complete?
3230
when 'educator_sheerid_form'
33-
(user.no_faculty_info? || user.pending_faculty?) && user.sheerid_verification_id.blank?
31+
(user.no_faculty_info? || user.pending_faculty? || user.incomplete_signup?) && user.sheerid_verification_id.blank?
3432
when 'educator_signup_form'
3533
user.is_anonymous?
3634
when 'educator_signup'
@@ -64,11 +62,4 @@ def next_step
6462
raise("Next step (#{current_step}) uncaught in #{self.class.name}")
6563
end
6664
end
67-
68-
private ###################
69-
70-
def shouldnt_proceed?
71-
user.student? || !Settings::FeatureFlags.educator_feature_flag
72-
end
73-
7465
end

spec/handlers/newflow/educator_signup/complete_profile_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ module EducatorSignup
3232

3333
it "should return correct error" do
3434
result = handle
35-
expect(result.errors.count).to eq 2
36-
expect(result.errors.first.message).to eq 'Please enter school name'
35+
expect(result.errors.count).to eq 1
36+
expect(result.errors.first.message).to eq 'Please enter other role name'
3737
end
3838
end
3939

@@ -44,8 +44,8 @@ module EducatorSignup
4444

4545
it "should return correct error" do
4646
result = handle
47-
expect(result.errors.count).to eq 2
48-
expect(result.errors.first.message).to eq 'Please enter school name'
47+
expect(result.errors.count).to eq 1
48+
expect(result.errors.first.message).to eq 'Please enter books used'
4949
end
5050
end
5151

@@ -55,8 +55,8 @@ module EducatorSignup
5555

5656
it "should return correct error" do
5757
result = handle
58-
expect(result.errors.count).to eq 2
59-
expect(result.errors.first.message).to eq 'Please enter school name'
58+
expect(result.errors.count).to eq 1
59+
expect(result.errors.first.message).to eq 'Please enter number of students taught'
6060
end
6161
end
6262
end

0 commit comments

Comments
 (0)