basic_assumption 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.3.11 / 2010-06-28
2
+ * Test Enhancement
3
+ * Cucumber features covering most of the basic functionality within a Rails 2.3 app (not included in gem)
4
+ * Bug Fix
5
+ * RestfulRails now works correctly on an index where pagination is in effect
1
6
  == 0.3.10 / 2010-06-18
2
7
  * License
3
8
  * Rename LICENSE to MIT-LICENSE; terms remain the same
@@ -318,6 +318,25 @@ manager. For example, if that's RubyGems:
318
318
 
319
319
  If you're unfamiliar with why this is being done, take a look
320
320
  {here for a start}[http://tomayko.com/writings/require-rubygems-antipattern].
321
+
322
+ There is also a Cucumber suite that can be run to check BasicAssumption against
323
+ an actual Rails app. Until Bundler has been introduced to manage the gem
324
+ dependencies for the development environment, you will need to ensure at least
325
+ the following gems are installed:
326
+
327
+ * aruba (0.1.9)
328
+ * capybara (0.3.8)
329
+ * cucumber (0.8.3)
330
+ * cucumber-rails (0.3.2)
331
+ * database_cleaner (0.5.2)
332
+ * rails (2.3.5)
333
+ * rake (0.8.7)
334
+ * sqlite3-ruby (1.3.0)
335
+ * will_paginate (2.3.14)
336
+
337
+ There is an .rvmrc file in the repository that will require a basic_assumption
338
+ gemset if you're using RVM, which will help to manage the gem dependencies.
339
+
321
340
  Other than that, fork away and send back pull requests! Thanks.
322
341
 
323
342
  == But should I use it?
@@ -14,8 +14,8 @@ module BasicAssumption
14
14
  @action = params['action']
15
15
  @resource_attributes = params[singular_name]
16
16
 
17
- if @page = params['page']
18
- @per_page = params['per_page'] || '15'
17
+ if @page = params[:page]
18
+ @per_page = params[:per_page]
19
19
  end
20
20
  end
21
21
 
@@ -45,9 +45,8 @@ module BasicAssumption
45
45
  # for the # behavior of +assume+. If the model responds to +paginate+ and
46
46
  # there is a +page+ key in the +params+ hash, +assume+ will attempt to
47
47
  # find all records of the model type paginated based on the +page+
48
- # value in params and also a +per_page+ value. 15 will be the default
49
- # if +per_page+ is not present. Otherwise, it returns all # records for
50
- # the model.
48
+ # value in params and also a +per_page+ value. Otherwise, it returns all
49
+ # # records for the model.
51
50
  def block
52
51
  super
53
52
  end
@@ -66,7 +65,7 @@ module BasicAssumption
66
65
 
67
66
  def list #:nodoc:
68
67
  if page?
69
- model_class.paginate('page' => page, 'per_page' => per_page)
68
+ model_class.paginate(:page => page, :per_page => per_page)
70
69
  else
71
70
  model_class.all
72
71
  end
@@ -1,3 +1,3 @@
1
1
  module BasicAssumption
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
3
3
  end
@@ -2,8 +2,9 @@ require 'spec_helper'
2
2
  require 'active_support'
3
3
  require 'basic_assumption/default_assumption/cautious_rails'
4
4
 
5
+ class Model; end
6
+
5
7
  describe BasicAssumption::DefaultAssumption::CautiousRails do
6
- class Model; end
7
8
 
8
9
  context "#block" do
9
10
  let(:default) { BasicAssumption::DefaultAssumption::CautiousRails.new }
@@ -2,8 +2,9 @@ require 'spec_helper'
2
2
  require 'active_support'
3
3
  require 'basic_assumption/default_assumption/rails'
4
4
 
5
+ class Model; end
6
+
5
7
  describe BasicAssumption::DefaultAssumption::Rails do
6
- class Model; end
7
8
 
8
9
  context "#block" do
9
10
  let(:default) { BasicAssumption::DefaultAssumption::Rails.new }
@@ -2,17 +2,16 @@ require 'spec_helper'
2
2
  require 'active_support'
3
3
  require 'basic_assumption/default_assumption/restful_rails'
4
4
 
5
- describe BasicAssumption::DefaultAssumption::RestfulRails do
6
- class Model
7
- attr_accessor :age, :color
8
- def initialize(hash = {})
9
- hash.each do |k, v|
10
- self.send("#{k}=", v)
11
- end
5
+ class Model
6
+ attr_accessor :age, :color
7
+ def initialize(hash = {})
8
+ hash.each do |k, v|
9
+ self.send("#{k}=", v)
12
10
  end
13
11
  end
12
+ end
14
13
 
15
- it { should be }
14
+ describe BasicAssumption::DefaultAssumption::RestfulRails do
16
15
 
17
16
  context "#block" do
18
17
  let(:default) { BasicAssumption::DefaultAssumption::RestfulRails.new(:model, params) }
@@ -33,13 +32,13 @@ describe BasicAssumption::DefaultAssumption::RestfulRails do
33
32
  before { params['id'] = 123 }
34
33
  context "when action is #{action}" do
35
34
  before { Model.should_receive(:all) }
36
- context "when 'page' exists in the request params" do
37
- before { params['page'] = '5' }
35
+ context "when :page exists in the request params" do
36
+ before { params[:page] = '5' }
38
37
  it "finds all the records of the model class" do
39
38
  default.block.call(name)
40
39
  end
41
40
  end
42
- context "when 'page' does not exist in the request params" do
41
+ context "when :page does not exist in the request params" do
43
42
  it "finds all the records of the model class" do
44
43
  default.block.call(name)
45
44
  end
@@ -50,13 +49,13 @@ describe BasicAssumption::DefaultAssumption::RestfulRails do
50
49
  context "when there is not an id in the params" do
51
50
  context "when action is #{action}" do
52
51
  before { Model.should_receive(:all) }
53
- context "when 'page' exists in the request params" do
54
- before { params['page'] = '5' }
52
+ context "when :page exists in the request params" do
53
+ before { params[:page] = '5' }
55
54
  it "finds all the records of the model class" do
56
55
  default.block.call(name)
57
56
  end
58
57
  end
59
- context "when 'page' does not exist in the request params" do
58
+ context "when :page does not exist in the request params" do
60
59
  it "finds all the records of the model class" do
61
60
  default.block.call(name)
62
61
  end
@@ -74,27 +73,27 @@ describe BasicAssumption::DefaultAssumption::RestfulRails do
74
73
  before { params['id'] = 123 }
75
74
  context "when action is #{action}" do
76
75
  before { Model.stub! :paginate }
77
- context "when 'page' exists in the request params" do
78
- before { params['page'] = '5' }
76
+ context "when :page exists in the request params" do
77
+ before { params[:page] = '5' }
79
78
  it "paginates the records of the model class" do
80
79
  Model.should_receive(:paginate)
81
80
  default.block.call(name)
82
81
  end
83
- context "when 'per_page' exists in the request params" do
84
- it "paginates using 'page' and 'per_page' from the params" do
85
- params['per_page'] = '10'
86
- Model.should_receive(:paginate).with('page' => '5', 'per_page' => '10')
82
+ context "when :per_page exists in the request params" do
83
+ it "paginates using :page and :per_page from the params" do
84
+ params[:per_page] = '10'
85
+ Model.should_receive(:paginate).with(:page => '5', :per_page => '10')
87
86
  default.block.call(name)
88
87
  end
89
88
  end
90
- context "when 'per_page' does not exist in the request params" do
91
- it "paginates using 'page' from the params and a default 'per_page' of 15" do
92
- Model.should_receive(:paginate).with('page' => '5', 'per_page' => '15')
89
+ context "when :per_page does not exist in the request params" do
90
+ it "paginates using :page from the params" do
91
+ Model.should_receive(:paginate).with(:page => '5', :per_page => nil)
93
92
  default.block.call(name)
94
93
  end
95
94
  end
96
95
  end
97
- context "when 'page' does not exist in the request params" do
96
+ context "when :page does not exist in the request params" do
98
97
  it "finds all the records of the model class" do
99
98
  Model.should_receive(:all)
100
99
  default.block.call(name)
@@ -106,27 +105,27 @@ describe BasicAssumption::DefaultAssumption::RestfulRails do
106
105
  context "when there is not an id in the params" do
107
106
  context "when action is #{action}" do
108
107
  before { Model.stub! :paginate }
109
- context "when 'page' exists in the request params" do
110
- before { params['page'] = '5' }
108
+ context "when :page exists in the request params" do
109
+ before { params[:page] = '5' }
111
110
  it "paginates the records of the model class" do
112
111
  Model.should_receive(:paginate)
113
112
  default.block.call(name)
114
113
  end
115
- context "when 'per_page' exists in the request params" do
116
- it "paginates using 'page' and 'per_page' from the params" do
117
- params['per_page'] = '10'
118
- Model.should_receive(:paginate).with('page' => '5', 'per_page' => '10')
114
+ context "when :per_page exists in the request params" do
115
+ it "paginates using :page and :per_page from the params" do
116
+ params[:per_page] = '10'
117
+ Model.should_receive(:paginate).with(:page => '5', :per_page => '10')
119
118
  default.block.call(name)
120
119
  end
121
120
  end
122
- context "when 'per_page' does not exist in the request params" do
123
- it "paginates using 'page' from the params and a default 'per_page' of 15" do
124
- Model.should_receive(:paginate).with('page' => '5', 'per_page' => '15')
121
+ context "when :per_page does not exist in the request params" do
122
+ it "paginates using :page from the params" do
123
+ Model.should_receive(:paginate).with(:page => '5', :per_page => nil)
125
124
  default.block.call(name)
126
125
  end
127
126
  end
128
127
  end
129
- context "when 'page' does not exist in the request params" do
128
+ context "when :page does not exist in the request params" do
130
129
  it "finds all the records of the model class" do
131
130
  Model.should_receive(:all)
132
131
  default.block.call(name)
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'lib/basic_assumption/default_assumption/rails'
2
+ require 'basic_assumption/default_assumption/rails'
3
3
 
4
4
  describe BasicAssumption::DefaultAssumption do
5
5
  let(:mod) { BasicAssumption::DefaultAssumption }
@@ -120,7 +120,7 @@ describe BasicAssumption do
120
120
 
121
121
  context "within Rails" do
122
122
  before(:all) do
123
- require 'rails/init.rb'
123
+ require File.expand_path(File.dirname(__FILE__) + '/../../rails/init.rb')
124
124
  end
125
125
  let(:controller_class) { Class.new(::ActionController::Base) }
126
126
  let(:controller_instance) { controller_class.new }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 10
9
- version: 0.3.10
8
+ - 11
9
+ version: 0.3.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matt Yoho
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-18 00:00:00 -05:00
17
+ date: 2010-06-28 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency