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

Support individual exemption deregistration #90

Merged
merged 38 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0a5a872
Support individual exemption deregistration
Mar 15, 2019
8f10837
Merge branch 'master' into support-individual-exemption-deregistration
Mar 18, 2019
b8d2428
Merge branch 'master' into support-individual-exemption-deregistration
Mar 19, 2019
d0aaba8
Merge branch 'master' into support-individual-exemption-deregistration
Mar 20, 2019
55dd74d
Merge branch 'master' into support-individual-exemption-deregistration
Mar 21, 2019
cd7ee78
Merge branch 'master' into support-individual-exemption-deregistration
Mar 22, 2019
fffa6a6
Merge branch 'master' into support-individual-exemption-deregistration
Mar 22, 2019
e153844
Bump dependency versions
Mar 22, 2019
2d53006
Add input SCSS partial from the front-office app
Mar 22, 2019
495e387
Add CanDeactivateExemption state machine concern
Mar 22, 2019
33c046e
Add deregistration service
Mar 22, 2019
25117de
Add translation files
Mar 22, 2019
f6674b1
Add validator test shared exampled from the WEX engine
Mar 22, 2019
880ee5f
Add form validators
Mar 22, 2019
a3445d7
Add test helper modules
Mar 22, 2019
0255b39
Add DeregisterExemptionsForm
Mar 22, 2019
0fd4b8f
Update views to support the deregister exemptions journey
Mar 22, 2019
fdecb0c
Add routes, controller, and request tests
Mar 22, 2019
1d825cf
Refactor DeregisterExemptionsController
Mar 22, 2019
343453f
Fix typo
Mar 22, 2019
9e32bdc
Merge branch 'master' into support-individual-exemption-deregistration
Mar 25, 2019
8bdd95e
Merge branch 'master' into support-individual-exemption-deregistration
Mar 26, 2019
b580edd
Merge branch 'master' into support-individual-exemption-deregistration
Mar 26, 2019
a4259f9
Fix typos
Mar 26, 2019
91d495d
Refactor DeregisterExemptionsForm spec
Mar 26, 2019
1e73e82
Refactor deregistration controller and form behaviour
Mar 26, 2019
ed42b41
Add the ability to call can? and cannot? on the User
Mar 26, 2019
8c673bf
Refactor deregistration to use CanCan abilities
Mar 26, 2019
a7a8666
Set deregistered_on when deregistration takes place
Mar 26, 2019
5782a39
Merge branch 'master' into support-individual-exemption-deregistration
Mar 27, 2019
3e8554f
Merge branch 'master' into support-individual-exemption-deregistration
Mar 28, 2019
216f1d3
Explicitly declare the S3 endpoint
Mar 28, 2019
8f3a445
Set AWS region ENV var in Travis config
Mar 28, 2019
3ab1f0e
Remove Travis AWS region ENV var
Mar 29, 2019
21e29c8
Fix typo
Mar 29, 2019
3c6532f
Rename AASM callback in CanDeactivateExemption
Mar 29, 2019
8ea36c0
Merge branch 'master' into support-individual-exemption-deregistration
Mar 29, 2019
97e9341
Merge branch 'master' into support-individual-exemption-deregistration
Mar 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GEM
ast (2.4.0)
aws-eventstream (1.0.2)
aws-partitions (1.144.0)
aws-sdk-core (3.48.0)
aws-sdk-core (3.48.1)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -117,7 +117,7 @@ GEM
railties (>= 3.2, < 6.1)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (5.0.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
factory_bot (~> 5.0.0)
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@import 'partials/dashboard';
@import 'partials/dates';
@import 'partials/footer';
@import 'partials/input';
@import 'partials/pagination';
@import 'partials/people';
@import 'partials/resource_details';
Expand Down
38 changes: 38 additions & 0 deletions app/assets/stylesheets/partials/_input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Reset all input widths to default
input.form-control {
width: 100%
}

// Following styles taken from https://github.com/alphagov/govuk-frontend/blob/master/src/components/input/_input.scss

// The ex measurements are based on the number of W's that can fit inside the input
// Extra space is left on the right hand side to allow for the Safari prefill icon
// Linear regression estimation based on visual tests: y = 1.76 + 1.81x

.govuk-input--width-30 {
max-width: 56ex + 3ex;
}

.govuk-input--width-20 {
max-width: 38ex + 3ex;
}

.govuk-input--width-10 {
max-width: 20ex + 3ex;
}

.govuk-input--width-5 {
max-width: 10.8ex;
}

.govuk-input--width-4 {
max-width: 9ex;
}

.govuk-input--width-3 {
max-width: 7.2ex;
}

.govuk-input--width-2 {
max-width: 5.4ex;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module WasteExemptionsEngine
module CanDeactivateExemption
extend ActiveSupport::Concern

included do
include AASM

aasm column: :state do
state :active
state :ceased
state :expired
state :revoked

event :cease do
transitions from: :active,
to: :ceased
end

event :revoke do
transitions from: :active,
to: :revoked
end

event :expire do
transitions from: :active,
to: :expired
end
end
end
end
end
9 changes: 9 additions & 0 deletions app/models/waste_exemptions_engine/registration_exemption.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require WasteExemptionsEngine::Engine.root.join("app", "models", "waste_exemptions_engine", "registration_Exemption")

module WasteExemptionsEngine
class RegistrationExemption
include CanDeactivateExemption
end
end
41 changes: 41 additions & 0 deletions spec/models/registration_exemption_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe WasteExemptionsEngine::RegistrationExemption, type: :model do
subject(:registration_exemption) { build(:registration).registration_exemptions.first }
let(:permitted_states) { registration_exemption.aasm.states(permitted: true).map(&:name) }

transitions = %i[cease revoke expire]
inactive_states = %i[ceased revoked expired]

describe "exemption state" do
context "when the state is 'active'" do
before(:each) { registration_exemption.state = :active }

it "can transition to any of the inactive states" do
expect(permitted_states).to match_array(inactive_states)
end

transitions.zip(inactive_states).each do |tansition, expected_state|
eminnett marked this conversation as resolved.
Show resolved Hide resolved
context "and the '#{tansition}' transition is executed" do
it "reflects the correct state" do
expect { registration_exemption.send("#{tansition}!") }
.to change { registration_exemption.state }
.from("active")
.to(expected_state.to_s)
end
end
end
end

inactive_states.each do |inactive_state|
context "when the state is #{inactive_state}" do
before(:each) { registration_exemption.state = inactive_state }
it "can not transition to any other status" do
expect(permitted_states).to be_empty
end
end
end
end
end