Skip to content
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

PC-20: Create AdminUser model #6

Merged
merged 28 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0afd86
PC-17: Add and config Devise gem
PivtoranisV Jan 14, 2025
d7618a9
PC-17: Add user model with devise
PivtoranisV Jan 14, 2025
b6b4342
PC-17: Add name parameter to Devise
PivtoranisV Jan 14, 2025
61ffaf4
PC-17: Add user model validations
PivtoranisV Jan 14, 2025
80f87a1
PC-17: Configure Devise to use ENV variable
PivtoranisV Jan 14, 2025
ad096c2
Merge branch 'master' of https://github.com/wahanegi/clever-calculato…
PivtoranisV Jan 14, 2025
185c40e
Fix rubocop offenses
PivtoranisV Jan 14, 2025
8690ab4
PC-17: Configure RSpec setup
PivtoranisV Jan 15, 2025
0a048b3
PC-17: Add Shoulda Matchers configuration
PivtoranisV Jan 15, 2025
4ebfabe
PC-17: Add specs for User model
PivtoranisV Jan 15, 2025
ab8f92c
PC-17: Update .rubocop.yml and add gem rubocop-rspec_rails
vb-cmd Jan 15, 2025
919f5ad
Add: validation for the password (maximum 128) and test for it.
IvanRuskevych Jan 15, 2025
e423413
Merge remote-tracking branch 'origin/pc-17' into pc-17
IvanRuskevych Jan 15, 2025
63f83cd
PC-17: Fixed lint errors
PivtoranisV Jan 15, 2025
7e2a1da
PC-17: Fixed merge conflicts
PivtoranisV Jan 15, 2025
84e0806
PC-17: set mailer sender to use environment variable
PivtoranisV Jan 15, 2025
8501157
PC-17: fixed email and name validation
PivtoranisV Jan 15, 2025
ca22fe6
PC-17: Remove :registerable User Devise configuration
PivtoranisV Jan 16, 2025
2d0dacb
PC-17: Remove unused configure_permitted_parameters
PivtoranisV Jan 16, 2025
78ab095
create AdminUser model and Add validations
IvanRuskevych Jan 16, 2025
03bdf6a
PC-20: fix lint errors
IvanRuskevych Jan 16, 2025
a0ee7e1
Refactor model tests: User and AdminUser
AndrewRiabets Jan 16, 2025
6bcab77
udpate tests
AndrewRiabets Jan 17, 2025
6475233
Upgraded tests
AndrewRiabets Jan 23, 2025
33c57bf
Deleted validatable_user
AndrewRiabets Jan 23, 2025
9839dca
updated tests styles
AndrewRiabets Jan 23, 2025
8c6e53a
fix lint
AndrewRiabets Jan 23, 2025
f86435d
update tests
AndrewRiabets Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--require spec_helper
--format documentation
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Add rules from rubocop-rails
require:
- rubocop-rails
- rubocop-rspec_rails

# Overwrite or add rules to create your own house style
#
Expand Down Expand Up @@ -30,4 +31,12 @@ Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false

Bundler/OrderedGems:
Enabled: true
Enabled: true

Metrics/MethodLength:
Exclude:
- db/migrate/*.rb

Metrics/BlockLength:
Exclude:
- spec/**/*
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ group :development, :test do
# Rubocop Ruby on Rails Style
gem "rubocop"
gem "rubocop-rails", require: false
gem "rubocop-rspec_rails", require: false

# Opens sent emails in the browser for easy debugging during development
gem "letter_opener"
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ GEM
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.3.0)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sassc (2.4.0)
Expand Down Expand Up @@ -460,6 +465,7 @@ DEPENDENCIES
rspec-rails
rubocop
rubocop-rails
rubocop-rspec_rails
sassc (~> 2.4)
shoulda-matchers
solid_cable
Expand Down
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end
16 changes: 16 additions & 0 deletions app/models/admin_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class AdminUser < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :recoverable,
:rememberable, :validatable

PASSWORD_SYMBOL_FORMAT = /\A(?=.*[^\w\s])[^\s]*\z/
PASSWORD_REPEATED_CHAR_FORMAT = /\A(?!.*(.)\1\1).*\z/

validates :name, presence: true
validates :email, presence: true, uniqueness: true,
format: { with: URI::MailTo::EMAIL_REGEXP, message: "must be a valid email format" }
validates :password, length: { minimum: 8, maximum: 128 },
format: { with: PASSWORD_SYMBOL_FORMAT, message: "must contain at least one symbol" }
validates :password, format: { with: PASSWORD_REPEATED_CHAR_FORMAT, message: "must not contain repeated characters" }
end
14 changes: 14 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :validatable
PASSWORD_SYMBOL_FORMAT = /\A(?=.*[^\w\s])[^\s]*\z/
PASSWORD_REPEATED_CHAR_FORMAT = /\A(?!.*(.)\1\1).*\z/

validates :name, presence: true
validates :email, presence: true, uniqueness: true,
format: { with: URI::MailTo::EMAIL_REGEXP, message: "must be a valid email format" }
validates :password, length: { minimum: 8, maximum: 128 },
format: { with: PASSWORD_SYMBOL_FORMAT, message: "must contain at least one symbol" }
validates :password, format: { with: PASSWORD_REPEATED_CHAR_FORMAT, message: "must not contain repeated characters" }
end
2 changes: 1 addition & 1 deletion app/views/home/app.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hello Clever Calculator!
<p>Hello Clever Calculator!</p>
5 changes: 5 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>

<%#= TODO: Delete this styles link when the markup for Clever Calculator is ready %>
<%= stylesheet_link_tag "http://cdn.simplecss.org/simple.css" %>
</head>

<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
</body>
</html>
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@

# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!

config.secret_key_base = ENV["DEVISE_SECRET_KEY"]
end
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@

# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true

config.secret_key_base = ENV["DEVISE_SECRET_KEY"]
end
Loading
Loading