From 1f7225e8cf52f48b923bc5d1445b3902c9e1c00b Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Fri, 24 Mar 2017 15:54:59 +0000 Subject: [PATCH 01/15] Upgrade RSpec from 3.2 to 3.5 --- Gemfile | 2 +- Gemfile.lock | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index eec99f10..505586f4 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ group :development, :test do end group :test do - gem 'rspec-rails', '~> 3.2.1' + gem 'rspec-rails', '~> 3.2' gem 'cucumber-rails', '~> 1.4.2', require: false gem 'launchy' gem 'webmock', '~> 1.20.4' diff --git a/Gemfile.lock b/Gemfile.lock index 55d080bf..11a57904 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,23 +168,23 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-rails (3.2.3) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-support (~> 3.5.0) + rspec-rails (3.5.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) safe_yaml (1.0.4) sass (3.4.16) sass-rails (5.0.3) @@ -248,7 +248,7 @@ DEPENDENCIES pry-byebug quiet_assets (~> 1.1.0) rails (= 4.2.5.2) - rspec-rails (~> 3.2.1) + rspec-rails (~> 3.2) sass-rails (~> 5.0) slimmer (= 10.0.0) timecop (~> 0.7.1) From 1c7c665fee06d45dc846eff65f10d395612ef50c Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Thu, 23 Mar 2017 23:52:40 +0000 Subject: [PATCH 02/15] Clean up cucumber test setup - Remove unused @mock-email-alert-api tag. - Remove manually added lines from support/env.rb - this is a generated file and shouldn't be modified. - Rename the helper that adds GovukContentSchemaExamples to World, more accurately reflecting what it does. - Extract a slimmer helper from env. --- features/email_alerts.feature | 1 - features/support/content_schema_helper.rb | 7 +++++++ features/support/email_alert_api.rb | 4 ---- features/support/email_alert_signup_helper.rb | 5 ----- features/support/env.rb | 7 ------- features/support/slimmer_helper.rb | 8 ++++++++ 6 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 features/support/content_schema_helper.rb delete mode 100644 features/support/email_alert_api.rb delete mode 100644 features/support/email_alert_signup_helper.rb create mode 100644 features/support/slimmer_helper.rb diff --git a/features/email_alerts.feature b/features/email_alerts.feature index 27140b91..bf4e3675 100644 --- a/features/email_alerts.feature +++ b/features/email_alerts.feature @@ -3,7 +3,6 @@ Feature: Email alert signup In order to get up to date notifications about content on GOV.UK I want to be able to sign up for email alerts for relevant content - @mock-email-alert-api Scenario: signing up for email alerts for a page Given a content item exists for an email alert signup page When I access the email signup page diff --git a/features/support/content_schema_helper.rb b/features/support/content_schema_helper.rb new file mode 100644 index 00000000..da7baea4 --- /dev/null +++ b/features/support/content_schema_helper.rb @@ -0,0 +1,7 @@ +require_relative '../../lib/govuk_content_schema_examples' + +module ContentSchemaHelper + include GovukContentSchemaExamples +end + +World(ContentSchemaHelper) diff --git a/features/support/email_alert_api.rb b/features/support/email_alert_api.rb deleted file mode 100644 index 826d5ec1..00000000 --- a/features/support/email_alert_api.rb +++ /dev/null @@ -1,4 +0,0 @@ -Before('@mock-email-alert-api') do - mock_email_alert_api = double - EmailAlertFrontend.register_service(:email_alert_api, mock_email_alert_api) -end diff --git a/features/support/email_alert_signup_helper.rb b/features/support/email_alert_signup_helper.rb deleted file mode 100644 index 70e087ac..00000000 --- a/features/support/email_alert_signup_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module EmailAlertSignupHelper - include GovukContentSchemaExamples -end - -World(EmailAlertSignupHelper) diff --git a/features/support/env.rb b/features/support/env.rb index 66346e48..3e054e02 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -7,7 +7,6 @@ require 'cucumber/rails' require 'cucumber/rspec/doubles' require 'webmock/cucumber' -require 'slimmer/test' # Capybara defaults to CSS3 selectors rather than XPath. # If you'd prefer to use XPath, just uncomment this line and adjust any @@ -31,10 +30,4 @@ # ActionController::Base.allow_rescue = false -require_relative '../../lib/govuk_content_schema_examples' -require 'slimmer/test_helpers/govuk_components' -include Slimmer::TestHelpers::GovukComponents -Before do - stub_shared_component_locales -end diff --git a/features/support/slimmer_helper.rb b/features/support/slimmer_helper.rb new file mode 100644 index 00000000..59142f00 --- /dev/null +++ b/features/support/slimmer_helper.rb @@ -0,0 +1,8 @@ +require 'slimmer/test' +require 'slimmer/test_helpers/govuk_components' + +include Slimmer::TestHelpers::GovukComponents + +Before do + stub_shared_component_locales +end From 674af225b2f1d8913f2eca56d0780075b76a78c3 Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Fri, 24 Mar 2017 00:32:26 +0000 Subject: [PATCH 03/15] Mock out email-alert-api in features with a verifying double Ensure that we can only stub methods that exist on instances of the GdsApi:EmailAlertApi object. --- features/support/email_alert_api_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 features/support/email_alert_api_helper.rb diff --git a/features/support/email_alert_api_helper.rb b/features/support/email_alert_api_helper.rb new file mode 100644 index 00000000..b0532f5a --- /dev/null +++ b/features/support/email_alert_api_helper.rb @@ -0,0 +1,4 @@ +Before do + @mock_email_alert_api = instance_double(GdsApi::EmailAlertApi) + EmailAlertFrontend.register_service(:email_alert_api, @mock_email_alert_api) +end From 37ecea4d173db3acbbb792ad9e512f7cb81e59ae Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Fri, 24 Mar 2017 01:28:33 +0000 Subject: [PATCH 04/15] Use mock email-alert-api in email alert feature, also test redirects - Use the verifying instance double of email-alert-api in the existing email alert feature. - Setup a route specific to the test environment to test redirecting to govdelivery subscription url. --- config/routes.rb | 5 ++++- .../step_definitions/email_alert_steps.rb | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 503e6e6f..57d90964 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,8 @@ Rails.application.routes.draw do - get '/*base_path' => 'email_alert_signups#new', as: :email_alert_signup, constraints: { base_path: %r|.*/email-signup|} post '/*base_path' => 'email_alert_signups#create', as: :email_alert_signups, constraints: { base_path: %r|.*/email-signup|} + + if Rails.env.test? + get '/govdelivery-redirect', to: proc { [200, {}, ['']] } + end end diff --git a/features/step_definitions/email_alert_steps.rb b/features/step_definitions/email_alert_steps.rb index 018f8508..e33a1e26 100644 --- a/features/step_definitions/email_alert_steps.rb +++ b/features/step_definitions/email_alert_steps.rb @@ -19,21 +19,25 @@ When(/^I sign up to the email alerts$/) do @subscription_params = { - "title" => "Employment policy", - "tags" => @tags, + 'title' => 'Employment policy', + 'tags' => @tags, } - allow(EmailAlertFrontend.services(:email_alert_api)). - to receive(:find_or_create_subscriber_list). - with(@subscription_params). - and_return(OpenStruct.new("subscriber_list" => OpenStruct.new("subscription_url" => @base_path))) + + @subscriber_list = { + 'subscription_url' => '/govdelivery-redirect', + } + + allow(@mock_email_alert_api).to receive(:find_or_create_subscriber_list) + .with(@subscription_params) + .and_return('subscriber_list' => @subscriber_list) click_on "Create subscription" end Then(/^my subscription should be registered$/) do - expect(EmailAlertFrontend.services(:email_alert_api)) - .to have_received(:find_or_create_subscriber_list) + expect(@mock_email_alert_api).to have_received(:find_or_create_subscriber_list) .with(@subscription_params) + expect(current_path).to eq '/govdelivery-redirect' end Given(/^a government email alert page exists$/) do From 7e9934e75b1295d535decefa61330e1de27aa064 Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Wed, 22 Mar 2017 13:03:45 +0000 Subject: [PATCH 05/15] Upgrade ruby version from 2.3.0 to 2.3.1 2.3.1 is the minimum version required by govuk_taxonomy_helpers. --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 276cbf9e..2bf1c1cc 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.0 +2.3.1 From ddd8af90d2f5f428332715cce3d8e9b156df05de Mon Sep 17 00:00:00 2001 From: Mo Baig Date: Thu, 23 Mar 2017 00:44:45 +0000 Subject: [PATCH 06/15] Add email signup flow and associated cucumber feature --- Gemfile | 1 + Gemfile.lock | 3 + app/assets/stylesheets/application.scss | 2 + app/assets/stylesheets/taxonomy-signup.scss | 23 +++++ .../taxonomy_signups_controller.rb | 34 ++++++++ app/models/taxonomy_signup.rb | 32 +++++++ app/views/taxonomy_signups/_taxon.html.erb | 16 ++++ app/views/taxonomy_signups/confirm.html.erb | 38 +++++++++ app/views/taxonomy_signups/new.html.erb | 21 +++++ config/routes.rb | 4 + .../taxonomy_email_alert_steps.rb | 85 +++++++++++++++++++ features/taxonomy_email_alerts.feature | 14 +++ spec/models/email_alert_signup_spec.rb | 2 +- spec/models/taxonomy_signup_spec.rb | 48 +++++++++++ 14 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/taxonomy-signup.scss create mode 100644 app/controllers/taxonomy_signups_controller.rb create mode 100644 app/models/taxonomy_signup.rb create mode 100644 app/views/taxonomy_signups/_taxon.html.erb create mode 100644 app/views/taxonomy_signups/confirm.html.erb create mode 100644 app/views/taxonomy_signups/new.html.erb create mode 100644 features/step_definitions/taxonomy_email_alert_steps.rb create mode 100644 features/taxonomy_email_alerts.feature create mode 100644 spec/models/taxonomy_signup_spec.rb diff --git a/Gemfile b/Gemfile index 505586f4..a62d3062 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ gem 'airbrake', '~> 4.1.0' gem 'decent_exposure', '~> 2.3.2' gem 'gds-api-adapters', '~> 40.1' +gem 'govuk_navigation_helpers', '~> 4.0' group :development, :test do gem 'pry-byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 11a57904..15117b7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,6 +97,8 @@ GEM govuk_frontend_toolkit (3.1.0) rails (>= 3.1.0) sass (>= 3.2.0) + govuk_navigation_helpers (4.0.0) + gds-api-adapters (~> 40.1) http-cookie (1.0.3) domain_name (~> 0.5) i18n (0.7.0) @@ -243,6 +245,7 @@ DEPENDENCIES gds-api-adapters (~> 40.1) govuk-content-schema-test-helpers (~> 1.0.2) govuk_frontend_toolkit (~> 3.1.0) + govuk_navigation_helpers (~> 4.0) launchy plek (~> 1.11.0) pry-byebug diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1d292d60..e450d435 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -15,3 +15,5 @@ margin: 20px 0; } } + +@import "https://github.com/taxonomy-signup" diff --git a/app/assets/stylesheets/taxonomy-signup.scss b/app/assets/stylesheets/taxonomy-signup.scss new file mode 100644 index 00000000..84bb7215 --- /dev/null +++ b/app/assets/stylesheets/taxonomy-signup.scss @@ -0,0 +1,23 @@ +.taxonomy-signup { + h1 { + @include bold-36; + margin: 1.25em 0; + } + + .taxonomy-signup-prompt { + @include core-24; + margin-bottom: 1.25em; + } + + .taxonomy-signup-button { + @include button; + font-size: 20px; + } + + .taxonomy-signup-taxon { + margin-bottom: 1.5em; + h3 { + display: inline-block; + } + } +} diff --git a/app/controllers/taxonomy_signups_controller.rb b/app/controllers/taxonomy_signups_controller.rb new file mode 100644 index 00000000..1796e1df --- /dev/null +++ b/app/controllers/taxonomy_signups_controller.rb @@ -0,0 +1,34 @@ +class TaxonomySignupsController < ApplicationController + def new + redirect_to '/' and return unless params[:paths].present? + + # Only handle one taxon path for now - multiple signups may be handled in + # future. + taxon_path = params[:paths].first + @taxon = EmailAlertFrontend.services(:content_store).content_item(taxon_path) + @breadcrumbs = GovukNavigationHelpers::NavigationHelper.new(@taxon) + .taxon_breadcrumbs[:breadcrumbs] + end + + def confirm + redirect_to '/' and return unless params[:paths].present? + + # Only handle one taxon path for now - multiple signups may be handled in + # future. + taxon_path = params[:paths].first + @taxon = EmailAlertFrontend.services(:content_store).content_item(taxon_path) + @breadcrumbs = GovukNavigationHelpers::NavigationHelper.new(@taxon) + .taxon_breadcrumbs[:breadcrumbs] + end + + def create + @taxon = EmailAlertFrontend.services(:content_store).content_item(params[:taxon_path]) + signup = TaxonomySignup.new(@taxon.to_h) + + if signup.save + redirect_to signup.subscription_management_url + else + redirect_to confirm_taxonomy_signup_path(paths: [params[:taxon_path]]) + end + end +end diff --git a/app/models/taxonomy_signup.rb b/app/models/taxonomy_signup.rb new file mode 100644 index 00000000..c34a12f0 --- /dev/null +++ b/app/models/taxonomy_signup.rb @@ -0,0 +1,32 @@ +class TaxonomySignup + attr_accessor :taxon, :subscription_management_url + + def initialize(taxon) + @taxon = taxon + end + + def save + return false unless taxon.present? + self.subscription_management_url = update_subscription.dig( + 'subscriber_list', 'subscription_url' + ) + true + end + +private + + def update_subscription + EmailAlertFrontend.services(:email_alert_api) + .find_or_create_subscriber_list(subscription_params) + end + + def subscription_params + { + 'title' => taxon['title'], + 'links' => { + 'taxons' => [taxon['content_id']] + } + } + end +end + diff --git a/app/views/taxonomy_signups/_taxon.html.erb b/app/views/taxonomy_signups/_taxon.html.erb new file mode 100644 index 00000000..5a0701a1 --- /dev/null +++ b/app/views/taxonomy_signups/_taxon.html.erb @@ -0,0 +1,16 @@ +<% is_parent ||= false %> + +' value='<%= taxon['base_path'] %>' <%= 'checked' if is_parent %>> + + +<% if is_parent %> +

