workbook_rails 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile +8 -7
- data/Gemfile.lock +206 -172
- data/README.md +3 -3
- data/Rakefile +7 -19
- data/lib/tasks/workbook_rails_tasks.rake +2 -0
- data/lib/workbook_rails/action_controller.rb +15 -10
- data/lib/workbook_rails/engine.rb +4 -4
- data/lib/workbook_rails/template_handler.rb +6 -5
- data/lib/workbook_rails/version.rb +3 -1
- data/lib/workbook_rails.rb +3 -2
- data/spec/ci.rb +5 -1
- data/spec/dummy/Rakefile +3 -1
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/home_controller.rb +14 -16
- data/spec/dummy/app/controllers/likes_controller.rb +3 -1
- data/spec/dummy/app/controllers/users_controller.rb +4 -2
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +5 -4
- data/spec/dummy/app/models/like.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/bin/bundle +3 -1
- data/spec/dummy/bin/rails +3 -1
- data/spec/dummy/bin/rake +2 -0
- data/spec/dummy/config/application.rb +9 -8
- data/spec/dummy/config/boot.rb +4 -2
- data/spec/dummy/config/environment.rb +3 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +6 -4
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +2 -0
- data/spec/dummy/config/initializers/mime_types.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +3 -1
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/routes.rb +13 -11
- data/spec/dummy/config.ru +3 -1
- data/spec/dummy/db/migrate/20120717192452_create_users.rb +2 -0
- data/spec/dummy/db/migrate/20121206210955_create_likes.rb +2 -0
- data/spec/dummy/db/schema.rb +1 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +6916 -16248
- data/spec/spec_helper.rb +14 -14
- data/spec/template_handler_spec.rb +12 -15
- data/spec/test_7.2.sh +6 -0
- data/spec/test_8.0.sh +6 -0
- data/spec/test_8.1.sh +6 -0
- data/spec/test_all_rails.sh +10 -4
- data/spec/workbook_mailer_spec.rb +9 -4
- data/spec/workbook_renderer_spec.rb +10 -10
- data/spec/workbook_request_spec.rb +60 -49
- metadata +13 -20
- data/spec/dummy/log/development.log +0 -24
- data/spec/test_6.0.sh +0 -4
- data/spec/test_6.1.sh +0 -4
- data/spec/test_7.0.sh +0 -4
- data/spec/test_7.1.sh +0 -4
data/lib/workbook_rails.rb
CHANGED
data/spec/ci.rb
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
exit system(
|
|
4
|
+
exit system(
|
|
5
|
+
'cd spec/dummy && bundle install && bundle exec rake db:create && ' \
|
|
6
|
+
'bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec'
|
|
7
|
+
)
|
data/spec/dummy/Rakefile
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
4
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
5
|
|
|
4
|
-
require File.expand_path('
|
|
6
|
+
require File.expand_path('config/application', __dir__)
|
|
5
7
|
|
|
6
8
|
Rails.application.load_tasks
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
#---
|
|
2
4
|
# Excerpted from "Crafting Rails Applications",
|
|
3
5
|
# published by The Pragmatic Bookshelf.
|
|
@@ -7,8 +9,7 @@
|
|
|
7
9
|
# Visit http://www.pragmaticprogrammer.com/titles/jvrails for more book information.
|
|
8
10
|
#---
|
|
9
11
|
class HomeController < ApplicationController
|
|
10
|
-
def index
|
|
11
|
-
end
|
|
12
|
+
def index; end
|
|
12
13
|
|
|
13
14
|
def generic
|
|
14
15
|
respond_to do |format|
|
|
@@ -22,36 +23,33 @@ class HomeController < ApplicationController
|
|
|
22
23
|
def only_html; end
|
|
23
24
|
|
|
24
25
|
def another
|
|
25
|
-
render :
|
|
26
|
+
render xlsx: 'index', filename: 'filename_test.xlsx'
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def render_elsewhere
|
|
29
30
|
case params[:type]
|
|
30
|
-
when '1'
|
|
31
|
-
render :
|
|
32
|
-
when '2'
|
|
33
|
-
render :xlsx => "users/respond_with", :template => 'users/respond_with'
|
|
31
|
+
when '1', '2'
|
|
32
|
+
render xlsx: params[:type] == '1' ? 'home/index' : 'users/respond_with', template: 'users/respond_with'
|
|
34
33
|
when '3'
|
|
35
|
-
render template:
|
|
34
|
+
render template: 'users/respond_with'
|
|
36
35
|
when '4'
|
|
37
|
-
render
|
|
36
|
+
render 'users/respond_with'
|
|
38
37
|
else
|
|
39
|
-
render :
|
|
38
|
+
render xlsx: 'index'
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
def withpartial
|
|
44
|
-
end
|
|
42
|
+
def withpartial; end
|
|
45
43
|
|
|
46
44
|
def useheader
|
|
47
45
|
respond_to do |format|
|
|
48
|
-
format.xlsx
|
|
46
|
+
format.xlsx do
|
|
49
47
|
if params[:set_direct]
|
|
50
|
-
response.headers['Content-Disposition'] =
|
|
48
|
+
response.headers['Content-Disposition'] = 'attachment; filename="filename_test.xlsx"'
|
|
51
49
|
else
|
|
52
|
-
render xlsx:
|
|
50
|
+
render xlsx: 'useheader', filename: 'filename_test.xlsx'
|
|
53
51
|
end
|
|
54
|
-
|
|
52
|
+
end
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class LikesController < ApplicationController
|
|
2
4
|
# GET /likes
|
|
3
5
|
# GET /likes.json
|
|
@@ -13,6 +15,6 @@ class LikesController < ApplicationController
|
|
|
13
15
|
|
|
14
16
|
def render_elsewhere
|
|
15
17
|
@user = User.find(params[:user_id])
|
|
16
|
-
render :
|
|
18
|
+
render xlsx: 'index', template: 'users/respond_with'
|
|
17
19
|
end
|
|
18
20
|
end
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class UsersController < ApplicationController
|
|
2
4
|
respond_to :xlsx, :html
|
|
3
5
|
|
|
4
6
|
def show
|
|
5
7
|
@user = User.find(params[:id])
|
|
6
8
|
respond_with(@user) do |format|
|
|
7
|
-
format.xlsx { render
|
|
9
|
+
format.xlsx { render 'respond_with' }
|
|
8
10
|
end
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
def send_instructions
|
|
12
14
|
@user = User.find(params[:user_id])
|
|
13
15
|
@user.send_instructions
|
|
14
|
-
render plain:
|
|
16
|
+
render plain: 'Email sent'
|
|
15
17
|
end
|
|
16
18
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Notifier < ActionMailer::Base
|
|
2
|
-
default :
|
|
4
|
+
default from: 'noreply@company.com'
|
|
3
5
|
|
|
4
6
|
def instructions(user)
|
|
5
7
|
@user = user
|
|
6
8
|
|
|
7
9
|
# normal syntax
|
|
8
10
|
xlsx = render_to_string handlers: [:wb], template: 'users/mailers/instructions', layout: false, formats: [:xlsx]
|
|
9
|
-
attachments["user_#{user.id}.xlsx"] = {mime_type: Mime[:xlsx], content: xlsx}
|
|
11
|
+
attachments["user_#{user.id}.xlsx"] = { mime_type: Mime[:xlsx], content: xlsx }
|
|
10
12
|
|
|
11
|
-
mail :
|
|
13
|
+
mail to: user.email, subject: 'Instructions'
|
|
12
14
|
end
|
|
13
|
-
|
|
14
15
|
end
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/rails
CHANGED
data/spec/dummy/bin/rake
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path('boot', __dir__)
|
|
2
4
|
|
|
3
5
|
require 'rails/version'
|
|
4
6
|
if Rails::VERSION::MAJOR < 4
|
|
5
7
|
# Pick the frameworks you want:
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
8
|
+
require 'active_record/railtie'
|
|
9
|
+
require 'action_controller/railtie'
|
|
10
|
+
require 'action_mailer/railtie'
|
|
11
|
+
require 'active_resource/railtie'
|
|
12
|
+
require 'sprockets/railtie'
|
|
11
13
|
# require "rails/test_unit/railtie"
|
|
12
14
|
else
|
|
13
15
|
require 'rails/all'
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
Bundler.require(*Rails.groups)
|
|
17
|
-
require
|
|
19
|
+
require 'workbook_rails'
|
|
18
20
|
|
|
19
21
|
module Dummy
|
|
20
22
|
class Application < Rails::Application
|
|
@@ -31,4 +33,3 @@ module Dummy
|
|
|
31
33
|
# config.i18n.default_locale = :de
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Set up gems listed in the Gemfile.
|
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
|
3
5
|
|
|
4
6
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rails.application.configure do
|
|
2
4
|
Dummy::Application.configure do
|
|
3
5
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
4
6
|
|
|
@@ -15,9 +17,9 @@ Dummy::Application.configure do
|
|
|
15
17
|
|
|
16
18
|
# Configure static asset server for tests with Cache-Control for performance.
|
|
17
19
|
if config.respond_to? :serve_static_files
|
|
18
|
-
config.serve_static_files
|
|
20
|
+
config.serve_static_files = true
|
|
19
21
|
else
|
|
20
|
-
config.serve_static_assets
|
|
22
|
+
config.serve_static_assets = true
|
|
21
23
|
end
|
|
22
24
|
config.static_cache_control = 'public, max-age=3600'
|
|
23
25
|
|
|
@@ -26,7 +28,7 @@ Dummy::Application.configure do
|
|
|
26
28
|
config.action_controller.perform_caching = false
|
|
27
29
|
|
|
28
30
|
# Raise exceptions instead of rendering exception templates.
|
|
29
|
-
config.action_dispatch.show_exceptions =
|
|
31
|
+
config.action_dispatch.show_exceptions = :none
|
|
30
32
|
|
|
31
33
|
# Disable request forgery protection in test environment.
|
|
32
34
|
config.action_controller.allow_forgery_protection = false
|
data/spec/dummy/config/routes.rb
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.routes.draw do
|
|
2
|
-
get
|
|
3
|
-
get
|
|
4
|
+
get '/users/:user_id/render_elsewhere(.:format)', to: 'likes#render_elsewhere'
|
|
5
|
+
get '/users/:user_id/send_instructions', to: 'users#send_instructions'
|
|
4
6
|
resources :users do
|
|
5
7
|
resources :likes
|
|
6
8
|
end
|
|
7
|
-
get
|
|
8
|
-
get
|
|
9
|
-
get
|
|
10
|
-
get
|
|
11
|
-
get
|
|
12
|
-
get
|
|
13
|
-
get
|
|
14
|
-
get
|
|
15
|
-
root to:
|
|
9
|
+
get '/home(.:format)', to: 'home#index', as: :home
|
|
10
|
+
get '/home/generic(.:format)', to: 'home#generic', as: :generic
|
|
11
|
+
get '/home/only_html', to: 'home#only_html', as: :only_html
|
|
12
|
+
get '/another(.:format)', to: 'home#another', as: :another
|
|
13
|
+
get '/useheader(.:format)', to: 'home#useheader', as: :useheader
|
|
14
|
+
get '/withpartial(.:format)', to: 'home#withpartial', as: :withpartial
|
|
15
|
+
get '/home/render_elsewhere(.:format)', to: 'home#render_elsewhere'
|
|
16
|
+
get '/render_elsewhere(.:format)', to: 'home#render_elsewhere'
|
|
17
|
+
root to: 'home#index'
|
|
16
18
|
end
|
data/spec/dummy/config.ru
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema[
|
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2012_12_06_210955) do
|
|
14
14
|
create_table "likes", force: :cascade do |t|
|
|
15
15
|
t.string "name"
|
|
16
16
|
t.integer "user_id"
|
|
@@ -26,5 +26,4 @@ ActiveRecord::Schema[7.0].define(version: 2012_12_06_210955) do
|
|
|
26
26
|
t.datetime "created_at", precision: nil
|
|
27
27
|
t.datetime "updated_at", precision: nil
|
|
28
28
|
end
|
|
29
|
-
|
|
30
29
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
|
Binary file
|