skip_activerecord_callbacks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG.md +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +33 -0
  4. data/Rakefile +38 -0
  5. data/lib/skip_activerecord_callbacks.rb +1 -0
  6. data/lib/skip_activerecord_callbacks/model_helpers.rb +29 -0
  7. data/lib/skip_activerecord_callbacks/railtie.rb +9 -0
  8. data/lib/skip_activerecord_callbacks/version.rb +3 -0
  9. data/lib/tasks/skip_activerecord_callbacks_tasks.rake +4 -0
  10. data/test/dummy/README.rdoc +261 -0
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/assets/javascripts/application.js +15 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/test/dummy/app/controllers/application_controller.rb +3 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/test/dummy/config.ru +4 -0
  18. data/test/dummy/config/application.rb +56 -0
  19. data/test/dummy/config/boot.rb +10 -0
  20. data/test/dummy/config/database.yml +25 -0
  21. data/test/dummy/config/environment.rb +5 -0
  22. data/test/dummy/config/environments/development.rb +37 -0
  23. data/test/dummy/config/environments/production.rb +67 -0
  24. data/test/dummy/config/environments/test.rb +37 -0
  25. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  26. data/test/dummy/config/initializers/inflections.rb +15 -0
  27. data/test/dummy/config/initializers/mime_types.rb +5 -0
  28. data/test/dummy/config/initializers/secret_token.rb +7 -0
  29. data/test/dummy/config/initializers/session_store.rb +8 -0
  30. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  31. data/test/dummy/config/locales/en.yml +5 -0
  32. data/test/dummy/config/routes.rb +58 -0
  33. data/test/dummy/db/test.sqlite3 +0 -0
  34. data/test/dummy/log/test.log +186 -0
  35. data/test/dummy/public/404.html +26 -0
  36. data/test/dummy/public/422.html +26 -0
  37. data/test/dummy/public/500.html +25 -0
  38. data/test/dummy/public/favicon.ico +0 -0
  39. data/test/dummy/script/rails +6 -0
  40. data/test/skip_activerecord_callbacks_test.rb +47 -0
  41. data/test/test_helper.rb +21 -0
  42. metadata +179 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class Product < ActiveRecord::Base
4
+ attr_accessible :name
5
+
6
+ before_save do |product|
7
+ product.name = 'bar'
8
+ end
9
+
10
+ after_save do |product|
11
+ product.name = product.name.titleize
12
+ end
13
+ end
14
+
15
+ describe SkipActiverecordCallbacks do
16
+ let(:product) { Product.new(:name => 'foo') }
17
+
18
+ describe "normal save" do
19
+ it "sets the product name to 'Bar'" do
20
+ product.save
21
+ product.name.must_equal 'Bar'
22
+ product.new_record?.must_equal false
23
+ end
24
+ end
25
+
26
+ describe "#update_without_callbacks" do
27
+ it "saves a record without running its save callbacks" do
28
+ product.update_without_callbacks
29
+ product.name.must_equal 'foo'
30
+ product.new_record?.must_equal false
31
+ end
32
+
33
+ it "updates a record without running its save callbacks" do
34
+ product.save
35
+ product.name = 'foo'
36
+ product.update_without_callbacks
37
+ product.name.must_equal 'foo'
38
+ product.new_record?.must_equal false
39
+ end
40
+
41
+ it "restores the callbacks afterwards" do
42
+ product.update_without_callbacks
43
+ product.save
44
+ product.name.must_equal 'Bar'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+ require 'minitest/autorun'
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
11
+ ActiveRecord::Base.class_eval do
12
+ silence do
13
+ connection.create_table :products, :force => true do |t|
14
+ t.column :name, :string
15
+ end
16
+ end
17
+ end
18
+
19
+ class UnitTest < MiniTest::Spec
20
+ register_spec_type(//, self)
21
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skip_activerecord_callbacks
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Donald Ball
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-13 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 3
29
+ - 2
30
+ version: "3.2"
31
+ name: rails
32
+ type: :runtime
33
+ prerelease: false
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ name: sqlite3
46
+ type: :development
47
+ prerelease: false
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ name: minitest
60
+ type: :development
61
+ prerelease: false
62
+ requirement: *id003
63
+ description: Provides support for the deprecated update_without_callbacks method from rails 2
64
+ email:
65
+ - donald.ball@gmail.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files: []
71
+
72
+ files:
73
+ - lib/skip_activerecord_callbacks/model_helpers.rb
74
+ - lib/skip_activerecord_callbacks/railtie.rb
75
+ - lib/skip_activerecord_callbacks/version.rb
76
+ - lib/skip_activerecord_callbacks.rb
77
+ - lib/tasks/skip_activerecord_callbacks_tasks.rake
78
+ - MIT-LICENSE
79
+ - Rakefile
80
+ - README.md
81
+ - CHANGELOG.md
82
+ - test/dummy/app/assets/javascripts/application.js
83
+ - test/dummy/app/assets/stylesheets/application.css
84
+ - test/dummy/app/controllers/application_controller.rb
85
+ - test/dummy/app/helpers/application_helper.rb
86
+ - test/dummy/app/views/layouts/application.html.erb
87
+ - test/dummy/config/application.rb
88
+ - test/dummy/config/boot.rb
89
+ - test/dummy/config/database.yml
90
+ - test/dummy/config/environment.rb
91
+ - test/dummy/config/environments/development.rb
92
+ - test/dummy/config/environments/production.rb
93
+ - test/dummy/config/environments/test.rb
94
+ - test/dummy/config/initializers/backtrace_silencers.rb
95
+ - test/dummy/config/initializers/inflections.rb
96
+ - test/dummy/config/initializers/mime_types.rb
97
+ - test/dummy/config/initializers/secret_token.rb
98
+ - test/dummy/config/initializers/session_store.rb
99
+ - test/dummy/config/initializers/wrap_parameters.rb
100
+ - test/dummy/config/locales/en.yml
101
+ - test/dummy/config/routes.rb
102
+ - test/dummy/config.ru
103
+ - test/dummy/db/test.sqlite3
104
+ - test/dummy/log/test.log
105
+ - test/dummy/public/404.html
106
+ - test/dummy/public/422.html
107
+ - test/dummy/public/500.html
108
+ - test/dummy/public/favicon.ico
109
+ - test/dummy/Rakefile
110
+ - test/dummy/README.rdoc
111
+ - test/dummy/script/rails
112
+ - test/skip_activerecord_callbacks_test.rb
113
+ - test/test_helper.rb
114
+ homepage: http://github.com/dball/skip_activerecord_callbacks
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options: []
119
+
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.8.21
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Lets you save activerecord models without callbacks
147
+ test_files:
148
+ - test/dummy/app/assets/javascripts/application.js
149
+ - test/dummy/app/assets/stylesheets/application.css
150
+ - test/dummy/app/controllers/application_controller.rb
151
+ - test/dummy/app/helpers/application_helper.rb
152
+ - test/dummy/app/views/layouts/application.html.erb
153
+ - test/dummy/config/application.rb
154
+ - test/dummy/config/boot.rb
155
+ - test/dummy/config/database.yml
156
+ - test/dummy/config/environment.rb
157
+ - test/dummy/config/environments/development.rb
158
+ - test/dummy/config/environments/production.rb
159
+ - test/dummy/config/environments/test.rb
160
+ - test/dummy/config/initializers/backtrace_silencers.rb
161
+ - test/dummy/config/initializers/inflections.rb
162
+ - test/dummy/config/initializers/mime_types.rb
163
+ - test/dummy/config/initializers/secret_token.rb
164
+ - test/dummy/config/initializers/session_store.rb
165
+ - test/dummy/config/initializers/wrap_parameters.rb
166
+ - test/dummy/config/locales/en.yml
167
+ - test/dummy/config/routes.rb
168
+ - test/dummy/config.ru
169
+ - test/dummy/db/test.sqlite3
170
+ - test/dummy/log/test.log
171
+ - test/dummy/public/404.html
172
+ - test/dummy/public/422.html
173
+ - test/dummy/public/500.html
174
+ - test/dummy/public/favicon.ico
175
+ - test/dummy/Rakefile
176
+ - test/dummy/README.rdoc
177
+ - test/dummy/script/rails
178
+ - test/skip_activerecord_callbacks_test.rb
179
+ - test/test_helper.rb