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 editing of business support editions without javascript #339

Merged
merged 11 commits into from Dec 24, 2014

Conversation

@fofr
Copy link
Contributor

@fofr fofr commented Dec 19, 2014

https://www.agileplannerapp.com/boards/173808/cards/9005

Previously if you attempted to save edits to a business support format either:

  • with javascript disabled
  • with serialised form submitted via ajax

It would error with:

Mongoid::Errors::InvalidType in EditionsController#update
Field was defined as a(n) Array, but received a String with the value "england, london, north-west, west-midlands, south-east, north-east, south-west, yorkshire-and-the-humber, eastern, east-midlands".
  • Split up business support tests into smaller ones
  • Add test helpers for testing with and without javascript
  • Coerce business support areas to an array when it's submitted as a string
  • Simplify the javascript now that the non-js version works

Suggest reviewing with ?w=1

Caveat: Now that the non-js version works it is easier to enter an ID for a region that is not necessarily a valid one. Some validation in content models that each item in the areas array corresponds to an actual area ID could be worthwhile.

fofr added 11 commits Dec 18, 2014
Refactor into smaller tests that test individual features
Test helpers are useful for both IntegrationTest and
JavascriptIntegrationTest classes.

* Add helper to check whether test is using javascript
* Switch action within save_edition based on this (default driver has
no trigger action)
When validating business support editions it expects areas to be an
array. Submitting without JS gives a comma separated string.

* If a string is submitted, coerce it into an array
Now non-js submission works we can avoid using a hidden input for the
select2.

* Use the text area for the select2 field
* Submit data as a comma separated string rather than a rails array
Be clearer about the form area IDs take in the Javascript spec
A custom label within the markup works fine
These boxes are helpers that fill in the regions for the UK or England
when checked, but they need JS to work.
vinayvinay added a commit that referenced this pull request Dec 24, 2014
Allow editing of business support editions without javascript
@vinayvinay vinayvinay merged commit e9a1954 into master Dec 24, 2014
1 check passed
1 check passed
default "Build #553 succeeded on Jenkins"
Details
@vinayvinay vinayvinay deleted the non-js-business-support branch Dec 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.