diff --git a/.rubocop.yml b/.rubocop.yml index ccd2a7a06..1ec897b79 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -47,3 +47,6 @@ Style/FormatStringToken: Style/OpenStructUse: Enabled: false + +RSpec/MessageChain: + Enabled: false diff --git a/Dockerfile b/Dockerfile index 1af512726..2861e54c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM opensuse/leap:15.3 RUN zypper --non-interactive install --no-recommends \ timezone wget gcc-c++ libffi-devel git-core zlib-devel \ - libxml2-devel libxslt-devel cron libmariadb-devel mariadb-client \ + libxml2-devel libxslt-devel cron libmariadb-devel mariadb-client sqlite3-devel \ vim ruby2.5 ruby2.5-devel ruby2.5-rubygem-bundler SUSEConnect && \ zypper --non-interactive install -t pattern devel_basis && \ update-alternatives --install /usr/bin/bundle bundle /usr/bin/bundle.ruby2.5 5 && \ diff --git a/README.md b/README.md index 697f53540..abf464ccd 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Please view our [guide](docs/installation.md) to assist you in the RMT installat 1. Install the system dependencies: ``` - sudo zypper in libxml2-devel libxslt-devel libmariadb-devel gcc + sudo zypper in libxml2-devel libxslt-devel libmariadb-devel sqlite3-devel gcc ``` 2. Install the ruby version specified in the `.ruby-version` [file](.ruby-version). 3. Install and setup the database: diff --git a/db/schema.rb b/db/schema.rb index 1f3795dbe..a1db7d82f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_08_14_105634) do +ActiveRecord::Schema.define(version: 2024_01_29_140413) do create_table "activations", charset: "utf8", force: :cascade do |t| t.bigint "service_id", null: false diff --git a/lib/rmt/lockfile.rb b/lib/rmt/lockfile.rb index 4fb6bf868..9b1242aee 100644 --- a/lib/rmt/lockfile.rb +++ b/lib/rmt/lockfile.rb @@ -3,7 +3,10 @@ class RMT::Lockfile class << self def lock(lock_name = nil) - yield and return if ActiveRecord::Base.connection.adapter_name != 'Mysql2' + if ActiveRecord::Base.connection.adapter_name != 'Mysql2' + yield + return + end lock_name = ['rmt-cli', lock_name].compact.join('-') diff --git a/spec/lib/rmt/lockfile_spec.rb b/spec/lib/rmt/lockfile_spec.rb index f7ac31acb..d1b86f968 100644 --- a/spec/lib/rmt/lockfile_spec.rb +++ b/spec/lib/rmt/lockfile_spec.rb @@ -51,5 +51,12 @@ ) end end + + context 'with sqlite backend' do + it 'yields block' do + allow(ActiveRecord::Base).to receive_message_chain(:connection, :adapter_name).and_return('sqlite3') + expect(lock).to eq nil + end + end end end diff --git a/spec/lib/suse/connect/api_spec.rb b/spec/lib/suse/connect/api_spec.rb index 865da6418..b73cfe669 100644 --- a/spec/lib/suse/connect/api_spec.rb +++ b/spec/lib/suse/connect/api_spec.rb @@ -44,7 +44,6 @@ end end - # rubocop:disable RSpec/MessageChain describe '#connect_api' do subject(:method_call) { api_client.send(:connect_api) } @@ -77,7 +76,6 @@ end end end - # rubocop:enable RSpec/MessageChain context 'api requests' do before do diff --git a/spec/support/cli_helpers.rb b/spec/support/cli_helpers.rb index 7dd870abf..f0e961e27 100644 --- a/spec/support/cli_helpers.rb +++ b/spec/support/cli_helpers.rb @@ -12,3 +12,7 @@ def silence_stdout def file_human_size(size_in_bytes) ActiveSupport::NumberHelper.number_to_human_size(size_in_bytes) end + +def running_mysql + ActiveRecord::Base.connection.adapter_name == 'Mysql2' +end diff --git a/spec/support/shared_examples/cli.rb b/spec/support/shared_examples/cli.rb index 57e38de8f..3b2ec407b 100644 --- a/spec/support/shared_examples/cli.rb +++ b/spec/support/shared_examples/cli.rb @@ -17,7 +17,7 @@ end shared_examples 'handles lockfile exception' do - context 'with existing lockfile' do + context 'with existing lockfile', if: running_mysql do before do allow(RMT::Lockfile).to receive(:obtain_lock).and_return(false) end