diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ef738514..f7e22540a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -166,7 +166,8 @@ def cx_collection_permissions?(cx_collection:) return false if cx_collection.blank? return true if performance_manager_permissions? - cx_collection.organization == current_user.organization + cx_collection.organization == current_user.organization || + cx_collection.organization == (current_user.organization.parent ? current_user.organization.parent : nil) end helper_method :website_permissions? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f3575fe94..d6cce44e7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,11 +22,13 @@ def organization_abbreviation_dropdown_options end def us_timezones - us_timezones = ActiveSupport::TimeZone["Eastern Time (US & Canada)"], + [ + ActiveSupport::TimeZone["Eastern Time (US & Canada)"], ActiveSupport::TimeZone["Central Time (US & Canada)"], ActiveSupport::TimeZone["Mountain Time (US & Canada)"], ActiveSupport::TimeZone["Pacific Time (US & Canada)"], ActiveSupport::TimeZone["Hawaii"] + ] end def hisp_questions_key diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml index 26faf8711..5e0136468 100644 --- a/config/locales/en-US.yml +++ b/config/locales/en-US.yml @@ -9,6 +9,7 @@ en-US: - Fri - Sat abbr_month_names: + - - Jan - Feb - Mar @@ -34,6 +35,7 @@ en-US: long: "%B %d, %Y" short: "%b %d" month_names: + - - January - February - March diff --git a/config/locales/en.yml b/config/locales/en.yml index c0b39c18f..9b7ab8b32 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -56,6 +56,7 @@ en-US: pm: pm date: abbr_month_names: + - - Jan - Feb - Mar @@ -69,6 +70,7 @@ en-US: - Nov - Dec month_names: + - - January - February - March diff --git a/config/locales/es.yml b/config/locales/es.yml index 425ff3e07..5a4771267 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -67,6 +67,7 @@ es: - vie - sáb abbr_month_names: + - - ene - feb - mar @@ -93,6 +94,7 @@ es: with_timezone: "%-d de %B de %Y (UTC%:z)" short: "%-d de %b" month_names: + - - enero - febrero - marzo diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 200f6e500..0395aa46c 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -87,6 +87,7 @@ zh-CN: - 周五 - 周六 abbr_month_names: + - - 1月 - 2月 - 3月 @@ -113,6 +114,7 @@ zh-CN: with_timezone: "%Y年%m月%d日 (%:z)" short: "%m月%d日" month_names: + - - 一月 - 二月 - 三月 diff --git a/spec/factories/organization.rb b/spec/factories/organization.rb index 0fae45493..dff94a8de 100644 --- a/spec/factories/organization.rb +++ b/spec/factories/organization.rb @@ -8,6 +8,14 @@ url { 'https://example.gov' } notes { 'Notes about this Organization' } + trait :parent do + name { 'Parent.gov' } + domain { 'parent.gov' } + abbreviation { 'PO' } + url { 'https://parent.gov' } + notes { 'Notes about parent Organization' } + end + trait :another do name { 'Another.gov' } domain { 'another.gov' } diff --git a/spec/features/admin/cx_collections_spec.rb b/spec/features/admin/cx_collections_spec.rb index 67fba2a41..c6c9cedc0 100644 --- a/spec/features/admin/cx_collections_spec.rb +++ b/spec/features/admin/cx_collections_spec.rb @@ -4,13 +4,14 @@ feature 'CX Data Collections', js: true do let(:organization) { FactoryBot.create(:organization) } - let(:another_organization) { FactoryBot.create(:organization, :another) } + let(:parent_organization) { FactoryBot.create(:organization, :parent ) } + let!(:parent_service_provider) { FactoryBot.create(:service_provider, organization: parent_organization, name: 'Parent HISP') } + let(:another_organization) { FactoryBot.create(:organization, :another, parent_id: parent_organization.id) } let!(:another_service_provider) { FactoryBot.create(:service_provider, organization: another_organization, name: 'Another HISP') } let(:admin) { FactoryBot.create(:user, :admin, organization:) } let(:user) { FactoryBot.create(:user, organization: another_organization) } let!(:service_provider) { FactoryBot.create(:service_provider, organization:) } let!(:service) { FactoryBot.create(:service, organization:, service_provider: service_provider, hisp: true, service_owner_id: user.id) } - let!(:service_provider2) { FactoryBot.create(:service_provider, organization:, name: "Another service provider") } let!(:service2) { FactoryBot.create(:service, organization:, service_provider: service_provider2, name: "Another public service", hisp: true, service_owner_id: user.id) } @@ -169,11 +170,18 @@ end describe 'GET /show' do - let(:collection) { FactoryBot.create(:collection, organization: another_organization, user:, service_provider: another_service_provider) } + let!(:parent_collection) { FactoryBot.create(:cx_collection, organization: parent_organization, user:, service_provider: parent_service_provider, service: service) } - it 'renders a successful response' do + it 'renders CX Collection for Another org' do visit admin_cx_collection_path(cx_collection) expect(page).to have_content('Data Collections') + expect(page).to have_content('Another.gov') + end + + it 'renders CX Collection for Parent org' do + visit admin_cx_collection_path(parent_collection) + expect(page).to have_content('Data Collections') + expect(page).to have_content('Parent.gov') end end diff --git a/spec/features/admin/forms_spec.rb b/spec/features/admin/forms_spec.rb index d8827c6e4..e3ef9f519 100644 --- a/spec/features/admin/forms_spec.rb +++ b/spec/features/admin/forms_spec.rb @@ -756,6 +756,7 @@ describe 'editing form timezone' do let!(:form_with_responses) { FactoryBot.create(:form, :single_question, :with_responses, organization:) } + let!(:additional_response) { FactoryBot.create(:submission, form: form_with_responses, answer_01: "hi", created_at: "2025-01-02") } let!(:user_role) { FactoryBot.create(:user_role, :form_manager, user: admin, form: form_with_responses) } before do @@ -764,9 +765,14 @@ expect(page).to have_content('Form Manager forms options updated successfully') end - it 'can view submissions with a form time_zone' do + it 'renders valid time' do visit responses_admin_form_path(form_with_responses) - expect(page.all("#submissions_table .usa-table.submissions tbody tr").size).to eq(3) + expect(page.all("#submissions_table .usa-table.submissions tbody tr").size).to eq(4) + end + + it 'ensure format_time translation is correct' do + visit responses_admin_form_path(form_with_responses) + expect(all("#submissions_table .usa-table.submissions tbody tr").last).to have_content("January 01, 2025") end end