openstax_utilities 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/openstax/utilities/status_controller.rb +66 -0
- data/app/views/layouts/openstax/utilities/status.html.erb +26 -0
- data/app/views/openstax/utilities/status/index.html.erb +45 -0
- data/config/routes.rb +3 -0
- data/lib/openstax/utilities/assets/manifest.rb +4 -0
- data/lib/openstax/utilities/engine.rb +3 -2
- data/lib/openstax/utilities/version.rb +1 -1
- metadata +21 -113
- data/spec/cassettes/OpenStax_Utilities_Assets/loading_remote_manifest/uses_remote_json.yml +0 -353
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/access_policies/dummier_access_policy.rb +0 -10
- data/spec/dummy/app/access_policies/dummy_access_policy.rb +0 -10
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/user.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -18
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -78
- data/spec/dummy/config/environments/test.rb +0 -39
- data/spec/dummy/config/initializers/access_policies.rb +0 -1
- data/spec/dummy/config/initializers/assets.rb +0 -8
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/search_users.rb +0 -26
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -2
- data/spec/dummy/config/secrets.yml +0 -19
- data/spec/dummy/db/migrate/0_create_users.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -29
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +0 -32144
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/C09/760/6da7b2a29da9cb0f80ef102c7effb91fab3374db +0 -0
- data/spec/factories/user.rb +0 -8
- data/spec/lib/openstax/utilities/access_policy_spec.rb +0 -68
- data/spec/lib/openstax/utilities/assets_spec.rb +0 -40
- data/spec/rails_helper.rb +0 -53
- data/spec/routines/openstax/utilities/limit_and_paginate_relation_spec.rb +0 -72
- data/spec/routines/openstax/utilities/order_relation_spec.rb +0 -55
- data/spec/routines/openstax/utilities/search_and_organize_relation_spec.rb +0 -139
- data/spec/routines/openstax/utilities/search_relation_spec.rb +0 -81
- data/spec/spec_helper.rb +0 -85
- data/spec/vcr_helper.rb +0 -18
data/spec/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
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
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
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
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
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>
|
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>
|
data/spec/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
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
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
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
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
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>
|
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>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
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
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
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
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
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>
|
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
|
Binary file
|
data/spec/factories/user.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module OpenStax
|
4
|
-
module Utilities
|
5
|
-
|
6
|
-
describe AccessPolicy do
|
7
|
-
|
8
|
-
let!(:user) { FactoryBot.create :user }
|
9
|
-
|
10
|
-
it 'responds to any _allowed? calls' do
|
11
|
-
AccessPolicy.register(User, DummyAccessPolicy)
|
12
|
-
|
13
|
-
DummyAccessPolicy.last_action = nil
|
14
|
-
DummyAccessPolicy.last_requestor = nil
|
15
|
-
DummyAccessPolicy.last_resource = nil
|
16
|
-
|
17
|
-
expect(AccessPolicy.respond_to? :wacky_allowed?).to eq(true)
|
18
|
-
expect(AccessPolicy.wacky_allowed?(user, user)).to eq(true)
|
19
|
-
|
20
|
-
expect(DummyAccessPolicy.last_action).to eq(:wacky)
|
21
|
-
expect(DummyAccessPolicy.last_requestor).to eq(user)
|
22
|
-
expect(DummyAccessPolicy.last_resource).to eq(user)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'delegates checks to policy classes based on resource class' do
|
26
|
-
dummy_object = double('Dummy')
|
27
|
-
|
28
|
-
AccessPolicy.register(User, DummyAccessPolicy)
|
29
|
-
AccessPolicy.register(dummy_object.class, DummierAccessPolicy)
|
30
|
-
|
31
|
-
DummyAccessPolicy.last_action = nil
|
32
|
-
DummyAccessPolicy.last_requestor = nil
|
33
|
-
DummyAccessPolicy.last_resource = nil
|
34
|
-
|
35
|
-
DummierAccessPolicy.last_action = nil
|
36
|
-
DummierAccessPolicy.last_requestor = nil
|
37
|
-
DummierAccessPolicy.last_resource = nil
|
38
|
-
|
39
|
-
expect(AccessPolicy.action_allowed?(:read, user, dummy_object)).to eq true
|
40
|
-
expect{
|
41
|
-
AccessPolicy.require_action_allowed!(:read, user, dummy_object)
|
42
|
-
}.not_to raise_error
|
43
|
-
|
44
|
-
expect(DummierAccessPolicy.last_action).to eq(:read)
|
45
|
-
expect(DummierAccessPolicy.last_requestor).to eq(user)
|
46
|
-
expect(DummierAccessPolicy.last_resource).to eq(dummy_object)
|
47
|
-
|
48
|
-
expect(AccessPolicy.action_allowed?(:create, user, User.new)).to eq true
|
49
|
-
expect{
|
50
|
-
AccessPolicy.require_action_allowed!(:create, user, User.new)
|
51
|
-
}.not_to raise_error
|
52
|
-
|
53
|
-
expect(DummyAccessPolicy.last_action).to eq(:create)
|
54
|
-
expect(DummyAccessPolicy.last_requestor).to eq(user)
|
55
|
-
expect(DummyAccessPolicy.last_resource).to be_instance_of(User)
|
56
|
-
expect(DummyAccessPolicy.last_resource.id).to be_nil
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'denies permission if the policy class is not registered' do
|
60
|
-
expect(OSU::AccessPolicy.action_allowed?(:destroy, user, Object)).to eq(false)
|
61
|
-
|
62
|
-
expect{OSU::AccessPolicy.require_action_allowed!(:destroy, user, Object)}.to raise_error(SecurityTransgression)
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
require 'vcr_helper'
|
3
|
-
|
4
|
-
RSpec.describe OpenStax::Utilities::Assets, vcr: VCR_OPTS do
|
5
|
-
before { RequestStore.store[:assets_manifest] = nil }
|
6
|
-
|
7
|
-
it 'defaults to name.js when manifest is missing' do
|
8
|
-
expect_any_instance_of(Faraday::Connection).to receive(:get).and_return(
|
9
|
-
OpenStruct.new success?: false
|
10
|
-
)
|
11
|
-
expect(described_class.tags_for(:foo)).to include "src='http://localhost:8000/dist/foo.js'"
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'reads asset url from manifest' do
|
15
|
-
expect_any_instance_of(Faraday::Connection).to receive(:get).and_return(
|
16
|
-
OpenStruct.new(
|
17
|
-
success?: true,
|
18
|
-
body: { entrypoints: { foo: { js: [ 'foo-732c56c32ff399b62.min.bar' ] } } }.to_json
|
19
|
-
)
|
20
|
-
)
|
21
|
-
expect(described_class.tags_for(:foo)).to include(
|
22
|
-
"src='http://localhost:8000/dist/foo-732c56c32ff399b62.min.bar'"
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'loading remote manifest' do
|
27
|
-
before do
|
28
|
-
@previous_assets_url = Rails.application.secrets.assets_url
|
29
|
-
Rails.application.secrets.assets_url = 'https://tutor-dev.openstax.org/assets'
|
30
|
-
end
|
31
|
-
after { Rails.application.secrets.assets_url = @previous_assets_url }
|
32
|
-
|
33
|
-
it 'uses remote json' do
|
34
|
-
expect(described_class.manifest).to be_kind_of described_class::Manifest
|
35
|
-
expect(described_class.tags_for(:tutor)).to(
|
36
|
-
eq "<script type='text/javascript' src='https://tutor-dev.openstax.org/assets/tutor-b920eb0be760a7c440bf.min.js' crossorigin='anonymous' async></script>"
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] ||= 'test'
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require File.expand_path("../dummy/config/environment", __FILE__)
|
5
|
-
require 'rspec/rails'
|
6
|
-
require 'factory_bot_rails'
|
7
|
-
require 'faker'
|
8
|
-
|
9
|
-
# Add additional requires below this line. Rails is not loaded until this point!
|
10
|
-
|
11
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
12
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
13
|
-
# run as spec files by default. This means that files in spec/support that end
|
14
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
15
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
16
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
17
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
18
|
-
#
|
19
|
-
# The following line is provided for convenience purposes. It has the downside
|
20
|
-
# of increasing the boot-up time by auto-requiring all files in the support
|
21
|
-
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
22
|
-
# require only the support files necessary.
|
23
|
-
#
|
24
|
-
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
25
|
-
|
26
|
-
# Checks for pending migrations before tests are run.
|
27
|
-
# If you are not using ActiveRecord, you can remove this line.
|
28
|
-
ActiveRecord::Migration.maintain_test_schema!
|
29
|
-
|
30
|
-
RSpec.configure do |config|
|
31
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
32
|
-
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
33
|
-
|
34
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
35
|
-
# examples within a transaction, remove the following line or assign false
|
36
|
-
# instead of true.
|
37
|
-
# config.use_transactional_fixtures = true
|
38
|
-
|
39
|
-
# RSpec Rails can automatically mix in different behaviours to your tests
|
40
|
-
# based on their file location, for example enabling you to call `get` and
|
41
|
-
# `post` in specs under `spec/controllers`.
|
42
|
-
#
|
43
|
-
# You can disable this behaviour by removing the line below, and instead
|
44
|
-
# explicitly tag your specs with their type, e.g.:
|
45
|
-
#
|
46
|
-
# RSpec.describe UsersController, :type => :controller do
|
47
|
-
# # ...
|
48
|
-
# end
|
49
|
-
#
|
50
|
-
# The different available types are documented in the features, such as in
|
51
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
52
|
-
config.infer_spec_type_from_file_location!
|
53
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module OpenStax
|
4
|
-
module Utilities
|
5
|
-
describe SearchRelation do
|
6
|
-
|
7
|
-
let!(:john_doe) { FactoryBot.create :user, name: "John Doe",
|
8
|
-
username: "doejohn",
|
9
|
-
email: "john@doe.com" }
|
10
|
-
|
11
|
-
let!(:jane_doe) { FactoryBot.create :user, name: "Jane Doe",
|
12
|
-
username: "doejane",
|
13
|
-
email: "jane@doe.com" }
|
14
|
-
|
15
|
-
let!(:jack_doe) { FactoryBot.create :user, name: "Jack Doe",
|
16
|
-
username: "doejack",
|
17
|
-
email: "jack@doe.com" }
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
100.times do
|
21
|
-
FactoryBot.create(:user)
|
22
|
-
end
|
23
|
-
|
24
|
-
@relation = User.unscoped
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns nothing if too many results" do
|
28
|
-
routine = LimitAndPaginateRelation.call(relation: @relation,
|
29
|
-
max_items: 10)
|
30
|
-
outputs = routine.outputs
|
31
|
-
errors = routine.errors
|
32
|
-
expect(outputs).not_to be_empty
|
33
|
-
expect(outputs[:total_count]).to eq User.count
|
34
|
-
expect(outputs[:items]).to be_empty
|
35
|
-
expect(errors).not_to be_empty
|
36
|
-
expect(errors.first.code).to eq :too_many_items
|
37
|
-
end
|
38
|
-
|
39
|
-
it "paginates results" do
|
40
|
-
all_items = @relation.to_a
|
41
|
-
|
42
|
-
items = LimitAndPaginateRelation.call(relation: @relation,
|
43
|
-
per_page: 20).outputs[:items]
|
44
|
-
expect(items.limit(nil).offset(nil).count).to eq all_items.count
|
45
|
-
expect(items.limit(nil).offset(nil).to_a).to eq all_items
|
46
|
-
expect(items.count).to eq 20
|
47
|
-
expect(items.to_a).to eq all_items[0..19]
|
48
|
-
|
49
|
-
for page in 1..5
|
50
|
-
items = LimitAndPaginateRelation.call(relation: @relation,
|
51
|
-
page: page,
|
52
|
-
per_page: 20)
|
53
|
-
.outputs[:items]
|
54
|
-
expect(items.limit(nil).offset(nil).count).to eq all_items.count
|
55
|
-
expect(items.limit(nil).offset(nil).to_a).to eq all_items
|
56
|
-
expect(items.count).to eq 20
|
57
|
-
expect(items.to_a).to eq all_items.slice(20*(page-1), 20)
|
58
|
-
end
|
59
|
-
|
60
|
-
items = LimitAndPaginateRelation.call(relation: @relation,
|
61
|
-
page: 1000,
|
62
|
-
per_page: 20)
|
63
|
-
.outputs[:items]
|
64
|
-
expect(items.limit(nil).offset(nil).count).to eq all_items.count
|
65
|
-
expect(items.limit(nil).offset(nil).to_a).to eq all_items
|
66
|
-
expect(items.count).to eq 0
|
67
|
-
expect(items.to_a).to be_empty
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|