activerecord-tableless 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -1
- data/.travis.yml +20 -0
- data/Appraisals +6 -0
- data/README.md +35 -4
- data/activerecord-tableless.gemspec +8 -3
- data/features/step_definitions/rails_steps.rb +21 -2
- data/features/step_definitions/tableless.rb +9 -12
- data/features/support/rails.rb +8 -4
- data/gemfiles/rails40.gemfile +9 -0
- data/lib/activerecord-tableless.rb +84 -42
- data/spec/lib/activerecord-tableless_spec.rb +21 -8
- metadata +37 -65
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29efeb3f4c0056e51c8fca581b8142296097fbc3
|
4
|
+
data.tar.gz: f46298d5363c5ee7cbf836270cd8c4147473c254
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 679ab1f5215a9d80afd45249274921172d4aba1d758c0725eb05acdf45bb4c28c4f6d00093c0f9a874aacaf9e3459a8ad10d92cb852b431c58cca7d6daa1ca8d
|
7
|
+
data.tar.gz: 9747379a1a8c98aa3bb3729dc711542a9b969a8dffdae1fc590c6933dae9ffb34021618a0c71e0170ed2df8745e073ffc32b01e25f6492de3f3007ea984e70f4
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color --backtrace --
|
1
|
+
--color --backtrace --format doc
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
#bundler_args: --without development
|
3
|
+
before_install: "(ruby -e 'exit (RUBY_VERSION < \"2\" ? 0 : 1)' && gem update --system 1.8.25) || true"
|
4
|
+
rvm:
|
5
|
+
- 1.8.7
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
gemfile:
|
9
|
+
- gemfiles/rails23.gemfile
|
10
|
+
- gemfiles/rails30.gemfile
|
11
|
+
- gemfiles/rails32.gemfile
|
12
|
+
- gemfiles/rails3x.gemfile
|
13
|
+
- gemfiles/rails40.gemfile
|
14
|
+
matrix:
|
15
|
+
exclude:
|
16
|
+
- rvm: 1.8.7
|
17
|
+
gemfile: gemfiles/rails40.gemfile
|
18
|
+
- rvm: 2.0.0
|
19
|
+
gemfile: gemfiles/rails23.gemfile
|
20
|
+
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,34 @@
|
|
1
1
|
ActiveRecord Tableless
|
2
2
|
======================
|
3
3
|
|
4
|
+
[![Build Status](https://secure.travis-ci.org/softace/activerecord-tableless.png)](http://travis-ci.org/softace/activerecord-tableless)
|
5
|
+
[![Dependency Status](https://gemnasium.com/softace/activerecord-tableless.png)](https://gemnasium.com/softace/activerecord-tableless)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/softace/activerecord-tableless.png)](https://codeclimate.com/github/softace/activerecord-tableless)
|
7
|
+
|
4
8
|
A single implementation of the ActiveRecord Tableless pattern for any
|
5
9
|
Rails project or other Ruby project that uses ActiveRecord.
|
6
10
|
|
11
|
+
Why, why, why
|
12
|
+
-------------
|
13
|
+
|
14
|
+
Why would you ever consider this gem as opposed to ActiveModel.
|
15
|
+
|
16
|
+
In Rails 2 ActiveModel does not exists (this is when it all started; see Hitosry section)
|
17
|
+
|
18
|
+
In Rails 3 there is an Active Model API, where you can use some
|
19
|
+
features of Active Record in other classes. Yehuda Katz has written
|
20
|
+
[a nice introduction about this](http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/).
|
21
|
+
|
22
|
+
In Rails 4 basic features of the Active Model API can be activated
|
23
|
+
by including
|
24
|
+
[ActiveModel:Model](http://api.rubyonrails.org/classes/ActiveModel/Model.html)
|
25
|
+
in the model. Carlos Antônio has written
|
26
|
+
[a nice tutorial about this](http://blog.plataformatec.com.br/2012/03/barebone-models-to-use-with-actionpack-in-rails-4-0/).
|
27
|
+
|
28
|
+
However neither the Active Model API (Rails 3) nor the
|
29
|
+
ActiveModel::Model (Rails 4) supports relations and nested attributes.
|
30
|
+
|
31
|
+
|
7
32
|
Installation
|
8
33
|
------------
|
9
34
|
|
@@ -18,8 +43,8 @@ Include the gem in your Gemfile:
|
|
18
43
|
Supported Versions
|
19
44
|
------------------
|
20
45
|
|
21
|
-
Supported version are ActiveRecord version **2.3.x**, **3.0.x**
|
22
|
-
|
46
|
+
Supported version are ActiveRecord version **2.3.x**, **3.0.x**
|
47
|
+
series, **3.2.x** series and **4.x** series
|
23
48
|
|
24
49
|
You may be able to make it work with 3.1.X, but you should expect to
|
25
50
|
put some time in it.
|
@@ -64,7 +89,6 @@ If you wish (this is not recommended), you can pretend you have a succeeding dat
|
|
64
89
|
has_no_table :database => :pretend_success
|
65
90
|
|
66
91
|
|
67
|
-
|
68
92
|
Development
|
69
93
|
-----------
|
70
94
|
|
@@ -87,7 +111,14 @@ Or you can see what other options are there:
|
|
87
111
|
History
|
88
112
|
-------
|
89
113
|
|
90
|
-
|
114
|
+
Originally this code was implemented for Rails 2 by Kenneth
|
115
|
+
Kalmer. For Rails 3 the need for this functionality was reduced
|
116
|
+
dramatically due to the introduction of ActiveModel. But because the
|
117
|
+
ActiveModel does not support relations and nested attributes the
|
118
|
+
existence of this gem is still justified.
|
119
|
+
|
120
|
+
For a history of technical implementation details feel free to take a
|
121
|
+
look in the git log :-)
|
91
122
|
|
92
123
|
|
93
124
|
Copyright
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.files = `git ls-files`.split($\)
|
11
11
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
-
gem.version = "1.
|
13
|
+
gem.version = "1.3.0"
|
14
14
|
gem.has_rdoc = true
|
15
15
|
|
16
16
|
gem.require_paths = ["lib"]
|
@@ -27,8 +27,13 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_development_dependency('appraisal', '~> 0.4')
|
28
28
|
gem.add_development_dependency('cucumber', '~> 1.1')
|
29
29
|
gem.add_development_dependency("rspec")
|
30
|
-
gem.add_development_dependency('launchy', '~> 2.1')
|
31
30
|
gem.add_development_dependency('aruba', '>= 0.5')
|
32
31
|
gem.add_development_dependency('capybara')
|
33
|
-
|
32
|
+
|
33
|
+
##Specifying upper limit version for ruby 1.8.7
|
34
|
+
gem.add_development_dependency('nokogiri', '< 1.6')
|
35
|
+
gem.add_development_dependency('capybara', '< 2.1')
|
36
|
+
|
37
|
+
# gem.add_development_dependency('launchy', '~> 2.1')
|
38
|
+
# gem.add_development_dependency('debugger')
|
34
39
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Given /^I generate a new rails application$/ do
|
2
2
|
steps %{
|
3
|
-
When I successfully run `bundle exec #{new_application_command
|
3
|
+
When I successfully run `bundle exec #{new_application_command(APP_NAME)}`
|
4
4
|
And I cd to "#{APP_NAME}"
|
5
5
|
And I turn off class caching
|
6
|
+
And I fix the application.rb for 3.0.12
|
6
7
|
And I write to "Gemfile" with:
|
7
8
|
"""
|
8
9
|
source "http://rubygems.org"
|
9
10
|
gem "rails", "#{framework_version}"
|
10
|
-
#{"gem \"jquery-rails\"" if framework_version >= "3.2"}
|
11
11
|
gem "sqlite3"
|
12
12
|
gem "capybara"
|
13
13
|
gem "gherkin"
|
@@ -18,6 +18,15 @@ Given /^I generate a new rails application$/ do
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
|
+
Given "I fix the application.rb for 3.0.12" do
|
22
|
+
##See https://github.com/rails/rails/issues/9619
|
23
|
+
in_current_dir do
|
24
|
+
File.open("config/application.rb", "a") do |f|
|
25
|
+
f << "ActionController::Base.config.relative_url_root = ''"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
Given /^I run a "(.*?)" generator to generate a "(.*?)" scaffold with "(.*?)"$/ do |generator_name, model_name, attributes|
|
22
31
|
step %[I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attributes}`]
|
23
32
|
end
|
@@ -133,6 +142,16 @@ module FileHelpers
|
|
133
142
|
File.open("Gemfile", 'w'){ |file| file.write(gemfile) }
|
134
143
|
end
|
135
144
|
end
|
145
|
+
|
146
|
+
def transform_file(filename)
|
147
|
+
if File.exists?(filename)
|
148
|
+
content = File.read(filename)
|
149
|
+
File.open(filename, "w") do |f|
|
150
|
+
content = yield(content)
|
151
|
+
f.write(content)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
136
155
|
end
|
137
156
|
|
138
157
|
World(FileHelpers)
|
@@ -24,17 +24,14 @@ end
|
|
24
24
|
|
25
25
|
Given /^I update my users controller to render instead of redirect$/ do
|
26
26
|
in_current_dir do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
content.gsub!(/format.html \{ redirect_to[\( ]@user, .*? \}/,
|
37
|
-
"format.html { render :action => 'show' }")
|
38
|
-
File.open(file_name, 'w') { |f| f << content }
|
27
|
+
transform_file('app/controllers/users_controller.rb') do |content|
|
28
|
+
##Changes in #create method
|
29
|
+
content.gsub!(/@user = User.new\((.*?)\)/,
|
30
|
+
'@user = User.new(\1); @user.id = 1')
|
31
|
+
content.gsub!("if @user.save",
|
32
|
+
"if @user.valid?")
|
33
|
+
content.gsub!(/redirect_to([\( ])@user, .*?([\)]| \}|$)/,
|
34
|
+
"render\\1:action => 'show'\\2")
|
35
|
+
end
|
39
36
|
end
|
40
37
|
end
|
data/features/support/rails.rb
CHANGED
@@ -31,16 +31,20 @@ module RailsCommandHelpers
|
|
31
31
|
@framework_version ||= `rails -v`[/^Rails (.+)$/, 1]
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
framework_version
|
34
|
+
def framework_major_version
|
35
|
+
framework_version.split(".").first.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
def new_application_command(app_name)
|
39
|
+
framework_major_version >= 3 ? "rails new #{app_name} --skip-sprockets --skip-javascript --skip-bundle" : "rails #{app_name}"
|
36
40
|
end
|
37
41
|
|
38
42
|
def generator_command
|
39
|
-
|
43
|
+
framework_major_version >= 3 ? "rails generate" : "script/generate"
|
40
44
|
end
|
41
45
|
|
42
46
|
def runner_command
|
43
|
-
|
47
|
+
framework_major_version >= 3 ? "rails runner" : "script/runner"
|
44
48
|
end
|
45
49
|
|
46
50
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
# See #ActiveRecord::Tableless
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
|
-
|
4
|
+
|
5
5
|
# = ActiveRecord::Tableless
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Allow classes to behave like ActiveRecord models, but without an associated
|
8
8
|
# database table. A great way to capitalize on validations. Based on the
|
9
9
|
# original post at http://www.railsweenie.com/forums/2/topics/724 (which seems
|
10
10
|
# to have disappeared from the face of the earth).
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# = Example usage
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# class ContactMessage < ActiveRecord::Base
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# has_no_table
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# column :name, :string
|
19
19
|
# column :email, :string
|
20
20
|
# column :message, :string
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# end
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# msg = ContactMessage.new( params[:msg] )
|
25
25
|
# if msg.valid?
|
26
26
|
# ContactMessageSender.deliver_message( msg )
|
@@ -28,7 +28,7 @@ module ActiveRecord
|
|
28
28
|
# end
|
29
29
|
#
|
30
30
|
module Tableless
|
31
|
-
|
31
|
+
|
32
32
|
class Exception < StandardError
|
33
33
|
end
|
34
34
|
class NoDatabase < Exception
|
@@ -37,9 +37,9 @@ module ActiveRecord
|
|
37
37
|
def self.included( base ) #:nodoc:
|
38
38
|
base.send :extend, ActsMethods
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
module ActsMethods #:nodoc:
|
42
|
-
|
42
|
+
|
43
43
|
# A model that needs to be tableless will call this method to indicate
|
44
44
|
# it.
|
45
45
|
def has_no_table(options = {:database => :fail_fast})
|
@@ -52,43 +52,45 @@ module ActiveRecord
|
|
52
52
|
}
|
53
53
|
)
|
54
54
|
class_inheritable_reader :tableless_options
|
55
|
-
|
55
|
+
elsif ActiveRecord::VERSION::STRING >= "3.2.0"
|
56
56
|
class_attribute :tableless_options
|
57
57
|
self.tableless_options = {
|
58
58
|
:database => options[:database],
|
59
59
|
:columns => []
|
60
60
|
}
|
61
|
+
else
|
62
|
+
raise Exception.new("Sorry, ActiveRecord version #{ActiveRecord::VERSION::STRING} is not supported")
|
61
63
|
end
|
62
64
|
|
63
65
|
# extend
|
64
66
|
extend ActiveRecord::Tableless::SingletonMethods
|
65
67
|
extend ActiveRecord::Tableless::ClassMethods
|
66
|
-
|
68
|
+
|
67
69
|
# include
|
68
70
|
include ActiveRecord::Tableless::InstanceMethods
|
69
|
-
|
71
|
+
|
70
72
|
# setup columns
|
71
73
|
end
|
72
|
-
|
74
|
+
|
73
75
|
def tableless?
|
74
76
|
false
|
75
77
|
end
|
76
78
|
|
77
79
|
end
|
78
|
-
|
80
|
+
|
79
81
|
module SingletonMethods
|
80
|
-
|
82
|
+
|
81
83
|
# Return the list of columns registered for the model. Used internally by
|
82
84
|
# ActiveRecord
|
83
85
|
def columns
|
84
86
|
tableless_options[:columns]
|
85
87
|
end
|
86
|
-
|
88
|
+
|
87
89
|
# Register a new column.
|
88
90
|
def column(name, sql_type = nil, default = nil, null = true)
|
89
91
|
tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
90
92
|
end
|
91
|
-
|
93
|
+
|
92
94
|
# Register a set of colums with the same SQL type
|
93
95
|
def add_columns(sql_type, *args)
|
94
96
|
args.each do |col|
|
@@ -113,18 +115,19 @@ module ActiveRecord
|
|
113
115
|
raise NoDatabase.new("Can't #destroy_all on Tableless class")
|
114
116
|
end
|
115
117
|
end
|
116
|
-
|
117
|
-
|
118
|
+
|
119
|
+
case ActiveRecord::VERSION::MAJOR
|
120
|
+
when 2
|
118
121
|
def find_from_ids(*args)
|
119
122
|
case tableless_options[:database]
|
120
123
|
when :pretend_success
|
121
124
|
raise ActiveRecord::RecordNotFound.new("Couldn't find #{self} with ID=#{args[0].to_s}")
|
122
|
-
|
125
|
+
|
123
126
|
when :fail_fast
|
124
127
|
raise NoDatabase.new("Can't #find_from_ids on Tableless class")
|
125
128
|
end
|
126
129
|
end
|
127
|
-
|
130
|
+
|
128
131
|
def find_every(*args)
|
129
132
|
case tableless_options[:database]
|
130
133
|
when :pretend_success
|
@@ -133,7 +136,7 @@ module ActiveRecord
|
|
133
136
|
raise NoDatabase.new("Can't #find_every on Tableless class")
|
134
137
|
end
|
135
138
|
end
|
136
|
-
|
139
|
+
when 3
|
137
140
|
def all(*args)
|
138
141
|
case tableless_options[:database]
|
139
142
|
when :pretend_success
|
@@ -141,10 +144,22 @@ module ActiveRecord
|
|
141
144
|
when :fail_fast
|
142
145
|
raise NoDatabase.new("Can't #find_every on Tableless class")
|
143
146
|
end
|
144
|
-
|
147
|
+
|
148
|
+
end
|
149
|
+
when 4
|
150
|
+
def find_by_sql(*args)
|
151
|
+
case tableless_options[:database]
|
152
|
+
when :pretend_success
|
153
|
+
[]
|
154
|
+
when :fail_fast
|
155
|
+
raise NoDatabase.new("Can't #find_by_sql on Tableless class")
|
156
|
+
end
|
157
|
+
|
145
158
|
end
|
159
|
+
else
|
160
|
+
raise Exceptioin.new("Unsupported ActiveRecord version")
|
146
161
|
end
|
147
|
-
|
162
|
+
|
148
163
|
def transaction(&block)
|
149
164
|
# case tableless_options[:database]
|
150
165
|
# when :pretend_success
|
@@ -154,21 +169,21 @@ module ActiveRecord
|
|
154
169
|
# raise NoDatabase.new("Can't #transaction on Tableless class")
|
155
170
|
# end
|
156
171
|
end
|
157
|
-
|
172
|
+
|
158
173
|
def tableless?
|
159
174
|
true
|
160
175
|
end
|
161
176
|
|
162
|
-
if ActiveRecord::VERSION::
|
177
|
+
if ActiveRecord::VERSION::MAJOR < 3
|
163
178
|
else
|
164
179
|
def table_exists?
|
165
180
|
false
|
166
181
|
end
|
167
182
|
end
|
168
183
|
end
|
169
|
-
|
184
|
+
|
170
185
|
module ClassMethods
|
171
|
-
|
186
|
+
|
172
187
|
def from_query_string(query_string)
|
173
188
|
unless query_string.blank?
|
174
189
|
params = query_string.split('&').collect do |chunk|
|
@@ -178,7 +193,7 @@ module ActiveRecord
|
|
178
193
|
value = value.nil? ? nil : CGI.unescape(value)
|
179
194
|
[ CGI.unescape(key), value ]
|
180
195
|
end.compact.to_h
|
181
|
-
|
196
|
+
|
182
197
|
new(params)
|
183
198
|
else
|
184
199
|
new
|
@@ -190,17 +205,27 @@ module ActiveRecord
|
|
190
205
|
def conn.quote_table_name(*args)
|
191
206
|
""
|
192
207
|
end
|
208
|
+
def conn.substitute_at(*args)
|
209
|
+
nil
|
210
|
+
end
|
211
|
+
def conn.schema_cache(*args)
|
212
|
+
schema_cache = Object.new()
|
213
|
+
def schema_cache.columns_hash(*args)
|
214
|
+
Hash.new()
|
215
|
+
end
|
216
|
+
schema_cache
|
217
|
+
end
|
193
218
|
conn
|
194
219
|
end
|
195
|
-
|
220
|
+
|
196
221
|
end
|
197
|
-
|
222
|
+
|
198
223
|
module InstanceMethods
|
199
|
-
|
224
|
+
|
200
225
|
def to_query_string(prefix = nil)
|
201
226
|
attributes.to_a.collect{|(name,value)| escaped_var_name(name, prefix) + "=" + escape_for_url(value) if value }.compact.join("&")
|
202
227
|
end
|
203
|
-
|
228
|
+
|
204
229
|
def quote_value(value, column = nil)
|
205
230
|
""
|
206
231
|
end
|
@@ -214,6 +239,15 @@ module ActiveRecord
|
|
214
239
|
end
|
215
240
|
end
|
216
241
|
|
242
|
+
def create_record(*args)
|
243
|
+
case self.class.tableless_options[:database]
|
244
|
+
when :pretend_success
|
245
|
+
true
|
246
|
+
when :fail_fast
|
247
|
+
raise NoDatabase.new("Can't #create_record a Tableless object")
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
217
251
|
def update(*args)
|
218
252
|
case self.class.tableless_options[:database]
|
219
253
|
when :pretend_success
|
@@ -223,6 +257,15 @@ module ActiveRecord
|
|
223
257
|
end
|
224
258
|
end
|
225
259
|
|
260
|
+
def update_record(*args)
|
261
|
+
case self.class.tableless_options[:database]
|
262
|
+
when :pretend_success
|
263
|
+
true
|
264
|
+
when :fail_fast
|
265
|
+
raise NoDatabase.new("Can't #update_record a Tableless object")
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
226
269
|
def destroy
|
227
270
|
case self.class.tableless_options[:database]
|
228
271
|
when :pretend_success
|
@@ -241,19 +284,18 @@ module ActiveRecord
|
|
241
284
|
raise NoDatabase.new("Can't #reload a Tableless object")
|
242
285
|
end
|
243
286
|
end
|
244
|
-
|
245
|
-
if ActiveRecord::VERSION::
|
246
|
-
else
|
287
|
+
|
288
|
+
if ActiveRecord::VERSION::MAJOR >= 3
|
247
289
|
def add_to_transaction
|
248
290
|
end
|
249
291
|
end
|
250
292
|
|
251
293
|
private
|
252
|
-
|
294
|
+
|
253
295
|
def escaped_var_name(name, prefix = nil)
|
254
296
|
prefix ? "#{URI.escape(prefix)}[#{URI.escape(name)}]" : URI.escape(name)
|
255
297
|
end
|
256
|
-
|
298
|
+
|
257
299
|
def escape_for_url(value)
|
258
300
|
case value
|
259
301
|
when true then "1"
|
@@ -264,9 +306,9 @@ module ActiveRecord
|
|
264
306
|
rescue
|
265
307
|
""
|
266
308
|
end
|
267
|
-
|
309
|
+
|
268
310
|
end
|
269
|
-
|
311
|
+
|
270
312
|
end
|
271
313
|
end
|
272
314
|
|
@@ -9,10 +9,10 @@ def make_tableless_model(database = nil, nested = nil)
|
|
9
9
|
#{database ? "has_no_table :database => :#{database}" : 'has_no_table'}
|
10
10
|
column :id, :integer
|
11
11
|
column :name, :string
|
12
|
-
#{if nested
|
12
|
+
#{if nested
|
13
13
|
'
|
14
14
|
has_many :arm_rests
|
15
|
-
accepts_nested_attributes_for :arm_rests
|
15
|
+
accepts_nested_attributes_for :arm_rests
|
16
16
|
'
|
17
17
|
end}
|
18
18
|
end
|
@@ -93,7 +93,8 @@ end
|
|
93
93
|
shared_examples_for "a tableless model with fail_fast" do
|
94
94
|
it_behaves_like "an active record"
|
95
95
|
describe "class" do
|
96
|
-
|
96
|
+
case ActiveRecord::VERSION::MAJOR
|
97
|
+
when 2
|
97
98
|
describe "#find" do
|
98
99
|
it "raises ActiveRecord::Tableless::NoDatabase" do
|
99
100
|
expect { Chair.find(1) }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
@@ -104,12 +105,23 @@ shared_examples_for "a tableless model with fail_fast" do
|
|
104
105
|
expect { Chair.find(:all) }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
105
106
|
end
|
106
107
|
end
|
107
|
-
|
108
|
+
when 3
|
108
109
|
describe "#all" do
|
109
110
|
it "raises ActiveRecord::Tableless::NoDatabase" do
|
110
111
|
expect { Chair.all }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
111
112
|
end
|
112
113
|
end
|
114
|
+
when 4
|
115
|
+
describe "#all" do
|
116
|
+
it "raises ActiveRecord::Tableless::NoDatabase" do
|
117
|
+
expect { Chair.all }.to_not raise_exception
|
118
|
+
end
|
119
|
+
end
|
120
|
+
describe "#all[]" do
|
121
|
+
it "raises ActiveRecord::Tableless::NoDatabase" do
|
122
|
+
expect { Chair.all[0] }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
123
|
+
end
|
124
|
+
end
|
113
125
|
end
|
114
126
|
describe "#create" do
|
115
127
|
it "raises ActiveRecord::Tableless::NoDatabase" do
|
@@ -180,7 +192,7 @@ describe "Tableless nested with fail_fast" do
|
|
180
192
|
end
|
181
193
|
describe "with nested attributes" do
|
182
194
|
subject do
|
183
|
-
Chair.new(:name => "Jarl",
|
195
|
+
Chair.new(:name => "Jarl",
|
184
196
|
:arm_rests_attributes => [
|
185
197
|
{:name => 'left'},
|
186
198
|
{:name => 'right'},
|
@@ -205,7 +217,8 @@ end
|
|
205
217
|
shared_examples_for "a succeeding database" do
|
206
218
|
it_behaves_like "an active record"
|
207
219
|
describe "class" do
|
208
|
-
|
220
|
+
case ActiveRecord::VERSION::MAJOR
|
221
|
+
when 2
|
209
222
|
describe "#find" do
|
210
223
|
it "raises ActiveRecord::RecordNotFound" do
|
211
224
|
expect { Chair.find(314) }.to raise_exception(ActiveRecord::RecordNotFound)
|
@@ -214,7 +227,7 @@ shared_examples_for "a succeeding database" do
|
|
214
227
|
describe "#find(:all)" do
|
215
228
|
specify { Chair.find(:all).should == []}
|
216
229
|
end
|
217
|
-
|
230
|
+
when 3, 4
|
218
231
|
describe "#all" do
|
219
232
|
specify { Chair.all.should == []}
|
220
233
|
end
|
@@ -252,7 +265,7 @@ describe "Active record with real database" do
|
|
252
265
|
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'tmp/test.db')
|
253
266
|
ActiveRecord::Base.connection.execute("drop table if exists chairs")
|
254
267
|
ActiveRecord::Base.connection.execute("create table chairs (id INTEGER PRIMARY KEY, name TEXT )")
|
255
|
-
|
268
|
+
|
256
269
|
class Chair < ActiveRecord::Base
|
257
270
|
end
|
258
271
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-tableless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jarl Friis
|
@@ -11,60 +10,53 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: activerecord
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - '>='
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: 2.3.0
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
|
-
- -
|
26
|
+
- - '>='
|
30
27
|
- !ruby/object:Gem::Version
|
31
28
|
version: 2.3.0
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: bundler
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
|
-
- -
|
33
|
+
- - '>='
|
38
34
|
- !ruby/object:Gem::Version
|
39
35
|
version: '0'
|
40
36
|
type: :development
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
|
-
- -
|
40
|
+
- - '>='
|
46
41
|
- !ruby/object:Gem::Version
|
47
42
|
version: '0'
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
44
|
name: rake
|
50
45
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
46
|
requirements:
|
53
|
-
- -
|
47
|
+
- - '>='
|
54
48
|
- !ruby/object:Gem::Version
|
55
49
|
version: '0'
|
56
50
|
type: :development
|
57
51
|
prerelease: false
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
|
-
- -
|
54
|
+
- - '>='
|
62
55
|
- !ruby/object:Gem::Version
|
63
56
|
version: '0'
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: sqlite3
|
66
59
|
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
60
|
requirements:
|
69
61
|
- - ~>
|
70
62
|
- !ruby/object:Gem::Version
|
@@ -72,7 +64,6 @@ dependencies:
|
|
72
64
|
type: :development
|
73
65
|
prerelease: false
|
74
66
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
68
|
- - ~>
|
78
69
|
- !ruby/object:Gem::Version
|
@@ -80,7 +71,6 @@ dependencies:
|
|
80
71
|
- !ruby/object:Gem::Dependency
|
81
72
|
name: appraisal
|
82
73
|
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
74
|
requirements:
|
85
75
|
- - ~>
|
86
76
|
- !ruby/object:Gem::Version
|
@@ -88,7 +78,6 @@ dependencies:
|
|
88
78
|
type: :development
|
89
79
|
prerelease: false
|
90
80
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
81
|
requirements:
|
93
82
|
- - ~>
|
94
83
|
- !ruby/object:Gem::Version
|
@@ -96,7 +85,6 @@ dependencies:
|
|
96
85
|
- !ruby/object:Gem::Dependency
|
97
86
|
name: cucumber
|
98
87
|
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
88
|
requirements:
|
101
89
|
- - ~>
|
102
90
|
- !ruby/object:Gem::Version
|
@@ -104,7 +92,6 @@ dependencies:
|
|
104
92
|
type: :development
|
105
93
|
prerelease: false
|
106
94
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
95
|
requirements:
|
109
96
|
- - ~>
|
110
97
|
- !ruby/object:Gem::Version
|
@@ -112,83 +99,73 @@ dependencies:
|
|
112
99
|
- !ruby/object:Gem::Dependency
|
113
100
|
name: rspec
|
114
101
|
requirement: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
102
|
requirements:
|
117
|
-
- -
|
103
|
+
- - '>='
|
118
104
|
- !ruby/object:Gem::Version
|
119
105
|
version: '0'
|
120
106
|
type: :development
|
121
107
|
prerelease: false
|
122
108
|
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
109
|
requirements:
|
125
|
-
- -
|
110
|
+
- - '>='
|
126
111
|
- !ruby/object:Gem::Version
|
127
112
|
version: '0'
|
128
113
|
- !ruby/object:Gem::Dependency
|
129
|
-
name:
|
114
|
+
name: aruba
|
130
115
|
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
116
|
requirements:
|
133
|
-
- -
|
117
|
+
- - '>='
|
134
118
|
- !ruby/object:Gem::Version
|
135
|
-
version: '
|
119
|
+
version: '0.5'
|
136
120
|
type: :development
|
137
121
|
prerelease: false
|
138
122
|
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
123
|
requirements:
|
141
|
-
- -
|
124
|
+
- - '>='
|
142
125
|
- !ruby/object:Gem::Version
|
143
|
-
version: '
|
126
|
+
version: '0.5'
|
144
127
|
- !ruby/object:Gem::Dependency
|
145
|
-
name:
|
128
|
+
name: capybara
|
146
129
|
requirement: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
130
|
requirements:
|
149
|
-
- -
|
131
|
+
- - '>='
|
150
132
|
- !ruby/object:Gem::Version
|
151
|
-
version: '0
|
133
|
+
version: '0'
|
152
134
|
type: :development
|
153
135
|
prerelease: false
|
154
136
|
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
137
|
requirements:
|
157
|
-
- -
|
138
|
+
- - '>='
|
158
139
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0
|
140
|
+
version: '0'
|
160
141
|
- !ruby/object:Gem::Dependency
|
161
|
-
name:
|
142
|
+
name: nokogiri
|
162
143
|
requirement: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
144
|
requirements:
|
165
|
-
- -
|
145
|
+
- - <
|
166
146
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
147
|
+
version: '1.6'
|
168
148
|
type: :development
|
169
149
|
prerelease: false
|
170
150
|
version_requirements: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
151
|
requirements:
|
173
|
-
- -
|
152
|
+
- - <
|
174
153
|
- !ruby/object:Gem::Version
|
175
|
-
version: '
|
154
|
+
version: '1.6'
|
176
155
|
- !ruby/object:Gem::Dependency
|
177
|
-
name:
|
156
|
+
name: capybara
|
178
157
|
requirement: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
158
|
requirements:
|
181
|
-
- -
|
159
|
+
- - <
|
182
160
|
- !ruby/object:Gem::Version
|
183
|
-
version: '
|
161
|
+
version: '2.1'
|
184
162
|
type: :development
|
185
163
|
prerelease: false
|
186
164
|
version_requirements: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
165
|
requirements:
|
189
|
-
- -
|
166
|
+
- - <
|
190
167
|
- !ruby/object:Gem::Version
|
191
|
-
version: '
|
168
|
+
version: '2.1'
|
192
169
|
description: ActiveRecord Tableless Models provides a simple mixin for creating models
|
193
170
|
that are not bound to the database. This approach is mostly useful for capitalizing
|
194
171
|
on the features ActiveRecord::Validation
|
@@ -200,6 +177,7 @@ extra_rdoc_files: []
|
|
200
177
|
files:
|
201
178
|
- .gitignore
|
202
179
|
- .rspec
|
180
|
+
- .travis.yml
|
203
181
|
- Appraisals
|
204
182
|
- Gemfile
|
205
183
|
- README.md
|
@@ -217,38 +195,32 @@ files:
|
|
217
195
|
- gemfiles/rails30.gemfile
|
218
196
|
- gemfiles/rails32.gemfile
|
219
197
|
- gemfiles/rails3x.gemfile
|
198
|
+
- gemfiles/rails40.gemfile
|
220
199
|
- init.rb
|
221
200
|
- lib/activerecord-tableless.rb
|
222
201
|
- spec/lib/activerecord-tableless_spec.rb
|
223
202
|
homepage: https://github.com/softace/activerecord-tableless
|
224
203
|
licenses: []
|
204
|
+
metadata: {}
|
225
205
|
post_install_message:
|
226
206
|
rdoc_options: []
|
227
207
|
require_paths:
|
228
208
|
- lib
|
229
209
|
required_ruby_version: !ruby/object:Gem::Requirement
|
230
|
-
none: false
|
231
210
|
requirements:
|
232
|
-
- -
|
211
|
+
- - '>='
|
233
212
|
- !ruby/object:Gem::Version
|
234
213
|
version: '0'
|
235
|
-
segments:
|
236
|
-
- 0
|
237
|
-
hash: 698122787109263404
|
238
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
|
-
none: false
|
240
215
|
requirements:
|
241
|
-
- -
|
216
|
+
- - '>='
|
242
217
|
- !ruby/object:Gem::Version
|
243
218
|
version: '0'
|
244
|
-
segments:
|
245
|
-
- 0
|
246
|
-
hash: 698122787109263404
|
247
219
|
requirements: []
|
248
220
|
rubyforge_project:
|
249
|
-
rubygems_version:
|
221
|
+
rubygems_version: 2.0.3
|
250
222
|
signing_key:
|
251
|
-
specification_version:
|
223
|
+
specification_version: 4
|
252
224
|
summary: A library for implementing tableless ActiveRecord models
|
253
225
|
test_files:
|
254
226
|
- features/basic_integration.feature
|