diff --git a/.ruby-version b/.ruby-version index c1026d2..2eb2fe9 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.3.1 +ruby-2.7.2 diff --git a/Appraisals b/Appraisals index 9e9ebba..2c49f9d 100644 --- a/Appraisals +++ b/Appraisals @@ -1,11 +1,15 @@ -appraise "rails-4.1" do - gem "rails", "~> 4.1" -end +# appraise "rails-4.1" do +# gem "rails", "~> 4.1" +# end -appraise "rails-4.2" do - gem "rails", "~> 4.2" -end +# appraise "rails-4.2" do +# gem "rails", "~> 4.2" +# end + +# appraise "rails-5.1" do +# gem "rails", "~> 5.1" +# end -appraise "rails-5.1" do - gem "rails", "~> 5.1" +appraise "rails-6.1" do + gem "rails", "~> 6.1" end diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b4d7cf..c5fa2a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.3.1] - rails 6 compatible ## [1.3.0] - 2021-03-24 ### Added [#14](http://github.com/G5/asyncapi-server/pull/10) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..5cc2c08 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css \ No newline at end of file diff --git a/app/controllers/asyncapi/server/v1/jobs_controller.rb b/app/controllers/asyncapi/server/v1/jobs_controller.rb index dc75b0d..5695c00 100644 --- a/app/controllers/asyncapi/server/v1/jobs_controller.rb +++ b/app/controllers/asyncapi/server/v1/jobs_controller.rb @@ -2,6 +2,7 @@ module Asyncapi module Server module V1 class JobsController < ApplicationController # TODO: Asyncapi::Server.parent_controller + include ActiveModelSerializersFix include Rails::Pagination protect_from_forgery with: :null_session diff --git a/app/controllers/concerns/active_model_serializers_fix.rb b/app/controllers/concerns/active_model_serializers_fix.rb new file mode 100644 index 0000000..85b7062 --- /dev/null +++ b/app/controllers/concerns/active_model_serializers_fix.rb @@ -0,0 +1,10 @@ +module ActiveModelSerializersFix + def namespace_for_serializer + @namespace_for_serializer ||= + if Module.method_defined?(:parent) + self.class.parent unless self.class.parent == Object + else + self.class.module_parent unless self.class.module_parent == Object + end + end +end \ No newline at end of file diff --git a/app/workers/asyncapi/server/job_worker.rb b/app/workers/asyncapi/server/job_worker.rb index bceb070..d350874 100644 --- a/app/workers/asyncapi/server/job_worker.rb +++ b/app/workers/asyncapi/server/job_worker.rb @@ -17,7 +17,7 @@ def perform(job_id, retries=0) raise e ensure if job - job.update_attributes(status: job_status) + job.update(status: job_status) report_job_status(job, job_message) else # For some reason "ActiveRecord::Base.after_transaction", diff --git a/asyncapi_server.gemspec b/asyncapi_server.gemspec index b4d0eef..1c6bd19 100644 --- a/asyncapi_server.gemspec +++ b/asyncapi_server.gemspec @@ -20,18 +20,18 @@ Gem::Specification.new do |s| s.add_dependency "kaminari" s.add_dependency "api-pagination" s.add_dependency "rails", ">= 4" - s.add_dependency "active_model_serializers", "~> 0.9.0" + s.add_dependency "active_model_serializers", "~> 0.9.7" s.add_dependency "typhoeus" s.add_dependency "sidekiq" s.add_dependency "responders" s.add_dependency "ar_after_transaction" - s.add_development_dependency "sqlite3", "~> 1.3.10" - s.add_development_dependency "rspec-rails", "~> 3.5.0" - s.add_development_dependency "rspec-its", "~> 1.1.0" + s.add_development_dependency "sqlite3", ">= 1.4" + s.add_development_dependency "rspec-rails" + s.add_development_dependency "rspec-its" s.add_development_dependency "rspec-sidekiq" - s.add_development_dependency "pry", "~> 0.10.1" + s.add_development_dependency "pry" s.add_development_dependency "factory_girl_rails", "~> 4.4.0" - s.add_development_dependency "database_cleaner", "~> 1.3.0" + s.add_development_dependency "database_cleaner" s.add_development_dependency "timecop" end diff --git a/gemfiles/rails_4.1.gemfile b/gemfiles/rails_4.1.gemfile index 403729d..423e2ae 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "appraisal" gem "rails", "~> 4.1" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index 3518ae6..f99ffb7 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "appraisal" gem "rails", "~> 4.2" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index 9b35bdb..8c78cb4 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "appraisal" gem "rails", "~> 5.1" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile new file mode 100644 index 0000000..c9d54f6 --- /dev/null +++ b/gemfiles/rails_6.1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", "~> 6.1" + +gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock new file mode 100644 index 0000000..b62eb4f --- /dev/null +++ b/gemfiles/rails_6.1.gemfile.lock @@ -0,0 +1,240 @@ +PATH + remote: .. + specs: + asyncapi-server (1.2.0) + active_model_serializers (= 0.9.7) + api-pagination + ar_after_transaction + kaminari + rails (>= 4) + responders + sidekiq + typhoeus + +GEM + remote: https://rubygems.org/ + specs: + actioncable (6.1.3) + actionpack (= 6.1.3) + activesupport (= 6.1.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.3) + actionpack (= 6.1.3) + activejob (= 6.1.3) + activerecord (= 6.1.3) + activestorage (= 6.1.3) + activesupport (= 6.1.3) + mail (>= 2.7.1) + actionmailer (6.1.3) + actionpack (= 6.1.3) + actionview (= 6.1.3) + activejob (= 6.1.3) + activesupport (= 6.1.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.3) + actionview (= 6.1.3) + activesupport (= 6.1.3) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.3) + actionpack (= 6.1.3) + activerecord (= 6.1.3) + activestorage (= 6.1.3) + activesupport (= 6.1.3) + nokogiri (>= 1.8.5) + actionview (6.1.3) + activesupport (= 6.1.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + active_model_serializers (0.9.7) + activemodel (>= 3.2) + concurrent-ruby (~> 1.0) + activejob (6.1.3) + activesupport (= 6.1.3) + globalid (>= 0.3.6) + activemodel (6.1.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activestorage (6.1.3) + actionpack (= 6.1.3) + activejob (= 6.1.3) + activerecord (= 6.1.3) + activesupport (= 6.1.3) + marcel (~> 0.3.1) + mimemagic (~> 0.3.2) + activesupport (6.1.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + api-pagination (4.8.2) + appraisal (2.4.0) + bundler + rake + thor (>= 0.14.0) + ar_after_transaction (0.7.0) + activerecord (>= 4.2.0, < 6.2) + builder (3.2.4) + coderay (1.1.3) + concurrent-ruby (1.1.8) + connection_pool (2.2.3) + crass (1.0.6) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + diff-lcs (1.4.4) + erubi (1.10.0) + ethon (0.12.0) + ffi (>= 1.3.0) + factory_girl (4.4.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.4.1) + factory_girl (~> 4.4.0) + railties (>= 3.0.0) + ffi (1.14.2) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + kaminari (1.2.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) + actionview + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) + activerecord + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) + loofah (2.9.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.5.0) + minitest (5.14.4) + nio4r (2.5.5) + nokogiri (1.11.1) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + racc (1.5.2) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.3) + actioncable (= 6.1.3) + actionmailbox (= 6.1.3) + actionmailer (= 6.1.3) + actionpack (= 6.1.3) + actiontext (= 6.1.3) + actionview (= 6.1.3) + activejob (= 6.1.3) + activemodel (= 6.1.3) + activerecord (= 6.1.3) + activestorage (= 6.1.3) + activesupport (= 6.1.3) + bundler (>= 1.15.0) + railties (= 6.1.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.1.3) + actionpack (= 6.1.3) + activesupport (= 6.1.3) + method_source + rake (>= 0.8.7) + thor (~> 1.0) + rake (13.0.3) + redis (4.2.5) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rspec-core (3.8.2) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.8.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-rails (3.8.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-support (~> 3.8.0) + rspec-sidekiq (3.1.0) + rspec-core (~> 3.0, >= 3.0.0) + sidekiq (>= 2.4.0) + rspec-support (3.8.2) + sidekiq (6.1.3) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) + sprockets (4.0.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.1.0) + timecop (0.9.4) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.3) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.4.2) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal + asyncapi-server! + database_cleaner + factory_girl_rails (~> 4.4.0) + pry + rails (~> 6.1) + rspec-its + rspec-rails + rspec-sidekiq + sqlite3 (>= 1.4) + timecop + +BUNDLED WITH + 1.17.3 diff --git a/lib/asyncapi/server/rails_ext/controller.rb b/lib/asyncapi/server/rails_ext/controller.rb index ea39726..c80a826 100644 --- a/lib/asyncapi/server/rails_ext/controller.rb +++ b/lib/asyncapi/server/rails_ext/controller.rb @@ -2,10 +2,10 @@ module Asyncapi module Server module RailsExt module Controller - extend ActiveSupport::Concern module ClassMethods + def async(method_name, klass) define_method(method_name) do job = Job.create(job_params_with(klass.name)) diff --git a/lib/asyncapi/server/version.rb b/lib/asyncapi/server/version.rb index bcc9e89..f69a744 100644 --- a/lib/asyncapi/server/version.rb +++ b/lib/asyncapi/server/version.rb @@ -1,5 +1,5 @@ module Asyncapi module Server - VERSION = "1.3.0" + VERSION = "1.3.1" end end diff --git a/spec/dummy/app/assets/config/manifest.js b/spec/dummy/app/assets/config/manifest.js new file mode 100644 index 0000000..5cc2c08 --- /dev/null +++ b/spec/dummy/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css \ No newline at end of file diff --git a/spec/dummy/app/controllers/tests_controller.rb b/spec/dummy/app/controllers/tests_controller.rb index ef6796c..b1bc3ff 100644 --- a/spec/dummy/app/controllers/tests_controller.rb +++ b/spec/dummy/app/controllers/tests_controller.rb @@ -1,4 +1,5 @@ class TestsController < ApplicationController + include ActiveModelSerializersFix async :create, Runner diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index a363083..6e231fd 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -1,24 +1,23 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150201231018) do +ActiveRecord::Schema.define(version: 2015_02_01_231018) do create_table "asyncapi_server_jobs", force: :cascade do |t| t.integer "status" - t.string "callback_url" - t.string "class_name" - t.text "params" - t.string "secret" + t.string "callback_url" + t.string "class_name" + t.text "params" + t.string "secret" end end diff --git a/spec/models/job_spec.rb b/spec/models/job_spec.rb index 7d2e49d..555afac 100644 --- a/spec/models/job_spec.rb +++ b/spec/models/job_spec.rb @@ -20,7 +20,7 @@ module Server its(:status) { is_expected.to eq "queued" } its(:callback_url) { is_expected.to eq "http://callback_url.com" } its(:class_name) { is_expected.to eq "CreateStorageFacility" } - its(:params) { is_expected.to eq("{\"param\"=>\"values\"}") } + its(:params) { is_expected.to eq("{\"param\":\"values\"}") } context "status" do it "can also be assigned other values" do