including alerts about all the topics below

+<% else %> +

this will include alerts about <%= taxon['description'] %>

+<% end %> + + diff --git a/app/views/taxonomy_signups/confirm.html.erb b/app/views/taxonomy_signups/confirm.html.erb new file mode 100644 index 00000000..ca5d97ed --- /dev/null +++ b/app/views/taxonomy_signups/confirm.html.erb @@ -0,0 +1,38 @@ +<% content_for :title, @taxon['title'] %> + +<%= render 'govuk_component/breadcrumbs', breadcrumbs: @breadcrumbs %> + + + diff --git a/app/views/taxonomy_signups/new.html.erb b/app/views/taxonomy_signups/new.html.erb new file mode 100644 index 00000000..6caee2af --- /dev/null +++ b/app/views/taxonomy_signups/new.html.erb @@ -0,0 +1,21 @@ +<% content_for :title, @taxon['title'] %> + +<%= render 'govuk_component/breadcrumbs', breadcrumbs: @breadcrumbs %> + + diff --git a/config/routes.rb b/config/routes.rb index 57d90964..ce58bd05 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,10 @@ get '/*base_path' => 'email_alert_signups#new', as: :email_alert_signup, constraints: { base_path: %r|.*/email-signup|} post '/*base_path' => 'email_alert_signups#create', as: :email_alert_signups, constraints: { base_path: %r|.*/email-signup|} + get '/email-signup' => 'taxonomy_signups#new', as: :new_taxonomy_signup + get '/email-signup/confirm' => 'taxonomy_signups#confirm', as: :confirm_taxonomy_signup + post '/email-signup' => 'taxonomy_signups#create' + if Rails.env.test? get '/govdelivery-redirect', to: proc { [200, {}, ['']] } end diff --git a/features/step_definitions/taxonomy_email_alert_steps.rb b/features/step_definitions/taxonomy_email_alert_steps.rb new file mode 100644 index 00000000..8e27e0ea --- /dev/null +++ b/features/step_definitions/taxonomy_email_alert_steps.rb @@ -0,0 +1,85 @@ +Given(/^a taxon in the middle of the taxonomy$/) do + @taxon = { + content_id: 'taxon-uuid', + base_path: '/education/further-education', + title: 'Further education', + description: 'Further education content', + links: { + parent_taxons: [ + { + base_path: '/education', + title: 'Education', + description: 'Education content', + links: {}, + } + ], + child_taxons: [ + { + base_path: '/education/funding', + title: 'Funding', + description: 'Funding content', + links: { + parent_taxons: [ + { + base_path: '/education/further-education', + title: 'Further education', + description: 'Further education content', + links: {}, + } + ] + } + } + ], + } + } + + content_store_has_item(@taxon[:base_path], @taxon) +end + +When(/^i visit its signup page$/) do + visit new_taxonomy_signup_path(paths: [@taxon[:base_path]] ) +end + +Then(/^i can subscribe to the taxon or one of its children$/) do + taxon_path = @taxon[:base_path] + child_taxon_path = @taxon.dig(:links, :child_taxons).first[:base_path] + + expect(page).to have_link(href: confirm_taxonomy_signup_path(paths: [taxon_path])) + expect(page).to have_link(href: confirm_taxonomy_signup_path(paths: [child_taxon_path])) +end + +When(/^i choose to subscribe to the taxon$/) do + click_link(href: confirm_taxonomy_signup_path(paths: [@taxon[:base_path]])) +end + +Then(/^i see a confirmation page$/) do + expect(page).to have_content("You can set your preferences once you've signed up.") + expect(page).to have_button('Sign up now') +end + +When(/^i confirm$/) do + @subscription_params = { + 'title' => @taxon[:title], + 'links' => { 'taxons' => [ @taxon[:content_id] ] }, + } + + @subscriber_list = { + 'subscription_url' => '/govdelivery-redirect', + } + + allow(@mock_email_alert_api).to receive(:find_or_create_subscriber_list) + .with(@subscription_params) + .and_return('subscriber_list' => @subscriber_list) + + click_button 'Sign up now' +end + +Then(/^my subscription is created$/) do + expect(@mock_email_alert_api).to have_received(:find_or_create_subscriber_list) + .with(@subscription_params) +end + +Then(/^i am redirected to manage my subscriptions off of govuk$/) do + expect(current_path).to eq '/govdelivery-redirect' +end + diff --git a/features/taxonomy_email_alerts.feature b/features/taxonomy_email_alerts.feature new file mode 100644 index 00000000..fbe6370b --- /dev/null +++ b/features/taxonomy_email_alerts.feature @@ -0,0 +1,14 @@ +Feature: Email alert signup + As an interested person + In order to get relevant notifications about content updates on GOV.UK + I want to be able to sign up for email alerts about topics within the taxonomy + + Scenario: Signing up for email alerts about a topic + Given a taxon in the middle of the taxonomy + When i visit its signup page + Then i can subscribe to the taxon or one of its children + When i choose to subscribe to the taxon + Then i see a confirmation page + When i confirm + Then my subscription is created + And i am redirected to manage my subscriptions off of govuk diff --git a/spec/models/email_alert_signup_spec.rb b/spec/models/email_alert_signup_spec.rb index 14a30413..aec48e76 100644 --- a/spec/models/email_alert_signup_spec.rb +++ b/spec/models/email_alert_signup_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require 'gds_api/test_helpers/email_alert_api' -describe EmailAlertSignup do +RSpec.describe EmailAlertSignup do include GovukContentSchemaExamples include GdsApi::TestHelpers::EmailAlertApi diff --git a/spec/models/taxonomy_signup_spec.rb b/spec/models/taxonomy_signup_spec.rb new file mode 100644 index 00000000..d2fa0e61 --- /dev/null +++ b/spec/models/taxonomy_signup_spec.rb @@ -0,0 +1,48 @@ +require 'rails_helper' + +RSpec.describe TaxonomySignup do + describe "#save" do + let(:mock_email_alert_api) do + instance_double(EmailAlertFrontend.services(:email_alert_api).class) + end + + let(:fake_taxon) { { 'title' => 'Foo', 'content_id' => 'foo-id' } } + + before do + allow(EmailAlertFrontend) + .to receive(:services) + .with(:email_alert_api) + .and_return(mock_email_alert_api) + allow(mock_email_alert_api) + .to receive(:find_or_create_subscriber_list) + .and_return('subscriber_list' => { 'subscription_url' => '/govdelivery' }) + end + + it 'asks email-alert-api to find or create a subscriber list' do + signup = TaxonomySignup.new(fake_taxon) + + expect(signup.save).to be + expect(mock_email_alert_api) + .to have_received(:find_or_create_subscriber_list) + .with('title' => 'Foo', 'links' => { 'taxons' => ['foo-id'] }) + end + + it 'sets the subscription management url' do + signup = TaxonomySignup.new(fake_taxon) + + expect(signup.save).to be + expect(signup.subscription_management_url).to eq '/govdelivery' + end + + context 'when no taxon present' do + it 'does nothing' do + signup = TaxonomySignup.new(nil) + + expect(signup.save).to_not be + expect(mock_email_alert_api).to_not have_received(:find_or_create_subscriber_list) + expect(signup.subscription_management_url).to eq nil + end + end + end +end + From 0a13d1fe7127f12979e92155c0cdfbf7efb0b6a2 Mon Sep 17 00:00:00 2001 From: Caroline Green Date: Thu, 23 Mar 2017 11:41:43 +0000 Subject: [PATCH 07/15] Update frontend toolkit and add elements Update frontend toolkit and add elements to bring in necessary sass for checkboxes. --- Gemfile | 3 +- Gemfile.lock | 122 +++++++++++--------- app/assets/stylesheets/_govuk-elements.scss | 55 +++++++++ app/assets/stylesheets/application.scss | 1 + app/controllers/application_controller.rb | 1 + app/views/taxonomy_signups/_taxon.html.erb | 10 +- app/views/taxonomy_signups/new.html.erb | 4 +- 7 files changed, 132 insertions(+), 64 deletions(-) create mode 100644 app/assets/stylesheets/_govuk-elements.scss diff --git a/Gemfile b/Gemfile index a62d3062..2e369e73 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,8 @@ source 'https://rubygems.org/' gem 'rails', '4.2.5.2' gem 'slimmer', '10.0.0' -gem 'govuk_frontend_toolkit', '~> 3.1.0' +gem 'govuk_elements_rails', '~> 3.0.1' +gem 'govuk_frontend_toolkit', '~> 5.1.2' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 2.7.2' diff --git a/Gemfile.lock b/Gemfile.lock index 15117b7c..852fbefe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,46 +41,50 @@ GEM airbrake (4.1.0) builder multi_json - arel (6.0.3) + arel (6.0.4) better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - builder (3.2.2) - byebug (5.0.0) - columnize (= 0.9.0) - capybara (2.4.4) + builder (3.2.3) + byebug (9.0.6) + capybara (2.13.0) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - coderay (1.1.0) - columnize (0.9.0) - concurrent-ruby (1.0.1) - crack (0.4.2) + coderay (1.1.1) + concurrent-ruby (1.0.5) + crack (0.4.3) safe_yaml (~> 1.0.0) - cucumber (1.3.20) + cucumber (2.4.0) builder (>= 2.1.2) + cucumber-core (~> 1.5.0) + cucumber-wire (~> 0.0.1) diff-lcs (>= 1.1.3) - gherkin (~> 2.12) + gherkin (~> 4.0) multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.1.2) - cucumber-rails (1.4.2) + cucumber-core (1.5.0) + gherkin (~> 4.0) + cucumber-rails (1.4.5) capybara (>= 1.1.2, < 3) - cucumber (>= 1.3.8, < 2) - mime-types (>= 1.16, < 3) + cucumber (>= 1.3.8, < 4) + mime-types (>= 1.16, < 4) nokogiri (~> 1.5) - rails (>= 3, < 5) + railties (>= 3, < 5.1) + cucumber-wire (0.0.1) debug_inspector (0.0.2) - decent_exposure (2.3.2) - diff-lcs (1.2.5) + decent_exposure (2.3.3) + diff-lcs (1.3) domain_name (0.5.20170223) unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) - execjs (2.6.0) + execjs (2.7.0) gds-api-adapters (40.5.0) link_header lrucache (~> 0.1.1) @@ -88,24 +92,27 @@ GEM plek (>= 1.9.0) rack-cache rest-client (~> 2.0) - gherkin (2.12.2) - multi_json (~> 1.3) - globalid (0.3.6) + gherkin (4.1.1) + globalid (0.3.7) activesupport (>= 4.1.0) govuk-content-schema-test-helpers (1.0.2) json-schema (~> 2.5.1) - govuk_frontend_toolkit (3.1.0) + govuk_elements_rails (3.0.1) + govuk_frontend_toolkit (>= 5.0.2) + rails (>= 4.1.0) + sass (>= 3.2.0) + govuk_frontend_toolkit (5.1.3) rails (>= 3.1.0) sass (>= 3.2.0) govuk_navigation_helpers (4.0.0) gds-api-adapters (~> 40.1) http-cookie (1.0.3) domain_name (~> 0.5) - i18n (0.7.0) - json (1.8.3) - json-schema (2.5.1) - addressable (~> 2.3.7) - kgio (2.9.3) + i18n (0.8.1) + json (1.8.6) + json-schema (2.5.2) + addressable (~> 2.3.8) + kgio (2.11.0) launchy (2.4.3) addressable (~> 2.3) link_header (0.0.8) @@ -113,25 +120,27 @@ GEM nokogiri (>= 1.5.9) lrucache (0.1.4) PriorityQueue (~> 0.1.2) - mail (2.6.3) - mime-types (>= 1.16, < 3) + mail (2.6.4) + mime-types (>= 1.16, < 4) method_source (0.8.2) - mime-types (2.99.3) - mini_portile2 (2.0.0) - minitest (5.8.4) - multi_json (1.11.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.1.0) + minitest (5.10.1) + multi_json (1.12.1) multi_test (0.1.2) netrc (0.11.0) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.8.1) + mini_portile2 (~> 2.1.0) null_logger (0.0.1) plek (1.11.0) - pry (0.10.3) + pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.2.0) - byebug (~> 5.0) + pry-byebug (3.4.2) + byebug (~> 9.0) pry (~> 0.10) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) @@ -153,9 +162,9 @@ GEM sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) + rails-dom-testing (1.0.8) activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) @@ -164,8 +173,8 @@ GEM activesupport (= 4.2.5.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.15.0) - rake (10.5.0) + raindrops (0.18.0) + rake (12.0.0) rest-client (2.0.1) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) @@ -188,13 +197,13 @@ GEM rspec-support (~> 3.5.0) rspec-support (3.5.0) safe_yaml (1.0.4) - sass (3.4.16) - sass-rails (5.0.3) - railties (>= 4.0.0, < 5.0) + sass (3.4.23) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) - tilt (~> 1.1) + tilt (>= 1.1, < 3) slimmer (10.0.0) activesupport json @@ -204,28 +213,26 @@ GEM rack rest-client slop (3.6.0) - sprockets (3.5.2) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.3) + sprockets-rails (3.2.0) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.19.1) - thread_safe (0.3.5) - tilt (1.4.1) + thor (0.19.4) + thread_safe (0.3.6) + tilt (2.0.7) timecop (0.7.4) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (3.1.9) + execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.2) - unicorn (4.9.0) + unicorn (5.2.0) kgio (~> 2.6) - rack raindrops (~> 0.7) webmock (1.20.4) addressable (>= 2.3.6) @@ -244,7 +251,8 @@ DEPENDENCIES decent_exposure (~> 2.3.2) gds-api-adapters (~> 40.1) govuk-content-schema-test-helpers (~> 1.0.2) - govuk_frontend_toolkit (~> 3.1.0) + govuk_elements_rails (~> 3.0.1) + govuk_frontend_toolkit (~> 5.1.2) govuk_navigation_helpers (~> 4.0) launchy plek (~> 1.11.0) diff --git a/app/assets/stylesheets/_govuk-elements.scss b/app/assets/stylesheets/_govuk-elements.scss new file mode 100644 index 00000000..d1b00663 --- /dev/null +++ b/app/assets/stylesheets/_govuk-elements.scss @@ -0,0 +1,55 @@ +// GOV.UK front end toolkit +// Sass variables, mixins and functions +// https://github.com/alphagov/govuk_frontend_toolkit/tree/master/stylesheets + +// Settings (variables) +@import "https://github.com/colours"; // Colour variables +@import "https://github.com/font_stack"; // Font family variables +@import "https://github.com/measurements"; // Widths and gutter variables + +// Mixins +@import "https://github.com/conditionals"; // Media query mixin +@import "https://github.com/device-pixels"; // Retina image mixin +@import "https://github.com/grid_layout"; // Basic grid layout mixin +@import "https://github.com/typography"; // Core bold and heading mixins, also external links +@import "https://github.com/shims"; // Inline block mixin, clearfix placeholder + +// Mixins to generate components (chunks of UI) +// @import "https://github.com/design-patterns/alpha-beta"; +@import "https://github.com/design-patterns/buttons"; +// @import "https://github.com/design-patterns/breadcrumbs"; + +// Functions +// @import "https://github.com/url-helpers"; // Function to output image-url, or prefixed path (Rails and Compass only) + +// GOV.UK elements + +@import "https://github.com/elements/helpers"; // Helper functions and classes + +// Generic (normalize/reset.css) +@import "https://github.com/elements/reset"; + +// Base (unclassed HTML elements) +// These are predefined by govuk_template +// If you're not using govuk_template, uncomment the line below. +// @import "https://github.com/elements/govuk-template-base"; // Base styles set by GOV.UK template + +// Objects (unstyled design patterns) +@import "https://github.com/elements/layout"; // Main content container. Grid layout - rows and column widths + +// Components (chunks of UI) +@import "https://github.com/elements/elements-typography"; // Typography +@import "https://github.com/elements/buttons"; // Buttons +// @import "https://github.com/elements/icons"; // Icons - numbered steps, calendar, search +@import "https://github.com/elements/lists"; // Lists - numbered, bulleted +@import "https://github.com/elements/tables"; // Tables - regular, numeric +@import "https://github.com/elements/details"; // Details summary +@import "https://github.com/elements/panels"; // Panels with a left grey border +@import "https://github.com/elements/forms"; // Form - wrappers, inputs, labels +@import "https://github.com/elements/forms/form-multiple-choice"; // Custom radio buttons and checkboxes +// @import "https://github.com/elements/forms/form-date"; // Date of birth pattern +@import "https://github.com/elements/forms/form-validation"; // Errors and validation +// @import "https://github.com/elements/breadcrumbs"; // Breadcrumbs +// @import "https://github.com/elements/phase-banner"; // Alpha and beta banners and tags +@import "https://github.com/elements/components"; // GOV.UK prefixed styles - blue highlighted box +@import "https://github.com/elements/shame"; // Hacks and workarounds that will go away eventually diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index e450d435..1c41aaf4 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,6 +1,7 @@ @import "https://github.com/typography"; @import "https://github.com/measurements"; @import "https://github.com/design-patterns/buttons"; +@import "https://github.com/govuk-elements"; #wrapper { padding-bottom: $gutter; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index def99843..e032b49c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,5 @@ class ApplicationController < ActionController::Base + include Slimmer::Template include Slimmer::GovukComponents # Prevent CSRF attacks by raising an exception. diff --git a/app/views/taxonomy_signups/_taxon.html.erb b/app/views/taxonomy_signups/_taxon.html.erb index 5a0701a1..74382961 100644 --- a/app/views/taxonomy_signups/_taxon.html.erb +++ b/app/views/taxonomy_signups/_taxon.html.erb @@ -1,9 +1,11 @@ <% is_parent ||= false %> -' value='<%= taxon['base_path'] %>' <%= 'checked' if is_parent %>> - +
+ ' value='<%= taxon['base_path'] %>' <%= 'checked' if is_parent %>> + +
<% if is_parent %>

