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

Allow talk proposals to elect a particular month. Closes #33 #44

Closed
wants to merge 4 commits into from
Closed

Allow talk proposals to elect a particular month. Closes #33 #44

wants to merge 4 commits into from

Conversation

dreadwail
Copy link
Contributor

No description provided.

@dreadwail
Copy link
Contributor Author

Now that I've sent this PR, I'm actually reconsidering one aspect of it. In it's current form the following scenario is possible:
If it's November and I select January it will default to last January (not the upcoming January).
So I'll probably change this to have further granularity. It will also be nice since the form can display the month/year instead of just month.

validates :proposed_month, allow_blank: true, numericality: {
greater_than: 0,
less_than_or_equal_to: 12
}
Copy link
Member

Choose a reason for hiding this comment

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

You could do this more concisely as something like:

validates_inclusion_of :proposed_month, :in => 1..12

@phiggins
Copy link
Member

In the abscence of #30 and #31 being completed, I think the simplest way to do this would be to have a helper method that would generate the dates of the next 12 meetups or so and jam those into the select tag. This would also allow the display of what day that was, rather than just the month. This could be more work than its worth, however, so I'm not completely opposed to your implementation. WDYT?

@dreadwail
Copy link
Contributor Author

Yep that's the route I referred to in my comment above. The above line issues you pointed out are moot with the new solution. Updated PR incoming shortly.

@dreadwail
Copy link
Contributor Author

Alright @phiggins have a gander.

@phiggins
Copy link
Member

Overall this looks good @benlakey. 👍

Please let me know if the comments I made don't make sense or if you'd like to discuss.

validate :proposed_date_valid?

def proposed_date_valid?
return if proposed_date.blank?
Copy link
Member

Choose a reason for hiding this comment

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

This should probably return true because the name implies it.

Copy link
Member

Choose a reason for hiding this comment

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

On second thought, I was thinking of the case where this used as an external query method, but that's not a use case we have. Make this private instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do one better: I'll rename it "validate_proposed_date" and make it private.

@phiggins
Copy link
Member

You should add a test for submitting a talk with a valid date and verifying that the record has the correct date associated with it.

1.upto(12).map do |increment|
future_month = Date.today >> increment
option = Date.new(future_month.year, future_month.month, 1)
option += 1 until option.tuesday?
Copy link
Member

Choose a reason for hiding this comment

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

Next month's meeting proves this code wrong. It is too exacting and doesn't take reality into account.

12 months out seems completely unrealistic and prone to failure/disappointment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zenspider On your first statement I'd argue that no pre-fab select list will be able to predict the future. When #33 is complete the data can be fed from there. So for now this is the best we can do.

As far as the 12-months-out case; Would 6 months be preferable? I have no strong opinions about this so if you want to provide a value I'll plug it in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phiggins I'm not sure what you're looking for with the test you suggested adding. The proposed_date attribute has no special logic around it so I don't know what value we'd get by testing that a thing got saved via activerecord and pulling it out again (seems like that'd just be testing activerecord). The validation aspect already has a test. Let me know if you had something different in mind.

Copy link
Member

Choose a reason for hiding this comment

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

I meant that if there was a test for submitting a talk through the controller that you should augment it to include a proposed date. This would help verify that the date survives going through the controller and strong_params / mass assignment, etc.

Again, not a huge deal, but a nice to have.

@dreadwail dreadwail closed this Mar 17, 2014
@dreadwail dreadwail reopened this Mar 17, 2014
@dreadwail
Copy link
Contributor Author

Oops I didn't mean to close and re-open this...

@dreadwail
Copy link
Contributor Author

Ok @phiggins I incorporated the last of your feedback. This should be pullable now unless @zenspider has strong feelings about the short-term solution we've got here (pre-fab select list until we have the calendar solution in place).

@dreadwail
Copy link
Contributor Author

Closing in favor of future calendar solution

@dreadwail dreadwail closed this Mar 19, 2014
@seattlerb seattlerb locked and limited conversation to collaborators Jan 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants