ajax-datatables-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07fee37ffeee9afc526dfe9f6e3bc348fa7a0025
4
- data.tar.gz: 775fc632420c285f59e0f44e7ccb09d3b6b9e63d
3
+ metadata.gz: 8c6d1a02fa3eea0fe1ec630d8d8d1679ead410eb
4
+ data.tar.gz: e8ed8700b2578035252dfcfeda21a02090df0f8d
5
5
  SHA512:
6
- metadata.gz: c3a210c5d90332b96b23a36ce135254c382929332fb7cc0a84b0097aadcd5504d55b56cbd37d28c829cd13c8670da35c5d497635495e2c708afa4ad8b52de322
7
- data.tar.gz: 7c31ff0b9f69466d788a68db525c13fe208ef59c06e16b13f06abe5de32d5484a3e0d94fbe8534d09932e759a8f4d0d77b035b6e78206cd827ff1c32a0a8ec34
6
+ metadata.gz: 61c70886ea5166a34bbe3dab9b98d62bcf0a3170d69583c07de17d9174ab69c08c079256607b07fa8c513309d2320093edac02a23480695ad615aa36c49acba7
7
+ data.tar.gz: 6db28cdf46a920d24c9270dbb136befb5bbbc5663eaccef145f1dafed24d900c53643269a4f764499e83fac217208e63526c27717024afe05110b780c6d25d5f
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.1
4
+ * Fixes problem on `searchable_columns` where the corresponding model is
5
+ a composite model name, e.g. `UserData`, `BillingAddress`.
6
+ Thanks to [iruca3](https://github.com/iruca3) for the fix.
7
+
3
8
  ## 0.1.0
4
9
  * A fresh start. Sets base class name to: `AjaxDatatablesRails::Base`.
5
10
  * Extracts pagination functions to mixable modules.
@@ -92,7 +92,7 @@ module AjaxDatatablesRails
92
92
 
93
93
  def search_condition(column, value)
94
94
  model, column = column.split('.')
95
- model = model.singularize.titleize.constantize
95
+ model = model.singularize.titleize.gsub( / /, '' ).constantize
96
96
  model.arel_table[column.to_sym].matches("%#{value}%")
97
97
  end
98
98
 
@@ -125,4 +125,4 @@ module AjaxDatatablesRails
125
125
  options.include?(params[:sSortDir_0]) ? params[:sSortDir_0].upcase : 'ASC'
126
126
  end
127
127
  end
128
- end
128
+ end
@@ -1,3 +1,3 @@
1
1
  module AjaxDatatablesRails
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -13,6 +13,12 @@ describe AjaxDatatablesRails::Base do
13
13
  end
14
14
  end
15
15
 
16
+ class UserData
17
+ def self.arel_table
18
+ { :bar => Column.new }
19
+ end
20
+ end
21
+
16
22
  params = {
17
23
  :sEcho => '0', :sSortDir_0 => 'asc',
18
24
  :iSortCol_0 => '1', :iDisplayStart => '11'
@@ -137,6 +143,19 @@ describe AjaxDatatablesRails::Base do
137
143
  datatable.send(:filter_records, records)
138
144
  end
139
145
  end
146
+
147
+ describe '#filter_records with multi word model' do
148
+ let(:records) { double('UserData', :where => []) }
149
+ let(:search_view) { double('view', :params => { :sSearch => 'bar' }) }
150
+
151
+ it 'applies search like functionality on a collection' do
152
+ datatable = AjaxDatatablesRails::Base.new(search_view)
153
+ datatable.stub(:searchable_columns) { ['user_datas.bar'] }
154
+
155
+ records.should_receive(:where)
156
+ datatable.send(:filter_records, records)
157
+ end
158
+ end
140
159
  end
141
160
 
142
161
  describe 'hook methods' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ajax-datatables-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Quenneville
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties