activerecord-refresh_connection 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +66 -0
  8. data/Rakefile +14 -0
  9. data/activerecord-refresh_connection.gemspec +27 -0
  10. data/example/.gitignore +16 -0
  11. data/example/Gemfile +41 -0
  12. data/example/README.rdoc +28 -0
  13. data/example/Rakefile +6 -0
  14. data/example/app/assets/images/.keep +0 -0
  15. data/example/app/assets/javascripts/application.js +16 -0
  16. data/example/app/assets/javascripts/articles.js.coffee +3 -0
  17. data/example/app/assets/javascripts/books.js.coffee +3 -0
  18. data/example/app/assets/stylesheets/application.css +15 -0
  19. data/example/app/assets/stylesheets/articles.css.scss +3 -0
  20. data/example/app/assets/stylesheets/books.css.scss +3 -0
  21. data/example/app/assets/stylesheets/scaffolds.css.scss +69 -0
  22. data/example/app/controllers/application_controller.rb +5 -0
  23. data/example/app/controllers/articles_controller.rb +74 -0
  24. data/example/app/controllers/books_controller.rb +74 -0
  25. data/example/app/controllers/concerns/.keep +0 -0
  26. data/example/app/helpers/application_helper.rb +2 -0
  27. data/example/app/helpers/articles_helper.rb +2 -0
  28. data/example/app/helpers/books_helper.rb +2 -0
  29. data/example/app/mailers/.keep +0 -0
  30. data/example/app/models/.keep +0 -0
  31. data/example/app/models/article.rb +2 -0
  32. data/example/app/models/book.rb +2 -0
  33. data/example/app/models/concerns/.keep +0 -0
  34. data/example/app/views/articles/_form.html.erb +21 -0
  35. data/example/app/views/articles/edit.html.erb +6 -0
  36. data/example/app/views/articles/index.html.erb +25 -0
  37. data/example/app/views/articles/index.json.jbuilder +4 -0
  38. data/example/app/views/articles/new.html.erb +5 -0
  39. data/example/app/views/articles/show.html.erb +9 -0
  40. data/example/app/views/articles/show.json.jbuilder +1 -0
  41. data/example/app/views/books/_form.html.erb +21 -0
  42. data/example/app/views/books/edit.html.erb +6 -0
  43. data/example/app/views/books/index.html.erb +25 -0
  44. data/example/app/views/books/index.json.jbuilder +4 -0
  45. data/example/app/views/books/new.html.erb +5 -0
  46. data/example/app/views/books/show.html.erb +9 -0
  47. data/example/app/views/books/show.json.jbuilder +1 -0
  48. data/example/app/views/layouts/application.html.erb +14 -0
  49. data/example/bin/bundle +3 -0
  50. data/example/bin/rails +4 -0
  51. data/example/bin/rake +4 -0
  52. data/example/config.ru +4 -0
  53. data/example/config/application.rb +26 -0
  54. data/example/config/boot.rb +4 -0
  55. data/example/config/database.yml +18 -0
  56. data/example/config/environment.rb +5 -0
  57. data/example/config/environments/development.rb +37 -0
  58. data/example/config/environments/production.rb +83 -0
  59. data/example/config/environments/test.rb +39 -0
  60. data/example/config/initializers/backtrace_silencers.rb +7 -0
  61. data/example/config/initializers/cookies_serializer.rb +3 -0
  62. data/example/config/initializers/filter_parameter_logging.rb +4 -0
  63. data/example/config/initializers/inflections.rb +16 -0
  64. data/example/config/initializers/mime_types.rb +4 -0
  65. data/example/config/initializers/session_store.rb +3 -0
  66. data/example/config/initializers/wrap_parameters.rb +14 -0
  67. data/example/config/locales/en.yml +23 -0
  68. data/example/config/routes.rb +60 -0
  69. data/example/config/secrets.yml +22 -0
  70. data/example/db/migrate/20140623044349_create_books.rb +9 -0
  71. data/example/db/migrate/20140623044357_create_articles.rb +9 -0
  72. data/example/db/schema.rb +28 -0
  73. data/example/db/seeds.rb +7 -0
  74. data/example/lib/assets/.keep +0 -0
  75. data/example/lib/tasks/.keep +0 -0
  76. data/example/log/.keep +0 -0
  77. data/example/public/404.html +67 -0
  78. data/example/public/422.html +67 -0
  79. data/example/public/500.html +66 -0
  80. data/example/public/favicon.ico +0 -0
  81. data/example/public/robots.txt +5 -0
  82. data/example/test/controllers/.keep +0 -0
  83. data/example/test/controllers/articles_controller_test.rb +49 -0
  84. data/example/test/controllers/books_controller_test.rb +49 -0
  85. data/example/test/fixtures/.keep +0 -0
  86. data/example/test/fixtures/articles.yml +7 -0
  87. data/example/test/fixtures/books.yml +7 -0
  88. data/example/test/helpers/.keep +0 -0
  89. data/example/test/helpers/articles_helper_test.rb +4 -0
  90. data/example/test/helpers/books_helper_test.rb +4 -0
  91. data/example/test/integration/.keep +0 -0
  92. data/example/test/mailers/.keep +0 -0
  93. data/example/test/models/.keep +0 -0
  94. data/example/test/models/article_test.rb +7 -0
  95. data/example/test/models/book_test.rb +7 -0
  96. data/example/test/test_helper.rb +13 -0
  97. data/example/vendor/assets/javascripts/.keep +0 -0
  98. data/example/vendor/assets/stylesheets/.keep +0 -0
  99. data/lib/activerecord-refresh_connection.rb +1 -0
  100. data/lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb +24 -0
  101. data/spec/spec_helper.rb +15 -0
  102. metadata +229 -0
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class ArticlesControllerTest < ActionController::TestCase
4
+ setup do
5
+ @article = articles(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:articles)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create article" do
20
+ assert_difference('Article.count') do
21
+ post :create, article: { title: @article.title }
22
+ end
23
+
24
+ assert_redirected_to article_path(assigns(:article))
25
+ end
26
+
27
+ test "should show article" do
28
+ get :show, id: @article
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @article
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update article" do
38
+ patch :update, id: @article, article: { title: @article.title }
39
+ assert_redirected_to article_path(assigns(:article))
40
+ end
41
+
42
+ test "should destroy article" do
43
+ assert_difference('Article.count', -1) do
44
+ delete :destroy, id: @article
45
+ end
46
+
47
+ assert_redirected_to articles_path
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class BooksControllerTest < ActionController::TestCase
4
+ setup do
5
+ @book = books(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:books)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create book" do
20
+ assert_difference('Book.count') do
21
+ post :create, book: { title: @book.title }
22
+ end
23
+
24
+ assert_redirected_to book_path(assigns(:book))
25
+ end
26
+
27
+ test "should show book" do
28
+ get :show, id: @book
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @book
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update book" do
38
+ patch :update, id: @book, book: { title: @book.title }
39
+ assert_redirected_to book_path(assigns(:book))
40
+ end
41
+
42
+ test "should destroy book" do
43
+ assert_difference('Book.count', -1) do
44
+ delete :destroy, id: @book
45
+ end
46
+
47
+ assert_redirected_to books_path
48
+ end
49
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+
6
+ two:
7
+ title: MyString
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+
6
+ two:
7
+ title: MyString
File without changes
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class ArticlesHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class BooksHelperTest < ActionView::TestCase
4
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ArticleTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BookTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,13 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
File without changes
@@ -0,0 +1 @@
1
+ require 'activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management'
@@ -0,0 +1,24 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ class RefreshConnectionManagement
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ testing = env.key?('rack.test')
10
+
11
+ response = @app.call(env)
12
+ response[2] = ::Rack::BodyProxy.new(response[2]) do
13
+ # disconnect all connections on the connection pool
14
+ ActiveRecord::Base.clear_all_connections! unless testing
15
+ end
16
+
17
+ response
18
+ rescue Exception
19
+ ActiveRecord::Base.clear_all_connections! unless testing
20
+ raise
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.setup(:default, :test)
5
+ Bundler.require(:default, :test)
6
+ require 'pry'
7
+ ROOT = File.dirname(File.dirname(__FILE__))
8
+
9
+ if ENV['TRAVIS']
10
+ require 'coveralls'
11
+ Coveralls.wear!
12
+ end
13
+
14
+ $TESTING=true
15
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
metadata ADDED
@@ -0,0 +1,229 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-refresh_connection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-nav
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Refresh ActiveRecord connection on each rack request.
98
+ email:
99
+ - sonots@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - activerecord-refresh_connection.gemspec
112
+ - example/.gitignore
113
+ - example/Gemfile
114
+ - example/README.rdoc
115
+ - example/Rakefile
116
+ - example/app/assets/images/.keep
117
+ - example/app/assets/javascripts/application.js
118
+ - example/app/assets/javascripts/articles.js.coffee
119
+ - example/app/assets/javascripts/books.js.coffee
120
+ - example/app/assets/stylesheets/application.css
121
+ - example/app/assets/stylesheets/articles.css.scss
122
+ - example/app/assets/stylesheets/books.css.scss
123
+ - example/app/assets/stylesheets/scaffolds.css.scss
124
+ - example/app/controllers/application_controller.rb
125
+ - example/app/controllers/articles_controller.rb
126
+ - example/app/controllers/books_controller.rb
127
+ - example/app/controllers/concerns/.keep
128
+ - example/app/helpers/application_helper.rb
129
+ - example/app/helpers/articles_helper.rb
130
+ - example/app/helpers/books_helper.rb
131
+ - example/app/mailers/.keep
132
+ - example/app/models/.keep
133
+ - example/app/models/article.rb
134
+ - example/app/models/book.rb
135
+ - example/app/models/concerns/.keep
136
+ - example/app/views/articles/_form.html.erb
137
+ - example/app/views/articles/edit.html.erb
138
+ - example/app/views/articles/index.html.erb
139
+ - example/app/views/articles/index.json.jbuilder
140
+ - example/app/views/articles/new.html.erb
141
+ - example/app/views/articles/show.html.erb
142
+ - example/app/views/articles/show.json.jbuilder
143
+ - example/app/views/books/_form.html.erb
144
+ - example/app/views/books/edit.html.erb
145
+ - example/app/views/books/index.html.erb
146
+ - example/app/views/books/index.json.jbuilder
147
+ - example/app/views/books/new.html.erb
148
+ - example/app/views/books/show.html.erb
149
+ - example/app/views/books/show.json.jbuilder
150
+ - example/app/views/layouts/application.html.erb
151
+ - example/bin/bundle
152
+ - example/bin/rails
153
+ - example/bin/rake
154
+ - example/config.ru
155
+ - example/config/application.rb
156
+ - example/config/boot.rb
157
+ - example/config/database.yml
158
+ - example/config/environment.rb
159
+ - example/config/environments/development.rb
160
+ - example/config/environments/production.rb
161
+ - example/config/environments/test.rb
162
+ - example/config/initializers/backtrace_silencers.rb
163
+ - example/config/initializers/cookies_serializer.rb
164
+ - example/config/initializers/filter_parameter_logging.rb
165
+ - example/config/initializers/inflections.rb
166
+ - example/config/initializers/mime_types.rb
167
+ - example/config/initializers/session_store.rb
168
+ - example/config/initializers/wrap_parameters.rb
169
+ - example/config/locales/en.yml
170
+ - example/config/routes.rb
171
+ - example/config/secrets.yml
172
+ - example/db/migrate/20140623044349_create_books.rb
173
+ - example/db/migrate/20140623044357_create_articles.rb
174
+ - example/db/schema.rb
175
+ - example/db/seeds.rb
176
+ - example/lib/assets/.keep
177
+ - example/lib/tasks/.keep
178
+ - example/log/.keep
179
+ - example/public/404.html
180
+ - example/public/422.html
181
+ - example/public/500.html
182
+ - example/public/favicon.ico
183
+ - example/public/robots.txt
184
+ - example/test/controllers/.keep
185
+ - example/test/controllers/articles_controller_test.rb
186
+ - example/test/controllers/books_controller_test.rb
187
+ - example/test/fixtures/.keep
188
+ - example/test/fixtures/articles.yml
189
+ - example/test/fixtures/books.yml
190
+ - example/test/helpers/.keep
191
+ - example/test/helpers/articles_helper_test.rb
192
+ - example/test/helpers/books_helper_test.rb
193
+ - example/test/integration/.keep
194
+ - example/test/mailers/.keep
195
+ - example/test/models/.keep
196
+ - example/test/models/article_test.rb
197
+ - example/test/models/book_test.rb
198
+ - example/test/test_helper.rb
199
+ - example/vendor/assets/javascripts/.keep
200
+ - example/vendor/assets/stylesheets/.keep
201
+ - lib/activerecord-refresh_connection.rb
202
+ - lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb
203
+ - spec/spec_helper.rb
204
+ homepage: ''
205
+ licenses:
206
+ - MIT
207
+ metadata: {}
208
+ post_install_message:
209
+ rdoc_options: []
210
+ require_paths:
211
+ - lib
212
+ required_ruby_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ required_rubygems_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ requirements: []
223
+ rubyforge_project:
224
+ rubygems_version: 2.2.2
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Refresh ActiveRecord connection on each rack request
228
+ test_files:
229
+ - spec/spec_helper.rb