-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add form for a person to contribute suggested councillor info #1208
Add form for a person to contribute suggested councillor info #1208
Conversation
…ustralia/planningalerts into person_contributes_councillor_info
…gested_councillors controllor
…ncillo in authority model, and changed the create method to use build in suggested_councillor controllerr
…ontributes_councillor_info_2 Added model, controller and view for suggested councillors.
The test for Council Name is nested in the feature_flag_is_on test, so that the feature is visible in the test environment.
to make it more readable and clear. still need some styling.
To separate the test exercise and test expectation.
…cillor_council_name Suggested councillor council name
to add a contributor info form in the suggested councillor.
The user has just submitted all these councillors themselves, so I don't think they need to be told where this list came from. This heading is also confusing as it comes above the form to put in a new councillor.
The heading of the page explains that this is for adding councillors, so I don't think we need to restate that here. This commit also changes the tests to use css to target the fieldset, rather than the text of the legend (now missing).
This makes it more the focus of the page and sets it apart from the other details, like the labels.
This pushes the actual data you're looking at forward a bit.
There's a bug in there flexbox implementation that a fieldset element can't be a flex container. Adding a wrapper div is the workaround. See https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers
…ontribution_basic_styles Add basic styles to the councillor contribution form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hisayohorie and I went through this and we found a few bits we want to improve before merging.
Looking really good though 💯 😄 looking forward to getting this deployed!
end | ||
end | ||
|
||
private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be indented to the same level as the methods it covers below.
app/models/contributor.rb
Outdated
@@ -0,0 +1,4 @@ | |||
class Contributor < ActiveRecord::Base | |||
has_many :suggested_councillors, through: :councillor_contributions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this association necessary? If we're not using it we should remove that line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested_councillor_spec.rb
anduser_contributes_new_councillor_spec.rb
pass without this association. Currently we don't have the controller/councillor_contribution_controller_spec.rb
nor model/contributor_spec_rb
so if we get to the stage to have the test, we may need the association? but for now I deleted it.
app/models/authority.rb
Outdated
@@ -21,6 +21,9 @@ class Authority < ActiveRecord::Base | |||
has_many :applications | |||
has_many :councillors | |||
has_many :comments, through: :applications | |||
has_many :councillor_contributions | |||
has_many :suggested_councillors, through: :councillor_contributions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this association necessary? If we're not using it we should remove that line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test will pass without it, but the actual code won't run. It returns error because councillor_contribution#new
needs authority_id. So I'm keeping this association. Also we have to create controller/councillr_contributions_controller_spec.rb
.
app/views/contributors/new.html.haml
Outdated
@@ -0,0 +1,20 @@ | |||
%h1 Thank you! | |||
%p | |||
This data you contributed will be reviewd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "reviewed".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
app/views/contributors/new.html.haml
Outdated
%h1 Thank you! | ||
%p | ||
This data you contributed will be reviewd | ||
by an administrator, and go live shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can improve this text a bit but that's not a problem for this first pass being merged. We should open an issue for that.
fill_in "Email", with: "[email protected]" | ||
end | ||
|
||
click_button "Submit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use the full button text like the other tests do for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to change this so that all the times this button is hit, the full text is used "Submit 1 new councillor".
fill_in "Email", with: "[email protected]" | ||
end | ||
|
||
click_button "Add another councillor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hisayohorie and I talked about this, and we recon that this test could be more focused if the person only adds one councillor. That keeps the focus on them not adding there contributor information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came to realize that this test is to check it works successfully when the contributor does not provide their information
, and the test is not what it's described. I changed the test to check what it described. I will make a change in the view page to pass the test in separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hisayohorie and I decided to try and make these tests more focused by splitting the options for the contributor to tell us their contact information into a new feature spec file 74466ea
expect(page).to have_content "Thank you" | ||
end | ||
|
||
it "works successfully without contributor information" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the test above, I recon the description here should be something like "works successfully when the contributor does not provide their information"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
click_button "Submit 3 new councillors" | ||
|
||
expect(page).to have_content "Thank you" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
spec/models/contributor_spec.rb
Outdated
require 'spec_helper' | ||
|
||
RSpec.describe Contributor, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this file if we're not adding tests yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
For clarification.
For consistency.
For clarification.
This responds to a comment here: openaustralia#1208 (comment)
This makes it clearer to the test reader which button is being pressed here, and it also adds slightly to the test to make sure that button text is what we intend. Relates to discussion: openaustralia#1208 (comment)
For proper gramma.
To give thank you for contributor who did not leave their info.
This creates a new file that covers the different options for contribution for providing their information to us. We split this out to make the original spec file more focused and easier to understand. This now means there isn't a single spec for working through the whole contribution process from beginning to end. But we think that's ok for now, because the contribution and the stage of providing details are quite separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hisayohorie nice work making all these fixes :) I think we made the tests clearer in particular :)
I think this is ready to go. I'll merge it and deploy! 🚀
post "/authorities/:authority_id/councillor_contributions/new", to: "councillor_contributions#new" | ||
|
||
resources :contributors, only:[:new, :create] | ||
get "/contributors/no_info", to: "contributors#no_contributor_info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should change to something a little more specific like "contributors/anonymous", but we don't need to do that before deploying.
The feature is globally enabled when the value of `ENV["CONTRIBUTE_COUNCILLORS_ENABLED"]` is `"true"`. | ||
This flag is useful if you need to turn the feature _off_ globally. | ||
|
||
We set this in the [`.env`](https://github.com/openaustralia/planningalerts/blob/master/.env) file in production. You can control setting in development by creating your own `.env.development` file which includes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we set it in production in .env.production
. We should update that.
This is related to this issue openaustralia/australian_local_councillors_popolo#98 (comment)
This PR is the most basic first version of how people contribute councillor info, so that we can load the information to the site.
People can go to this page from each authorities, and put the names and emails of the councillors they want to contribute. After they submit their contribution, optionally they can give us their contact information(name and email), so that we can contact them to thank them.
The suggested councillors appear on admin page, and admin can copy them in the existing process of adding new councillors.
When this is deployed, migration needs to run to add new database tables.