diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml new file mode 100644 index 0000000..712c861 --- /dev/null +++ b/.github/workflows/react.yml @@ -0,0 +1,54 @@ +--- +name: React Testing + +on: + pull_request: + paths: + - 'webpack/**' + - 'package.json' + - '.github/workflows/react.yml' + - '*.js' + push: + branches: + - master + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + Test: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [12] + foreman-core-branch: ['develop', '2.5-stable', '2.4-stable'] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: theforeman/foreman + ref: ${{ matrix.foreman-core-branch }} + path: foreman + + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: npm install + run: | + npm install + cd foreman; npm install; cd - + + - name: Lint Stylesheets + run: npm run stylelint + - name: Lint Javascript + run: npm run lint + - name: Test + run: npm run test +... diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..937e491 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,89 @@ +--- +name: Ruby Testing + +# Controls when the action will run. +on: + pull_request: + push: + branches: + - master + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + BUNDLE_WITHOUT: journald:development:console:libvirt + RAILS_ENV: test + DATABASE_URL: postgresql://postgres:@localhost/test + DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true + +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + - name: Run rubocop + run: bundle exec rubocop + + ruby-test: + # The type of runner that the job will run on + runs-on: ubuntu-latest + needs: rubocop + services: + postgres: + image: postgres:12.1 + ports: ['5432:5432'] + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + strategy: + fail-fast: false + matrix: + ruby-version: ['2.7'] + foreman-core-branch: ['develop', '2.5-stable', '2.4-stable'] + proxmox: ['~>0.13.3'] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Install build packages + run: | + sudo apt-get update + sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + with: + repository: theforeman/foreman + ref: ${{ matrix.foreman-core-branch }} + + - uses: actions/checkout@v2 + with: + path: foreman_snapshot_management + + - name: Setup Bundler + run: | + echo "gem 'foreman_fog_proxmox', '${{ matrix.proxmox }}'" > bundler.d/proxmox.rb + echo "gem 'foreman_snapshot_management', path: './foreman_snapshot_management'" > bundler.d/foreman_snapshot_mgmt.local.rb + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Prepare test env + if: github.event_name != 'push' + run: | + bundle exec rake db:create + bundle exec rake db:migrate + bundle exec rake db:test:prepare + + - name: Run plugin tests + if: github.event_name != 'push' + run: | + bundle exec rake test:foreman_snapshot_management +... diff --git a/.gitignore b/.gitignore index 39114ca..20e8493 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ Gemfile.lock *.gem locale/*/*.edit.po locale/*/*.po.time_stamp +node_modules +package-lock.json diff --git a/.rubocop.yml b/.rubocop.yml index eaebb7f..f47f83f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,56 +1,84 @@ + +require: + - rubocop-performance + - rubocop-rails + - rubocop-minitest + AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.5 + TargetRailsVersion: 5.2 Exclude: + - 'locale/**/*' + - 'node_modules/**/*' + - 'vendor/**/*' - '*.spec' - - 'doc/plugins/**' - -Rails/Date: - Exclude: - - 'foreman_snapshot_management.gemspec' -Rails: - Enabled: True +Layout/LineLength: + Max: 190 -Rails/FindEach: - Exclude: - - 'app/models/foreman_snapshot_management/vmware_extensions.rb' +Metrics/AbcSize: + Enabled: false -# Don't enforce documentation -Style/Documentation: +Metrics/BlockLength: Enabled: false +Metrics/ClassLength: + Max: 500 + Metrics/MethodLength: Max: 40 -Naming/AccessorMethodName: +Metrics/ModuleLength: + Max: 400 + +Metrics/ParameterLists: Enabled: false -Style/RedundantSelf: +Metrics/PerceivedComplexity: Enabled: false -Metrics/ClassLength: - Max: 500 +Naming/AccessorMethodName: + Enabled: false Naming/FileName: Exclude: - 'db/seeds.d/*' -Style/WordArray: - Enabled: false +Naming/MethodName: + Exclude: + - 'app/models/concerns/orchestration/*.rb' -Style/BracesAroundHashParameters: - Enabled: false +Rails: + Enabled: True -Style/RescueModifier: +Rails/Date: + Exclude: + - 'foreman_snapshot_management.gemspec' + +Rails/FindEach: + Exclude: + - 'app/models/foreman_snapshot_management/vmware_extensions.rb' + +Style/CaseEquality: Enabled: false Style/ClassAndModuleChildren: Enabled: false +# Don't enforce documentation +Style/Documentation: + Enabled: false + Style/EachWithObject: Enabled: false -Metrics/ParameterLists: +Style/FormatString: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Style/GuardClause: Enabled: false # Support both ruby19 and hash_rockets @@ -60,41 +88,23 @@ Style/HashSyntax: - ruby19 - hash_rockets -Metrics/LineLength: - Max: 190 - -# Offense count: 21 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 400 - -Naming/MethodName: - Exclude: - - 'app/models/concerns/orchestration/*.rb' - -Style/SymbolArray: - Enabled: false - -Style/FormatString: - Enabled: false - -Style/FormatStringToken: +Style/RedundantSelf: Enabled: false Style/RegexpLiteral: Enabled: false -Metrics/AbcSize: +Style/RescueModifier: Enabled: false -Metrics/BlockLength: - Enabled: false +Style/StringLiterals: + Exclude: + - 'Gemfile' + - '*.gemspec' -Metrics/PerceivedComplexity: +Style/SymbolArray: Enabled: false -Style/CaseEquality: +Style/WordArray: Enabled: false -Style/GuardClause: - Enabled: false diff --git a/Gemfile b/Gemfile index 7f4f5e9..6f615ac 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,9 @@ source 'https://rubygems.org' gemspec + +gem 'rdoc', '~> 5.1' +gem "rubocop", "~> 0.89.0" +gem "rubocop-minitest", "~> 0.10.3" +gem "rubocop-performance", "~> 1.8" +gem "rubocop-rails", "~> 2.8" diff --git a/README.md b/README.md index fc9008e..707e36d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![Build Status](https://travis-ci.org/ATIX-AG/foreman_snapshot_management.svg?branch=master)](https://travis-ci.org/ATIX-AG/foreman_snapshot_management) +[![React Testing](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/react.yml/badge.svg)](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/react.yml) +[![Ruby Testing](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/ruby.yml/badge.svg)](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/ruby.yml) # ForemanSnapshotManagement @@ -22,6 +23,7 @@ See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wi | Foreman Version | Plugin Version | | --------------- | -------------- | +| 2.3 | >= 2.0.0 | | 1.24 | >= 1.7.0 | | 1.23 | >= 1.7.0 | | 1.22 | >= 1.6.0 | diff --git a/Rakefile b/Rakefile index e0bcf45..545e849 100755 --- a/Rakefile +++ b/Rakefile @@ -14,6 +14,13 @@ rescue LoadError RDoc::Task = Rake::RDocTask end +begin + require 'rubocop/rake_task' + RuboCop::RakeTask.new +rescue StandardError => _e + puts 'Rubocop not loaded.' +end + RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'ForemanSnapshotManagement' @@ -22,6 +29,4 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__) - Bundler::GemHelper.install_tasks diff --git a/app/models/foreman_snapshot_management/proxmox_extensions.rb b/app/models/foreman_snapshot_management/proxmox_extensions.rb index 7111450..5af6d26 100644 --- a/app/models/foreman_snapshot_management/proxmox_extensions.rb +++ b/app/models/foreman_snapshot_management/proxmox_extensions.rb @@ -12,7 +12,7 @@ def capabilities # This method creates a Snapshot with a given name and optional description. def create_snapshot(host, name, description, _include_ram = false) server = find_vm_by_uuid host.uuid - raise _('Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _') unless name =~ /^[A-Za-z][\w]{1,}$/ + raise _('Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _') unless /^[A-Za-z][\w]{1,}$/.match?(name) snapshot = server.snapshots.create(name: name) snapshot.description = description diff --git a/app/models/foreman_snapshot_management/snapshot.rb b/app/models/foreman_snapshot_management/snapshot.rb index b016222..e0c58f8 100644 --- a/app/models/foreman_snapshot_management/snapshot.rb +++ b/app/models/foreman_snapshot_management/snapshot.rb @@ -28,6 +28,10 @@ def self.model_name ) end + def self.any? + true + end + def self.new_for_host(host) host.compute_resource.new_snapshot(host) end diff --git a/app/views/api/v2/snapshots/base.json.rabl b/app/views/api/v2/snapshots/base.json.rabl index bc783f8..c33651d 100644 --- a/app/views/api/v2/snapshots/base.json.rabl +++ b/app/views/api/v2/snapshots/base.json.rabl @@ -4,4 +4,4 @@ object @snapshot attributes :id, :name -node(:formatted_created_at){|snapshot| snapshot.create_time&.httpdate} +node(:formatted_created_at) { |snapshot| snapshot.create_time&.httpdate } diff --git a/foreman_snapshot_management.gemspec b/foreman_snapshot_management.gemspec index 439aa0f..e8b0b52 100644 --- a/foreman_snapshot_management.gemspec +++ b/foreman_snapshot_management.gemspec @@ -18,6 +18,5 @@ Gem::Specification.new do |s| s.files = Dir['{app,config,db,lib,locale,webpack}/**/*'] + ['LICENSE', 'package.json', 'Rakefile', 'README.md'] s.test_files = Dir['test/**/*'] - s.add_development_dependency 'rdoc', '~> 5.1' - s.add_development_dependency 'rubocop', '~> 0.75.0' + s.required_ruby_version = '>= 2.5' end diff --git a/lib/foreman_snapshot_management/engine.rb b/lib/foreman_snapshot_management/engine.rb index a9b73af..600233c 100644 --- a/lib/foreman_snapshot_management/engine.rb +++ b/lib/foreman_snapshot_management/engine.rb @@ -86,33 +86,31 @@ class Engine < ::Rails::Engine # Include concerns in this config.to_prepare block config.to_prepare do - begin - # Load Foreman extensions - ::HostsHelper.prepend ForemanSnapshotManagement::HostsHelperExtension + # Load Foreman extensions + ::HostsHelper.prepend ForemanSnapshotManagement::HostsHelperExtension - begin - ::ForemanFogProxmox::Proxmox.prepend ForemanSnapshotManagement::ProxmoxExtensions + begin + ::ForemanFogProxmox::Proxmox.prepend ForemanSnapshotManagement::ProxmoxExtensions - # Load Fog extensions - Fog::Proxmox::Compute::Mock.prepend FogExtensions::Proxmox::Snapshots::Mock if ForemanFogProxmox::Proxmox.available? - rescue StandardError => e - Rails.logger.warn "Failed to load Proxmox extension #{e}" - end + # Load Fog extensions + Fog::Proxmox::Compute::Mock.prepend FogExtensions::Proxmox::Snapshots::Mock if ForemanFogProxmox::Proxmox.available? + rescue StandardError => e + Rails.logger.warn "Failed to load Proxmox extension #{e}" + end - begin - ::Foreman::Model::Vmware.prepend ForemanSnapshotManagement::VmwareExtensions + begin + ::Foreman::Model::Vmware.prepend ForemanSnapshotManagement::VmwareExtensions - # Load Fog extensions - if Foreman::Model::Vmware.available? - ForemanSnapshotManagement.fog_vsphere_namespace::Real.prepend FogExtensions::Vsphere::Snapshots::Real - ForemanSnapshotManagement.fog_vsphere_namespace::Mock.prepend FogExtensions::Vsphere::Snapshots::Mock - end - rescue StandardError => e - Rails.logger.warn "Failed to load VMware extension #{e}" + # Load Fog extensions + if Foreman::Model::Vmware.available? + ForemanSnapshotManagement.fog_vsphere_namespace::Real.prepend FogExtensions::Vsphere::Snapshots::Real + ForemanSnapshotManagement.fog_vsphere_namespace::Mock.prepend FogExtensions::Vsphere::Snapshots::Mock end rescue StandardError => e - Rails.logger.warn "ForemanSnapshotManagement: skipping engine hook (#{e})" + Rails.logger.warn "Failed to load VMware extension #{e}" end + rescue StandardError => e + Rails.logger.warn "ForemanSnapshotManagement: skipping engine hook (#{e})" end rake_tasks do diff --git a/lib/foreman_snapshot_management/version.rb b/lib/foreman_snapshot_management/version.rb index 6ee97e2..691f6be 100644 --- a/lib/foreman_snapshot_management/version.rb +++ b/lib/foreman_snapshot_management/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ForemanSnapshotManagement - VERSION = '1.8.1' + VERSION = '2.0.0' end diff --git a/lib/tasks/foreman_snapshot_management_tasks.rake b/lib/tasks/foreman_snapshot_management_tasks.rake index 9085039..2346f89 100644 --- a/lib/tasks/foreman_snapshot_management_tasks.rake +++ b/lib/tasks/foreman_snapshot_management_tasks.rake @@ -20,7 +20,7 @@ begin "#{ForemanSnapshotManagement::Engine.root}/test/**/*.rb"] namespace :foreman_snapshot_management do - task :rubocop do + task rubocop: :environment do RuboCop::RakeTask.new(:rubocop_foreman_snapshot_management) do |task| task.patterns = test_patterns end @@ -42,7 +42,7 @@ end namespace :jenkins do desc 'Test ForemanSnapshotManagement with XML output for jenkins' - task 'foreman_snapshot_management' do + task 'foreman_snapshot_management' => :environment do Rake::Task['jenkins:setup:minitest'].invoke Rake::Task['rake:test:foreman_snapshot_management'].invoke end diff --git a/locale/de/LC_MESSAGES/foreman_snapshot_management.mo b/locale/de/LC_MESSAGES/foreman_snapshot_management.mo index a9af2dd..e26ff69 100644 Binary files a/locale/de/LC_MESSAGES/foreman_snapshot_management.mo and b/locale/de/LC_MESSAGES/foreman_snapshot_management.mo differ diff --git a/locale/de/foreman_snapshot_management.po b/locale/de/foreman_snapshot_management.po index 3791c52..56e5e06 100644 --- a/locale/de/foreman_snapshot_management.po +++ b/locale/de/foreman_snapshot_management.po @@ -5,18 +5,19 @@ # # Translators: # Lukáš Zapletal, 2019 -# Ettore Atalan , 2019 # Wiederoder , 2019 -# Bryan Kearney , 2019 # Martin Zimmermann , 2019 -# Markus Bucher , 2020 +# Ettore Atalan , 2021 +# Bryan Kearney , 2021 +# Markus Bucher , 2021 # +#, fuzzy msgid "" msgstr "" "Project-Id-Version: foreman_snapshot_management 1.8.1\n" "Report-Msgid-Bugs-To: \n" "PO-Revision-Date: 2019-10-22 11:54+0000\n" -"Last-Translator: Markus Bucher , 2020\n" +"Last-Translator: Markus Bucher , 2021\n" "Language-Team: German (https://www.transifex.com/foreman/teams/114/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -28,13 +29,13 @@ msgid "Action" msgstr "Aktion" msgid "Action with sub plans" -msgstr "" +msgstr "Aktion mit Unterplänen" msgid "Create Snapshot" msgstr "Snapshot erstellen" msgid "Create Snapshot for %s" -msgstr "" +msgstr "Snapshot anlegen für %s" msgid "Create a snapshot" msgstr "Einen Snapshot erstellen" @@ -43,10 +44,10 @@ msgid "Created %{snapshots} for %{num} %{hosts}" msgstr "%{snapshots} für %{num} %{hosts} erstellt" msgid "Delete" -msgstr "" +msgstr "Löschen" msgid "Delete Snapshot \"%s\"?" -msgstr "" +msgstr "\"%s\" wirklich löschen?" msgid "Delete a snapshot" msgstr "Snapshot löschen" @@ -70,10 +71,10 @@ msgid "Error occurred while rolling back VM: %s" msgstr "Beim Zurücksetzen der VM ist ein Fehler aufgetreten: %s" msgid "Error occurred while updating Snapshot: %s" -msgstr "" +msgstr "Fehler beim Aktualisieren des Snapshots: %s" msgid "Failed to load snapshot list" -msgstr "" +msgstr "Fehler beim Laden der Snapshotliste" msgid "Failed to update Snapshot: %s" msgstr "Das Aktualisieren des Snapshots ist fehlgeschlagen: %s" @@ -82,10 +83,10 @@ msgid "Foreman-plugin to manage snapshots in a virtual-hardware environments." msgstr "Ein Foremanplugin, welches Snapshots in Umgebungen mit virtueller Hardware nutzbar macht." msgid "Import Puppet classes" -msgstr "" +msgstr "Puppet-Klassen importieren" msgid "Import facts" -msgstr "" +msgstr "Fakten importieren" msgid "Include RAM" msgstr "RAM einbeziehen" @@ -97,10 +98,10 @@ msgid "Loading Snapshots information ..." msgstr "Lade Snapshot Informationen ..." msgid "N/A" -msgstr "" +msgstr "N/A" msgid "Name" -msgstr "" +msgstr "Name" msgid "Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _" msgstr "Der Name muss aus mindestens 2 Zeichen bestehen und mit einem Buchstaben beginnen. Gültige Zeichen: A-Z a-z 0-9 _" @@ -124,7 +125,7 @@ msgid "Rollback" msgstr "Wiederherstellen" msgid "Rollback to \"%s\"?" -msgstr "" +msgstr "\"%s\" wirklich wiederherstellen?" msgid "Snapshot" msgid_plural "Snapshots" @@ -135,7 +136,7 @@ msgid "Snapshot name cannot be changed" msgstr "Der Name des Snapshots kann nicht geändert werden" msgid "Snapshot successfully created!" -msgstr "" +msgstr "Snapshot erfolgreich erzeugt!" msgid "Snapshots" msgstr "Snapshots" @@ -144,13 +145,13 @@ msgid "Something went wrong while selecting hosts - %s" msgstr "Fehler beim Auswählen der Hosts – %s" msgid "Successfully removed Snapshot \"%s\" from host %s" -msgstr "" +msgstr "Snapshot \"%s\" erfolgreich von Host %s entfernt." msgid "Successfully rolled back Snapshot \"%s\" on host %s" -msgstr "" +msgstr "Snapshot \"%s\" erfolgreich auf Host %s zurückgesetzt." msgid "Successfully updated Snapshot \"%s\"" -msgstr "" +msgstr "Snapshot \"%s\" erfolgreich aktualisiert." msgid "Unable to create Proxmox Snapshot" msgstr "Proxmox Snapshot konnte nicht erstellt werden" @@ -186,7 +187,7 @@ msgid "Whether to include the RAM state in the snapshot" msgstr "Ob auch der aktuelle Hauptspeicherstand im Snapshot gespeichert werden soll" msgid "edit entry" -msgstr "" +msgstr "Eintrag bearbeiten" msgid "host" msgid_plural "hosts" diff --git a/package.json b/package.json index 26f0d44..fad60dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foreman_snapshot_management", - "version": "1.8.1", + "version": "2.0.0", "description": "Foreman-plugin to manage snapshots in a virtual-hardware environments.", "main": "index.js", "scripts": { diff --git a/rubygem-foreman_snapshot_management.spec b/rubygem-foreman_snapshot_management.spec deleted file mode 100644 index 9aa53c0..0000000 --- a/rubygem-foreman_snapshot_management.spec +++ /dev/null @@ -1,141 +0,0 @@ -# template: foreman_plugin -%{?scl:%scl_package rubygem-%{gem_name}} -%{!?scl:%global pkg_name %{name}} - -%global gem_name foreman_snapshot_management -%global plugin_name snapshot_management -%global foreman_min_version 1.20.0 - -Name: %{?scl_prefix}rubygem-%{gem_name} -Version: 1.7.1 -Release: 1%{?foremandist}%{?dist} -Summary: Snapshot Management for VMware vSphere -Group: Applications/Systems -License: GPLv3 -URL: https://www.orcharhino.com -Source0: https://rubygems.org/downloads/%{gem_name}-%{version}.gem - -# start specfile generated dependencies -Requires: foreman >= %{foreman_min_version} -Requires: %{?scl_prefix_ruby}ruby(release) -Requires: %{?scl_prefix_ruby}ruby -Requires: %{?scl_prefix_ruby}ruby(rubygems) -BuildRequires: foreman-plugin >= %{foreman_min_version} -BuildRequires: %{?scl_prefix_ruby}ruby(release) -BuildRequires: %{?scl_prefix_ruby}ruby -BuildRequires: %{?scl_prefix_ruby}rubygems-devel -BuildArch: noarch -Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version} -Provides: foreman-plugin-%{plugin_name} = %{version} -# end specfile generated dependencies - -%description -Foreman-plugin to manage snapshots in a vSphere environment. - - -%package doc -Summary: Documentation for %{pkg_name} -Group: Documentation -Requires: %{?scl_prefix}%{pkg_name} = %{version}-%{release} -BuildArch: noarch - -%description doc -Documentation for %{pkg_name}. - -%prep -%{?scl:scl enable %{scl} - << \EOF} -gem unpack %{SOURCE0} -%{?scl:EOF} - -%setup -q -D -T -n %{gem_name}-%{version} - -%{?scl:scl enable %{scl} - << \EOF} -gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec -%{?scl:EOF} - -%build -# Create the gem as gem install only works on a gem file -%{?scl:scl enable %{scl} - << \EOF} -gem build %{gem_name}.gemspec -%{?scl:EOF} - -# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir -# by default, so that we can move it into the buildroot in %%install -%{?scl:scl enable %{scl} - << \EOF} -%gem_install -%{?scl:EOF} - -%install -mkdir -p %{buildroot}%{gem_dir} -cp -pa .%{gem_dir}/* \ - %{buildroot}%{gem_dir}/ - -%foreman_bundlerd_file -%foreman_precompile_plugin -a - -%files -%dir %{gem_instdir} -%license %{gem_instdir}/LICENSE -%{gem_instdir}/app -%{gem_instdir}/config -%{gem_libdir} -%{gem_instdir}/locale -%exclude %{gem_cache} -%{gem_spec} -%{foreman_bundlerd_plugin} -%{foreman_apipie_cache_foreman} -%{foreman_apipie_cache_plugin} - -%files doc -%doc %{gem_docdir} -%doc %{gem_instdir}/README.md -%{gem_instdir}/Rakefile -%{gem_instdir}/test - -%changelog -* Mon Mar 02 2020 Markus Bucher - 1.7.1-1 -- Update to 1.7.1 -- Proxmox support -- Update translations - -* Wed Jan 22 2020 Matthias Dellweg 1.7.0-1 -- Update to 1.7.0 -- Remove dependency on deface -- Update translations - -* Fri Jan 17 2020 Eric D. Helms - 1.6.0-2 -- Drop posttrans macros - -* Thu Apr 11 2019 Matthias Dellweg 1.6.0-1 -- Update to 1.6.0 -- Add compatibility workaround for foreman-1.22 (timogoebel) - -* Fri Oct 19 2018 Matthias Dellweg 1.5.1-1 -- Update to 1.5.1 - -* Fri Sep 07 2018 Eric D. Helms - 1.5.0-3 -- Rebuild for Rails 5.2 and Ruby 2.5 - -* Mon May 28 2018 Ewoud Kohl van Wijngaarden - 1.5.0-2 -- Regenerate spec file based on the current template - -* Fri May 25 2018 Matthias Dellweg 1.5.0-1 -- Update to 1.5.0 -- Add a bulk action for snapshots - -* Thu Apr 05 2018 Ewoud Kohl van Wijngaarden 1.4.0-1 -- Update to 1.4.0 - -* Wed Jan 10 2018 Ewoud Kohl van Wijngaarden 1.3.0-2 -- Bump Foreman plugins release (ericdhelms@gmail.com) - -* Fri Dec 15 2017 Ewoud Kohl van Wijngaarden 1.3.0-1 -- Update foreman_snapshot_management to 1.3.0 (mail@timogoebel.name) - -* Tue Sep 26 2017 Daniel Lobato Garcia 1.1.0-1 -- Update foreman_snapshot_management to 1.1.0 (mail@timogoebel.name) -- Use HTTPS URLs for github and rubygems (ewoud@kohlvanwijngaarden.nl) - -* Tue Aug 15 2017 Eric D. Helms 1.0.0-1 -- new package built with tito - diff --git a/test/controllers/api/v2/snapshots_test.rb b/test/controllers/api/v2/snapshots_test.rb index 90369b8..74688e0 100644 --- a/test/controllers/api/v2/snapshots_test.rb +++ b/test/controllers/api/v2/snapshots_test.rb @@ -17,16 +17,16 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase ComputeResource.find_by(id: cr.id) end let(:vmid) { '100' } - let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => vmid) } + let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => "1_#{vmid}") } let(:proxmox_snapshot) { 'snapshot1' } - let(:manager_user) { - roles = [Role.find_by_name('Snapshot Manager')] + let(:manager_user) do + roles = [Role.find_by(name: 'Snapshot Manager')] FactoryBot.create(:user, :organizations => [tax_organization], :locations => [tax_location], :roles => roles) - } - let(:view_user) { - roles = [Role.find_by_name('Snapshot Viewer')] + end + let(:view_user) do + roles = [Role.find_by(name: 'Snapshot Viewer')] FactoryBot.create(:user, :organizations => [tax_organization], :locations => [tax_location], :roles => roles) - } + end setup { ::Fog.mock! } teardown { ::Fog.unmock! } @@ -43,7 +43,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase end test 'should get index of Vmware Snapshots' do - get :index, params: { :host_id => host.to_param } + get :index, params: { :host_id => host.to_param } assert_response :success assert_not_nil assigns(:snapshots) body = ActiveSupport::JSON.decode(@response.body) @@ -53,7 +53,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase test 'should get index of Proxmox Snapshots' do Host::Managed.any_instance.stubs(:vm_exists?).returns(false) - get :index, params: { :host_id => proxmox_host.to_param } + get :index, params: { :host_id => proxmox_host.to_param } assert_response :success assert_not_nil assigns(:snapshots) body = ActiveSupport::JSON.decode(@response.body) @@ -68,7 +68,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase body = ActiveSupport::JSON.decode(@response.body) assert_not_empty body assert_not_empty body['results'] - assert body['results'].count == 1 + assert_equal body['results'].count, 1 end test 'should search Proxmox snapshot' do @@ -79,7 +79,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase body = ActiveSupport::JSON.decode(@response.body) assert_not_empty body assert_not_empty body['results'] - assert body['results'].count == 1 + assert_equal body['results'].count, 1 end test 'should refute search Vmware snapshot' do @@ -170,7 +170,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase body = ActiveSupport::JSON.decode(@response.body) assert_not_empty body assert_not_empty body['results'] - assert body['results'].count == 1 + assert_equal body['results'].count, 1 end test 'should search Proxmox snapshot' do @@ -181,7 +181,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase body = ActiveSupport::JSON.decode(@response.body) assert_not_empty body assert_not_empty body['results'] - assert body['results'].count == 1 + assert_equal body['results'].count, 1 end test 'should refute search Vmware snapshot' do diff --git a/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb b/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb index db3e3c8..6eaf1d7 100644 --- a/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +++ b/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb @@ -19,7 +19,7 @@ class SnapshotsControllerTest < ActionController::TestCase FactoryBot.create(:proxmox_cr) ComputeResource.find_by(type: 'ForemanFogProxmox::Proxmox') end - let(:vmid) { '100' } + let(:vmid) { '1_100' } let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => vmid) } let(:proxmox_snapshot) { 'snapshot1' } setup { ::Fog.mock! } diff --git a/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap b/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap index e4e3a5a..88ee09e 100644 --- a/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +++ b/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap @@ -2,6 +2,7 @@ exports[`SnapshotForm rendering render 1`] = `