remotipart 1.3.0 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +35 -0
  3. data/Appraisals +25 -0
  4. data/Gemfile +14 -1
  5. data/History.rdoc +27 -0
  6. data/README.rdoc +2 -0
  7. data/Rakefile +5 -7
  8. data/gemfiles/rails_3.2.gemfile +26 -0
  9. data/gemfiles/rails_4.2.gemfile +24 -0
  10. data/gemfiles/rails_5.2.gemfile +24 -0
  11. data/gemfiles/rails_6.0.gemfile +24 -0
  12. data/lib/remotipart/middleware.rb +2 -2
  13. data/lib/remotipart/rails/engine.rb +8 -4
  14. data/lib/remotipart/rails/railtie.rb +8 -4
  15. data/lib/remotipart/rails/version.rb +2 -2
  16. data/lib/remotipart/render_overrides.rb +28 -8
  17. data/lib/remotipart/request_helper.rb +2 -0
  18. data/lib/remotipart/view_helper.rb +2 -0
  19. data/remotipart.gemspec +94 -18
  20. data/spec/dummy_app/.gitignore +17 -0
  21. data/spec/dummy_app/Rakefile +7 -0
  22. data/spec/dummy_app/app/assets/config/manifest.js +4 -0
  23. data/spec/dummy_app/app/assets/images/rails.png +0 -0
  24. data/spec/dummy_app/app/assets/javascripts/application.js.erb +8 -0
  25. data/spec/dummy_app/app/assets/javascripts/comments.js +28 -0
  26. data/spec/dummy_app/app/assets/stylesheets/application.css +6 -0
  27. data/spec/dummy_app/app/assets/stylesheets/scaffold.css +65 -0
  28. data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
  29. data/spec/dummy_app/app/controllers/comments_controller.rb +72 -0
  30. data/spec/dummy_app/app/controllers/prepended_controller.rb +9 -0
  31. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy_app/app/helpers/comments_helper.rb +2 -0
  33. data/spec/dummy_app/app/models/comment.rb +7 -0
  34. data/spec/dummy_app/app/views/comments/_comment.html.erb +9 -0
  35. data/spec/dummy_app/app/views/comments/_form.html.erb +40 -0
  36. data/spec/dummy_app/app/views/comments/_new_comment_links.html.erb +5 -0
  37. data/spec/dummy_app/app/views/comments/create.html.erb +7 -0
  38. data/spec/dummy_app/app/views/comments/create.js.erb +20 -0
  39. data/spec/dummy_app/app/views/comments/destroy.js.erb +1 -0
  40. data/spec/dummy_app/app/views/comments/edit.html.erb +6 -0
  41. data/spec/dummy_app/app/views/comments/escape_test.html.erb +1 -0
  42. data/spec/dummy_app/app/views/comments/index.html.erb +19 -0
  43. data/spec/dummy_app/app/views/comments/new.html.erb +7 -0
  44. data/spec/dummy_app/app/views/comments/show.html.erb +15 -0
  45. data/spec/dummy_app/app/views/layouts/application.html.erb +14 -0
  46. data/spec/dummy_app/app/views/prepended/show.html.erb +1 -0
  47. data/spec/dummy_app/bin/bundle +3 -0
  48. data/spec/dummy_app/bin/rails +4 -0
  49. data/spec/dummy_app/bin/rake +4 -0
  50. data/spec/dummy_app/bin/setup +34 -0
  51. data/spec/dummy_app/bin/update +29 -0
  52. data/spec/dummy_app/config/application.rb +18 -0
  53. data/spec/dummy_app/config/boot.rb +3 -0
  54. data/spec/dummy_app/config/database.yml +7 -0
  55. data/spec/dummy_app/config/environment.rb +5 -0
  56. data/spec/dummy_app/config/environments/development.rb +54 -0
  57. data/spec/dummy_app/config/environments/test.rb +53 -0
  58. data/spec/dummy_app/config/initializers/secret_token.rb +3 -0
  59. data/spec/dummy_app/config/routes.rb +7 -0
  60. data/spec/dummy_app/config/secrets.yml +5 -0
  61. data/spec/dummy_app/config.ru +4 -0
  62. data/spec/dummy_app/db/migrate/20110209210252_create_comments.rb +14 -0
  63. data/spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb +15 -0
  64. data/spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb +8 -0
  65. data/spec/dummy_app/db/schema.rb +31 -0
  66. data/spec/dummy_app/db/seeds.rb +7 -0
  67. data/spec/features/comments_spec.rb +414 -0
  68. data/spec/features/prepended_spec.rb +9 -0
  69. data/spec/fixtures/hi.txt +1 -0
  70. data/spec/fixtures/qr.jpg +0 -0
  71. data/spec/spec_helper.rb +40 -0
  72. data/spec/support/arel_helper.rb +15 -0
  73. data/spec/support/connection_helper.rb +12 -0
  74. data/spec/support/integration_helper.rb +28 -0
  75. data/vendor/assets/javascripts/jquery.iframe-transport.js +40 -29
  76. data/vendor/assets/javascripts/jquery.remotipart.js +1 -1
  77. metadata +134 -4
