fortitude 0.0.5 → 0.0.6

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +20 -20
  3. data/CHANGES.md +19 -0
  4. data/CONTRIBUTORS.md +2 -0
  5. data/fortitude.gemspec +1 -0
  6. data/lib/fortitude/rails/railtie.rb +27 -75
  7. data/lib/fortitude/rails/rendering_methods.rb +77 -0
  8. data/lib/fortitude/tags/tags_module.rb +1 -0
  9. data/lib/fortitude/tilt/fortitude_template.rb +3 -1
  10. data/lib/fortitude/version.rb +1 -1
  11. data/lib/fortitude/widget/modules_and_subclasses.rb +2 -0
  12. data/spec/helpers/fortitude_rails_helpers.rb +19 -0
  13. data/spec/helpers/global_helper.rb +4 -2
  14. data/spec/rails/capture_system_spec.rb +1 -1
  15. data/spec/rails/development_mode_system_spec.rb +100 -6
  16. data/spec/rails/mailer_system_spec.rb +31 -0
  17. data/spec/rails/rendering_system_spec.rb +3 -3
  18. data/spec/rails/templates/development_mode_system_spec/app/controllers/development_mode_system_spec_controller.rb +16 -0
  19. data/spec/rails/templates/development_mode_system_spec/app/controllers/replaced_controller.rb +5 -0
  20. data/spec/rails/templates/development_mode_system_spec/app/mailers/development_mode_mailer.rb +17 -0
  21. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_formatting_test.rb +7 -0
  22. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_layout_test.rb +5 -0
  23. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_view_test.rb +5 -0
  24. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_formatting_test.rb +5 -0
  25. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_layout_test.rb +5 -0
  26. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_view_test.rb +5 -0
  27. data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/reload_widget_with_html_extension.html.rb +8 -0
  28. data/spec/rails/templates/development_mode_system_spec/app/views/layouts/mail_layout.rb +7 -0
  29. data/spec/rails/templates/development_mode_system_spec/app/views/replaced/reload_widget.rb +7 -0
  30. data/spec/rails/templates/development_mode_system_spec/app/views/shared/some_module.rb +5 -0
  31. data/spec/rails/templates/development_mode_system_spec/config/environments/development.rb +39 -0
  32. data/spec/rails/templates/mailer_system_spec/app/controllers/mailer_system_spec_controller.rb +17 -0
  33. data/spec/rails/templates/mailer_system_spec/app/mailers/basic_mailer.rb +25 -0
  34. data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/basic_mail.rb +5 -0
  35. data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_erb_layout_and_fortitude_view.rb +5 -0
  36. data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_fortitude_layout.rb +5 -0
  37. data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_fortitude_layout_and_erb_view.html.erb +1 -0
  38. data/spec/rails/templates/mailer_system_spec/app/views/layouts/erb_layout.html.erb +1 -0
  39. data/spec/rails/templates/mailer_system_spec/app/views/layouts/fortitude_layout.rb +8 -0
  40. data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail.rb +5 -0
  41. data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_erb_layout_and_fortitude_view.rb +5 -0
  42. data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_fortitude_layout.rb +5 -0
  43. data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_fortitude_layout_and_erb_view.rb +5 -0
  44. data/spec/rails/templates/mailer_system_spec/config/environments/production.rb +84 -0
  45. data/spec/rails/templates/rendering_system_spec/app/views/layouts/application.html.erb +1 -1
  46. data/spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb +1 -1
  47. data/spec/system/tilt_system_spec.rb +15 -0
  48. metadata +73 -16
  49. data/spec/helpers/rails_helpers.rb +0 -85
  50. data/spec/helpers/rails_server.rb +0 -390
  51. data/spec/rails/templates/base/app/controllers/application_controller.rb +0 -15
  52. data/spec/rails/templates/base/app/controllers/working_controller.rb +0 -5
  53. data/spec/rails/templates/base/app/views/layouts/application.html.erb +0 -11
  54. data/spec/rails/templates/base/config/routes.rb +0 -4
  55. data/spec/rails/templates/base/config/secrets.yml +0 -22
