smart_table 0.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +171 -0
- data/LICENSE.txt +21 -0
- data/README.md +132 -0
- data/app/assets/javascripts/smart_table.js +137 -0
- data/app/assets/stylesheets/smart_table.scss +85 -0
- data/app/controllers/concerns/smart_table/smart_table_concern.rb +58 -0
- data/app/helpers/smart_table/smart_table_helper.rb +211 -0
- data/app/views/kaminari/smart_table/_first_page.html.erb +12 -0
- data/app/views/kaminari/smart_table/_gap.html.erb +8 -0
- data/app/views/kaminari/smart_table/_last_page.html.erb +12 -0
- data/app/views/kaminari/smart_table/_next_page.html.erb +12 -0
- data/app/views/kaminari/smart_table/_page.html.erb +10 -0
- data/app/views/kaminari/smart_table/_paginator.html.erb +25 -0
- data/app/views/kaminari/smart_table/_prev_page.html.erb +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/locales/smart_table.en.yml +25 -0
- data/config/locales/smart_table.pt.yml +25 -0
- data/lib/generators/init_generator.rb +16 -0
- data/lib/generators/templates/smart_table_initializer.rb +6 -0
- data/lib/smart_table/config.rb +15 -0
- data/lib/smart_table/engine.rb +21 -0
- data/lib/smart_table/version.rb +3 -0
- data/lib/smart_table.rb +28 -0
- data/smart_table-0.0.1.gem +0 -0
- data/smart_table.gemspec +33 -0
- data/spec/dummy_app/Rakefile +6 -0
- data/spec/dummy_app/app/assets/config/manifest.js +3 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +15 -0
- data/spec/dummy_app/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +2 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/jobs/application_job.rb +2 -0
- data/spec/dummy_app/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy_app/app/models/application_record.rb +3 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy_app/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy_app/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy_app/bin/bundle +3 -0
- data/spec/dummy_app/bin/rails +4 -0
- data/spec/dummy_app/bin/rake +4 -0
- data/spec/dummy_app/bin/setup +36 -0
- data/spec/dummy_app/bin/update +31 -0
- data/spec/dummy_app/bin/yarn +11 -0
- data/spec/dummy_app/config/application.rb +17 -0
- data/spec/dummy_app/config/boot.rb +5 -0
- data/spec/dummy_app/config/cable.yml +10 -0
- data/spec/dummy_app/config/database.yml +25 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +61 -0
- data/spec/dummy_app/config/environments/production.rb +94 -0
- data/spec/dummy_app/config/environments/test.rb +46 -0
- data/spec/dummy_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy_app/config/initializers/assets.rb +14 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_app/config/initializers/inflections.rb +16 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_app/config/locales/en.yml +33 -0
- data/spec/dummy_app/config/puma.rb +34 -0
- data/spec/dummy_app/config/routes.rb +3 -0
- data/spec/dummy_app/config/spring.rb +6 -0
- data/spec/dummy_app/config/storage.yml +34 -0
- data/spec/dummy_app/config.ru +5 -0
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +0 -0
- data/spec/dummy_app/package.json +5 -0
- data/spec/dummy_app/public/404.html +67 -0
- data/spec/dummy_app/public/422.html +67 -0
- data/spec/dummy_app/public/500.html +66 -0
- data/spec/dummy_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy_app/public/apple-touch-icon.png +0 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +13 -0
- data/spec/smart_table/app/controllers/concerns/smart_table_concern_spec.rb +104 -0
- data/spec/smart_table/app/helpers/smart_table_helper_spec.rb +48 -0
- data/spec/smart_table/lib/config_spec.rb +18 -0
- data/spec/smart_table/lib/engine_spec.rb +12 -0
- data/spec/smart_table_spec.rb +26 -0
- data/spec/spec_helper.rb +20 -0
- metadata +263 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
.rails-default-error-page {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rails-default-error-page div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rails-default-error-page div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rails-default-error-page h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rails-default-error-page div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body class="rails-default-error-page">
|
|
58
|
+
<!-- This file lives in public/404.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
.rails-default-error-page {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rails-default-error-page div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rails-default-error-page div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rails-default-error-page h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rails-default-error-page div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body class="rails-default-error-page">
|
|
58
|
+
<!-- This file lives in public/422.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
.rails-default-error-page {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rails-default-error-page div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rails-default-error-page div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rails-default-error-page h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rails-default-error-page div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body class="rails-default-error-page">
|
|
58
|
+
<!-- This file lives in public/500.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
62
|
+
</div>
|
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This file must be included in tests of engine components (helpers, concerns).
|
|
2
|
+
# In other words, in tests inside the smart_table/app dir.
|
|
3
|
+
#
|
|
4
|
+
# Tests of the smart_table/lib dir should not require a rails engine and therefore
|
|
5
|
+
# should include spec_helper.rb only
|
|
6
|
+
|
|
7
|
+
require_relative 'spec_helper'
|
|
8
|
+
|
|
9
|
+
# Loads dummy_app, so we can test the Rails Engine components
|
|
10
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
11
|
+
require File.expand_path("../dummy_app/config/environment", __FILE__)
|
|
12
|
+
|
|
13
|
+
require 'rspec/rails'
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
require_relative '../../../../rails_helper.rb'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SmartTable::SmartTableConcern do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@params = HashWithIndifferentAccess.new
|
|
7
|
+
controller.instance_variable_set(:@params, @params)
|
|
8
|
+
controller.define_singleton_method(:params) do
|
|
9
|
+
@params
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# makes helper available through `controller`
|
|
14
|
+
let(:controller) do
|
|
15
|
+
klass = Class.new
|
|
16
|
+
klass.extend SmartTable::SmartTableConcern
|
|
17
|
+
klass
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#smart_table_params' do
|
|
21
|
+
it 'initializes parameters on first call' do
|
|
22
|
+
smart_table_params = controller.smart_table_params
|
|
23
|
+
expect(smart_table_params.sort).to be_nil
|
|
24
|
+
expect(smart_table_params.search).to be_nil
|
|
25
|
+
expect(smart_table_params.page_number).to be == 1
|
|
26
|
+
expect(smart_table_params.page_size).to be == 25
|
|
27
|
+
expect(smart_table_params.limit).to be == 25
|
|
28
|
+
expect(smart_table_params.offset).to be == 0
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'allows user to specify initial page size' do
|
|
32
|
+
smart_table_params = controller.smart_table_params(initial_page_size: 10)
|
|
33
|
+
expect(smart_table_params.sort).to be_nil
|
|
34
|
+
expect(smart_table_params.search).to be_nil
|
|
35
|
+
expect(smart_table_params.page_number).to be == 1
|
|
36
|
+
expect(smart_table_params.page_size).to be == 10
|
|
37
|
+
expect(smart_table_params.limit).to be == 10
|
|
38
|
+
expect(smart_table_params.offset).to be == 0
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'considers st_page parameter to choose the page_number' do
|
|
42
|
+
@params[:st_page] = '2'
|
|
43
|
+
|
|
44
|
+
smart_table_params = controller.smart_table_params(initial_page_size: 10)
|
|
45
|
+
expect(smart_table_params.sort).to be_nil
|
|
46
|
+
expect(smart_table_params.search).to be_nil
|
|
47
|
+
expect(smart_table_params.page_number).to be == 2
|
|
48
|
+
expect(smart_table_params.page_size).to be == 10
|
|
49
|
+
expect(smart_table_params.limit).to be == 10
|
|
50
|
+
expect(smart_table_params.offset).to be == 10
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'considers st_page_size parameter to choose the page_size' do
|
|
54
|
+
@params[:st_page] = '2'
|
|
55
|
+
@params[:st_page_size] = '5'
|
|
56
|
+
|
|
57
|
+
smart_table_params = controller.smart_table_params(initial_page_size: 10)
|
|
58
|
+
expect(smart_table_params.sort).to be_nil
|
|
59
|
+
expect(smart_table_params.search).to be_nil
|
|
60
|
+
expect(smart_table_params.page_number).to be == 2
|
|
61
|
+
expect(smart_table_params.page_size).to be == 5
|
|
62
|
+
expect(smart_table_params.limit).to be == 5
|
|
63
|
+
expect(smart_table_params.offset).to be == 5
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'allows st_page_size to be "show_all"' do
|
|
67
|
+
@params[:st_page] = '2'
|
|
68
|
+
@params[:st_page_size] = 'show_all'
|
|
69
|
+
|
|
70
|
+
smart_table_params = controller.smart_table_params(initial_page_size: 10)
|
|
71
|
+
expect(smart_table_params.sort).to be_nil
|
|
72
|
+
expect(smart_table_params.search).to be_nil
|
|
73
|
+
expect(smart_table_params.page_number).to be == 1
|
|
74
|
+
expect(smart_table_params.page_size).to be_nil
|
|
75
|
+
expect(smart_table_params.limit).to be_nil
|
|
76
|
+
expect(smart_table_params.offset).to be_nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'considers st_sort parameter to populate sort attribute' do
|
|
80
|
+
@params[:st_sort] = 'attribute DESC'
|
|
81
|
+
|
|
82
|
+
smart_table_params = controller.smart_table_params
|
|
83
|
+
expect(smart_table_params.sort).to be == 'attribute DESC'
|
|
84
|
+
expect(smart_table_params.search).to be_nil
|
|
85
|
+
expect(smart_table_params.page_number).to be == 1
|
|
86
|
+
expect(smart_table_params.page_size).to be == 25
|
|
87
|
+
expect(smart_table_params.limit).to be == 25
|
|
88
|
+
expect(smart_table_params.offset).to be == 0
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'considers st_search parameter to populate search attribute' do
|
|
92
|
+
@params[:st_search] = 'somestring'
|
|
93
|
+
|
|
94
|
+
smart_table_params = controller.smart_table_params
|
|
95
|
+
expect(smart_table_params.sort).to be_nil
|
|
96
|
+
expect(smart_table_params.search).to be == 'somestring'
|
|
97
|
+
expect(smart_table_params.page_number).to be == 1
|
|
98
|
+
expect(smart_table_params.page_size).to be == 25
|
|
99
|
+
expect(smart_table_params.limit).to be == 25
|
|
100
|
+
expect(smart_table_params.offset).to be == 0
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require_relative '../../../rails_helper.rb'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SmartTable::SmartTableHelper do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
# this helper requires access to the get_cached_smart_table_params method,
|
|
7
|
+
# which returns the current smart_table_params defined on the controller.
|
|
8
|
+
# We initialize a default @smart_table_params with page_size=3
|
|
9
|
+
@smart_table_params = SmartTable::SmartTableConcern::Params.new
|
|
10
|
+
@smart_table_params.sort = nil
|
|
11
|
+
@smart_table_params.page_size = 3
|
|
12
|
+
@smart_table_params.page_number = 1
|
|
13
|
+
@smart_table_params.search = nil
|
|
14
|
+
helper.instance_variable_set(:@smart_table_params, @smart_table_params)
|
|
15
|
+
helper.define_singleton_method(:get_cached_smart_table_params) do
|
|
16
|
+
@smart_table_params
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Kaminari, which is a dependency of smart_table, requires access to params
|
|
20
|
+
# inside its helpers. It reads the :st_page parameter to know what is the
|
|
21
|
+
# current page, or it assumes it is the first page if no :st_page is found
|
|
22
|
+
@params = HashWithIndifferentAccess.new
|
|
23
|
+
helper.instance_variable_set(:@params, @params)
|
|
24
|
+
helper.define_singleton_method(:params) do
|
|
25
|
+
@params
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@records = [1,2,3]
|
|
29
|
+
@total_records_count = 8
|
|
30
|
+
@record_model_name = 'User'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# makes helper available through `helper`
|
|
34
|
+
let(:helper) do
|
|
35
|
+
klass = Class.new
|
|
36
|
+
klass.extend SmartTable::SmartTableHelper
|
|
37
|
+
klass
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#smart_table_paginate' do
|
|
41
|
+
pending 'returns pagination commands' do
|
|
42
|
+
html = helper.smart_table_paginate(@records, @total_records_count, @record_model_name)
|
|
43
|
+
|
|
44
|
+
# I was not able to make the helper render kaminari pagination
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SmartTable::Config do
|
|
4
|
+
|
|
5
|
+
describe 'accessors and default values' do
|
|
6
|
+
it 'should have accessors for all configurations, initialized with default values' do
|
|
7
|
+
SmartTable::Config::DEFAULT_CONFIGS.each do |config_name, default_value|
|
|
8
|
+
# test writter
|
|
9
|
+
initial_value = described_class.send(config_name)
|
|
10
|
+
expect(described_class.send(config_name.to_s + '=', 1435))
|
|
11
|
+
expect(described_class.send(config_name)).to be == 1435
|
|
12
|
+
|
|
13
|
+
# restores initial value
|
|
14
|
+
expect(described_class.send(config_name.to_s + '=', initial_value))
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SmartTable::Engine do
|
|
4
|
+
|
|
5
|
+
describe 'initializers' do
|
|
6
|
+
it 'defines solvis_auth initializers' do
|
|
7
|
+
engine = SmartTable::Engine.send(:new)
|
|
8
|
+
expect(engine.initializers.last.name).to be == 'smart_table.action_controller'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative './spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SmartTable do
|
|
4
|
+
it "has a version number" do
|
|
5
|
+
expect(SmartTable::VERSION).not_to be nil
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'loads engine' do
|
|
9
|
+
expect(defined? SmartTable::Engine).to be_truthy
|
|
10
|
+
expect(SmartTable::Engine.superclass).to be == Rails::Engine
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'loads init generator' do
|
|
14
|
+
expect(defined? SmartTable::InitGenerator).to be_truthy
|
|
15
|
+
expect(SmartTable::InitGenerator.superclass).to be == Rails::Generators::Base
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '.setup' do
|
|
19
|
+
it 'receives a block and yields gem configuration' do
|
|
20
|
+
SmartTable.setup do |config|
|
|
21
|
+
expect(config).to be == SmartTable::Config
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "bundler/setup"
|
|
2
|
+
require "smart_table"
|
|
3
|
+
|
|
4
|
+
# test support gems
|
|
5
|
+
require 'byebug'
|
|
6
|
+
|
|
7
|
+
# test support
|
|
8
|
+
# require_relative 'support/some_file'
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
# Enable flags like --only-failures and --next-failure
|
|
12
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
|
13
|
+
|
|
14
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
15
|
+
config.disable_monkey_patching!
|
|
16
|
+
|
|
17
|
+
config.expect_with :rspec do |c|
|
|
18
|
+
c.syntax = :expect
|
|
19
|
+
end
|
|
20
|
+
end
|