Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4174 Add Last Distribution Date column on the Organization view for Super Admin user. #4207

Conversation

pshong79
Copy link
Collaborator

Resolves #4174

Description

This change adds the Last Distribution Date to the Organization view for the Super Admin user.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Test manually visually.
  • Added a test in the organization_requests_spec.rb file to verify all the data returned for an organization, including the last_distribution_date

Screenshots

Before:
Screenshot 2024-03-20 at 11 50 08

After:
Screenshot 2024-03-20 at 11 45 28

@pshong79
Copy link
Collaborator Author

Removing In Progress label. I was seeing a test fail which was unrelated to any of my changes. It is passing now. 🤷‍♂️

@pshong79 pshong79 changed the title 4171 Add Last Distribution Date column on the Organization view for Super Admin user. 4174 Add Last Distribution Date column on the Organization view for Super Admin user. Mar 21, 2024
@@ -264,6 +264,11 @@ def earliest_reporting_year
year
end

def last_distribution_date
distribution = distributions.order(issued_at: :desc).first
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call this display_last_distribution_date rather than last_distribution_date. Naming it last_distribution_date implies that it is a date, to me, anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I've made this change and have pushed up the changes.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality works great! @dorner - do you have any concerns about the code?

it { expect(response).to be_successful }

it 'organization details' do
expect(assigns(:organization)).to have_attributes(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this spec as super helpful - you're diving way deep into the weeds of implementation. I'd rather look at the rendered text and verify that the value you expect to see is there. In this case you should use travel_to to lock in the date and time, update the organization to have specified values, and then expect those values to be in the output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will take a look at this again. Sorry, I have not forgotten about this. I just got a new Macbook and am still in the process of getting things up and running!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorner Starting to take a look at this now and trying to wrap my head around your suggestion. Sorry, I'm still relatively newer and still learning a lot. Do you know if there is something similar or an example I can look at?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example of the traveling:

travel_to Time.zone.local(2019, 6, 30)

and here's how you can check the rendered text:

expect(response.body).to include("John Doe")

You can get more nitty-gritty by actually turning the text into DOM and checking it specifically:

expect(page.css(".deactivate-kit-button")).not_to be_empty

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we actually need to travel-to to test this out -- we're looking at the issued_at, rather than the created_at for the last distribution date, and that is "manually" set. Or am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kind of been struggling with how to use travel_to with the issued_at myself...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad - as usual @cielf is right 😃

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can I resolve this conversation and we're good to go with this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - it's still an issue IMO. You shouldn't be looking at assigns - it's better to look at the rendered text.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took waaaay longer than I had hoped and expected. I think I figured it out though and, of course, it seems to be way simpler than I had made it out to be.
Sorry, that it took so long.... still learning over here 🙃

@dorner dorner merged commit bed5a24 into rubyforgood:main Apr 9, 2024
19 checks passed
@dorner
Copy link
Collaborator

dorner commented Apr 9, 2024

Nice, thanks!

Copy link
Contributor

@pshong79: Your PR 4174 Add Last Distribution Date column on the Organization view for Super Admin user. is part of today's Human Essentials production release: 2024.04.14.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants