lazy_columns 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ describe LazyColumns::ActsAsLazyColumnLoader do
7
7
 
8
8
  describe "#lazy_column" do
9
9
  it "excludes single column from active record objects" do
10
- @action.has_attribute?(:comments).should_not == "The action should not contain the lazy :comments attribute"
10
+ @action.has_attribute?(:comments).should be_false
11
11
  end
12
12
 
13
13
  it "loads column when requested" do
@@ -19,9 +19,46 @@ describe LazyColumns::ActsAsLazyColumnLoader do
19
19
  @action.should_not_receive :reload
20
20
  @action.comments
21
21
  end
22
+
23
+ it "should not reload the object if after the column was fetched" do
24
+ @action.comments
25
+ @action.should_not_receive :reload
26
+ @action.comments
27
+ end
28
+
29
+ it "should let you define the attribute when creating the object" do
30
+ @action = Action.create!(comments: "some new comments")
31
+ @action.comments.should == "some new comments"
32
+ end
33
+
34
+ it "should let you update the attribute using #update_attribute" do
35
+ @action.update_attribute(:comments, "some new comments")
36
+ @action.comments.should == "some new comments"
37
+ end
38
+
39
+ it "should let you update the attribute using #update_attributes" do
40
+ @action.update_attributes(comments: "some new comments")
41
+ @action.comments.should == "some new comments"
42
+ end
43
+
44
+ it "should let you define multiple lazy columns at the same time" do
45
+ @action = create_and_reload_action_from_db(ActionWith2LazyColumns)
46
+ @action.has_attribute?(:comments).should be_false
47
+ @action.has_attribute?(:title).should be_false
48
+ @action.title.should == "some action"
49
+ @action.comments.should == "some comments"
50
+ end
22
51
  end
23
52
 
24
- def create_and_reload_action_from_db
25
- Action.find Action.create(title: "some action", comments: "some comments")
53
+ def create_and_reload_action_from_db(klass=Action)
54
+ klass.find Action.create(title: "some action", comments: "some comments")
55
+ end
56
+
57
+ class ActionWith2LazyColumns < ActiveRecord::Base
58
+ self.table_name = "actions"
59
+
60
+ lazy_load :comments, :title
61
+
62
+ attr_accessible :comments, :title
26
63
  end
27
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -89,7 +89,7 @@ files:
89
89
  - lib/tasks/lazy_columns_tasks.rake
90
90
  - MIT-LICENSE
91
91
  - Rakefile
92
- - README.rdoc
92
+ - README.md
93
93
  - spec/dummy/app/assets/javascripts/application.js
94
94
  - spec/dummy/app/assets/stylesheets/application.css
95
95
  - spec/dummy/app/controllers/application_controller.rb
@@ -112,12 +112,10 @@ files:
112
112
  - spec/dummy/config/locales/en.yml
113
113
  - spec/dummy/config/routes.rb
114
114
  - spec/dummy/config.ru
115
- - spec/dummy/db/development.sqlite3
116
115
  - spec/dummy/db/migrate/20130107093428_create_actions.rb
117
116
  - spec/dummy/db/schema.rb
118
117
  - spec/dummy/db/test.sqlite3
119
118
  - spec/dummy/log/development.log
120
- - spec/dummy/log/RAILS_ENV=test.log
121
119
  - spec/dummy/log/test.log
122
120
  - spec/dummy/public/404.html
123
121
  - spec/dummy/public/422.html
@@ -143,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
141
  version: '0'
144
142
  segments:
145
143
  - 0
146
- hash: 1478773402457556686
144
+ hash: 151826556132538192
147
145
  required_rubygems_version: !ruby/object:Gem::Requirement
148
146
  none: false
149
147
  requirements:
@@ -152,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
150
  version: '0'
153
151
  segments:
154
152
  - 0
155
- hash: 1478773402457556686
153
+ hash: 151826556132538192
156
154
  requirements: []
157
155
  rubyforge_project:
158
156
  rubygems_version: 1.8.24
@@ -182,12 +180,10 @@ test_files:
182
180
  - spec/dummy/config/locales/en.yml
183
181
  - spec/dummy/config/routes.rb
184
182
  - spec/dummy/config.ru
185
- - spec/dummy/db/development.sqlite3
186
183
  - spec/dummy/db/migrate/20130107093428_create_actions.rb
187
184
  - spec/dummy/db/schema.rb
188
185
  - spec/dummy/db/test.sqlite3
189
186
  - spec/dummy/log/development.log
190
- - spec/dummy/log/RAILS_ENV=test.log
191
187
  - spec/dummy/log/test.log
192
188
  - spec/dummy/public/404.html
193
189
  - spec/dummy/public/422.html
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = LazyColumns
2
-
3
- This project rocks and uses MIT-LICENSE.
Binary file
@@ -1 +0,0 @@
1
- Connecting to database specified by database.yml