letter_opener_web 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +27 -0
  5. data/.travis.yml +21 -4
  6. data/CHANGELOG.md +7 -0
  7. data/Gemfile +3 -7
  8. data/README.md +15 -4
  9. data/Rakefile +6 -35
  10. data/app/assets/javascripts/letter_opener_web/application.js +1 -1
  11. data/app/controllers/letter_opener_web/application_controller.rb +2 -0
  12. data/app/controllers/letter_opener_web/letters_controller.rb +19 -21
  13. data/app/models/letter_opener_web/letter.rb +27 -23
  14. data/app/views/layouts/letter_opener_web/{application.html.erb → letters.html.erb} +0 -2
  15. data/app/views/letter_opener_web/letters/index.html.erb +8 -8
  16. data/{script → bin}/rails +4 -1
  17. data/bin/setup +6 -0
  18. data/config/routes.rb +2 -0
  19. data/letter_opener_web.gemspec +13 -11
  20. data/lib/letter_opener_web.rb +20 -1
  21. data/lib/letter_opener_web/delivery_method.rb +5 -3
  22. data/lib/letter_opener_web/engine.rb +12 -7
  23. data/lib/letter_opener_web/version.rb +3 -1
  24. data/script/pre-push +2 -0
  25. data/spec/controllers/letter_opener_web/letters_controller_spec.rb +50 -32
  26. data/spec/dummy/Rakefile +8 -0
  27. data/spec/dummy/app/assets/config/manifest.js +5 -0
  28. data/spec/{internal/public/favicon.ico → dummy/app/assets/images/.keep} +0 -0
  29. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  30. data/spec/dummy/app/assets/stylesheets/application.css +31 -0
  31. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  32. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  33. data/spec/dummy/app/controllers/home_controller.rb +10 -0
  34. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  35. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  36. data/spec/dummy/app/mailers/contact_mailer.rb +14 -0
  37. data/spec/dummy/app/views/contact_mailer/new_message.html.erb +21 -0
  38. data/spec/dummy/app/views/contact_mailer/new_message.text.erb +3 -0
  39. data/spec/dummy/app/views/home/index.html.erb +50 -0
  40. data/spec/dummy/app/views/layouts/application.html.erb +18 -0
  41. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  42. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  43. data/spec/dummy/bin/bundle +5 -0
  44. data/spec/dummy/bin/rails +6 -0
  45. data/spec/dummy/bin/rake +6 -0
  46. data/spec/dummy/bin/setup +36 -0
  47. data/spec/dummy/bin/update +31 -0
  48. data/spec/dummy/config.ru +7 -0
  49. data/spec/dummy/config/application.rb +23 -0
  50. data/spec/dummy/config/boot.rb +7 -0
  51. data/spec/dummy/config/environment.rb +7 -0
  52. data/spec/dummy/config/environments/development.rb +40 -0
  53. data/spec/dummy/config/environments/production.rb +85 -0
  54. data/spec/dummy/config/environments/test.rb +37 -0
  55. data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
  56. data/spec/dummy/config/initializers/assets.rb +13 -0
  57. data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
  58. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  59. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  60. data/spec/dummy/config/initializers/inflections.rb +17 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  62. data/spec/dummy/config/initializers/new_framework_defaults.rb +10 -0
  63. data/spec/dummy/config/initializers/session_store.rb +5 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  65. data/spec/dummy/config/locales/en.yml +23 -0
  66. data/spec/dummy/config/puma.rb +49 -0
  67. data/spec/dummy/config/routes.rb +8 -0
  68. data/spec/dummy/config/secrets.yml +22 -0
  69. data/spec/dummy/config/spring.rb +8 -0
  70. data/spec/dummy/lib/assets/.keep +0 -0
  71. data/spec/dummy/public/404.html +67 -0
  72. data/spec/dummy/public/422.html +67 -0
  73. data/spec/dummy/public/500.html +66 -0
  74. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  75. data/spec/dummy/public/apple-touch-icon.png +0 -0
  76. data/spec/dummy/public/favicon.ico +0 -0
  77. data/spec/letter_opener_web_spec.rb +44 -0
  78. data/spec/models/letter_opener_web/letter_spec.rb +23 -15
  79. data/spec/rails_helper.rb +8 -0
  80. data/spec/spec_helper.rb +2 -16
  81. metadata +142 -30
  82. data/Gemfile.lock +0 -167
  83. data/Guardfile +0 -14
  84. data/lib/tasks/letter_opener_web_tasks.rake +0 -4
  85. data/spec/internal/config/database.yml +0 -3
  86. data/spec/internal/config/routes.rb +0 -7
  87. data/spec/internal/db/schema.rb +0 -3
  88. data/spec/internal/log/.gitignore +0 -1
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Configure sensitive parameters which will be filtered from the log file.
6
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new inflection rules using the following format. Inflections
5
+ # are locale specific, and you may define rules for as many different
6
+ # locales as you wish. All of these examples are active by default:
7
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
8
+ # inflect.plural /^(ox)$/i, '\1en'
9
+ # inflect.singular /^(ox)en/i, '\1'
10
+ # inflect.irregular 'person', 'people'
11
+ # inflect.uncountable %w( fish sheep )
12
+ # end
13
+
14
+ # These inflection rules are supported but not enabled by default:
15
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
16
+ # inflect.acronym 'RESTful'
17
+ # end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new mime types for use in respond_to blocks:
5
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+ #
5
+ # This file contains migration options to ease your Rails 5.0 upgrade.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+
9
+ # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
10
+ Rails.application.config.ssl_options = { hsts: { subdomains: true } }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # This file contains settings for ActionController::ParamsWrapper which
6
+ # is enabled by default.
7
+
8
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9
+ ActiveSupport.on_load(:action_controller) do
10
+ wrap_parameters format: [:json]
11
+ end
12
+
13
+ # To enable root element in JSON for ActiveRecord objects.
14
+ # ActiveSupport.on_load(:active_record) do
15
+ # self.include_root_in_json = true
16
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Puma can serve each request in a thread from an internal thread pool.
4
+ # The `threads` method setting takes two numbers a minimum and maximum.
5
+ # Any libraries that use thread pools should be configured to match
6
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
7
+ # and maximum, this matches the default thread size of Active Record.
8
+ #
9
+ threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
10
+ threads threads_count, threads_count
11
+
12
+ # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
13
+ #
14
+ port ENV.fetch('PORT') { 3000 }
15
+
16
+ # Specifies the `environment` that Puma will run in.
17
+ #
18
+ environment ENV.fetch('RAILS_ENV') { 'development' }
19
+
20
+ # Specifies the number of `workers` to boot in clustered mode.
21
+ # Workers are forked webserver processes. If using threads and workers together
22
+ # the concurrency of the application would be max `threads` * `workers`.
23
+ # Workers do not work on JRuby or Windows (both of which do not support
24
+ # processes).
25
+ #
26
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
27
+
28
+ # Use the `preload_app!` method when specifying a `workers` number.
29
+ # This directive tells Puma to first boot the application and load code
30
+ # before forking the application. This takes advantage of Copy On Write
31
+ # process behavior so workers use less memory. If you use this option
32
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
33
+ # block.
34
+ #
35
+ # preload_app!
36
+
37
+ # The code in the `on_worker_boot` will be called if you are using
38
+ # clustered mode by specifying a number of `workers`. After each worker
39
+ # process is booted this block will be run, if you are using `preload_app!`
40
+ # option you will want to use this block to reconnect to any threads
41
+ # or connections that may have been created at application boot, Ruby
42
+ # cannot share connections between processes.
43
+ #
44
+ # on_worker_boot do
45
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
46
+ # end
47
+
48
+ # Allow puma to be restarted by `rails restart` command.
49
+ plugin :tmp_restart
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ mount LetterOpenerWeb::Engine => '/letter_opener'
5
+
6
+ root to: 'home#index'
7
+ post '/', to: 'home#create'
8
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: a620e35d747d88c5fc8892b46a0fbb32b6b9975b2edcb4aaf1b76a8e46b70cca77d55c55ff1146a14ea9ee91eec9a6a5ebda33745cb5c05a58968d2b318af86b
15
+
16
+ test:
17
+ secret_key_base: a18afce29fc99e78cd2abf56c7b4bade7bba4da68ca781dbaa3cb53afe9819f6cf0a42667a6d0c9a23bfe34ce070eeaef32f14b67887d25c9333d9371df30ee6
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ .ruby-version
5
+ .rbenv-vars
6
+ tmp/restart.txt
7
+ tmp/caching-dev.txt
8
+ ].each { |path| Spring.watch(path) }
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe LetterOpenerWeb do
6
+ subject { described_class }
7
+ after(:each) { described_class.reset! }
8
+
9
+ describe '.config' do
10
+ it 'sets defaults' do
11
+ expected = Rails.root.join('tmp', 'letter_opener')
12
+ expect(subject.config.letters_location).to eq(expected)
13
+ end
14
+ end
15
+
16
+ describe '.configure' do
17
+ it 'yields config to the block' do
18
+ subject.configure do |config|
19
+ expect(config).to eq(subject.config)
20
+ end
21
+ end
22
+
23
+ it 'retains settings set within the block' do
24
+ subject.configure do |config|
25
+ config.letters_location = 'tmp/test_path'
26
+ end
27
+
28
+ expect(subject.config.letters_location).to eq('tmp/test_path')
29
+ end
30
+ end
31
+
32
+ describe '.reset!' do
33
+ it 'resets configuration' do
34
+ subject.configure do |config|
35
+ config.letters_location = 'tmp/test_path'
36
+ end
37
+
38
+ subject.reset!
39
+
40
+ expected = Rails.root.join('tmp', 'letter_opener')
41
+ expect(subject.config.letters_location).to eq(expected)
42
+ end
43
+ end
44
+ end