defra_ruby_email 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/defra_ruby_email/version.rb +1 -1
  3. metadata +14 -177
  4. data/spec/defra_ruby_email_spec.rb +0 -39
  5. data/spec/dummy/README.rdoc +0 -28
  6. data/spec/dummy/Rakefile +0 -6
  7. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  8. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  9. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  10. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  11. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  12. data/spec/dummy/bin/bundle +0 -3
  13. data/spec/dummy/bin/rails +0 -4
  14. data/spec/dummy/bin/rake +0 -4
  15. data/spec/dummy/bin/setup +0 -29
  16. data/spec/dummy/config/application.rb +0 -29
  17. data/spec/dummy/config/boot.rb +0 -5
  18. data/spec/dummy/config/environment.rb +0 -5
  19. data/spec/dummy/config/environments/development.rb +0 -38
  20. data/spec/dummy/config/environments/production.rb +0 -76
  21. data/spec/dummy/config/environments/test.rb +0 -42
  22. data/spec/dummy/config/initializers/assets.rb +0 -11
  23. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  24. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  25. data/spec/dummy/config/initializers/defra_ruby_email.rb +0 -5
  26. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  27. data/spec/dummy/config/initializers/inflections.rb +0 -16
  28. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  29. data/spec/dummy/config/initializers/session_store.rb +0 -3
  30. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -9
  32. data/spec/dummy/config/locales/en.yml +0 -23
  33. data/spec/dummy/config/routes.rb +0 -4
  34. data/spec/dummy/config/secrets.yml +0 -22
  35. data/spec/dummy/config.ru +0 -4
  36. data/spec/dummy/log/test.log +0 -13969
  37. data/spec/dummy/public/404.html +0 -67
  38. data/spec/dummy/public/422.html +0 -67
  39. data/spec/dummy/public/500.html +0 -66
  40. data/spec/dummy/public/favicon.ico +0 -0
  41. data/spec/examples.txt +0 -38
  42. data/spec/lib/last_email_cache_spec.rb +0 -221
  43. data/spec/lib/last_notify_message_spec.rb +0 -85
  44. data/spec/rails_helper.rb +0 -46
  45. data/spec/requests/last_email_spec.rb +0 -34
  46. data/spec/requests/last_notify_message_spec.rb +0 -82
  47. data/spec/spec_helper.rb +0 -83
  48. data/spec/support/helpers/configuration.rb +0 -16
  49. data/spec/support/pry.rb +0 -7
  50. data/spec/support/simplecov.rb +0 -17
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails_helper"
4
- require "notifications/client"
5
-
6
- module DefraRubyEmail
7
- RSpec.describe "LastNotifyMessage", type: :request do
8
- after(:all) { Helpers::Configuration.reset_for_tests }
9
-
10
- let(:path) { "/defra_ruby_email/last-notify-message" }
11
-
12
- let(:notify_api_key) { "hello-i-am-a-key" }
13
- let(:client) { double(:client, get_notifications: notifications) }
14
- let(:notifications) { double(:notifications, collection: collection) }
15
- let(:collection) { double(:collection, first: notification) }
16
- let(:notification) do
17
- double(:notification,
18
- type: "email",
19
- template: "template",
20
- subject: "Subject",
21
- body: "Body",
22
- sent_at: "datetime",
23
- email_address: "test@example.com",
24
- phone_number: nil,
25
- line_1: nil,
26
- line_2: nil,
27
- line_3: nil,
28
- line_4: nil,
29
- line_5: nil,
30
- line_6: nil,
31
- postcode: nil)
32
- end
33
-
34
- context "when the API is enabled" do
35
- let(:expected_data) do
36
- {
37
- last_notify_message: {
38
- type: "email",
39
- template: "template",
40
- subject: "Subject",
41
- body: "Body",
42
- date: "datetime",
43
- to: "test@example.com",
44
- line_1: nil,
45
- line_2: nil,
46
- line_3: nil,
47
- line_4: nil,
48
- line_5: nil,
49
- line_6: nil,
50
- postcode: nil
51
- }
52
- }.to_json
53
- end
54
-
55
- before(:each) do
56
- Helpers::Configuration.prep_for_tests
57
-
58
- expect(DefraRubyEmail.configuration).to receive(:notify_api_key).and_return(notify_api_key)
59
-
60
- expect(Notifications::Client).to receive(:new).with(notify_api_key).and_return(client)
61
- expect(client).to receive(:get_notifications).and_return(notifications)
62
- end
63
-
64
- it "returns a JSON response with a 200 code containing details of the last Notify message sent" do
65
- get path
66
-
67
- expect(response.media_type).to eq("application/json")
68
- expect(response.code).to eq("200")
69
-
70
- expect(response.body).to eq(expected_data)
71
- end
72
- end
73
-
74
- context "when the API is disabled" do
75
- before(:all) { DefraRubyEmail.configuration.enable = false }
76
-
77
- it "cannot load the page" do
78
- expect { get path }.to raise_error(ActionController::RoutingError)
79
- end
80
- end
81
- end
82
- end
data/spec/spec_helper.rb DELETED
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Require and run our simplecov initializer as the very first thing we do.
4
- # This is as per its docs https://github.com/colszowka/simplecov#getting-started
5
- require "./spec/support/simplecov"
6
-
7
- # This file was generated by the `rails generate rspec:install` command. Conventionally, all
8
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
- # The generated `.rspec` file contains `--require spec_helper` which will cause
10
- # this file to always be loaded, without a need to explicitly require it in any
11
- # files.
12
- #
13
- # Given that it is always loaded, you are encouraged to keep this file as
14
- # light-weight as possible. Requiring heavyweight dependencies from this file
15
- # will add to the boot time of your test suite on EVERY test run, even for an
16
- # individual file that may not need all of that loaded. Instead, consider making
17
- # a separate helper file that requires the additional dependencies and performs
18
- # the additional setup, and require it from the spec files that actually need
19
- # it.
20
- #
21
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
- RSpec.configure do |config|
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47
- # have no way to turn it off -- the option exists only for backwards
48
- # compatibility in RSpec 3). It causes shared context metadata to be
49
- # inherited by the metadata hash of host groups and examples, rather than
50
- # triggering implicit auto-inclusion in groups with matching metadata.
51
- config.shared_context_metadata_behavior = :apply_to_host_groups
52
-
53
- # This allows you to limit a spec run to individual examples or groups
54
- # you care about by tagging them with `:focus` metadata. When nothing
55
- # is tagged with `:focus`, all examples get run. RSpec also provides
56
- # aliases for `it`, `describe`, and `context` that include `:focus`
57
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
- config.filter_run_when_matching :focus
59
-
60
- # Allows RSpec to persist some state between runs in order to support
61
- # the `--only-failures` and `--next-failure` CLI options. We recommend
62
- # you configure your source control system to ignore this file.
63
- config.example_status_persistence_file_path = "spec/examples.txt"
64
-
65
- # Limits the available syntax to the non-monkey patched syntax that is
66
- # recommended. For more details, see:
67
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
- config.disable_monkey_patching!
71
-
72
- # Run specs in random order to surface order dependencies. If you find an
73
- # order dependency and want to debug it, you can fix the order by providing
74
- # the seed, which is printed after each run.
75
- # --seed 1234
76
- config.order = :random
77
-
78
- # Seed global randomization in this process using the `--seed` CLI option.
79
- # Setting this allows you to use `--seed` to deterministically reproduce
80
- # test failures related to randomization by passing the same `--seed` value
81
- # as the one that triggered the failure.
82
- Kernel.srand config.seed
83
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Helpers
4
- module Configuration
5
- def self.prep_for_tests
6
- DefraRubyEmail.reset_configuration
7
- DefraRubyEmail.configure do |config|
8
- config.enable = true
9
- end
10
- end
11
-
12
- def self.reset_for_tests
13
- DefraRubyEmail.reset_configuration
14
- end
15
- end
16
- end
data/spec/support/pry.rb DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Support debugging in the tests. Add `binding.pry` wherever you want execution
4
- # to stop and the debugger to kick in.
5
- # Details on the debugging commands can be found here
6
- # https://github.com/deivid-rodriguez/pry-byebug#commands
7
- require "pry-byebug"
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "simplecov"
4
-
5
- # We start it with the rails param to ensure it includes coverage for all code
6
- # started by the rails app, and not just the files touched by our unit tests.
7
- # This gives us the most accurate assessment of our unit test coverage
8
- # https://github.com/colszowka/simplecov#getting-started
9
- SimpleCov.start do
10
- # We filter the spec folder, mainly to ensure that any dummy apps don't get
11
- # included in the coverage report. However our intent is that nothing in the
12
- # spec folder should be included
13
- add_filter "/spec/"
14
- # The version file is simply just that, so we do not feel the need to ensure
15
- # we have a test for it
16
- add_filter "lib/defra_ruby_email/version"
17
- end