Skip to content
Merged

Misc #26

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
7 changes: 3 additions & 4 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ on: [pull_request]
jobs:
danger:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: Gemfile.danger
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 2.7
bundler-cache: true
- name: Run Danger
env:
BUNDLE_GEMFILE: Gemfile.danger
run: |
bundle install
# the personal token is public, this is ok, base64 encode to avoid tripping Github
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: 3.4
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop
9 changes: 6 additions & 3 deletions .github/workflows/test-mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ jobs:
strategy:
matrix:
entry:
- { ruby: 2.6.2, mongoid: 6.4.8, mongodb: 4.4 }
- { ruby: 2.6.2, mongoid: 7.3.0, mongodb: 5.0 }
- { ruby: 3.1.1, mongoid: 7.3.0, mongodb: 5.0 }
- { ruby: 3.1, mongoid: 6.4.8, mongodb: 4.4 }
- { ruby: 3.1, mongoid: 7.3.0, mongodb: 5.0 }
- { ruby: 3.1, mongoid: 7.3.0, mongodb: 5.0 }
- { ruby: 3.2, mongoid: 8.1.11, mongodb: 6.0 }
- { ruby: 3.4, mongoid: 8.1.11, mongodb: 7.0 }
- { ruby: 3.4, mongoid: 9.0.8, mongodb: 8.0 }
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }})
steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/test-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ jobs:
strategy:
matrix:
entry:
- { ruby: 2.6.2, postgresql: 11 }
- { ruby: 2.6.2, postgresql: 14 }
- { ruby: 3.1.1, postgresql: 14 }
- { ruby: 3.1, postgresql: 11 }
- { ruby: 3.1, postgresql: 14 }
- { ruby: 3.1, postgresql: 14 }
- { ruby: 3.2, postgresql: 15 }
- { ruby: 3.3, postgresql: 16 }
- { ruby: 3.4, postgresql: 17 }
name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }})
services:
postgres:
Expand Down
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AllCops:
NewCops: enable

Metrics:
Enabled: false

Expand All @@ -11,5 +14,9 @@ Style/Documentation:
Style/ModuleFunction:
EnforcedStyle: extend_self

plugins:
- rubocop-rake
- rubocop-rspec

inherit_from: .rubocop_todo.yml

60 changes: 57 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,74 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-07-19 23:46:20 -0400 using RuboCop version 0.81.0.
# on 2025-09-22 13:18:33 UTC using RuboCop version 1.80.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# Configuration parameters: Severity.
Gemspec/RequiredRubyVersion:
Exclude:
- 'slack-ruby-bot-server-events.gemspec'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'Rakefile.rb'
- 'lib/slack-ruby-bot-server-events.rb'

# Offense count: 7
RSpec/AnyInstance:
Exclude:
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint_spec.rb'
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/commands_endpoint_spec.rb'
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/events_endpoint_spec.rb'

# Offense count: 2
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint_spec.rb'

# Offense count: 3
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 9

# Offense count: 22
RSpec/MultipleExpectations:
Max: 2

# Offense count: 5
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 5

# Offense count: 5
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata.
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint_spec.rb'
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/commands_endpoint_spec.rb'
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/events_endpoint_spec.rb'
- 'spec/slack-ruby-bot-server-events/config_spec.rb'
- 'spec/slack-ruby-bot-server-events/version_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'spec/database_adapters/activerecord/activerecord.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength.
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'spec/slack-ruby-bot-server-events/api/endpoints/slack/events_endpoint_spec.rb'
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
### Changelog

#### 0.3.3 (Next)
#### 0.4.0 (Next)

* Your contribution here.
* [#18](https://github.com/slack-ruby/slack-ruby-bot-server-events/pull/18): Use pagy_cursor in place of cursor_pagination - [@duffn](https://github.com/duffn).
* [#26](https://github.com/slack-ruby/slack-ruby-bot-server-events/pull/26): Upgraded RuboCop to 1.80.2 - [@dblock](https://github.com/dblock).
* Your contribution here.

#### 0.3.2 (2022/06/09)

Expand Down
13 changes: 8 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

source 'https://rubygems.org'

case ENV['DATABASE_ADAPTER']
when 'mongoid' then
case ENV.fetch('DATABASE_ADAPTER', nil)
when 'mongoid'
gem 'kaminari-mongoid'
gem 'mongoid', ENV['MONGOID_VERSION'] || '~> 7.3.0'
gem 'mongoid-scroll'
when 'activerecord' then
gem 'mutex_m'
when 'activerecord'
gem 'activerecord'
gem 'otr-activerecord'
gem 'pagy_cursor'
Expand All @@ -16,7 +17,7 @@ when 'activerecord' then
when nil
warn "Missing ENV['DATABASE_ADAPTER']."
else
warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV['DATABASE_ADAPTER']}."
warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV.fetch('DATABASE_ADAPTER', nil)}."
end

