Skip to content

Commit

Permalink
chore: add rubocop to rails app
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose committed Sep 27, 2024
1 parent 3a7c1e3 commit 44bbfa9
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 13 deletions.
15 changes: 15 additions & 0 deletions apps/govquests-api/rails_app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,23 @@ group :development, :test do
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false

# Pry
gem "pry-byebug"
gem "pry-meta"
gem "pry-rails", "~> 0.3.9"

# Rubocop
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rake"
# gem "rubocop-sorbet", require: false
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

# Types
# gem "sorbet"
# gem "tapioca"
end

group :test do
Expand Down
30 changes: 30 additions & 0 deletions apps/govquests-api/rails_app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ GEM
arkency-command_bus (0.4.1)
concurrent-ruby
ast (2.4.2)
awesome_print (1.9.2)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
bcrypt_pbkdf (1.1.1-arm64-darwin)
Expand All @@ -133,6 +134,8 @@ GEM
brakeman (6.2.1)
racc
builder (3.3.0)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
Expand Down Expand Up @@ -202,6 +205,7 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.25.0)
msgpack (1.7.2)
Expand Down Expand Up @@ -246,6 +250,22 @@ GEM
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
pry-meta (0.0.10)
awesome_print
pry
pry-byebug
pry-remote
pry-rails (0.3.11)
pry (>= 0.13.0)
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
psych (5.1.2)
stringio
puma (6.4.3)
Expand Down Expand Up @@ -313,6 +333,8 @@ GEM
rubocop-minitest
rubocop-performance
rubocop-rails
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
ruby_event_store (2.15.0)
concurrent-ruby (~> 1.0, >= 1.1.6)
Expand All @@ -326,6 +348,7 @@ GEM
activesupport (>= 5.0)
ruby_event_store (>= 2.0.0, < 3.0.0)
securerandom (0.3.1)
slop (3.6.0)
solid_cache (1.0.6)
activejob (>= 7.2)
activerecord (>= 7.2)
Expand Down Expand Up @@ -401,10 +424,17 @@ DEPENDENCIES
minitest (= 5.25.0)!
mutant-license!
mutant-minitest (= 0.12.4)!
pry-byebug
pry-meta
pry-rails (~> 0.3.9)
puma (>= 5.0)
rails!
rails_event_store (~> 2.15.0)
rubocop
rubocop-performance
rubocop-rails
rubocop-rails-omakase
rubocop-rake
solid_cache
solid_queue
sqlite3 (>= 2.1)
Expand Down
10 changes: 10 additions & 0 deletions apps/govquests-api/rails_app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
install:
@bundle install

test:
@bin/rails test

lint:
@bundle exec rubocop -A

.PHONY: install test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Account < ApplicationRecord

class Configuration
def call(event_store)
event_store.subscribe(CreateAccount, to: [Authentication::AccountRegistered])
event_store.subscribe(CreateAccount, to: [ Authentication::AccountRegistered ])
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ def initialize(event_store, active_record_name, id_column)
end

def subscribe_create(creation_event)
@event_store.subscribe(create_handler(creation_event), to: [creation_event])
@event_store.subscribe(create_handler(creation_event), to: [ creation_event ])
end

def subscribe_copy(event, sequence_of_keys, column = Array(sequence_of_keys).join('_'))
@event_store.subscribe(copy_handler(event, sequence_of_keys, column), to: [event])
def subscribe_copy(event, sequence_of_keys, column = Array(sequence_of_keys).join("_"))
@event_store.subscribe(copy_handler(event, sequence_of_keys, column), to: [ event ])
end

private
Expand Down Expand Up @@ -114,4 +114,4 @@ def call(event)

private
attr_reader :sequence_of_keys, :column
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
wrap_parameters format: [ :json ]
end

# To enable root element in JSON for ActiveRecord objects.
Expand Down
2 changes: 1 addition & 1 deletion apps/govquests-api/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
mount RailsEventStore::Browser => '/res' if Rails.env.development?
mount RailsEventStore::Browser => "/res" if Rails.env.development?
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def change
t.references :event, null: false, type: :string, limit: 36, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
t.datetime :created_at, null: false, precision: 6, index: true

t.index [:stream, :position], unique: true
t.index [:stream, :event_id], unique: true
t.index [ :stream, :position ], unique: true
t.index [ :stream, :event_id ], unique: true
end
end
end
5 changes: 1 addition & 4 deletions apps/govquests-api/rails_app/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
ActiveJob::Base.logger = Logger.new(nil)

class InMemoryTestCase < ActiveSupport::TestCase

def before_setup
result = super
@previous_event_store = Rails.configuration.event_store
Expand All @@ -33,14 +32,12 @@ def run_command(command)
end

class RealRESIntegrationTestCase < ActionDispatch::IntegrationTest

def run_command(command)
Rails.configuration.command_bus.call(command)
end
end

class InMemoryRESIntegrationTestCase < ActionDispatch::IntegrationTest

def before_setup
result = super
@previous_event_store = Rails.configuration.event_store
Expand Down Expand Up @@ -88,7 +85,7 @@ def update_price(product_id, new_price)
params: {
"authenticity_token" => "[FILTERED]",
"product_id" => product_id,
price: new_price,
price: new_price
}
end

Expand Down

0 comments on commit 44bbfa9

Please sign in to comment.