including alerts about all the topics below

diff --git a/app/views/taxonomy_signups/new.html.erb b/app/views/taxonomy_signups/new.html.erb index 6caee2af..7ff7572f 100644 --- a/app/views/taxonomy_signups/new.html.erb +++ b/app/views/taxonomy_signups/new.html.erb @@ -2,8 +2,9 @@ <%= render 'govuk_component/breadcrumbs', breadcrumbs: @breadcrumbs %> - <% end %> - From c4eef7dc8dd511f5b3b1dbf4e99bbb4553c66687 Mon Sep 17 00:00:00 2001 From: Caroline Green Date: Thu, 23 Mar 2017 13:10:53 +0000 Subject: [PATCH 08/15] Add markup, copy tweaks and styling --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/taxonomy-signup.scss | 30 +++++++++------------ app/views/taxonomy_signups/_taxon.html.erb | 20 +++++++------- app/views/taxonomy_signups/confirm.html.erb | 21 +++++++++------ app/views/taxonomy_signups/new.html.erb | 15 +++++------ 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1c41aaf4..d58367bf 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,6 +2,7 @@ @import "https://github.com/measurements"; @import "https://github.com/design-patterns/buttons"; @import "https://github.com/govuk-elements"; +@import "https://github.com/taxonomy-signup"; #wrapper { padding-bottom: $gutter; diff --git a/app/assets/stylesheets/taxonomy-signup.scss b/app/assets/stylesheets/taxonomy-signup.scss index 84bb7215..ecff4041 100644 --- a/app/assets/stylesheets/taxonomy-signup.scss +++ b/app/assets/stylesheets/taxonomy-signup.scss @@ -1,23 +1,19 @@ -.taxonomy-signup { - h1 { - @include bold-36; - margin: 1.25em 0; - } +#email-alert-frontend{ - .taxonomy-signup-prompt { - @include core-24; - margin-bottom: 1.25em; + .description-block { + float: left; + width: 100%; + margin-bottom: $gutter; + margin-left: 16px; } - .taxonomy-signup-button { - @include button; - font-size: 20px; + .multiple-choice { + margin-top: 10px; + margin-bottom: 10px; } - .taxonomy-signup-taxon { - margin-bottom: 1.5em; - h3 { - display: inline-block; - } + .email-option { + @include core-24; } -} + +} \ No newline at end of file diff --git a/app/views/taxonomy_signups/_taxon.html.erb b/app/views/taxonomy_signups/_taxon.html.erb index 74382961..eaaa59df 100644 --- a/app/views/taxonomy_signups/_taxon.html.erb +++ b/app/views/taxonomy_signups/_taxon.html.erb @@ -1,18 +1,20 @@ <% is_parent ||= false %> -
+
' value='<%= taxon['base_path'] %>' <%= 'checked' if is_parent %>>
-<% if is_parent %> -

including alerts about all the topics below

-<% else %> -

this will include alerts about <%= taxon['description'] %>

-<% end %> +
+ <% if is_parent %> +

This will include alerts about all the topics below

+ <% else %> +

This will include: <%= taxon['description'] %>

+ <% end %> - + + Continue + +
diff --git a/app/views/taxonomy_signups/confirm.html.erb b/app/views/taxonomy_signups/confirm.html.erb index ca5d97ed..a627ac3e 100644 --- a/app/views/taxonomy_signups/confirm.html.erb +++ b/app/views/taxonomy_signups/confirm.html.erb @@ -2,23 +2,28 @@ <%= render 'govuk_component/breadcrumbs', breadcrumbs: @breadcrumbs %> -