Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@

# rspec failure tracking
.rspec_status

/spec/dummy/log/*
/spec/dummy/tmp/*
/spec/dummy/storage/*

.byebug_history
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
--require rails_helper

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: why did we need to add this? I think in general only the spec_helper is required on this file 🤔

--format progress
--format documentation
Comment on lines +2 to 3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one of these two options will be used? Should we remove the one that won't be used?

--color
--require spec_helper
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ Metrics/MethodLength:

Gemspec/DevelopmentDependencies:
Enabled: false

RSpec/MultipleExpectations:
Max: 3

RSpec/ExampleLength:
Max: 20

Style/NumericLiterals:
Exclude:
- 'spec/dummy/db/schema.rb'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we exclude this file from the dummy from all Rubocop's cops? Should we exclude all the files of the dummy app from Rubocop's cops?


Style/FrozenStringLiteralComment:
Exclude:
- 'spec/dummy/db/schema.rb'
117 changes: 117 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (8.0.2)
actionpack (= 8.0.2)
activesupport (= 8.0.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.0.2)
actionpack (= 8.0.2)
activejob (= 8.0.2)
activerecord (= 8.0.2)
activestorage (= 8.0.2)
activesupport (= 8.0.2)
mail (>= 2.8.0)
actionmailer (8.0.2)
actionpack (= 8.0.2)
actionview (= 8.0.2)
activejob (= 8.0.2)
activesupport (= 8.0.2)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.0.2)
actionview (= 8.0.2)
activesupport (= 8.0.2)
Expand All @@ -18,12 +38,34 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.0.2)
actionpack (= 8.0.2)
activerecord (= 8.0.2)
activestorage (= 8.0.2)
activesupport (= 8.0.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.0.2)
activesupport (= 8.0.2)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.0.2)
activesupport (= 8.0.2)
globalid (>= 0.3.6)
activemodel (8.0.2)
activesupport (= 8.0.2)
activerecord (8.0.2)
activemodel (= 8.0.2)
activesupport (= 8.0.2)
timeout (>= 0.4.0)
activestorage (8.0.2)
actionpack (= 8.0.2)
activejob (= 8.0.2)
activerecord (= 8.0.2)
activesupport (= 8.0.2)
marcel (~> 1.0)
activesupport (8.0.2)
base64
benchmark (>= 0.3)
Expand All @@ -45,6 +87,7 @@ GEM
bigdecimal (3.2.2)
bindata (2.5.1)
builder (3.3.0)
byebug (12.0.0)
cbor (0.5.10.1)
concurrent-ruby (1.3.5)
connection_pool (2.5.3)
Expand All @@ -63,8 +106,14 @@ GEM
drb (2.2.3)
erb (5.0.2)
erubi (1.13.1)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
importmap-rails (2.2.2)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.8.1)
irb (1.15.2)
pp (>= 0.6.0)
Expand All @@ -79,8 +128,27 @@ GEM
loofah (2.24.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.4)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.25.5)
net-imap (0.5.9)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.9)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
openssl (3.3.0)
openssl-signature_algorithm (1.3.0)
Expand All @@ -94,9 +162,15 @@ GEM
prettyprint
prettyprint (0.2.0)
prism (1.4.0)
propshaft (1.2.1)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
psych (5.2.6)
date
stringio
puma (6.6.1)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.2.0)
rack-session (2.1.1)
Expand All @@ -106,6 +180,20 @@ GEM
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
rails (8.0.2)
actioncable (= 8.0.2)
actionmailbox (= 8.0.2)
actionmailer (= 8.0.2)
actionpack (= 8.0.2)
actiontext (= 8.0.2)
actionview (= 8.0.2)
activejob (= 8.0.2)
activemodel (= 8.0.2)
activerecord (= 8.0.2)
activestorage (= 8.0.2)
activesupport (= 8.0.2)
bundler (>= 1.15.0)
railties (= 8.0.2)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
Expand Down Expand Up @@ -144,6 +232,14 @@ GEM
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.5)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.4)
rubocop (1.79.1)
json (~> 2.3)
Expand Down Expand Up @@ -172,12 +268,20 @@ GEM
safety_net_attestation (0.4.0)
jwt (~> 2.0)
securerandom (0.4.1)
sqlite3 (2.7.3)
mini_portile2 (~> 2.8.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.7)
thor (1.4.0)
timeout (0.4.3)
tpm-key_attestation (0.14.1)
bindata (~> 2.4)
openssl (> 2.0)
openssl-signature_algorithm (~> 1.0)
turbo-rails (2.0.16)
actionpack (>= 7.1.0)
railties (>= 7.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
Expand All @@ -195,17 +299,30 @@ GEM
openssl (>= 2.2)
safety_net_attestation (~> 0.4.0)
tpm-key_attestation (~> 0.14.0)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.3)

PLATFORMS
ruby

DEPENDENCIES
byebug
devise-webauthn!
importmap-rails
propshaft
puma
rails (~> 8.0)
rspec (~> 3.13)
rspec-rails (~> 6.1)
rubocop (~> 1.79)
rubocop-rails (~> 2.32)
rubocop-rspec (~> 3.6)
sqlite3 (~> 2.7)
stimulus-rails (~> 1.3)
turbo-rails (~> 2.0)

BUNDLED WITH
2.7.1
9 changes: 5 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "bundler/setup"

RSpec::Core::RakeTask.new(:spec)
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"
load "rails/tasks/statistics.rake"

task default: :spec
require "bundler/gem_tasks"
14 changes: 14 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/devise/webauthn/engine", __dir__)
APP_PATH = File.expand_path("../spec/dummy/config/application", __dir__)

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
9 changes: 9 additions & 0 deletions devise-webauthn.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ Gem::Specification.new do |spec|
spec.metadata["rubygems_mfa_required"] = "true"
spec.required_ruby_version = ">= 3.1"

spec.add_development_dependency "byebug"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughs about using pry-byebug?

spec.add_development_dependency "importmap-rails"
spec.add_development_dependency "propshaft"
spec.add_development_dependency "puma"
spec.add_development_dependency "rails", "~> 8.0"
spec.add_development_dependency "rspec", "~> 3.13"
spec.add_development_dependency "rspec-rails", "~> 6.1"
spec.add_development_dependency "rubocop", "~> 1.79"
spec.add_development_dependency "rubocop-rails", "~> 2.32"
spec.add_development_dependency "rubocop-rspec", "~> 3.6"
spec.add_development_dependency "sqlite3", "~> 2.7"
spec.add_development_dependency "stimulus-rails", "~> 1.3"
spec.add_development_dependency "turbo-rails", "~> 2.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: is turbo-rails needed?


spec.add_dependency "devise", "~> 4.9"
spec.add_dependency "webauthn", "~> 3.0"
Expand Down
15 changes: 15 additions & 0 deletions spec/devise/models/passkey_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

RSpec.describe Passkey do
it "allows building and saving a passkey" do
user = User.new(email: "test@example.com", password: "password")
passkey = described_class.new(name: "test", external_id: "external_id_123", public_key: "public_key_123",
sign_count: 0, user:)

expect(passkey.save).to be_truthy

passkey.reload

expect(passkey).to be_persisted
end
end
Comment on lines +4 to +15

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we trying to test here? Seems to me that we are testing ActiveRecord's validations and persistance methods, which feels unnecessary to me.

What do you all think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was simply adding some test to verify that the models were loaded correctly and the database changes worked as well. So simple tests for that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! What do you think about skipping the tests for now and add them as part of a different PR?

13 changes: 13 additions & 0 deletions spec/devise/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

RSpec.describe User do
it "allows building and saving a user" do
user = described_class.new(email: "test@example.com", password: "password")

expect(user.save).to be_truthy

user.reload

expect(user).to be_persisted
end
end
8 changes: 8 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"

Rails.application.load_tasks
4 changes: 4 additions & 0 deletions spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
Comment on lines +1 to +4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove this as we are using propshaft, right?

15 changes: 15 additions & 0 deletions spec/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
Comment on lines +1 to +15

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here!

Suggested change
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
/*
* This is a manifest file that'll be compiled into application.css.
*
* With Propshaft, assets are served efficiently without preprocessing steps. You can still include
* application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
* cascading order, meaning styles declared later in the document or manifest will override earlier ones,
* depending on specificity.
*
* Consider organizing styles into separate files for maintainability.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh that makes sense. I wonder why rails plugin new generates an application.css in the dummy app but does not install any gem to manage the asset pipeline 🤔

That said, if we are installing propshaft on this dummy app I think we should use the application.css that comes in a default Rails 8 app, don't you think?

4 changes: 4 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
7 changes: 7 additions & 0 deletions spec/dummy/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class HomeController < ApplicationController
before_action :authenticate_user!

def index; end
end
5 changes: 5 additions & 0 deletions spec/dummy/app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import { Turbo } from "@hotwired/turbo-rails"
import "controllers/application"

Turbo.session.drive = false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

9 changes: 9 additions & 0 deletions spec/dummy/app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

export { application }
4 changes: 4 additions & 0 deletions spec/dummy/app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Import and register all your controllers from the importmap via controllers/**/*_controller
import { application } from "controllers/application"
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
4 changes: 4 additions & 0 deletions spec/dummy/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
end
Loading