diff --git a/.msync.yml b/.msync.yml index 179bafc..7d6d4ee 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '10.5.0' +modulesync_config_version: '10.6.0' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 265e5e6..c0fa687 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,52 +1,25 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2022-12-13 08:48:17 UTC using RuboCop version 1.22.3. +# `rubocop --auto-gen-config --no-auto-gen-timestamp` +# using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterExample: - Exclude: - - 'spec/classes/init_spec.rb' - -# Offense count: 30 -# Cop supports --auto-correct. -RSpec/EmptyLineAfterExampleGroup: - Exclude: - - 'spec/classes/init_spec.rb' - # Offense count: 2 RSpec/RepeatedExampleGroupDescription: Exclude: - 'spec/defines/system_hook_spec.rb' -# Offense count: 6 -# Cop supports --auto-correct. +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Exclude: + - '**/*.arb' - 'spec/acceptance/gitlab_spec.rb' - 'spec/classes/init_spec.rb' - 'spec/defines/global_hook_spec.rb' - 'spec/defines/system_hook_spec.rb' - 'spec/spec_helper_acceptance.rb' - - 'spec/spec_helper_methods.rb' - -# Offense count: 47 -# Cop supports --auto-correct. -Style/RedundantRegexpEscape: - Exclude: - - 'spec/classes/init_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 4 diff --git a/Gemfile b/Gemfile index 5f69bec..e0c8581 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 13.0', :require => false + gem 'voxpupuli-test', '~> 14.0', :require => false gem 'puppet_metadata', '~> 6.0', :require => false end @@ -18,7 +18,7 @@ group :system_tests do end group :release do - gem 'voxpupuli-release', '~> 5.0', :require => false + gem 'voxpupuli-release', '~> 5.3', :require => false end gem 'rake', :require => false diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index e5637c4..7936e7c 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -25,6 +25,7 @@ it { is_expected.to contain_class('apt::update').that_comes_before('Class[gitlab::install]') } it { is_expected.not_to contain_apt__source('gitlab_official_') } it { is_expected.not_to contain_yumrepo('gitlab_official_ce') } + case facts[:operatingsystem] when 'Ubuntu' it { is_expected.to contain_apt__source('gitlab_official_ce').with_location('https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu') } @@ -64,6 +65,7 @@ it { is_expected.to contain_yumrepo('gitlab_official_ce').with_ensure('absent') } end end + describe 'service_manage' do let(:params) { { service_manage: true } } @@ -71,75 +73,82 @@ is_expected.to contain_service('gitlab-runsvdir').without_notify } end + describe 'service_provider_restart' do let(:params) do { service_manage: true, - service_provider_restart: true } + service_provider_restart: true, } end it { - is_expected.to contain_exec('gitlab_reconfigure'). \ - that_notifies('Service[gitlab-runsvdir]') + is_expected.to contain_exec('gitlab_reconfigure') + .that_notifies('Service[gitlab-runsvdir]') } end + describe 'external_url' do let(:params) { { external_url: 'http://gitlab.mycompany.com/' } } it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*external_url 'http:\/\/gitlab\.mycompany\.com\/'$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*external_url 'http://gitlab\.mycompany\.com/'$}) } end + describe 'external_port' do let(:params) { { external_port: 9654 } } it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*external_port '9654'$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*external_port '9654'$}) } end + describe 'nginx' do let(:params) do { nginx: { 'enable' => true, - 'listen_port' => 80 + 'listen_port' => 80, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*nginx\['enable'\] = true$}). - with_content(%r{^\s*nginx\['listen_port'\] = ('|)80('|)$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*nginx\['enable'\] = true$}) + .with_content(%r{^\s*nginx\['listen_port'\] = ('|)80('|)$}) } end + describe 'alertmanager' do let(:params) do { alertmanager: { 'enable' => true, - 'flags' => { 'cluster.advertise-address' => '127.0.0.1:9093' } + 'flags' => { 'cluster.advertise-address' => '127.0.0.1:9093' }, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*alertmanager\['enable'\] = true$}). - with_content(%r{^\s*alertmanager\['flags'\] = {\"cluster.advertise-address\"=>\"127.0.0.1:9093\"}$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*alertmanager\['enable'\] = true$}) + .with_content(%r{^\s*alertmanager\['flags'\] = {"cluster.advertise-address"=>"127.0.0.1:9093"}$}) } end + describe 'letsencrypt' do let(:params) do { letsencrypt: { 'enable' => true, - 'contact_emails' => ['test@example.com'] + 'contact_emails' => ['test@example.com'], } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*letsencrypt\['enable'\] = true$}). - with_content(%r{^\s*letsencrypt\['contact_emails'\] = \["test@example.com"\]$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*letsencrypt\['enable'\] = true$}) + .with_content(%r{^\s*letsencrypt\['contact_emails'\] = \["test@example.com"\]$}) } end + describe 'package' do let(:params) do { package: { @@ -149,35 +158,38 @@ end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*package\['systemd_after'\] = "foo.target"$}). - with_content(%r{^\s*package\['systemd_wanted_by'\] = "bar.target"$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*package\['systemd_after'\] = "foo.target"$}) + .with_content(%r{^\s*package\['systemd_wanted_by'\] = "bar.target"$}) } end + describe 'consul' do let(:params) do { consul: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*consul\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*consul\['enable'\] = true$}) } end + describe 'pgbouncer' do let(:params) do { pgbouncer: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*pgbouncer\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*pgbouncer\['enable'\] = true$}) } end + describe 'praefect' do let(:params) do { @@ -188,37 +200,41 @@ 'default' => { 'host01' => { 'address' => 'tcp://host01:8075', 'token' => 'xxx-xxx-xxx' }, 'host02' => { 'address' => 'tcp://host02:8075', 'token' => 'xxx-xxx-xxx' }, - } - } - } + }, + }, + }, } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*praefect\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*praefect\['enable'\] = true$}) } + it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*praefect\['listen_addr'\] = "0\.0\.0\.0:2305"$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*praefect\['listen_addr'\] = "0\.0\.0\.0:2305"$}) } + it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*praefect\['virtual_storage'\] = \{"default"=>\{"host01"=>\{"address"=>"tcp://host01:8075", "token"=>"xxx-xxx-xxx"\}, "host02"=>\{"address"=>"tcp://host02:8075", "token"=>"xxx-xxx-xxx"\}\}\}$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*praefect\['virtual_storage'\] = \{"default"=>\{"host01"=>\{"address"=>"tcp://host01:8075", "token"=>"xxx-xxx-xxx"\}, "host02"=>\{"address"=>"tcp://host02:8075", "token"=>"xxx-xxx-xxx"\}\}\}$}) } end + describe 'repmgr' do let(:params) do { repmgr: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*repmgr\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*repmgr\['enable'\] = true$}) } end + describe 'skip_auto_reconfigure' do let(:params) { { skip_auto_reconfigure: 'present' } } @@ -227,10 +243,11 @@ 'ensure' => 'present', 'owner' => 'root', 'group' => 'root', - 'mode' => '0644' + 'mode' => '0644', ) } end + describe 'skip_post_deployment_migrations' do let(:params) do { skip_post_deployment_migrations: true } @@ -240,10 +257,12 @@ is_expected.to contain_exec('gitlab_reconfigure').with_environment(['SKIP_POST_DEPLOYMENT_MIGRATIONS=true']) } end + context 'managing pgpass_file' do describe 'with defaults' do it { is_expected.to contain_file('/home/gitlab-consul/.pgpass').with_ensure('absent') } end + context "with pgpass_file_ensure => 'present'" do let(:params) do { pgpass_file_ensure: 'present' } @@ -252,6 +271,7 @@ describe 'without a password for pgbouncer_password' do it { is_expected.to raise_error(%r{A password must be provided to pgbouncer_password}) } end + describe 'with a password for pgbouncer_password' do let(:params) do super().merge('pgbouncer_password' => 'PAsswd') @@ -262,14 +282,15 @@ 'ensure' => 'present', 'path' => '/home/gitlab-consul/.pgpass', 'owner' => 'gitlab-consul', - 'group' => 'gitlab-consul' + 'group' => 'gitlab-consul', ).with_content( - %r{^127.0.0.1:\*:pgbouncer:pgbouncer:PAsswd} + %r{^127.0.0.1:\*:pgbouncer:pgbouncer:PAsswd}, ) } end end end + describe 'gitlab_rails with hash value' do let(:params) do { gitlab_rails: { @@ -287,56 +308,59 @@ 'allow_username_or_email_login' => false, 'block_auto_created_users' => false, 'base' => '', - 'user_filter' => '' - } + 'user_filter' => '', + }, }, 'omniauth_providers' => [ { 'name' => 'google_oauth2', 'app_id' => 'YOUR APP ID', 'app_secret' => 'YOUR APP SECRET', - 'args' => { 'access_type' => 'offline', 'approval_prompt' => '' } - } - ] + 'args' => { 'access_type' => 'offline', 'approval_prompt' => '' }, + }, + ], } } end let(:expected_content) do { - gitlab_rb__ldap_servers: %(gitlab_rails['ldap_servers'] = {"main"=>{"active_directory"=>true, "allow_username_or_email_login"=>false, "base"=>"", "bind_dn"=>"_the_full_dn_of_the_user_you_will_bind_with", "block_auto_created_users"=>false, "host"=>"_your_ldap_server", "label"=>"LDAP", "method"=>"plain", "password"=>"_the_password_of_the_bind_user", "port"=>389, "uid"=>"sAMAccountName", "user_filter"=>""}}\n) + gitlab_rb__ldap_servers: %(gitlab_rails['ldap_servers'] = {"main"=>{"active_directory"=>true, "allow_username_or_email_login"=>false, "base"=>"", "bind_dn"=>"_the_full_dn_of_the_user_you_will_bind_with", "block_auto_created_users"=>false, "host"=>"_your_ldap_server", "label"=>"LDAP", "method"=>"plain", "password"=>"_the_password_of_the_bind_user", "port"=>389, "uid"=>"sAMAccountName", "user_filter"=>""}}\n), } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_rails\['ldap_enabled'\] = true$}). - with_content(%r{\s*#{Regexp.quote(expected_content[:gitlab_rb__ldap_servers])}}m). - with_content(%r{^\s*gitlab_rails\['omniauth_providers'\] = \[{\"app_id\"=>\"YOUR APP ID\", \"app_secret\"=>\"YOUR APP SECRET\", \"args\"=>{\"access_type\"=>\"offline\", \"approval_prompt\"=>\"\"}, \"name\"=>\"google_oauth2\"}\]$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_rails\['ldap_enabled'\] = true$}) + .with_content(%r{\s*#{Regexp.quote(expected_content[:gitlab_rb__ldap_servers])}}m) + .with_content(%r{^\s*gitlab_rails\['omniauth_providers'\] = \[{"app_id"=>"YOUR APP ID", "app_secret"=>"YOUR APP SECRET", "args"=>{"access_type"=>"offline", "approval_prompt"=>""}, "name"=>"google_oauth2"}\]$}) } end + describe 'gitlab_git_http_server with hash value' do let(:params) do { gitlab_git_http_server: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_git_http_server\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_git_http_server\['enable'\] = true$}) } end + describe 'gitlab_rails with string value' do let(:params) do { gitlab_rails: { - 'backup_path' => '/opt/gitlab_backup' + 'backup_path' => '/opt/gitlab_backup', } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_rails\['backup_path'\] = "\/opt\/gitlab_backup"$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_rails\['backup_path'\] = "/opt/gitlab_backup"$}) } end + describe 'rack_attack_git_basic_auth with Numbers and Strings' do let(:params) do { @@ -346,76 +370,81 @@ 'ip_whitelist' => ['127.0.0.1', '10.0.0.0'], 'maxretry' => 10, 'findtime' => 60, - 'bantime' => 3600 - } - } + 'bantime' => 3600, + }, + }, } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_rails\['rack_attack_git_basic_auth'\] = {\"bantime\"=>3600, \"enable\"=>true, \"findtime\"=>60, \"ip_whitelist\"=>\[\"127.0.0.1\", \"10.0.0.0\"\], \"maxretry\"=>10}$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_rails\['rack_attack_git_basic_auth'\] = {"bantime"=>3600, "enable"=>true, "findtime"=>60, "ip_whitelist"=>\["127.0.0.1", "10.0.0.0"\], "maxretry"=>10}$}) } end + describe 'mattermost external URL' do let(:params) { { mattermost_external_url: 'https://mattermost.myserver.tld' } } it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*mattermost_external_url 'https:\/\/mattermost\.myserver\.tld'$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*mattermost_external_url 'https://mattermost\.myserver\.tld'$}) } end + describe 'mattermost with hash value' do let(:params) do { mattermost: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*mattermost\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*mattermost\['enable'\] = true$}) } end + describe 'with roles' do let(:params) do { - 'roles' => %w[redis_sentinel_role redis_master_role] + 'roles' => %w[redis_sentinel_role redis_master_role], } end let(:expected_content) do { - roles: %(roles ["redis_sentinel_role", "redis_master_role"]) + roles: %(roles ["redis_sentinel_role", "redis_master_role"]), } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). - with_content(%r{\s*#{Regexp.quote(expected_content[:roles])}}m) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{\s*#{Regexp.quote(expected_content[:roles])}}m) } end + describe 'with data_dirs' do let(:params) do { 'git_data_dirs' => { 'default' => { - 'path' => '/git-data/data' - } - } + 'path' => '/git-data/data', + }, + }, } end let(:expected_content) do { - datadirs: %(git_data_dirs({"default"=>{"path"=>"/git-data/data"}})\n) + datadirs: %(git_data_dirs({"default"=>{"path"=>"/git-data/data"}})\n), } end it do - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). - with_content(%r{\s*#{Regexp.quote(expected_content[:datadirs])}}m) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{\s*#{Regexp.quote(expected_content[:datadirs])}}m) end end + describe 'with store_git_keys_in_db' do let(:params) { { store_git_keys_in_db: true } } @@ -423,85 +452,93 @@ is_expected.to contain_file('/opt/gitlab-shell/authorized_keys') end end + describe 'gitlab_monitor' do let(:params) do { gitlab_monitor: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_monitor\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_monitor\['enable'\] = true$}) } + it { is_expected.to contain_notify("DEPRECTATION: 'gitlab_monitor' is deprecated if using GitLab 12.3 or greater. Set 'gitlab_exporter' instead") } end + describe 'gitlab_exporter' do let(:params) do { gitlab_exporter: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_exporter\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_exporter\['enable'\] = true$}) } end + describe 'puma' do let(:params) do { puma: { 'enable' => true, 'worker_processes' => 3, - 'worker_timeout' => 60 + 'worker_timeout' => 60, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). - with_content(%r{^\s*puma\['enable'\] = true$}). - with_content(%r{^\s*puma\['worker_processes'\] = 3$}). - with_content(%r{^\s*puma\['worker_timeout'\] = 60$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*puma\['enable'\] = true$}) + .with_content(%r{^\s*puma\['worker_processes'\] = 3$}) + .with_content(%r{^\s*puma\['worker_timeout'\] = 60$}) } end + describe 'pgbouncer_exporter' do let(:params) do { pgbouncer_exporter: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*pgbouncer_exporter\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*pgbouncer_exporter\['enable'\] = true$}) } end + describe 'geo_logcursor' do let(:params) do { geo_logcursor: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*geo_logcursor\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*geo_logcursor\['enable'\] = true$}) } end + describe 'gitlab_sshd' do let(:params) do { gitlab_sshd: { - 'enable' => true + 'enable' => true, } } end it { - is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ - with_content(%r{^\s*gitlab_sshd\['enable'\] = true$}) + is_expected.to contain_file('/etc/gitlab/gitlab.rb') + .with_content(%r{^\s*gitlab_sshd\['enable'\] = true$}) } end + describe 'package_hold' do let(:params) do { package_ensure: '16.10.3-ce.0', package_hold: 'hold' } @@ -519,8 +556,8 @@ let(:facts) do { 'os' => { - 'family' => 'Solaris' - } + 'family' => 'Solaris', + }, } end diff --git a/spec/defines/custom_hook_spec.rb b/spec/defines/custom_hook_spec.rb index 949d0ab..66307be 100644 --- a/spec/defines/custom_hook_spec.rb +++ b/spec/defines/custom_hook_spec.rb @@ -13,7 +13,7 @@ class { 'gitlab': MANIFEST end - ['post-receive', 'pre-receive', 'update'].each do |type| + %w[post-receive pre-receive update].each do |type| context "with type => #{type} and source" do let(:source) { 'puppet:///modules/my_module/post-receive' } let(:params) do @@ -22,21 +22,21 @@ class { 'gitlab': repos_path: '/custom/hooks/dir', source: source, namespace: 'foo', - project: 'bar' + project: 'bar', } end it { is_expected.to compile } it do - is_expected.to contain_file('/custom/hooks/dir/foo/bar.git/custom_hooks'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir/foo/bar.git/custom_hooks') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/foo/bar.git/custom_hooks/#{type}"). - with_ensure('file'). - with_source(source) + is_expected.to contain_file("/custom/hooks/dir/foo/bar.git/custom_hooks/#{type}") + .with_ensure('file') + .with_source(source) end end @@ -48,21 +48,21 @@ class { 'gitlab': repos_path: '/custom/hooks/dir', content: content, namespace: 'foo', - project: 'bar' + project: 'bar', } end it { is_expected.to compile } it do - is_expected.to contain_file('/custom/hooks/dir/foo/bar.git/custom_hooks'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir/foo/bar.git/custom_hooks') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/foo/bar.git/custom_hooks/#{type}"). - with_ensure('file'). - with_content(content) + is_expected.to contain_file("/custom/hooks/dir/foo/bar.git/custom_hooks/#{type}") + .with_ensure('file') + .with_content(content) end end @@ -74,21 +74,21 @@ class { 'gitlab': repos_path: '/custom/hooks/dir', content: content, hashed_storage: true, - project: '6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d' + project: '6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d', } end it { is_expected.to compile } it do - is_expected.to contain_file('/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks/#{type}"). - with_ensure('file'). - with_content(content) + is_expected.to contain_file("/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks/#{type}") + .with_ensure('file') + .with_content(content) end end @@ -100,21 +100,21 @@ class { 'gitlab': repos_path: '/custom/hooks/dir', content: content, hashed_storage: true, - project: 93 + project: 93, } end it { is_expected.to compile } it do - is_expected.to contain_file('/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks/#{type}"). - with_ensure('file'). - with_content(content) + is_expected.to contain_file("/custom/hooks/dir/@hashed/6e/40/6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e301f5c4a35a4d.git/custom_hooks/#{type}") + .with_ensure('file') + .with_content(content) end end end diff --git a/spec/defines/global_hook_spec.rb b/spec/defines/global_hook_spec.rb index 632e282..6feb276 100644 --- a/spec/defines/global_hook_spec.rb +++ b/spec/defines/global_hook_spec.rb @@ -11,28 +11,28 @@ class { 'gitlab': MANIFEST end - ['post-receive', 'pre-receive', 'update'].each do |type| + %w[post-receive pre-receive update].each do |type| context "with type => #{type} and source" do let(:source) { 'puppet:///modules/my_module/post-receive' } let(:params) do { type: type, custom_hooks_dir: '/custom/hooks/dir', - source: source + source: source, } end it { is_expected.to compile } it do - is_expected.to contain_file("/custom/hooks/dir/#{type}.d"). - with_ensure('directory') + is_expected.to contain_file("/custom/hooks/dir/#{type}.d") + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/#{type}.d/#{title}"). - with_ensure('file'). - with_source(source) + is_expected.to contain_file("/custom/hooks/dir/#{type}.d/#{title}") + .with_ensure('file') + .with_source(source) end end @@ -42,21 +42,21 @@ class { 'gitlab': { type: type, custom_hooks_dir: '/custom/hooks/dir', - content: content + content: content, } end it { is_expected.to compile } it do - is_expected.to contain_file("/custom/hooks/dir/#{type}.d"). - with_ensure('directory') + is_expected.to contain_file("/custom/hooks/dir/#{type}.d") + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/#{type}.d/#{title}"). - with_ensure('file'). - with_content(content) + is_expected.to contain_file("/custom/hooks/dir/#{type}.d/#{title}") + .with_ensure('file') + .with_content(content) end end end diff --git a/spec/defines/system_hook_spec.rb b/spec/defines/system_hook_spec.rb index 6bb3a3c..a327c7e 100644 --- a/spec/defines/system_hook_spec.rb +++ b/spec/defines/system_hook_spec.rb @@ -16,21 +16,21 @@ class { 'gitlab': let(:params) do { system_hooks_dir: '/custom/hooks/dir', - source: source + source: source, } end it { is_expected.to compile.with_all_deps } it do - is_expected.to contain_file('/custom/hooks/dir'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/#{title}"). - with_ensure('file'). - with_source(source) + is_expected.to contain_file("/custom/hooks/dir/#{title}") + .with_ensure('file') + .with_source(source) end end @@ -39,21 +39,21 @@ class { 'gitlab': let(:params) do { system_hooks_dir: '/custom/hooks/dir', - content: content + content: content, } end it { is_expected.to compile.with_all_deps } it do - is_expected.to contain_file('/custom/hooks/dir'). - with_ensure('directory') + is_expected.to contain_file('/custom/hooks/dir') + .with_ensure('directory') end it do - is_expected.to contain_file("/custom/hooks/dir/#{title}"). - with_ensure('file'). - with_content(content) + is_expected.to contain_file("/custom/hooks/dir/#{title}") + .with_ensure('file') + .with_content(content) end end end