@@ -0,0 +1,31 @@
1
+ describe "Rails ActionMailer support", :type => :rails do
2
+ uses_rails_with_template :mailer_system_spec
3
+
4
+ it "should allow using Fortitude as a mailer template" do
5
+ expect_match("send_mail", /mail sent/)
6
+
7
+ mail = mail_sent_to('somebody@example.com')
8
+ expect(mail[:body].strip).to eq("<p>this is the basic mail!</p>")
9
+ end
10
+
11
+ it "should allow using a Fortitude layout with a non-Fortitude view" do
12
+ expect_match("send_mail_with_fortitude_layout_and_erb_view", /mail sent/)
13
+
14
+ mail = mail_sent_to('somebody_with_fortitude_layout_and_erb_view@example.com')
15
+ expect(mail[:body].strip).to match(%r{<div><p>this is the Fortitude layout</p><p>this is the mail with an ERb view!</p>\s*</div>}i)
16
+ end
17
+
18
+ it "should allow using a non-Fortitude layout with a Fortitude view" do
19
+ expect_match("send_mail_with_erb_layout_and_fortitude_view", /mail sent/)
20
+
21
+ mail = mail_sent_to('somebody_with_erb_layout_and_fortitude_view@example.com')
22
+ expect(mail[:body].strip).to match(%r{<div><p>this is the ERb layout</p><p>this is the mail with a Fortitude view!</p>\s*</div>}i)
23
+ end
24
+
25
+ it "should allow using a Fortitude layout with a Fortitude view" do
26
+ expect_match("send_mail_with_fortitude_layout", /mail sent/)
27
+
28
+ mail = mail_sent_to('somebody_with_fortitude_layout@example.com')
29
+ expect(mail[:body].strip).to eq("<div><p>this is the Fortitude layout</p><p>this is the mail with Fortitude layout!</p></div>")
30
+ end
31
+ end
@@ -12,12 +12,12 @@ describe "Rails rendering support", :type => :rails do
12
12
 
13
13
  it "should let you specify a widget with 'render :widget =>', which should use a layout by default" do
14
14
  data = expect_match("render_widget", /hello from a widget named Fred/)
15
- expect(data).to match(/rails_spec_application/)
15
+ expect(data).to match(/oop_rails_server_base_template/)
16
16
  end
17
17
 
18
18
  it "should let you omit the layout with 'render :widget =>', if you ask for it" do
19
19
  data = expect_match("render_widget_without_layout", /hello from a widget named Fred/, :no_layout => true)
20
- expect(data).not_to match(/rails_spec_application/)
20
+ expect(data).not_to match(/oop_rails_server_base_template/)
21
21
  end
22
22
 
23
23
  it "should set the Content-Type to text/html when using render :widget" do
@@ -149,7 +149,7 @@ describe "Rails rendering support", :type => :rails do
149
149
  end
150
150
 
151
151
  it "should let you stream from a widget that's in an ERb layout" do
152
- skip("Fortitude streaming test is not supported under Rails 3.0.x") if @rails_server.rails_version =~ /^3\.0\./
152
+ skip("Fortitude streaming test is not supported under Rails 3.0.x") if rails_server.rails_version =~ /^3\.0\./
153
153
  skip("Fortitude streaming test is not supported under Ruby 1.8") if RUBY_VERSION =~ /^1\.8\./
154
154
 
155
155
  chunks = collect_chunks("stream_widget_with_layout")
@@ -3,7 +3,23 @@ class DevelopmentModeSystemSpecController < ApplicationController
3
3
  @datum = "one"
4
4
  end
5
5
 
6
+ def reload_widget_with_html_extension
7
+ @datum = "five"
8
+ end
9
+
6
10
  def sample_output
7
11
  @name = "Jessica"
8
12
  end
13
+
14
+ def mailer_view_test
15
+ DevelopmentModeMailer.mailer_view_test.deliver
16
+ end
17
+
18
+ def mailer_layout_test
19
+ DevelopmentModeMailer.mailer_layout_test.deliver
20
+ end
21
+
22
+ def mailer_formatting_test
23
+ DevelopmentModeMailer.mailer_formatting_test.deliver
24
+ end
9
25
  end
