|
45 | 45 | end |
46 | 46 | end |
47 | 47 |
|
48 | | - describe "#batch_csv_filename" do |
| 48 | + describe "#daily_batch_csv_filename" do |
| 49 | + subject(:filename) { described_class.daily_batch_csv_filename(form_name:, mode:, csv_version:, date:) } |
| 50 | + |
49 | 51 | let(:date) { Time.zone.local(2024, 6, 1) } |
50 | 52 | let(:mode) { instance_double(Mode, preview?: false) } |
51 | | - let(:form_version) { "1" } |
| 53 | + let(:csv_version) { "1" } |
52 | 54 |
|
53 | 55 | context "when there is a long form name that would cause the filename to be longer than 100 characters" do |
54 | 56 | let(:form_name) { "A form name that will cause the filename to be truncated to obey the limit" } |
55 | 57 |
|
56 | 58 | it "truncates the form name in the filename" do |
57 | | - filename = described_class.batch_csv_filename(form_name:, date:, mode:, form_version:) |
58 | 59 | expect(filename).to eq("govuk_forms_a_form_name_that_will_cause_the_filename_to_be_truncated_to_obey_the_2024-06-01_1.csv") |
59 | 60 | end |
60 | 61 | end |
|
63 | 64 | let(:form_name) { "Form name that will cause the filename to be 100 characters long exact" } |
64 | 65 |
|
65 | 66 | it "does not truncate the form name in the filename" do |
66 | | - filename = described_class.batch_csv_filename(form_name:, date:, mode:, form_version:) |
67 | 67 | expect(filename).to eq("govuk_forms_form_name_that_will_cause_the_filename_to_be_100_characters_long_exact_2024-06-01_1.csv") |
68 | 68 | end |
69 | 69 | end |
70 | 70 |
|
71 | 71 | context "when there is no form version provided" do |
72 | 72 | let(:form_name) { "Form name" } |
73 | | - let(:form_version) { nil } |
| 73 | + let(:csv_version) { nil } |
74 | 74 |
|
75 | 75 | it "does not include the form version in the filename" do |
76 | | - filename = described_class.batch_csv_filename(form_name:, date:, mode:, form_version:) |
77 | 76 | expect(filename).to eq("govuk_forms_form_name_2024-06-01.csv") |
78 | 77 | end |
79 | 78 | end |
|
83 | 82 | let(:form_name) { "Form name" } |
84 | 83 |
|
85 | 84 | it "includes 'test_' in the filename" do |
86 | | - filename = described_class.batch_csv_filename(form_name:, date:, mode:, form_version:) |
87 | 85 | expect(filename).to eq("test_govuk_forms_form_name_2024-06-01_1.csv") |
88 | 86 | end |
89 | 87 |
|
90 | 88 | context "when the form name would cause the filename to be over 100 characters long including the 'test_' prefix" do |
91 | 89 | let(:form_name) { "A form name that will cause the filename to be truncated to obey the limit" } |
92 | 90 |
|
93 | 91 | it "truncates the form name in the filename" do |
94 | | - filename = described_class.batch_csv_filename(form_name:, date:, mode:, form_version:) |
95 | 92 | expect(filename).to eq("test_govuk_forms_a_form_name_that_will_cause_the_filename_to_be_truncated_to_obey_2024-06-01_1.csv") |
96 | 93 | end |
97 | 94 | end |
98 | 95 | end |
99 | 96 | end |
| 97 | + |
| 98 | + describe "#weekly_batch_csv_filename" do |
| 99 | + subject(:filename) { described_class.weekly_batch_csv_filename(form_name:, mode:, csv_version:, begin_date:, end_date:) } |
| 100 | + |
| 101 | + let(:begin_date) { Time.zone.local(2024, 6, 1) } |
| 102 | + let(:end_date) { Time.zone.local(2024, 6, 7) } |
| 103 | + let(:mode) { instance_double(Mode, preview?: false) } |
| 104 | + let(:csv_version) { "1" } |
| 105 | + |
| 106 | + context "when there is a long form name that would cause the filename to be longer than 100 characters" do |
| 107 | + let(:form_name) { "A form name that will cause the filename to be truncated to obey" } |
| 108 | + |
| 109 | + it "truncates the form name in the filename" do |
| 110 | + expect(filename).to eq("govuk_forms_a_form_name_that_will_cause_the_filename_to_be_truncated_to_2024-06-01-2024-06-07_1.csv") |
| 111 | + end |
| 112 | + end |
| 113 | + |
| 114 | + context "when the form name would cause the filename to be exactly 100 characters long" do |
| 115 | + let(:form_name) { "Form name that will cause the filename to be 100 characterss" } |
| 116 | + |
| 117 | + it "does not truncate the form name in the filename" do |
| 118 | + expect(filename).to eq("govuk_forms_form_name_that_will_cause_the_filename_to_be_100_characterss_2024-06-01-2024-06-07_1.csv") |
| 119 | + end |
| 120 | + end |
| 121 | + |
| 122 | + context "when there is no form version provided" do |
| 123 | + let(:form_name) { "Form name" } |
| 124 | + let(:csv_version) { nil } |
| 125 | + |
| 126 | + it "does not include the form version in the filename" do |
| 127 | + expect(filename).to eq("govuk_forms_form_name_2024-06-01-2024-06-07.csv") |
| 128 | + end |
| 129 | + end |
| 130 | + |
| 131 | + context "when the mode is preview" do |
| 132 | + let(:mode) { instance_double(Mode, preview?: true) } |
| 133 | + let(:form_name) { "Form name" } |
| 134 | + |
| 135 | + it "includes 'test_' in the filename" do |
| 136 | + expect(filename).to eq("test_govuk_forms_form_name_2024-06-01-2024-06-07_1.csv") |
| 137 | + end |
| 138 | + |
| 139 | + context "when the form name would cause the filename to be over 100 characters long including the 'test_' prefix" do |
| 140 | + let(:form_name) { "A form name that will cause the filename to be truncated" } |
| 141 | + |
| 142 | + it "truncates the form name in the filename" do |
| 143 | + expect(filename).to eq("test_govuk_forms_a_form_name_that_will_cause_the_filename_to_be_2024-06-01-2024-06-07_1.csv") |
| 144 | + end |
| 145 | + end |
| 146 | + end |
| 147 | + end |
100 | 148 | end |
0 commit comments