From a67e577a16f6669d334660c1e1c24ac4e85e615e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:09:05 +0000 Subject: [PATCH 1/3] Initial plan From 5b0278c76bab3b1e359dfef96e350148db1edc65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:14:44 +0000 Subject: [PATCH 2/3] Extract config_file method from action_class to enable external access Co-authored-by: damacus <40786+damacus@users.noreply.github.com> --- resources/site.rb | 8 ++++---- spec/unit/resources/site_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/resources/site.rb b/resources/site.rb index 18d6bd078..7189ba82b 100644 --- a/resources/site.rb +++ b/resources/site.rb @@ -63,13 +63,13 @@ description: 'Additional helper modules to include in the site template', coerce: proc { |p| p.is_a?(Array) ? p : [p] } +def config_file + ::File.join(conf_dir, "#{name}.conf") +end + action_class do include Nginx::Cookbook::ResourceHelpers - def config_file - ::File.join(new_resource.conf_dir, "#{new_resource.name}.conf") - end - def config_file_disabled "#{config_file}.disabled" end diff --git a/spec/unit/resources/site_spec.rb b/spec/unit/resources/site_spec.rb index 0207df860..42d8a060e 100644 --- a/spec/unit/resources/site_spec.rb +++ b/spec/unit/resources/site_spec.rb @@ -46,4 +46,28 @@ it { is_expected.to delete_file('/etc/nginx/conf.http.d/default.conf') } end + + context 'config_file method accessibility' do + recipe do + nginx_install 'distro' + + site = nginx_site 'test-site' do + conf_dir '/etc/nginx/sites-available' + action :create + end + + # This tests the new functionality - accessing config_file on the resource instance + ruby_block 'test_config_file_access' do + block do + expected_path = '/etc/nginx/sites-available/test-site.conf' + actual_path = site.config_file + raise "Expected #{expected_path}, got #{actual_path}" unless actual_path == expected_path + end + action :run + end + end + + it { is_expected.to create_template('/etc/nginx/sites-available/test-site.conf') } + it { is_expected.to run_ruby_block('test_config_file_access') } + end end From 13f62b2efe75cd31526fc49e480d137945779de9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 08:35:47 +0000 Subject: [PATCH 3/3] Extract config_file logic to helpers.rb Co-authored-by: damacus <40786+damacus@users.noreply.github.com> --- libraries/helpers.rb | 4 ++++ resources/site.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 2bbae718e..e5dd39a48 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -104,6 +104,10 @@ def debian_9? def ubuntu_18? platform?('ubuntu') && node['platform_version'].to_f == 18.04 end + + def nginx_site_config_file(conf_dir, site_name) + ::File.join(conf_dir, "#{site_name}.conf") + end end end end diff --git a/resources/site.rb b/resources/site.rb index 7189ba82b..43e5606ec 100644 --- a/resources/site.rb +++ b/resources/site.rb @@ -64,7 +64,7 @@ coerce: proc { |p| p.is_a?(Array) ? p : [p] } def config_file - ::File.join(conf_dir, "#{name}.conf") + nginx_site_config_file(conf_dir, name) end action_class do