@@ -0,0 +1,5 @@
1
+ class ReplacedController < ApplicationController
2
+ def reload_widget
3
+ @datum = "one"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ class DevelopmentModeMailer < ActionMailer::Base
2
+ default :from => 'nobody@example.com'
3
+
4
+ def mailer_view_test
5
+ mail(:to => 'mailer_view_test@example.com', :subject => 'Mailer View Test')
6
+ end
7
+
8
+ def mailer_layout_test
9
+ mail(:to => 'mailer_layout_test@example.com', :subject => 'Mailer Layout Test') do |format|
10
+ format.html { render :layout => 'mail_layout' }
11
+ end
12
+ end
13
+
14
+ def mailer_formatting_test
15
+ mail(:to => 'mailer_formatting_test@example.com', :subject => 'Mailer Formatting Test')
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ class Views::DevelopmentModeMailer::MailerFormattingTest < Fortitude::Widgets::Html5
2
+ def content
3
+ div {
4
+ p "this is the text!"
5
+ }
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class Views::DevelopmentModeMailer::MailerLayoutTest < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the basic mail!"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::DevelopmentModeMailer::MailerViewTest < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the basic mail!"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::DevelopmentModeSystemSpec::MailerFormattingTest < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::DevelopmentModeSystemSpec::MailerLayoutTest < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::DevelopmentModeSystemSpec::MailerViewTest < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ class Views::DevelopmentModeSystemSpec::ReloadWidgetWithHtmlExtension < Fortitude::Widgets::Html5
2
+ include Views::Shared::SomeModule
3
+ needs :datum
4
+
5
+ def content
6
+ p "with_html_extension: datum #{datum} datum, helper: #{some_helper}"
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ class Views::Layouts::MailLayout < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the layout, before"
4
+ yield
5
+ p "this is the layout, after"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Views::Replaced::ReloadWidget < Fortitude::Widgets::Html5
2
+ needs :datum
3
+
4
+ def content
5
+ p "before_reload: datum #{datum} datum"
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Views::Shared::SomeModule
2
+ def some_helper
3
+ "yo"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ DevelopmentModeSystemSpec::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ # config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ # config.assets.debug = true
29
+
30
+ # Adds additional error checking when serving assets at runtime.
31
+ # Checks for improperly declared sprockets dependencies.
32
+ # Raises helpful error messages.
33
+ # config.assets.raise_runtime_errors = true
34
+
35
+ # Raises error for missing translations
36
+ # config.action_view.raise_on_missing_translations = true
37
+
38
+ config.action_mailer.delivery_method = :file
39
+ end
@@ -0,0 +1,17 @@
1
+ class MailerSystemSpecController < ApplicationController
2
+ def send_mail
3
+ BasicMailer.basic_mail.deliver
4
+ end
5
+
6
+ def send_mail_with_fortitude_layout
7
+ BasicMailer.mail_with_fortitude_layout.deliver
8
+ end
9
+
10
+ def send_mail_with_fortitude_layout_and_erb_view
11
+ BasicMailer.mail_with_fortitude_layout_and_erb_view.deliver
12
+ end
13
+
14
+ def send_mail_with_erb_layout_and_fortitude_view
15
+ BasicMailer.mail_with_erb_layout_and_fortitude_view.deliver
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ class BasicMailer < ActionMailer::Base
2
+ default :from => 'nobody@example.com'
3
+
4
+ def basic_mail
5
+ mail(:to => 'somebody@example.com', :subject => 'Basic Mail')
6
+ end
7
+
8
+ def mail_with_fortitude_layout
9
+ mail(:to => 'somebody_with_fortitude_layout@example.com', :subject => 'Basic Mail') do |format|
10
+ format.html { render :layout => 'fortitude_layout' }
11
+ end
12
+ end
13
+
14
+ def mail_with_fortitude_layout_and_erb_view
15
+ mail(:to => 'somebody_with_fortitude_layout_and_erb_view@example.com', :subject => 'Basic Mail') do |format|
16
+ format.html { render :layout => 'fortitude_layout' }
17
+ end
18
+ end
19
+
20
+ def mail_with_erb_layout_and_fortitude_view
21
+ mail(:to => 'somebody_with_erb_layout_and_fortitude_view@example.com', :subject => 'Basic Mail') do |format|
22
+ format.html { render :layout => 'erb_layout' }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ class Views::BasicMailer::BasicMail < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the basic mail!"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::BasicMailer::MailWithErbLayoutAndFortitudeView < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the mail with a Fortitude view!"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::BasicMailer::MailWithFortitudeLayout < Fortitude::Widgets::Html5
2
+ def content
3
+ p "this is the mail with Fortitude layout!"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ <div><p>this is the ERb layout</p><%= yield %></div>
@@ -0,0 +1,8 @@
1
+ class Views::Layouts::FortitudeLayout < Fortitude::Widgets::Html5
2
+ def content
3
+ div {
4
+ p "this is the Fortitude layout"
5
+ yield
6
+ }
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ class Views::MailerSystemSpec::SendMail < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::MailerSystemSpec::SendMailWithErbLayoutAndFortitudeView < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::MailerSystemSpec::SendMailWithFortitudeLayout < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Views::MailerSystemSpec::SendMailWithFortitudeLayoutAndErbView < Fortitude::Widgets::Html5
2
+ def content
3
+ p "mail sent"
4
+ end
5
+ end
@@ -0,0 +1,84 @@
1
+ MailerSystemSpec::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ # config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ # config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ # config.assets.digest = true
34
+
35
+ # `config.assets.precompile` has moved to config/initializers/assets.rb
36
+
37
+ # Specifies the header that your server uses for sending files.
38
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
39
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40
+
41
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
+ # config.force_ssl = true
43
+
44
+ # Set to :debug to see everything in the log.
45
+ config.log_level = :info
46
+
47
+ # Prepend all log lines with the following tags.
48
+ # config.log_tags = [ :subdomain, :uuid ]
49
+
50
+ # Use a different logger for distributed setups.
51
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
52
+
53
+ # Use a different cache store in production.
54
+ # config.cache_store = :mem_cache_store
55
+
56
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
57
+ # config.action_controller.asset_host = "http://assets.example.com"
58
+
59
+ # Precompile additional assets.
60
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
61
+ # config.assets.precompile += %w( search.js )
62
+
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
+ # config.action_mailer.raise_delivery_errors = false
66
+
67
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
+ # the I18n.default_locale when a translation cannot be found).
69
+ config.i18n.fallbacks = true
70
+
71
+ # Send deprecation notices to registered listeners.
72
+ config.active_support.deprecation = :notify
73
+
74
+ # Disable automatic flushing of the log to improve performance.
75
+ # config.autoflush_log = false
76
+
77
+ # Use default logging formatter so that PID and timestamp are not suppressed.
78
+ config.log_formatter = ::Logger::Formatter.new
79
+
80
+ # Do not dump schema after migrations.
81
+ # config.active_record.dump_schema_after_migration = false
82
+
83
+ config.action_mailer.delivery_method = :file
84
+ end
@@ -5,7 +5,7 @@ $order << :layout_start if $order
5
5
  start_of_layout order: <%= $order.inspect %>
