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

Move logic from country_of_ceremony question to MarriageAbroadCalculator #2297

Conversation

Projects
None yet
1 participant
@chrisroos
Copy link
Contributor

commented Feb 24, 2016

This supersedes PR #2288. See that PR for description and comments.

chrisroos added some commits Feb 16, 2016

Add MarriageAbroadCalculator#world_location
I've moved the behaviour from the `location` calculate block to this new
method.

I don't think the `#world_location` method should be raising an
`InvalidResponse` exception if `WorldLocation#find` returns `nil`. I
think it should probably raise a custom error (e.g. "Data not found for
the chosen ceremony country" that's then handled somehow in the front
end). Note that the `country_select` question itself already handles the
case where the ceremony country doesn't exist in the list of countries
(this can happen if the URL is manually updated).

I'm not memoising the `world_location` because `WorldLocation` already
includes a cache to minimise the number of network requests.
Add MarriageAbroadCalculator#fco_organisation
I've moved the behaviour from the `organisation` calculate block to this
new method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#overseas_passports_embassies
I've moved the behaviour from the `overseas_passports_embassies`
calculate block to this new method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.

I'm not using `quacks_like` for the "World Office" as we don't have a
World Office object - we use an `OpenStruct` in the production code.
Add MarriageAbroadCalculator#marriage_and_partnership_phrases
I've moved the behaviour from the `marriage_and_partnership_phrases`
calculate block to this new method.

I've replicated this method as-is at the moment although I can imagine
it changing/going away in future as its purpose becomes clearer.

I don't fully understand the methods on the MarriageAbroadDataQuery so I
can't be sure that my test names are accurate.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#ceremony_country_name
I've moved the behaviour from the `ceremony_country_name` calculate
block to this new method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#country_name_lowercase_prefix
I've moved the behaviour from the `country_name_lower_case_prefix`
calculate block to this new method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#country_name_uppercase_prefix
I've moved the behaviour from the `country_name_uppercase_prefix`
calculate block to this new method.

It seems slightly odd to me that the implementation of this method is
different to `#country_name_lowercase_prefix` but that'll have to wait
for another time.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#country_name_partner_residence
I've moved the behaviour from the `country_name_partner_residence`
calculate block to this new method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Add MarriageAbroadCalculator#embassy_or_consulate_ceremony_country
I've moved the behaviour from the
`embassy_or_consulate_ceremony_country` calculate block to this new
method.

I've used stub.quacks_like(<instance-of-object>) in some of these tests.
This is instead of using a real instance of the object, or of using a
plain stub. It gives me confidence that I'm not accidentally relying on
behaviour in the real object, and that I'm not stubbing/calling a method
that doesn't exist on the real object.
Update checksum data for marriage-abroad
All the regression tests pass for marriage-abroad so I can safely update
the checksum data.

Updated using:

    $ rails r script/generate-checksums-for-smart-answer.rb \
    marriage-abroad

chrisroos added a commit that referenced this pull request Feb 24, 2016

Merge pull request #2297 from alphagov/move-logic-from-country-of-cer…
…emony-question-to-marriage-abroad-calculator

Move logic from country_of_ceremony question to MarriageAbroadCalculator

@chrisroos chrisroos merged commit b814f71 into master Feb 24, 2016

1 check passed

default "Build #4120 succeeded on Jenkins"
Details

@chrisroos chrisroos deleted the move-logic-from-country-of-ceremony-question-to-marriage-abroad-calculator branch Feb 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.