-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: User flow redesign #736
Changes from 6 commits
c7e1446
b379470
b651599
a9ac3ba
9fb02e6
3fe8699
f13d133
bb13080
30f1595
e31d551
31f96ed
b8bc48e
e452572
257af98
f9802d8
6810326
46a94de
bc504b7
94d5e9a
ef719f9
c526389
387086e
600cd9e
865d1e5
2850377
53d0461
696e40e
a0be4e0
96b6ebd
c95dccd
9b01e04
b2156ba
bafffc6
5c3ce7b
bd7c300
8ce34d5
f881aa1
58ff325
7bf355b
fd1c1df
390df30
76b0d98
d7fdb1c
739fa52
d5c7ce8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
class TeaTimesController < ApplicationController | ||
helper TeaTimesHelper | ||
before_action :set_tea_time, except: [:index, :new, :create] | ||
before_action :authenticate_user! | ||
before_action :authorized?, only: [:new, :edit, :create, :update, :cancel, :destroy, :index] | ||
before_action :set_tea_time, except: [:index, :list, :new, :create] | ||
before_action :authenticate_user!, except: [:index] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
before_action :authorized?, only: [:new, :edit, :create, :update, :cancel, :destroy, :list] | ||
before_action :use_new_styles, except: [:create, :update, :cancel, :destroy] | ||
|
||
# GET /tea_times | ||
# GET /tea_times.json | ||
def index | ||
@tea_times = TeaTime.this_month.order(start_time: :asc).includes(:city).all | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we are converting a list of tea times into a hash like:
along with a list of names in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will return an array of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: array: Whoops, my bad for not being clear. I meant this comment to 'introduce' the following lines of code which are doing the process of converting that list to a hash. Re: scope: I added a custom scope in the model, let me know if it looks right: https://github.com/TeaWithStrangers/tws-on-rails/pull/736/files#diff-c0448cf921e60c620dcf5c85c1718605R35 Re: rolling period: This was something Ankit requested in the spec - I think the idea was to have tea times come out in "batches" at the beginning of the month. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: rolling period — Mark is right on what I suggested in the spec. We discussed having following month's tea times be available with the click of a "Show Next Month's Tea Times" button. Not sure if we landed on a conclusion there. @markbao Do you remember? |
||
# Array of cities holding tea times this month | ||
# Extract all names of cities from tea times and deduplicate | ||
@cities = @tea_times.map { |tt| tt.city.name }.uniq | ||
|
||
# For each available city, create a hash entry and an empty list | ||
# of tea times | ||
@tea_times_by_city = Hash.new | ||
@cities.each { |city| @tea_times_by_city[city] = [] } | ||
|
||
# Iterate through tea times and segment into cities | ||
@tea_times.each do |tt| | ||
@tea_times_by_city[tt.city.name].push(tt) | ||
end | ||
|
||
respond_to do |format| | ||
format.html { render layout: !request.xhr? } | ||
format.json { render json: @tea_times } | ||
end | ||
end | ||
|
||
# GET /tea_times/list | ||
# GET /tea_times/list.json | ||
def list | ||
@tea_times = TeaTime.all | ||
respond_to do |format| | ||
format.html { render layout: !request.xhr? } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,20 @@ | |
</button> | ||
<% end %> | ||
<% end %> | ||
<% elsif (no_signin_button ||= false) # No signin button; don't show signin CTA text %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the |
||
<%= link_to sign_up_path(redirect_to_tt: tea_time.id) do %> | ||
<% if tea_time.spots_remaining? %> | ||
<button class="spots<%= tea_time.spots_remaining %>"> | ||
Count Me In | ||
</button> | ||
<% else %> | ||
<button class="yellow button"> | ||
Join Waitlist | ||
</button> | ||
<% end %> | ||
<% end %> | ||
<% else %> | ||
<%= link_to new_user_session_path do %> | ||
<%= link_to new_user_session_path(redirect_to_tt: tea_time.id) do %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<button class="yellow button"> | ||
Sign in to schedule | ||
</button> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<% next_month_name = Date.today.next_month.strftime("%B") %> | ||
|
||
<div class="cover-photo" style="background-image: linear-gradient(to bottom, rgba(247, 191, 77, 0.87), rgba(247, 191, 77, 0.87)), url('<%= image_path("missing-city-image.jpg") %>'); margin-bottom: 50px;"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Styles are inline because @ankitshah811 will do the CSS and I don't want to create classes that might be rewritten later. |
||
<%= render partial: 'shared/header' %> | ||
<div class="content"> | ||
<div class="content-box"> | ||
<h1 class="cover-photo-lede">Tea times this month</h1> | ||
<span class='cover-photo-subtext'> | ||
We announce tea times at the beginning of each month. | ||
If nothing this month fits you, sign up and we'll | ||
email you in <%= next_month_name %> about tea times | ||
then. | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="container"> | ||
<div class="light-background"> | ||
<div> | ||
<% if @tea_times_by_city.empty? %> | ||
<p> | ||
No tea times scheduled for this month! Check back later. | ||
</p> | ||
<% else %> | ||
<p> | ||
This month, there are tea times happening in <%= @cities.to_sentence %>. | ||
</p> | ||
<p> | ||
If you don't live in any of these places or the tea times below don't | ||
work for your schedule, we can try to make something work for you in | ||
<%= next_month_name %>. | ||
</p> | ||
<% end %> | ||
</div> | ||
<div> | ||
<button>Email me in <%= next_month_name %></button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet implemented. |
||
</div> | ||
<% @tea_times_by_city.each do |city, tts| %> | ||
<div class="tt-set-container"> | ||
<div class="tt-container tt-city-name" style="border: 5px solid #EF6236; color: #EF6236; font-weight: bold; height: 200px; padding: 20px; font-size: 30px; text-transform: uppercase; text-align: center;"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above (Styles are inline because @ankitshah811 will do the CSS and I don't want to create classes that might be rewritten later.) |
||
<%= city %> | ||
</div> | ||
<% tts.each do |tt| %> | ||
<%= render partial: 'shared/tea_time_row', locals: {tea_time: tt, no_signin_button: true} %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,16 @@ | |
expect(page).to have_content 'Dashboard' | ||
end | ||
|
||
scenario 'can sign up with a valid email and password and a redirect_to_tt path' do | ||
tt = create(:tea_time) | ||
visit sign_up_path(redirect_to_tt: tt.id) | ||
fill_in('user_name', with: 'Darth Helmet') | ||
fill_in('user_email', with: '[email protected]') | ||
fill_in('user_password', with: SecureRandom.hex) | ||
click_button("Let's Get Tea") | ||
expect(page.current_path).to eq tea_time_path(tt.id) | ||
end | ||
|
||
scenario 'with blank name' do | ||
sign_up_with('', '[email protected]') | ||
#User should be redirected to the sign up page | ||
|
@@ -23,6 +33,14 @@ | |
expect(page).to have_content user.home_city.name | ||
end | ||
|
||
scenario 'can sign in with a redirect_to_tt path and be redirected correctly' do | ||
tt = create(:tea_time) | ||
user = create(:user) | ||
visit new_user_session_path(redirect_to_tt: tt.id) | ||
sign_in user | ||
expect(page.current_path).to eq tea_time_path(tt.id) | ||
end | ||
|
||
scenario 'with an already created user account from a registration form' do | ||
user = create(:user) | ||
sign_up_with(user.nickname, user.email) | ||
|
@@ -102,6 +120,30 @@ | |
end | ||
end | ||
|
||
feature 'Registered User without home city' do | ||
before(:each) do | ||
@host = create(:user, :host) | ||
@user = create(:user, home_city: nil) | ||
@tt = create(:tea_time, host: @host, city: @host.home_city) | ||
sign_in @user | ||
end | ||
|
||
feature 'Tea Time Attendance' do | ||
scenario 'signing up to a tea time sets user home city to tea time city' do | ||
visit city_path(@host.home_city) | ||
expect(page.status_code).to eq(200) | ||
click_link('Count Me In') | ||
expect(current_path).to eq tea_time_path(@tt) | ||
|
||
find('input.confirm').click | ||
|
||
# Reload the user model and check the user's home city is set | ||
@user.reload | ||
expect(@user.home_city).to eq @tt.city | ||
end | ||
end | ||
end | ||
|
||
private | ||
def sign_up_with(name, email, opts = nil) | ||
visit sign_up_path | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the param should be coerced to a string automatically when you concatenate it to the result of
store_location_for
- does it not work without theto_i.to_s
that way?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was a bit of a weird design decision. I was thinking that it was possible that
params[:redirect_to_tt]
might not be a string containing an integer, so here I was ensuring that it was an integer, but if we doTeaTime.find(params[:redirect_to_tt])
(which I added later) that already checks if it's an integer. I'll remove this.