From 180f42cf7b30d5aa48bb82f427ddd525911e87e5 Mon Sep 17 00:00:00 2001 From: Anita Graham Date: Wed, 9 Dec 2020 13:29:23 +0800 Subject: [PATCH 1/5] Get settings using friendlyId Update factory to use block --- app/controllers/refinery/admin/settings_controller.rb | 2 +- spec/factories/settings.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/refinery/admin/settings_controller.rb b/app/controllers/refinery/admin/settings_controller.rb index aef0ec8..e92159c 100644 --- a/app/controllers/refinery/admin/settings_controller.rb +++ b/app/controllers/refinery/admin/settings_controller.rb @@ -16,7 +16,7 @@ def new end def edit - @setting = ::Refinery::Setting.find(params[:id]) + @setting = ::Refinery::Setting.friendly.find(params[:id]) render :layout => false if request.xhr? end diff --git a/spec/factories/settings.rb b/spec/factories/settings.rb index 531b84d..69221ed 100644 --- a/spec/factories/settings.rb +++ b/spec/factories/settings.rb @@ -1,5 +1,5 @@ FactoryBot.define do factory :setting, :class => Refinery::Setting do - name "Refinery CMS setting" + name { "Refinery CMS setting" } end end From e89bf77cc3676576827e5a058ff641d0bc23a73d Mon Sep 17 00:00:00 2001 From: Anita Graham Date: Thu, 3 Mar 2022 11:52:43 +0800 Subject: [PATCH 2/5] Add CI Workflow Add Dependabot.yml --- .github/dependabot.yml | 6 +++++ .github/workflows/main.yml | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e4d674d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: bundler + directory: "/" + schedule: + interval: monthly diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..03fe9b1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,52 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + strategy: + matrix: + database: [ mysql, postgresql ] + ruby: [ 2.7, 2.6 ] + fail-fast: false + max-parallel: 20 + runs-on: ubuntu-latest + + env: + CI: true + DB: ${{ matrix.database }} + MYSQL_PASSWORD: root + PGHOST: localhost + PGPASSWORD: runner + PGUSER: runner + RAILS_ENV: test + RETRY_COUNT: 3 + + name: ${{ matrix.extension }} ${{ matrix.ruby }} ${{ matrix.database }} + steps: + - run: sudo apt-get update && sudo apt-get install libsqlite3-dev -y + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ${{ matrix.ruby }} + + - name: "Set up MySQL using VM's server" + if: ${{ env.DB == 'mysql' }} + run: | + sudo apt-get install libmysqlclient-dev -y + sudo systemctl start mysql.service + + - name: "Set up PostgreSQL using VM's server" + if: ${{ env.DB == 'postgresql' }} + run: | + sudo apt-get install libpq-dev -y + sudo systemctl start postgresql.service + sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER PASSWORD 'runner'" + + - run: bin/rake refinery:testing:dummy_app + - run: bin/rspec spec From f5540c4bab3bfc4719f16cd11975192efd1746b5 Mon Sep 17 00:00:00 2001 From: Anita Date: Fri, 4 Mar 2022 12:07:08 +0800 Subject: [PATCH 3/5] Change version of pg to match refinery --- Gemfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 0c0f2ba..c87e9f4 100644 --- a/Gemfile +++ b/Gemfile @@ -22,9 +22,11 @@ if !ENV["TRAVIS"] || ENV["DB"] == "mysql" gem "mysql2", :platform => :ruby end -if !ENV["TRAVIS"] || ENV["DB"] == "postgresql" - gem "activerecord-jdbcpostgresql-adapter", :platform => :jruby - gem 'pg', '~> 0.21', platform: :ruby +if !ENV['CI'] || ENV['DB'] == 'postgresql' + group :postgres, :postgresql do + gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.0.rc1', platform: :jruby + gem 'pg', '~> 1.1', platform: :ruby + end end gem "jruby-openssl", :platform => :jruby @@ -49,4 +51,4 @@ end # Load local gems according to Refinery developer preference. if File.exist? local_gemfile = File.expand_path("../.gemfile", __FILE__) eval File.read(local_gemfile) -end \ No newline at end of file +end From 415486ced6be2495173149132ec9bdc06c382dba Mon Sep 17 00:00:00 2001 From: Anita Date: Fri, 4 Mar 2022 12:21:12 +0800 Subject: [PATCH 4/5] Add ability to run CI manually on a branch using workflow_dispatch --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03fe9b1..7c7c73e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,8 @@ on: branches: - master pull_request: + workflow_dispatch: + jobs: test: From 05fc5f887595d75abce0eebcecd366c2f7b1efa8 Mon Sep 17 00:00:00 2001 From: Anita Date: Fri, 4 Mar 2022 12:37:27 +0800 Subject: [PATCH 5/5] Add refinery_login to spec/support --- Rakefile | 4 ++-- spec/support/refinery_login.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 spec/support/refinery_login.rb diff --git a/Rakefile b/Rakefile index 83d140f..d6e7de7 100644 --- a/Rakefile +++ b/Rakefile @@ -13,8 +13,8 @@ if File.exists?(APP_RAKEFILE) end require "refinerycms-testing" -Refinery::Testing::Railtie.load_dummy_tasks File.dirname(__FILE__) +Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH) load File.expand_path('../tasks/rspec.rake', __FILE__) -task :default => :spec +task default: :spec diff --git a/spec/support/refinery_login.rb b/spec/support/refinery_login.rb new file mode 100644 index 0000000..b533a34 --- /dev/null +++ b/spec/support/refinery_login.rb @@ -0,0 +1,3 @@ +def refinery_login + let(:logged_in_user) { Refinery::Core::NilUser.new } +end