@@ -0,0 +1,65 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ legend.required:before {
28
+ content: "*";
29
+ color: red;
30
+ }
31
+ label.required:after {
32
+ content: "*";
33
+ color: red;
34
+ }
35
+
36
+ .field_with_errors {
37
+ padding: 2px;
38
+ background-color: red;
39
+ display: table;
40
+ }
41
+
42
+ #error_explanation, #ajax-validation-errors {
43
+ width: 450px;
44
+ border: 2px solid red;
45
+ padding: 7px;
46
+ padding-bottom: 0;
47
+ margin-bottom: 20px;
48
+ background-color: #f0f0f0;
49
+ }
50
+
51
+ #error_explanation h2, #ajax-validation-errors h2{
52
+ text-align: left;
53
+ font-weight: bold;
54
+ padding: 5px 5px 5px 15px;
55
+ font-size: 12px;
56
+ margin: -7px;
57
+ margin-bottom: 0px;
58
+ background-color: #c00;
59
+ color: #fff;
60
+ }
61
+
62
+ #error_explanation ul li {
63
+ font-size: 12px;
64
+ list-style: square;
65
+ }
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,72 @@
1
+ class CommentsController < ApplicationController
2
+ def index
3
+ @comments = Comment.all
4
+ respond_to do |format|
5
+ format.html
6
+ format.json { render json: @comments }
7
+ end
8
+ end
9
+
10
+ def show
11
+ @comment = Comment.find(params[:id])
12
+ respond_to do |format|
13
+ format.html
14
+ format.json { render json: @comment }
15
+ end
16
+ end
17
+
18
+ def new
19
+ @comment = Comment.new
20
+ respond_to do |format|
21
+ format.html { render :layout => ! request.xhr? }
22
+ end
23
+ end
24
+
25
+ def edit
26
+ @comment = Comment.find(params[:id])
27
+ respond_to do |format|
28
+ format.html
29
+ format.json { render json: @comment }
30
+ end
31
+ end
32
+
33
+ def create
34
+ @comment = Comment.create(comment_params)
35
+ if request.xhr? || remotipart_submitted?
36
+ sleep 1 if params[:pause]
37
+ respond_to do |format|
38
+ format.html { render (params[:template] == 'escape' ? 'comments/escape_test' : 'comments/create'), layout: false }
39
+ format.js { render 'comments/create', layout: false, status:(@comment.errors.any? ? :unprocessable_entity : :ok) }
40
+ format.json { render json: @comment }
41
+ end
42
+ else
43
+ redirect_to comments_path
44
+ end
45
+ end
46
+
47
+ def update
48
+ @comment = Comment.find(params[:id])
49
+ respond_to do |format|
50
+ format.html { redirect_to @comment }
51
+ format.js { render json: @comment }
52
+ end
53
+ end
54
+
55
+ def destroy
56
+ @comment = Comment.destroy(params[:id])
57
+ end
58
+
59
+ def say
60
+ if Rails.version < '4'
61
+ render text: params[:message], content_type: 'text/plain'
62
+ else
63
+ render plain: params[:message]
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def comment_params
70
+ params.require(:comment).permit(:subject, :body, :attachment, :other_attachment)
71
+ end
72
+ end
@@ -0,0 +1,9 @@
1
+ class PrependedController < ApplicationController
2
+ # order matters, only prepend then include causes the issue
3
+ prepend Module.new
4
+ include Remotipart::RenderOverrides
5
+
6
+ def show
7
+ render
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CommentsHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class Comment < ActiveRecord::Base
2
+ has_attached_file :attachment
3
+ has_attached_file :other_attachment
4
+ validates :subject, :body, :presence => true
5
+ validates_attachment :attachment, content_type: { content_type: /\Aimage\/.*\Z/ }
6
+ validates_attachment :other_attachment, content_type: { content_type: 'text/plain' }
7
+ end
@@ -0,0 +1,9 @@
1
+ <tr class='comment' id='comment-<%= comment.id %>'>
2
+ <td><%= comment.subject %></td>
3
+ <td><%= comment.body %></td>
4
+ <td><%= link_to comment.attachment_file_name, comment.attachment.url if comment.attachment? %></td>
5
+ <td><%= link_to comment.other_attachment_file_name, comment.other_attachment.url if comment.other_attachment? %></td>
6
+ <td><%= link_to 'Show', comment %></td>
7
+ <td><%= link_to 'Edit', edit_comment_path(comment) %></td>
8
+ <td><%= link_to 'Destroy', comment, :data => {:confirm => 'Are you sure?'}, :method => :delete, :remote => true %></td>
9
+ </tr>
@@ -0,0 +1,40 @@
1
+ <%= form_for(@comment, :remote => (params[:action] == 'new' ? true : false)) do |f| %>
2
+ <% if @comment.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @comment.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <fieldset>
15
+ <legend class='required'>
16
+ Required fields
17
+ </legend>
18
+ <div class="field">
19
+ <%= f.label :subject, :class => 'required' %><br />
20
+ <%= f.text_field :subject, :required => true %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :body, :class => 'required' %><br />
24
+ <%= f.text_area :body, :required => true %>
25
+ </div>
26
+ <% if params[:attachment] %>
27
+ <div class="field">
28
+ <%= f.label :attachment %><br />
29
+ <%= f.file_field :attachment %>
30
+ </div>
31
+ <div class="field">
32
+ <%= f.label :other_attachment %><br />
33
+ <%= f.file_field :other_attachment %>
34
+ </div>
35
+ <% end %>
36
+ </fieldset>
37
+ <div class="actions">
38
+ <%= f.submit :data => {disable_with: "Submitting..."} %>
39
+ </div>
40
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <div id='new-comment-links'>
2
+ <%= link_to 'New Comment', new_comment_path, :remote => true, :'data-type' => 'html', :id => 'new-comment-link' %>
3
+ <br />
4
+ <%= link_to 'New Comment with Attachment', new_comment_path(:attachment => true), :remote => true, :'data-type' => 'html', :id => 'new-comment-attachment-link' %>
5
+ </div>
@@ -0,0 +1,7 @@
1
+ <span>
2
+ HTML response:
3
+ </span>
4
+
5
+ <table>
6
+ <%= render @comment %>
7
+ </table>
@@ -0,0 +1,20 @@
1
+ <%= remotipart_response do %>
2
+ <% unless @comment.errors.any? %>
3
+ $('#comments').append( '<%= escape_javascript(
4
+ render @comment
5
+ ) %>' );
6
+ $('#new-comment-form-container').find('input:not(:submit),select,textarea').val('');
7
+ <% if request.put? %>
8
+ $('#comments').after('PUT request!');
9
+ <% end %>
10
+ <% else %>
11
+ var $form = $('#new_comment'),
12
+ $errorDiv = $('<div id="error_explanation">'),
13
+ $errorList = $('<ul>');
14
+ <% @comment.errors.full_messages.each do |msg| %>
15
+ $errorList.append('<li><%= escape_javascript msg %></li>');
16
+ <% end %>
17
+ $form.find('#error_explanation').remove();
18
+ $form.prepend($errorDiv.append($errorList));
19
+ <% end %>
20
+ <% end %>
@@ -0,0 +1 @@
1
+ $('#comment-<%= @comment.id %>').remove();
@@ -0,0 +1,6 @@
1
+ <h1>Editing comment</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @comment %> |
6
+ <%= link_to 'Back', comments_path %>
@@ -0,0 +1 @@
1
+ <%= text_field_tag :quote, '"' %>
@@ -0,0 +1,19 @@
1
+ <h1>Listing comments</h1>
2
+
3
+ <table id='comments'>
4
+ <tr>
5
+ <th>Subject</th>
6
+ <th>Body</th>
7
+ <th>Attachment</td>
8
+ <th>Other Attachment</td>
9
+ <th></th>
10
+ <th></th>
11
+ <th></th>
12
+ </tr>
13
+
14
+ <%= render @comments %>
15
+ </table>
16
+
17
+ <br />
18
+
19
+ <%= render 'new_comment_links' %>
@@ -0,0 +1,7 @@
1
+ <div id='new-comment-form-container'>
2
+ <h1>New comment</h1>
3
+
4
+ <%= render 'form' %>
5
+
6
+ <%= link_to 'Cancel', comments_path, :id => 'cancel-button' %>
7
+ </div>
@@ -0,0 +1,15 @@
1
+ <table>
2
+ <tr>
3
+ <th>Subject</th>
4
+ <th>Body</th>
5
+ <th>Attachment</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+ <%= render @comment %>
11
+ </table>
12
+
13
+ <br />
14
+
15
+ <%= link_to 'Back', comments_path %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>JqueryRails</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ <p>prepended</p>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') or system!('bundle install')
20
+
21
+ # puts "\n== Copying sample files =="
22
+ # unless File.exist?('config/database.yml')
23
+ # cp 'config/database.yml.sample', 'config/database.yml'
24
+ # end
25
+
26
+ puts "\n== Preparing database =="
27
+ system! 'bin/rails db:setup'
28
+
29
+ puts "\n== Removing old logs and tempfiles =="
30
+ system! 'bin/rails log:clear tmp:clear'
31
+
32
+ puts "\n== Restarting application server =="
33
+ system! 'bin/rails restart'
34
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system 'bundle check' or system! 'bundle install'
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module DummyApp
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ config.assets.paths << Rails.root.join("..", "..", "vendor", "assets", "javascripts")
14
+ config.active_record.raise_in_transactional_callbacks = true if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2
15
+ config.active_record.time_zone_aware_types = [:datetime, :time] if Rails::VERSION::MAJOR >= 5
16
+ config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer=) && Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../gemfiles/rails_5.2.gemfile', __FILE__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,7 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+
5
+ test:
6
+ adapter: sqlite3
7
+ database: ":memory:"
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ DummyApp::Application.initialize!
@@ -0,0 +1,54 @@
1
+ DummyApp::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.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+ config.cache_store = :memory_store
19
+ config.public_file_server.headers = {'Cache-Control' => 'public, max-age=172800'}
20
+ else
21
+ config.action_controller.perform_caching = false
22
+ config.cache_store = :null_store
23
+ end
24
+
25
+ # Don't care if the mailer can't send.
26
+ config.action_mailer.raise_delivery_errors = false
27
+
28
+ # Print deprecation notices to the Rails logger.
29
+ config.active_support.deprecation = :log
30
+
31
+ # Raise an error on page load if there are pending migrations.
32
+ config.active_record.migration_error = :page_load
33
+
34
+ # Debug mode disables concatenation and preprocessing of assets.
35
+ # This option may cause significant delays in view rendering with a large
36
+ # number of complex assets.
37
+ config.assets.debug = true
38
+
39
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
40
+ # yet still be able to expire them through the digest params.
41
+ config.assets.digest = true
42
+
43
+ # Adds additional error checking when serving assets at runtime.
44
+ # Checks for improperly declared sprockets dependencies.
45
+ # Raises helpful error messages.
46
+ config.assets.raise_runtime_errors = true
47
+
48
+ # Raises error for missing translations
49
+ # config.action_view.raise_on_missing_translations = true
50
+
51
+ # Use an evented file watcher to asynchronously detect changes in source code,
52
+ # routes, locales, etc. This feature depends on the listen gem.
53
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54
+ end
@@ -0,0 +1,53 @@
1
+ DummyApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure public file server for tests with Cache-Control for performance.
16
+ if config.respond_to?(:public_file_server)
17
+ config.public_file_server.enabled = true
18
+ config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
19
+ else
20
+ if Rails::VERSION::MAJOR < 4
21
+ config.assets.enabled = true
22
+ config.assets.debug = true
23
+ config.serve_static_assets = true
24
+ else
25
+ config.serve_static_files = true
26
+ end
27
+ config.static_cache_control = 'public, max-age=3600'
28
+ end
29
+
30
+ # Show full error reports and disable caching.
31
+ config.consider_all_requests_local = true
32
+ config.action_controller.perform_caching = false
33
+
34
+ # Raise exceptions instead of rendering exception templates.
35
+ config.action_dispatch.show_exceptions = false
36
+
37
+ # Disable request forgery protection in test environment.
38
+ config.action_controller.allow_forgery_protection = false
39
+
40
+ # Tell Action Mailer not to deliver emails to the real world.
41
+ # The :test delivery method accumulates sent emails in the
42
+ # ActionMailer::Base.deliveries array.
43
+ config.action_mailer.delivery_method = :test
44
+
45
+ # Randomize the order test cases are executed.
46
+ config.active_support.test_order = :random
47
+
48
+ # Print deprecation notices to the stderr.
49
+ config.active_support.deprecation = :stderr
50
+
51
+ # Raises error for missing translations
52
+ # config.action_view.raise_on_missing_translations = true
53
+ end
@@ -0,0 +1,3 @@
1
+ if Rails::VERSION::MAJOR < 4
2
+ DummyApp::Application.config.secret_token = 'f2338e8b8018053b0b322cd6469d8c0ed06ab0aaf43dd30a1c33a4c55d9c0d6a1c1ad4140049019f85388db3ce1ddbeff597cf07c49c5b22242cecd146f2bd66'
3
+ end
@@ -0,0 +1,7 @@
1
+ DummyApp::Application.routes.draw do
2
+ match 'comments' => 'comments#create', :via => [:put]
3
+ match 'say' => 'comments#say', :via => [:get]
4
+ resources :comments
5
+ match 'prepended' => 'prepended#show', :via => [:get]
6
+ root :to => "comments#index"
7
+ end
@@ -0,0 +1,5 @@
1
+ development:
2
+ secret_key_base: d059ae03480564f4e9dcb7c96b901e5803037b0e09fd53e96343dff0d18dc54390a2f07b99c231eacb1d0cc6b74b90676fec4786afaf0f2e7f69b971ab2f9600
3
+
4
+ test:
5
+ secret_key_base: e5e0e4811c8cfc047799cf3e82d1626adbf02fa7a3530b4bdd39cc17e1098d328f4da6ada090ec01449b5c92662bcec92cfb13b4c3c4c4bb3fac5a303e91c356
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run DummyApp::Application
@@ -0,0 +1,14 @@
1
+ class CreateComments < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :comments do |t|
4
+ t.string :subject
5
+ t.text :body
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :comments
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class AddAttachmentToComment < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :comments, :attachment_file_name, :string
4
+ add_column :comments, :attachment_content_type, :string
5
+ add_column :comments, :attachment_file_size, :integer
6
+ add_column :comments, :attachment_updated_at, :datetime
7
+ end
8
+
9
+ def self.down
10
+ remove_column :comments, :attachment_file_name
11
+ remove_column :comments, :attachment_content_type
12
+ remove_column :comments, :attachment_file_size
13
+ remove_column :comments, :attachment_updated_at
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ class AddOtherAttachmentToComment < ActiveRecord::Migration
2
+ def change
3
+ add_column :comments, :other_attachment_file_name, :string
4
+ add_column :comments, :other_attachment_content_type, :string
5
+ add_column :comments, :other_attachment_file_size, :integer
6
+ add_column :comments, :other_attachment_updated_at, :datetime
7
+ end
8
+ end