* increase mentee-mentor description length and fix linting errors * fix char limit issue and refactor tests
This commit is contained in:
parent
83c9196704
commit
d303692bc0
12 changed files with 48 additions and 20 deletions
|
|
@ -41,7 +41,8 @@ end
|
|||
module StreamRails
|
||||
class Enrich
|
||||
def retrieve_objects(references)
|
||||
Hash[references.map { |model, ids| [model, Hash[construct_query(model, ids).map { |i| [i.id.to_s, i] }]] }]
|
||||
Hash[references.
|
||||
map { |model, ids| [model, Hash[construct_query(model, ids).map { |i| [i.id.to_s, i] }]] }]
|
||||
end
|
||||
|
||||
def construct_query(model, ids)
|
||||
|
|
|
|||
|
|
@ -94,8 +94,10 @@ class User < ApplicationRecord
|
|||
:employment_title, :education, :location,
|
||||
length: { maximum: 100 }
|
||||
validates :mostly_work_with, :currently_learning, :currently_hacking_on,
|
||||
:available_for, :mentee_description, :mentor_description,
|
||||
:available_for,
|
||||
length: { maximum: 500 }
|
||||
validates :mentee_description, :mentor_description,
|
||||
length: { maximum: 1000 }
|
||||
validate :conditionally_validate_summary
|
||||
validate :validate_feed_url
|
||||
validate :unique_including_orgs
|
||||
|
|
@ -202,6 +204,7 @@ class User < ApplicationRecord
|
|||
"user-#{id}-#{updated_at}-#{following_users_count}/following_users_ids",
|
||||
expires_in: 120.hours,
|
||||
) do
|
||||
|
||||
# More efficient query. May not cover future edge cases.
|
||||
# Should probably only return users who have published lately
|
||||
# But this should be okay for most for now.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class AdminPolicy < ApplicationPolicy
|
||||
def show?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ApplicationPolicy
|
|||
end
|
||||
end
|
||||
|
||||
def user_is_admin?
|
||||
def user_admin?
|
||||
user.has_role?(:super_admin)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class ArticlePolicy < ApplicationPolicy
|
||||
def update?
|
||||
user_is_author? || user_is_admin? || user_is_org_admin?
|
||||
user_is_author? || user_admin? || user_org_admin?
|
||||
end
|
||||
|
||||
def new?
|
||||
|
|
@ -24,7 +24,7 @@ class ArticlePolicy < ApplicationPolicy
|
|||
end
|
||||
|
||||
def analytics_index?
|
||||
(user_is_author? && user_can_view_analytics?) || user_is_org_admin?
|
||||
(user_is_author? && user_can_view_analytics?) || user_org_admin?
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
|
|
@ -39,7 +39,7 @@ class ArticlePolicy < ApplicationPolicy
|
|||
record.user_id == user.id
|
||||
end
|
||||
|
||||
def user_is_org_admin?
|
||||
def user_org_admin?
|
||||
user.org_admin && user.organization_id == record.organization_id
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
class BlockPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def new?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def edit?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def create?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def update?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user_is_admin?
|
||||
user_admin?
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ChatChannelPolicy < ApplicationPolicy
|
|||
end
|
||||
|
||||
def moderate?
|
||||
!user_is_banned? && user_is_admin?
|
||||
!user_is_banned? && user_admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class TagPolicy < ApplicationPolicy
|
|||
private
|
||||
|
||||
def has_mod_permission?
|
||||
user_is_admin? ||
|
||||
user_admin? ||
|
||||
user.has_role?(:tag_moderator, record)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class UserPolicy < ApplicationPolicy
|
|||
end
|
||||
|
||||
def dashboard_show?
|
||||
current_user? || user_is_admin?
|
||||
current_user? || user_admin?
|
||||
end
|
||||
|
||||
def moderation_routes?
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
</div>
|
||||
<div class="field">
|
||||
<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 %>
|
||||
<%= 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: 1000 %>
|
||||
</div>
|
||||
<h3>Seeking Help</h3>
|
||||
<p><em><% if @user.mentee_form_updated_at? %>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
<div class="field">
|
||||
<%= f.label :mentee_description, "How can we help?" %>
|
||||
<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 %>
|
||||
<%= 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: 1000 %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label></label>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ Rolify.configure do |config|
|
|||
# By default ORM adapter is ActiveRecord. uncomment to use mongoid
|
||||
# config.use_mongoid
|
||||
|
||||
# Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
|
||||
# Dynamic shortcuts for User class (user.admin? like methods). Default is: false
|
||||
# config.use_dynamic_shortcuts
|
||||
end
|
||||
|
|
|
|||
|
|
@ -184,6 +184,30 @@ RSpec.describe User, type: :model do
|
|||
expect(user.mentee_form_updated_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
it "does not allow mentee description to be too long" do
|
||||
user.mentee_description = Faker::Lorem.paragraph_by_chars(1001)
|
||||
user.save
|
||||
expect(user.mentee_form_updated_at).to eq(nil)
|
||||
end
|
||||
|
||||
it "does not allow mentor description to be too long" do
|
||||
user.mentor_description = Faker::Lorem.paragraph_by_chars(1001)
|
||||
user.save
|
||||
expect(user.mentor_form_updated_at).to eq(nil)
|
||||
end
|
||||
|
||||
it "allow mentee description to be the max length" do
|
||||
user.mentee_description = Faker::Lorem.paragraph_by_chars(1000)
|
||||
user.save
|
||||
expect(user.mentee_form_updated_at).not_to eq(nil)
|
||||
end
|
||||
|
||||
it "allow mentor description to be the max length" do
|
||||
user.mentor_description = Faker::Lorem.paragraph_by_chars(1000)
|
||||
user.save
|
||||
expect(user.mentor_form_updated_at).not_to 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