gemspec
Expand All @@ -30,7 +31,9 @@ group :development, :test do
gem 'rack-test'
gem 'rake'
gem 'rspec'
gem 'rubocop', '0.81.0'
gem 'rubocop', '1.80.2'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'vcr'
gem 'webmock'
end
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 Daniel Doubrovkine & Contributors
Copyright (c) 2020-2025 Daniel Doubrovkine & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ end

### Copyright & License

Copyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2020
Copyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2020-2025

[MIT License](LICENSE)
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require 'rspec/core'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb'].exclude(%r{ext\/(?!#{ENV['DATABASE_ADAPTER']})})
spec.pattern = FileList['spec/**/*_spec.rb'].exclude(%r{ext/(?!#{ENV.fetch('DATABASE_ADAPTER', nil)})})
end

require 'rubocop/rake_task'
Expand Down
2 changes: 1 addition & 1 deletion lib/slack-ruby-bot-server-events/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Config

def reset!
self.callbacks = Hash.new { |h, k| h[k] = [] }
self.signing_secret = ENV['SLACK_SIGNING_SECRET']
self.signing_secret = ENV.fetch('SLACK_SIGNING_SECRET', nil)
self.signature_expires_in = 5 * 60

on :event, 'url_verification' do |event|
Expand Down
2 changes: 1 addition & 1 deletion lib/slack-ruby-bot-server-events/requests/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Request < ActiveSupport::HashWithIndifferentAccess

def initialize(params, request)
@request = request
super params
super(params)
end

def logger
Expand Down
2 changes: 1 addition & 1 deletion lib/slack-ruby-bot-server-events/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module SlackRubyBotServer
module Events
VERSION = '0.3.3'
VERSION = '0.4.0'
end
end
16 changes: 7 additions & 9 deletions lib/slack-ruby-bot-server/api/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ class RootEndpoint
format :json

before do
begin
::Slack::Events::Request.new(
request,
signing_secret: SlackRubyBotServer::Events.config.signing_secret,
signature_expires_in: SlackRubyBotServer::Events.config.signature_expires_in
).verify!
rescue ::Slack::Events::Request::TimestampExpired
error!('Invalid Signature', 403)
end
::Slack::Events::Request.new(
request,
signing_secret: SlackRubyBotServer::Events.config.signing_secret,
signature_expires_in: SlackRubyBotServer::Events.config.signature_expires_in
).verify!
rescue ::Slack::Events::Request::TimestampExpired
error!('Invalid Signature', 403)
end

mount SlackRubyBotServer::Events::Api::Endpoints::Slack::CommandsEndpoint
Expand Down
1 change: 1 addition & 0 deletions slack-ruby-bot-server-events.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'slack-ruby-bot-server', '>= 0.12.0'
spec.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 2 additions & 2 deletions spec/database_adapters/activerecord/activerecord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

yml = ERB.new(File.read(File.expand_path('postgresql.yml', __dir__))).result
db_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
::YAML.safe_load(yml, aliases: true)[ENV['RACK_ENV']]
YAML.safe_load(yml, aliases: true)[ENV.fetch('RACK_ENV', nil)]
else
::YAML.safe_load(yml, [], [], true)[ENV['RACK_ENV']]
YAML.safe_load(yml, [], [], true)[ENV.fetch('RACK_ENV', nil)]
end
ActiveRecord::Tasks::DatabaseTasks.create(db_config)
ActiveRecord::Base.establish_connection(db_config)
Expand Down
2 changes: 1 addition & 1 deletion spec/database_adapters/mongoid/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

Mongo::Logger.logger.level = Logger::INFO
Mongoid.load!(File.expand_path('mongoid.yml', __dir__), ENV['RACK_ENV'])
Mongoid.load!(File.expand_path('mongoid.yml', __dir__), ENV.fetch('RACK_ENV', nil))
6 changes: 5 additions & 1 deletion spec/slack-ruby-bot-server-events/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
it 'defaults signature_expires_in' do
expect(SlackRubyBotServer::Events.config.signature_expires_in).to eq 300
end

context 'with ENV[SLACK_SIGNING_SECRET] set' do
before do
allow(ENV).to receive(:[]) { |k| "#{k} was set" }
allow(ENV).to receive(:fetch) { |k| "#{k} was set" }
SlackRubyBotServer::Events.config.reset!
end

it 'sets signing_secret' do
expect(SlackRubyBotServer::Events.config.signing_secret).to eq 'SLACK_SIGNING_SECRET was set'
end
end

%i[
signing_secret
signature_expires_in
Expand All @@ -25,6 +28,7 @@
config.send("#{k}=", 'set')
end
end

it "sets and returns #{k}" do
expect(SlackRubyBotServer::Events.config.send(k)).to eq 'set'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/slack-ruby-bot-server-events/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

describe SlackRubyBotServer::Events do
it 'has a version' do
expect(SlackRubyBotServer::Events::VERSION).to_not be nil
expect(SlackRubyBotServer::Events::VERSION).not_to be_nil
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ENV['RACK_ENV'] = 'test'
ENV['DATABASE_ADAPTER'] ||= 'mongoid'

require 'logger'

Bundler.require

require 'rack/test'
Expand Down