|
107 | 107 |
|
108 | 108 | describe 'users' do |
109 | 109 | subject { organization.users } |
110 | | - let(:organization) { create(:organization) } |
111 | 110 |
|
112 | 111 | context 'when a organizaton has a user that has two roles' do |
113 | 112 | let(:user) { create(:user) } |
|
361 | 360 | end |
362 | 361 |
|
363 | 362 | context 'with invisible items' do |
364 | | - let!(:organization) { create(:organization) } |
365 | 363 | let!(:item1) { create(:item, organization: organization, active: true, visible_to_partners: true) } |
366 | 364 | let!(:item2) { create(:item, organization: organization, active: true, visible_to_partners: false) } |
367 | 365 | let!(:item3) { create(:item, organization: organization, active: false, visible_to_partners: true) } |
|
401 | 399 | describe 'earliest reporting year' do |
402 | 400 | # re 2813 update annual report -- allowing an earliest reporting year will let us do system testing and staging for annual reports |
403 | 401 | it 'is the organization created year if no associated data' do |
404 | | - org = create(:organization) |
405 | | - expect(org.earliest_reporting_year).to eq(org.created_at.year) |
| 402 | + expect(organization.earliest_reporting_year).to eq(organization.created_at.year) |
406 | 403 | end |
| 404 | + |
407 | 405 | it 'is the year of the earliest of donation, purchase, or distribution if they are earlier ' do |
408 | | - org = create(:organization) |
409 | | - create(:donation, organization: org, issued_at: 364.days.from_now) |
410 | | - create(:purchase, organization: org, issued_at: 364.days.from_now) |
411 | | - create(:distribution, organization: org, issued_at: 364.days.from_now) |
412 | | - expect(org.earliest_reporting_year).to eq(org.created_at.year) |
413 | | - create(:donation, organization: org, issued_at: 5.years.ago) |
414 | | - expect(org.earliest_reporting_year).to eq(5.years.ago.year) |
415 | | - create(:purchase, organization: org, issued_at: 6.years.ago) |
416 | | - expect(org.earliest_reporting_year).to eq(6.years.ago.year) |
417 | | - create(:purchase, organization: org, issued_at: 7.years.ago) |
418 | | - expect(org.earliest_reporting_year).to eq(7.years.ago.year) |
| 406 | + freeze_time do |
| 407 | + create(:donation, organization: organization, issued_at: DateTime.current.next_year - 1.day) |
| 408 | + create(:purchase, organization: organization, issued_at: DateTime.current.next_year - 1.day) |
| 409 | + create(:distribution, organization: organization, issued_at: DateTime.current.next_year - 1.day) |
| 410 | + expect(organization.earliest_reporting_year).to eq(organization.created_at.year) |
| 411 | + create(:donation, organization: organization, issued_at: 5.years.ago) |
| 412 | + expect(organization.earliest_reporting_year).to eq(5.years.ago.year) |
| 413 | + create(:purchase, organization: organization, issued_at: 6.years.ago) |
| 414 | + expect(organization.earliest_reporting_year).to eq(6.years.ago.year) |
| 415 | + create(:purchase, organization: organization, issued_at: 7.years.ago) |
| 416 | + expect(organization.earliest_reporting_year).to eq(7.years.ago.year) |
| 417 | + ensure |
| 418 | + travel_back |
| 419 | + end |
419 | 420 | end |
420 | 421 | end |
421 | 422 |
|
|
0 commit comments