-
Notifications
You must be signed in to change notification settings - Fork 0
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
[38] Create Rails User model #46
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b43eeb7
created rails user model via scaffold to schema gem
bilalhankins 693cf6d
removed app/views/ and spec/views
bilalhankins d926ab7
removed unneccesary generated file
bilalhankins 62802ef
add annotate gem and user schema documentation
stepchud 74b2b9b
Merge branch '38/create-user-model' of https://github.com/GSA/Challen…
bilalhankins 7a11156
remove user route
bilalhankins d620a9e
Added attr and associations for user model
bilalhankins 04ab88d
Merge branch 'dev' into 38/create-user-model
stepchud 223387e
Update spec/helpers/users_helper_spec.rb
bilalhankins c954c6b
added defaults, validation, and remove virtual attributes
bilalhankins 9d42c1f
rubocop lint fixes
bilalhankins ea19663
linting
bilalhankins 6fe2cbb
linting
bilalhankins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module UsersHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :bigint not null, primary key | ||
# email :string(255) not null | ||
# password_hash :string(255) | ||
# token :uuid | ||
# first_name :string(255) | ||
# last_name :string(255) | ||
# phone_number :string(255) | ||
# inserted_at :datetime not null | ||
# updated_at :datetime not null | ||
# email_verification_token :string(255) | ||
# email_verified_at :datetime | ||
# role :string(255) default("user"), not null | ||
# password_reset_token :uuid | ||
# password_reset_expires_at :datetime | ||
# finalized :boolean default(TRUE), not null | ||
# avatar_key :uuid | ||
# avatar_extension :string(255) | ||
# display :boolean default(TRUE), not null | ||
# terms_of_use :datetime | ||
# privacy_guidelines :datetime | ||
# agency_id :bigint | ||
# last_active :datetime | ||
# status :string(255) | ||
# active_session :boolean default(FALSE) | ||
# renewal_request :string(255) | ||
# jwt_token :text | ||
# recertification_expired_at :datetime | ||
# | ||
class User < ApplicationRecord | ||
has_many :challenges | ||
has_many :challenge_managers | ||
has_many :challenge_manager_challenges, through: :challenge_managers, source: :challenge | ||
has_many :members | ||
has_many :supporting_documents, class_name: 'Document' | ||
has_many :submissions, foreign_key: :submitter_id | ||
has_many :managed_submissions, class_name: 'Submission', foreign_key: :manager_id | ||
has_many :submission_documents, class_name: 'Submissions::Document' | ||
has_many :message_context_statuses | ||
|
||
# Virtual Attributes | ||
attr_accessor :email_confirmation, :password, :password_confirmation | ||
|
||
attribute :role, :string, default: -> { read_attribute(:role) } | ||
attribute :status, :string, default: 'pending' | ||
attribute :finalized, :boolean, default: true | ||
attribute :display, :boolean, default: true | ||
|
||
attribute :email, :string | ||
attribute :password_hash, :string | ||
attribute :token, :uuid | ||
attribute :jwt_token, :string | ||
|
||
attribute :email_verification_token, :string | ||
attribute :email_verified_at, :datetime | ||
|
||
attribute :password_reset_token, :uuid | ||
attribute :password_reset_expires_at, :datetime | ||
|
||
attribute :first_name, :string | ||
attribute :last_name, :string | ||
attribute :phone_number, :string | ||
|
||
attribute :avatar_key, :uuid | ||
attribute :avatar_extension, :string | ||
|
||
attribute :terms_of_use, :datetime | ||
attribute :privacy_guidelines, :datetime | ||
attribute :agency_id, :integer | ||
|
||
attribute :last_active, :datetime | ||
attribute :recertification_expired_at, :datetime | ||
attribute :active_session, :boolean | ||
bilalhankins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
attribute :renewal_request, :string | ||
|
||
attribute :created_at, :datetime, precision: 6 | ||
attribute :updated_at, :datetime, precision: 6 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rails_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the UsersHelper. For example: | ||
# | ||
# describe UsersHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# expect(helper.concat_strings("this","that")).to eq("this that") | ||
# end | ||
# end | ||
# end | ||
RSpec.describe UsersHelper, type: :helper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end | ||
bilalhankins marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :bigint not null, primary key | ||
# email :string(255) not null | ||
# password_hash :string(255) | ||
# token :uuid | ||
# first_name :string(255) | ||
# last_name :string(255) | ||
# phone_number :string(255) | ||
# inserted_at :datetime not null | ||
# updated_at :datetime not null | ||
# email_verification_token :string(255) | ||
# email_verified_at :datetime | ||
# role :string(255) default("user"), not null | ||
# password_reset_token :uuid | ||
# password_reset_expires_at :datetime | ||
# finalized :boolean default(TRUE), not null | ||
# avatar_key :uuid | ||
# avatar_extension :string(255) | ||
# display :boolean default(TRUE), not null | ||
# terms_of_use :datetime | ||
# privacy_guidelines :datetime | ||
# agency_id :bigint | ||
# last_active :datetime | ||
# status :string(255) | ||
# active_session :boolean default(FALSE) | ||
# renewal_request :string(255) | ||
# jwt_token :text | ||
# recertification_expired_at :datetime | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe User, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
stepchud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 docs for the attribute method say it doesn't need to be backed by the DB. however, I'm not sure that we need these attributes anyways. AFAIK users shouldn't be able to reset their login.gov password from the app, and I don't know about the email_confirmation.