Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI
on:
pull_request:
jobs:
rspec:
strategy:
fail-fast: false
matrix:
include:
- { ruby: '3.3', rails: '7.2' }
- { ruby: '3.3', rails: '8.0' }
- { ruby: '3.3', rails: '8.1' }
- { ruby: '3.4', rails: '7.2' }
- { ruby: '3.4', rails: '8.0' }
- { ruby: '3.4', rails: '8.1' }
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bookingsync_engine_test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/bookingsync_engine_test
BOOKINGSYNC_URL: https://some_url.com
BOOKINGSYNC_APP_ID: some_client_id
BOOKINGSYNC_APP_SECRET: some_client_secret
BOOKINGSYNC_VERIFY_SSL: false
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0
3.3.10
16 changes: 6 additions & 10 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
appraise "rails-5.0" do
gem "rails", "~> 5.0.7.1"
appraise "rails-7.2" do
gem "rails", "~> 7.2.0"
end

appraise "rails-5.1" do
gem "rails", "~> 5.1.6.1"
appraise "rails-8.0" do
gem "rails", "~> 8.0.0"
end

appraise "rails-5.2" do
gem "rails", "~> 5.2.0"
end

appraise "rails-6.0" do
gem "rails", "~> 6.0"
appraise "rails-8.1" do
gem "rails", "~> 8.1.0"
end
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Master
# Master (Unreleased)

* Fix oauth2 2.0 `auth_scheme` breaking change (now defaults to `:basic_auth`)
* Add `BookingSync::Engine.auth_scheme` configuration option

# 6.0.1 (2021-07-16)

Expand Down Expand Up @@ -31,7 +34,7 @@
* Fix `AuthHelpers` include when `helper_method` is missing

# 4.0.0 (2019-04-24)

ª
* Add support for multi application setup
* BREAKING CHANGE: Account models method `from_omniauth` now takes the host as second argument
* BREAKING CHANGE: Rename BookingSync::Engine::Model in BookingSync::Engine::Models::Account
Expand Down
7 changes: 0 additions & 7 deletions gemfiles/rails_5.1.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails_5.2.gemfile → gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "~> 5.2.0"
gem "rails", "~> 7.2.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_6.0.gemfile → gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "~> 6.0"
gem "rails", "~> 8.0.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_5.0.gemfile → gemfiles/rails_8.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "~> 5.0.7.1"
gem "rails", "~> 8.1.0"

gemspec path: "../"
3 changes: 3 additions & 0 deletions lib/bookingsync-engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module BookingSyncEngine
cattr_accessor :oauth_client_connection_options
self.oauth_client_connection_options = { request: { timeout: 2 } }

cattr_accessor :oauth_client_auth_scheme
self.oauth_client_auth_scheme = :request_body

cattr_accessor :token_refresh_timeout_retry_count
self.token_refresh_timeout_retry_count = 2

Expand Down
3 changes: 2 additions & 1 deletion lib/bookingsync/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def self.oauth_client(client_id: ENV["BOOKINGSYNC_APP_ID"], client_secret: ENV["

client_options = {
site: ENV["BOOKINGSYNC_URL"] || 'https://www.bookingsync.com',
connection_opts: connection_options
connection_opts: connection_options,
auth_scheme: ::BookingSyncEngine.oauth_client_auth_scheme
}
client_options[:ssl] = { verify: ENV['BOOKINGSYNC_VERIFY_SSL'] != 'false' }
OAuth2::Client.new(client_id, client_secret, client_options)
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/authenticated_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
it "renders autosubmitted form" do
get :index
expect(response.status).to eq(200)
expect(response.body).to include("action='/auth/bookingsync' method='post'")
expect(response.body).to include("<input type='hidden' name='account_id' value=''>")
expect(response.body).to include("action=\"/auth/bookingsync\" method=\"post\"")
expect(response.body).to include("<input type=\"hidden\" name=\"account_id\" value=\"\">")
expect(response.header["Content-Type"]).to include("text/html")
end
end
Expand All @@ -24,8 +24,8 @@
it "renders autosubmitted form" do
get :index
expect(response.status).to eq(200)
expect(response.body).to include("action='/auth/bookingsync' method='post'")
expect(response.body).to include("<input type='hidden' name='account_id' value=''>")
expect(response.body).to include("action=\"/auth/bookingsync\" method=\"post\"")
expect(response.body).to include("<input type=\"hidden\" name=\"account_id\" value=\"\">")
end
end
end
Expand All @@ -37,8 +37,8 @@
it "renders autosubmitted form" do
get :index, xhr: true
expect(response.status).to eq(401)
expect(response.body).to include("action='/auth/bookingsync' method='post'")
expect(response.body).to include("<input type='hidden' name='account_id' value=''>")
expect(response.body).to include("action=\"/auth/bookingsync\" method=\"post\"")
expect(response.body).to include("<input type=\"hidden\" name=\"account_id\" value=\"\">")
end
end

Expand All @@ -48,8 +48,8 @@
it "renders autosubmitted form" do
get :index, xhr: true
expect(response.status).to eq(401)
expect(response.body).to include("action='/auth/bookingsync' method='post'")
expect(response.body).to include("<input type='hidden' name='account_id' value=''>")
expect(response.body).to include("action=\"/auth/bookingsync\" method=\"post\"")
expect(response.body).to include("<input type=\"hidden\" name=\"account_id\" value=\"\">")
end
end
end
Expand Down
12 changes: 11 additions & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'
require "rails"
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
# require "active_storage/engine"
# require "action_mailbox/engine"
# require "action_text/engine"
# require "action_cable/engine"
require "rails/test_unit/railtie"

Bundler.require(*Rails.groups)
require "bookingsync"
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
1 change: 1 addition & 0 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ test:
encoding: unicode
database: bookingsync_engine_test
pool: 5
url: <%= ENV['DATABASE_URL'] %>
21 changes: 9 additions & 12 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# In the development environment your application's code is reloaded any time
# it changes. 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 = false
config.enable_reloading = true

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

# Show full error reports and disable caching.
config.consider_all_requests_local = true
# Show full error reports.
config.consider_all_requests_local = true

# Disable caching.
config.action_controller.perform_caching = false

# Don't care if the mailer can't send.
Expand All @@ -19,11 +21,6 @@
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
end
end
21 changes: 10 additions & 11 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
config.enable_reloading = false

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a CI environment.
config.eager_load = ENV["CI"].present?

# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = { "Cache-Control" => "public, max-age=3600" }

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
config.action_dispatch.show_exceptions = :none

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
Expand All @@ -33,4 +32,4 @@

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
end
end