mongoid_data_table 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/mongoid/data_table/base.rb +1 -1
- data/lib/mongoid/data_table/version.rb +1 -1
- data/spec/mongoid_data_table_spec.rb +2 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
|
@@ -7,7 +7,7 @@ module Mongoid
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
module ClassMethods
|
|
10
|
-
def
|
|
10
|
+
def for_data_table controller, fields, search_fields=nil, &block
|
|
11
11
|
params = controller.params
|
|
12
12
|
search_fields ||= fields
|
|
13
13
|
objects = self.where(_where_conditions params[:sSearch], search_fields).
|
|
@@ -11,7 +11,7 @@ describe Mongoid::DataTable do
|
|
|
11
11
|
it "should extend ActionView::Helpers::JavaScriptHelper"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
context "#
|
|
14
|
+
context "#for_data_table" do
|
|
15
15
|
|
|
16
16
|
it "should produce JSON for the datatables plugin to consume" do
|
|
17
17
|
params = {:sSearch => "answer", :iSortCol_0 => "0", :sSortDir_0 => "desc", :iDisplayLength => 10, :sEcho => 1}
|
|
@@ -27,7 +27,7 @@ describe Mongoid::DataTable do
|
|
|
27
27
|
mock(self).where("where clause") { mock!.order_by("order by") { mock!.paginate({:page => "page", :per_page => 10}) { objects } } }
|
|
28
28
|
mock(self).count { 42 }
|
|
29
29
|
|
|
30
|
-
result =
|
|
30
|
+
result = for_data_table(controller, %w(foo bar baz), %w(foo bar)) {|x| [x] }
|
|
31
31
|
result.should == {:sEcho => 1, :iTotalRecords => 42, :iTotalDisplayRecords => 10, :aaData => %([["x"], ["x"]])}.to_json.html_safe
|
|
32
32
|
end
|
|
33
33
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid_data_table
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 31
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 0.1.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.1.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jason Dew
|