6
6
  <html>
7
7
  <head>
8
- <title>rails_spec_application layout_default</title>
8
+ <title>oop_rails_server_base_template layout_default</title>
9
9
  </head>
10
10
  <body>
11
11
 
@@ -7,7 +7,7 @@ class Views::Layouts::FortitudeLayoutWithP < Fortitude::Widgets::Html5
7
7
 
8
8
  html {
9
9
  head {
10
- title "rails_spec_application"
10
+ title "oop_rails_server_base_template"
11
11
  }
12
12
  }
13
13
  body {
@@ -54,6 +54,16 @@ class SimpleTemplateWithVariables < Fortitude::Widgets::Html5
54
54
  text "foo: \#{foo}, bar: \#{bar}"
55
55
  end
56
56
  end
57
+ EOS
58
+
59
+ SIMPLE_TEMPLATE_WITH_VARIABLES_ALL_DEFAULTED = <<-EOS
60
+ class SimpleTemplateWithVariablesAllDefaulted < Fortitude::Widgets::Html5
61
+ needs :foo => 'something', :bar => 'whatever'
62
+
63
+ def content
64
+ text "foo: \#{foo}, bar: \#{bar}"
65
+ end
66
+ end
57
67
  EOS
58
68
 
59
69
  SIMPLE_TEMPLATE_WITH_VARIABLES_NO_EXTRA_ASSIGNS = <<-EOS
@@ -83,6 +93,11 @@ EOS
83
93
  expect(result).to eq("foo: the_foo, bar: the_bar")
84
94
  end
85
95
 
96
+ it "should allow passing nil for locals to the template, and should act like there are no variables" do
97
+ result = render_text_with_tilt("simple_template_with_variables.rb", SIMPLE_TEMPLATE_WITH_VARIABLES_ALL_DEFAULTED, context_object, nil)
98
+ expect(result).to eq("foo: something, bar: whatever")
99
+ end
100
+
86
101
  def context_object(variable_mappings = { }, klass = Object.class, &block)
87
102
  out = klass.new
88
103
  variable_mappings.each do |name, value|