|
84 | 84 | end |
85 | 85 |
|
86 | 86 | describe 'ORM API' do |
87 | | - describe '#filter_records' do |
88 | | - let(:records) { User.all } |
| 87 | + context 'when ORM is not implemented' do |
| 88 | + let(:datatable) { AjaxDatatablesRails::Base.new(sample_params) } |
89 | 89 |
|
90 | | - let(:datatable) do |
91 | | - datatable = Class.new(ComplexDatatable) do |
92 | | - def filter_records(records) |
93 | | - raise NotImplementedError |
94 | | - end |
| 90 | + describe '#fetch_records' do |
| 91 | + it 'raises an error if it does not include an ORM module' do |
| 92 | + expect { datatable.fetch_records }.to raise_error NotImplementedError |
95 | 93 | end |
96 | | - datatable.new(sample_params) |
97 | 94 | end |
98 | 95 |
|
99 | | - it 'should allow method override' do |
100 | | - expect { datatable.filter_records(records) }.to raise_error(NotImplementedError) |
| 96 | + describe '#filter_records' do |
| 97 | + it 'raises an error if it does not include an ORM module' do |
| 98 | + expect { datatable.filter_records([]) }.to raise_error NotImplementedError |
| 99 | + end |
101 | 100 | end |
102 | | - end |
103 | | - |
104 | | - describe '#sort_records' do |
105 | | - let(:records) { User.all } |
106 | 101 |
|
107 | | - let(:datatable) do |
108 | | - datatable = Class.new(ComplexDatatable) do |
109 | | - def sort_records(records) |
110 | | - raise NotImplementedError |
111 | | - end |
| 102 | + describe '#sort_records' do |
| 103 | + it 'raises an error if it does not include an ORM module' do |
| 104 | + expect { datatable.sort_records([]) }.to raise_error NotImplementedError |
112 | 105 | end |
113 | | - datatable.new(sample_params) |
114 | 106 | end |
115 | 107 |
|
116 | | - it 'should allow method override' do |
117 | | - expect { datatable.sort_records(records) }.to raise_error(NotImplementedError) |
| 108 | + describe '#paginate_records' do |
| 109 | + it 'raises an error if it does not include an ORM module' do |
| 110 | + expect { datatable.paginate_records([]) }.to raise_error NotImplementedError |
| 111 | + end |
118 | 112 | end |
119 | 113 | end |
120 | 114 |
|
121 | | - describe '#paginate_records' do |
122 | | - let(:records) { User.all } |
123 | | - |
124 | | - let(:datatable) do |
125 | | - datatable = Class.new(ComplexDatatable) do |
126 | | - def paginate_records(records) |
127 | | - raise NotImplementedError |
| 115 | + context 'when ORM is implemented' do |
| 116 | + describe 'it allows method override' do |
| 117 | + let(:datatable) do |
| 118 | + datatable = Class.new(ComplexDatatable) do |
| 119 | + def filter_records(records) |
| 120 | + raise NotImplementedError.new('FOO') |
| 121 | + end |
| 122 | + |
| 123 | + def sort_records(records) |
| 124 | + raise NotImplementedError.new('FOO') |
| 125 | + end |
| 126 | + |
| 127 | + def paginate_records(records) |
| 128 | + raise NotImplementedError.new('FOO') |
| 129 | + end |
128 | 130 | end |
| 131 | + datatable.new(sample_params) |
129 | 132 | end |
130 | | - datatable.new(sample_params) |
131 | | - end |
132 | 133 |
|
133 | | - it 'should allow method override' do |
134 | | - expect { datatable.paginate_records(records) }.to raise_error(NotImplementedError) |
| 134 | + describe '#filter_records' do |
| 135 | + it { |
| 136 | + expect { datatable.filter_records([]) }.to raise_error(NotImplementedError).with_message('FOO') |
| 137 | + } |
| 138 | + end |
| 139 | + |
| 140 | + describe '#sort_records' do |
| 141 | + it { |
| 142 | + expect { datatable.sort_records([]) }.to raise_error(NotImplementedError).with_message('FOO') |
| 143 | + } |
| 144 | + end |
| 145 | + |
| 146 | + describe '#paginate_records' do |
| 147 | + it { |
| 148 | + expect { datatable.paginate_records([]) }.to raise_error(NotImplementedError).with_message('FOO') |
| 149 | + } |
| 150 | + end |
135 | 151 | end |
136 | 152 | end |
137 | 153 | end |
@@ -164,36 +180,6 @@ def paginate_records(records) |
164 | 180 | end |
165 | 181 | end |
166 | 182 |
|
167 | | - context 'Private API' do |
168 | | - context 'when orm is not implemented' do |
169 | | - let(:datatable) { AjaxDatatablesRails::Base.new(sample_params) } |
170 | | - |
171 | | - describe '#fetch_records' do |
172 | | - it 'raises an error if it does not include an ORM module' do |
173 | | - expect { datatable.fetch_records }.to raise_error NoMethodError |
174 | | - end |
175 | | - end |
176 | | - |
177 | | - describe '#filter_records' do |
178 | | - it 'raises an error if it does not include an ORM module' do |
179 | | - expect { datatable.filter_records }.to raise_error NoMethodError |
180 | | - end |
181 | | - end |
182 | | - |
183 | | - describe '#sort_records' do |
184 | | - it 'raises an error if it does not include an ORM module' do |
185 | | - expect { datatable.sort_records }.to raise_error NoMethodError |
186 | | - end |
187 | | - end |
188 | | - |
189 | | - describe '#paginate_records' do |
190 | | - it 'raises an error if it does not include an ORM module' do |
191 | | - expect { datatable.paginate_records }.to raise_error NoMethodError |
192 | | - end |
193 | | - end |
194 | | - end |
195 | | - end |
196 | | - |
197 | 183 | describe 'User helper methods' do |
198 | 184 | describe '#column_id' do |
199 | 185 | let(:datatable) { ComplexDatatable.new(sample_params) } |
|
0 commit comments