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,3 @@
1
+ # New message from: <%= @from %>
2
+
3
+ <%= @message %>
@@ -0,0 +1,50 @@
1
+ <h1><a href="https://github.com/fgrehm/letter_opener_web">letter_opener_web</a> Demo</h1>
2
+
3
+ <div class="row">
4
+ <div class="span6 offset3">
5
+
6
+ <div class="well">
7
+ <%= form_tag root_path, multipart: true do %>
8
+ <legend>Contact form</legend>
9
+ <div class="control-group">
10
+ <label class="control-label" for="email">Email</label>
11
+ <div class="controls">
12
+ <input type="text" class="input-block-level" name="email">
13
+ </div>
14
+ </div>
15
+ <div class="control-group">
16
+ <label class="control-label" for="attachment">Attachment <em>(optional)</em></label>
17
+ <div class="controls">
18
+ <input type='file' name='attachment' />
19
+ </div>
20
+ </div>
21
+ <div class="control-group">
22
+ <label class="control-label" for="message">Message</label>
23
+ <div class="controls">
24
+ <textarea class="input-block-level" name="message" rows="6"></textarea>
25
+ </div>
26
+ </div>
27
+ <div class="control-group">
28
+ <div class="controls">
29
+ <button type="submit" class="btn btn-primary pull-right">
30
+ <i class="icon-envelope icon-white"></i>
31
+ Send mail
32
+ </button>
33
+ <div class="clearfix"></div>
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+
38
+ <p class="footer">
39
+ <a href="/letter_opener" target="_blank">Click here</a>
40
+ to see sent mails
41
+ </p>
42
+ </div>
43
+
44
+ <% if flash[:notice].present? %>
45
+ <div class="alert alert-success">
46
+ <%= flash[:notice] %>
47
+ </div>
48
+ <% end %>
49
+ </div>
50
+ </div>
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
+ <%= stylesheet_link_tag '//maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css' %>
9
+ </head>
10
+
11
+ <body>
12
+ <div class="container">
13
+ <%= yield %>
14
+ </div>
15
+
16
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
17
+ </body>
18
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../config/boot'
5
+ require 'rake'
6
+ Rake.application.run
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a starting point to setup your application.
17
+ # Add necessary setup steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a way to update your development environment automatically.
17
+ # Add necessary update steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require_relative 'config/environment'
6
+
7
+ run Rails.application
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boot'
4
+
5
+ require 'active_model/railtie'
6
+ require 'action_controller/railtie'
7
+ require 'action_mailer/railtie'
8
+ require 'action_view/railtie'
9
+ require 'sprockets/railtie'
10
+ require 'rails/test_unit/railtie'
11
+
12
+ Bundler.require(*Rails.groups)
13
+ require 'letter_opener_web'
14
+
15
+ module Dummy
16
+ class Application < Rails::Application
17
+ # Settings in config/environments/* take precedence over those specified here.
18
+ # Application configuration should go into files in config/initializers
19
+ # -- all .rb files in that directory are automatically loaded.
20
+
21
+ config.action_mailer.delivery_method = :letter_opener_web
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
+
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative 'application'
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded on
7
+ # every request. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ config.action_controller.perform_caching = false
18
+ config.cache_store = :null_store
19
+
20
+ # Don't care if the mailer can't send.
21
+ config.action_mailer.raise_delivery_errors = false
22
+
23
+ # Print deprecation notices to the Rails logger.
24
+ config.active_support.deprecation = :log
25
+
26
+ # Debug mode disables concatenation and preprocessing of assets.
27
+ # This option may cause significant delays in view rendering with a large
28
+ # number of complex assets.
29
+ config.assets.debug = true
30
+
31
+ # Suppress logger output for asset requests.
32
+ config.assets.quiet = true
33
+
34
+ # Raises error for missing translations
35
+ # config.action_view.raise_on_missing_translations = true
36
+
37
+ # Use an evented file watcher to asynchronously detect changes in source code,
38
+ # routes, locales, etc. This feature depends on the listen gem.
39
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
40
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.cache_classes = true
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Disable serving static files from the `/public` folder by default since
20
+ # Apache or NGINX already handles this.
21
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
22
+
23
+ # Compress JavaScripts and CSS.
24
+ config.assets.js_compressor = :uglifier
25
+ # config.assets.css_compressor = :sass
26
+
27
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
28
+ config.assets.compile = false
29
+
30
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
31
+
32
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
33
+ # config.action_controller.asset_host = 'http://assets.example.com'
34
+
35
+ # Specifies the header that your server uses for sending files.
36
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
37
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
38
+
39
+ # Mount Action Cable outside main process or domain
40
+ # config.action_cable.mount_path = nil
41
+ # config.action_cable.url = 'wss://example.com/cable'
42
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
43
+
44
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
+ # config.force_ssl = true
46
+
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
50
+
51
+ # Prepend all log lines with the following tags.
52
+ config.log_tags = [:request_id]
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Use a real queuing backend for Active Job (and separate queues per environment)
58
+ # config.active_job.queue_adapter = :resque
59
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
60
+ config.action_mailer.perform_caching = false
61
+
62
+ # Ignore bad email addresses and do not raise email delivery errors.
63
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
64
+ # config.action_mailer.raise_delivery_errors = false
65
+
66
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
67
+ # the I18n.default_locale when a translation cannot be found).
68
+ config.i18n.fallbacks = true
69
+
70
+ # Send deprecation notices to registered listeners.
71
+ config.active_support.deprecation = :notify
72
+
73
+ # Use default logging formatter so that PID and timestamp are not suppressed.
74
+ config.log_formatter = ::Logger::Formatter.new
75
+
76
+ # Use a different logger for distributed setups.
77
+ # require 'syslog/logger'
78
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
79
+
80
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
81
+ logger = ActiveSupport::Logger.new(STDOUT)
82
+ logger.formatter = config.log_formatter
83
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
84
+ end
85
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+ config.cache_classes = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Show full error reports and disable caching.
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates.
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment.
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Print deprecation notices to the stderr.
33
+ config.active_support.deprecation = :stderr
34
+
35
+ # Raises error for missing translations
36
+ # config.action_view.raise_on_missing_translations = true
37
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # ApplicationController.renderer.defaults.merge!(
5
+ # http_host: 'example.org',
6
+ # https: false
7
+ # )
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Version of your assets, change this if you want to expire all your assets.
6
+ Rails.application.config.assets.version = '1.0'
7
+
8
+ # Add additional assets to the asset load path
9
+ # Rails.application.config.assets.paths << Emoji.images_path
10
+
11
+ # Precompile additional assets.
12
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
13
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6
+
7
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Specify a serializer for the signed and encrypted cookie jars.
6
+ # Valid options are :json, :marshal, and :hybrid.
7
+ Rails.application.config.action_dispatch.cookies_serializer = :json