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

Routes with authentication should work with web #562

Merged
merged 1 commit into from Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion .rubocop.yml
Expand Up @@ -16,9 +16,18 @@ AllCops:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/LineLength:
Exclude:
- myapp/db/**/*.rb
- myapp/config/initializers/devise.rb

Lint/AmbiguousBlockAssociation:
Exclude:
- "spec/**/*"
- spec/**/*

Lint/EmptyBlock:
Exclude:
- spec/**/*

Lint/SuppressedException:
Enabled: true
Expand All @@ -34,10 +43,14 @@ Metrics/CyclomaticComplexity:

Metrics/MethodLength:
Max: 13
Exclude:
- myapp/db/**/*.rb
- myapp/config/initializers/devise.rb

Metrics/BlockLength:
Enabled: true
Exclude:
- "myapp/db/**/*.rb"
- "**/spec/**/*.rb"
- "**/*.rake"
- "Rakefile"
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -72,7 +72,7 @@ namespace :appraisal do
end

desc "Runs rspec for older appraisals than sidekiq 6"
task :pre_sidekiq_6 do
task :pre_sidekiq6 do
sh("bundle exec appraisal sidekiq-4.0 rspec")
sh("bundle exec appraisal sidekiq-4.1 rspec")
sh("bundle exec appraisal sidekiq-4.2 rspec")
Expand All @@ -82,7 +82,7 @@ namespace :appraisal do
end

desc "Runs rspec for appraisals containing sidekiq 6 or greater"
task :post_sidekiq_6 do
task :post_sidekiq6 do
sh("bundle exec appraisal sidekiq-6.0 rspec")
sh("bundle exec appraisal sidekiq-develop rspec")
end
Expand Down
15 changes: 4 additions & 11 deletions lib/sidekiq_unique_jobs/web.rb
@@ -1,11 +1,5 @@
# frozen_string_literal: true

begin
require "sidekiq/web"
rescue LoadError
# client-only usage
end

require_relative "web/helpers"

module SidekiqUniqueJobs
Expand Down Expand Up @@ -59,8 +53,7 @@ def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
end
end

if defined?(Sidekiq::Web)
Sidekiq::Web.register SidekiqUniqueJobs::Web
Sidekiq::Web.tabs["Locks"] = "locks"
Sidekiq::Web.settings.locales << File.join(File.dirname(__FILE__), "locales")
end
require "sidekiq/web" unless defined?(Sidekiq::Web)
Sidekiq::Web.register(SidekiqUniqueJobs::Web)
Sidekiq::Web.tabs["Locks"] = "locks"
Sidekiq::Web.settings.locales << File.join(File.dirname(__FILE__), "locales")
5 changes: 5 additions & 0 deletions myapp/.rubocop.yml
Expand Up @@ -7,3 +7,8 @@ require:
inherit_mode:
merge:
- Exclude

AllCops:
Exclude:
- 'bin/*'
- '**/.keep'
14 changes: 11 additions & 3 deletions myapp/Gemfile
Expand Up @@ -2,18 +2,19 @@

source "https://rubygems.org"

ruby "2.6.6"
ruby "2.7.2"

gem "bigdecimal"
gem "coverband"
gem "devise"
gem "hiredis"
gem "json"
gem "pg"
gem "puma"
gem "rack-protection"
gem "rails", ">= 6.0"
gem "redis"
gem "sidekiq", "~> 6.0.0"
gem "sidekiq", "~> 6.1"
gem "sidekiq-cron"
gem "sidekiq-global_id"
gem "sidekiq-status"
Expand All @@ -22,16 +23,23 @@ gem "sinatra"
gem "slim-rails"

group :development, :test do
gem "capybara"
gem "dotenv-rails"
gem "factory_bot_rails"
gem "fuubar"
gem "listen"
gem "pry-byebug"
gem "pry-rails"
gem "rspec-rails"
end

group :development do
gem "rubocop"
gem "rubocop-mhenrixon"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rspec"
end

group :test do
gem "capybara"
end
9 changes: 9 additions & 0 deletions myapp/app/models/user.rb
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class User < ApplicationRecord
# Include default devise modules. Others available are:
#
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,
:confirmable, :lockable, :timeoutable, :trackable # , :omniauthable
end
6 changes: 3 additions & 3 deletions myapp/app/views/layouts/application.html.slim
Expand Up @@ -2,12 +2,12 @@ doctype html
html
head
title MyApp
/ = stylesheet_link_tag 'application', media: 'all'
/ = javascript_include_tag 'application'
= csrf_meta_tags
body
ul#top-menu
li.menu-item
= link_to 'Issue 384', issue_384_path
= link_to 'Sign in', new_user_session_path
li.menu-item
= link_to 'Sign out', destroy_user_session_path, method: :delete

= yield
1 change: 1 addition & 0 deletions myapp/app/workers/until_executed_job.rb
Expand Up @@ -4,6 +4,7 @@ class UntilExecutedJob
include Sidekiq::Worker

sidekiq_options lock: :until_executed,
lock_info: true,
lock_timeout: 0,
lock_ttl: 0,
lock_limit: 5
Expand Down
4 changes: 1 addition & 3 deletions myapp/config/application.rb
Expand Up @@ -9,12 +9,10 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

$stdout.sync = true

module MyApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.0
config.load_defaults 6.1
config.time_zone = "CET"

# Settings in config/environments/* take precedence over those specified here.
Expand Down
6 changes: 3 additions & 3 deletions myapp/config/environments/development.rb
Expand Up @@ -6,10 +6,10 @@
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = true
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = true
config.eager_load = false

# Show full error reports.
config.consider_all_requests_local = true
Expand All @@ -34,8 +34,8 @@
config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
config.action_mailer.raise_delivery_errors = false

config.action_mailer.perform_caching = false

# Print deprecation notices to the Rails logger.
Expand Down