|
124 | 124 | expect(subject.errors[:date_range]).to be_empty
|
125 | 125 | end
|
126 | 126 | end
|
127 |
| - |
128 |
| - describe "#working_days_count" do |
129 |
| - it "returns nil if not_set? is true" do |
130 |
| - allow(Day).to receive(:working) |
131 |
| - |
132 |
| - subject.start_date = nil |
133 |
| - subject.finish_date = nil |
134 |
| - |
135 |
| - expect(subject.working_days_count).to be_nil |
136 |
| - expect(Day).not_to have_received(:working) |
137 |
| - end |
138 |
| - |
139 |
| - it "returns the correct number of days if start_date and finish_date are the same" do |
140 |
| - subject.start_date = Time.zone.today |
141 |
| - subject.finish_date = Time.zone.today |
142 |
| - expect(subject.working_days_count).to eq(1) |
143 |
| - end |
144 |
| - |
145 |
| - it "returns the correct number of days for a valid date range" do |
146 |
| - subject.start_date = Date.parse("2024-11-25") |
147 |
| - subject.finish_date = Date.parse("2024-11-27") |
148 |
| - expect(subject.working_days_count).to eq(3) |
149 |
| - end |
150 |
| - |
151 |
| - it "calls the Day.working.from_range method with the right arguments" do |
152 |
| - subject.start_date = Date.parse("2024-11-25") |
153 |
| - subject.finish_date = Date.parse("2024-11-27") |
154 |
| - |
155 |
| - allow(Day).to receive(:working).and_return(Day) |
156 |
| - allow(Day).to receive(:from_range) |
157 |
| - .with(from: subject.start_date, to: subject.finish_date) |
158 |
| - .and_return([]) |
159 |
| - |
160 |
| - expect(subject.working_days_count).to eq(0) |
161 |
| - |
162 |
| - expect(Day).to have_received(:working).with(no_args) |
163 |
| - expect(Day).to have_received(:from_range).with(from: subject.start_date, to: subject.finish_date) |
164 |
| - end |
165 |
| - end |
166 | 127 | end
|
0 commit comments