Jess/mentorship form updates (#653)
* add timestamps for mentroship form updates * update placeholder text * Add tests for mentee description change
This commit is contained in:
parent
d77db61d0a
commit
33f590ecc8
6 changed files with 45 additions and 5 deletions
|
|
@ -103,6 +103,8 @@ class User < ApplicationRecord
|
|||
after_save :subscribe_to_mailchimp_newsletter
|
||||
after_save :conditionally_resave_articles
|
||||
after_create :estimate_default_language!
|
||||
before_update :mentor_status_update
|
||||
before_update :mentee_status_update
|
||||
before_validation :set_username
|
||||
before_validation :downcase_email
|
||||
before_validation :check_for_username_change
|
||||
|
|
@ -497,4 +499,16 @@ class User < ApplicationRecord
|
|||
follower_relationships.destroy_all
|
||||
follows.destroy_all
|
||||
end
|
||||
|
||||
def mentor_status_update
|
||||
if mentor_description_changed? || offering_mentorship_changed?
|
||||
self.mentor_form_updated_at = Time.now
|
||||
end
|
||||
end
|
||||
|
||||
def mentee_status_update
|
||||
if mentee_description_changed? || seeking_mentorship_changed?
|
||||
self.mentee_form_updated_at = Time.now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -72,7 +72,9 @@ class UserPolicy < ApplicationPolicy
|
|||
looking_for_work_publicly
|
||||
medium_url
|
||||
mentee_description
|
||||
mentee_form_updated_at
|
||||
mentor_description
|
||||
mentor_form_updated_at
|
||||
mostly_work_with
|
||||
name
|
||||
offering_mentorship
|
||||
|
|
|
|||
|
|
@ -2,23 +2,27 @@
|
|||
<p>If you're interested in participating as a mentor, mentee, or both, please indicate below and we will be in contact via email.</p>
|
||||
|
||||
<%= form_for(@user) do |f| %>
|
||||
<h3>Offering Help:</h3>
|
||||
<h3>Offering Help</h3>
|
||||
<p><em><% if @user.mentor_form_updated_at? %>Last Updated: <%= @user.mentor_form_updated_at.strftime("%b %d, %Y") %><% end %></em></p>
|
||||
<div class="field checkbox-label-first">
|
||||
<%= f.label :offering_mentorship, "I'd like to be a mentor!"%>
|
||||
<%= f.check_box :offering_mentorship %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :mentor_description, "How can you help?" %>
|
||||
<%= f.text_area :mentor_description, placeholder: "Languages, subject preference, career advice, etc.", maxlength: 500 %>
|
||||
<p>Please share the top 3 technologies/concepts you'd be comfortable working on with your mentee, how much experience you currently have (0-10, 10 being super duper expert), and anything else you'd like us to know.</p>
|
||||
<%= f.text_area :mentor_description, placeholder: "For example:\n\n1. Vim - 6, I love teaching people how to use vim because I really believe it increases productivity.\n\nI don't think I'd be comfortable teaching a total beginner. ", maxlength: 500 %>
|
||||
</div>
|
||||
<h3>Seeking Help:</h3>
|
||||
<h3>Seeking Help</h3>
|
||||
<p><em><% if @user.mentee_form_updated_at? %>Last Updated:
|
||||
<%= @user.mentor_form_updated_at.strftime("%b %d, %Y") %><% end %></em></p>
|
||||
<div class="field checkbox-label-first">
|
||||
<%= f.label :seeking_mentorship, "I'm looking for a mentor!"%>
|
||||
<%= f.check_box :seeking_mentorship %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :mentee_description, "How can we help?" %>
|
||||
<%= f.text_area :mentee_description, placeholder: "Languages, subject preference, career advice, etc.", maxlength: 500 %>
|
||||
<p>Please share the top 3 technologies/concepts you'd like to work on with your mentor, how much experience you currently have (0-10, 0 being no experience at all), and why you're interested in learning more. Please also share your general technical background and career goals.</p>
|
||||
<%= f.text_area :mentee_description, placeholder: "For example:\n\n1. React - 1, I walked through the tutorial on the React website, but I'm feeling lost. I see React listed in lots of job descriptions so I'd like to learn how to utilize the framework.\n\nI graduated from a coding bootcamp 3 months ago and my goal is to land my first developer role. I learned jQuery in the program.", maxlength: 500 %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label></label>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
class AddUpdatedTimestampsToUsers < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :users, :mentee_form_updated_at, :timestamp
|
||||
add_column :users, :mentor_form_updated_at, :timestamp
|
||||
end
|
||||
end
|
||||
|
|
@ -669,7 +669,9 @@ ActiveRecord::Schema.define(version: 20180806142338) do
|
|||
t.boolean "looking_for_work_publicly", default: false
|
||||
t.datetime "membership_started_at"
|
||||
t.text "mentee_description"
|
||||
t.datetime "mentee_form_updated_at"
|
||||
t.text "mentor_description"
|
||||
t.datetime "mentor_form_updated_at"
|
||||
t.integer "monthly_dues", default: 0
|
||||
t.string "mostly_work_with"
|
||||
t.string "name"
|
||||
|
|
|
|||
|
|
@ -145,6 +145,18 @@ RSpec.describe User, type: :model do
|
|||
expect(user.old_old_username).to eq(old_username)
|
||||
end
|
||||
|
||||
it "updates mentor_form_updated_at at appropriate time" do
|
||||
user.mentor_description = "hello"
|
||||
user.save
|
||||
expect(user.mentor_form_updated_at).to_not eq(nil)
|
||||
end
|
||||
|
||||
it "updates mentee_form_updated_at at appropriate time" do
|
||||
user.mentee_description = "hello"
|
||||
user.save
|
||||
expect(user.mentee_form_updated_at).to_not eq(nil)
|
||||
end
|
||||
|
||||
it "does not allow too short or too long name" do
|
||||
user.name = ""
|
||||
expect(user).not_to be_valid
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue