mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-29 00:14:41 +08:00
Use the previous way of handling request params in rspec [SCI-2732]
This commit is contained in:
parent
d9281b66d5
commit
e5129160fe
1 changed files with 309 additions and 366 deletions
|
@ -45,11 +45,11 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#project_cards' do
|
describe '#project_cards' do
|
||||||
before(:all) { @params = {} }
|
let(:params) { {} }
|
||||||
|
|
||||||
context 'with no request parameters' do
|
context 'with request parameters { }' do
|
||||||
it 'returns all projects' do
|
it 'returns all projects' do
|
||||||
projects = projects_overview.project_cards(@params)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects).to include(project_1, project_2, project_3, project_4,
|
expect(projects).to include(project_1, project_2, project_3, project_4,
|
||||||
project_5)
|
project_5)
|
||||||
expect(projects).not_to include project_6
|
expect(projects).not_to include project_6
|
||||||
|
@ -58,12 +58,11 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context "with request parameters { filter: 'active' }" do
|
||||||
before(:all) { @params1 = @params.merge(filter: 'active') }
|
let(:params) { { filter: 'active' } }
|
||||||
|
|
||||||
context "with #{@params1} request parameters" do
|
|
||||||
it 'returns all active projects' do
|
it 'returns all active projects' do
|
||||||
projects = projects_overview.project_cards(@params1)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).to include(project_1, project_3)
|
expect(projects).to include(project_1, project_3)
|
||||||
|
@ -71,13 +70,12 @@ describe ProjectsOverviewService do
|
||||||
project_6)
|
project_6)
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'old' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'old') }
|
let(:params) { super().merge(sort: 'old') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all active projects, sorted by ascending creation ' \
|
it 'returns all active projects, sorted by ascending creation ' \
|
||||||
'time attribute' do
|
'time attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.first(2)).to eq [project_1, project_3]
|
expect(projects.first(2)).to eq [project_1, project_3]
|
||||||
|
@ -85,16 +83,14 @@ describe ProjectsOverviewService do
|
||||||
project_6)
|
project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'new' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'new') }
|
let(:params) { super().merge(sort: 'new') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all active projects, sorted by descending creation ' \
|
it 'returns all active projects, sorted by descending creation ' \
|
||||||
'time attribute' do
|
'time attribute' do
|
||||||
|
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(2)).to eq [project_3, project_1]
|
expect(projects.last(2)).to eq [project_3, project_1]
|
||||||
|
@ -102,15 +98,13 @@ describe ProjectsOverviewService do
|
||||||
project_6)
|
project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'atoz' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'atoz') }
|
let(:params) { super().merge(sort: 'atoz') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all active projects, sorted by ascending name ' \
|
it 'returns all active projects, sorted by ascending name ' \
|
||||||
'attribute' do
|
'attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.first(2)).to eq [project_3, project_1]
|
expect(projects.first(2)).to eq [project_3, project_1]
|
||||||
|
@ -118,15 +112,13 @@ describe ProjectsOverviewService do
|
||||||
project_6)
|
project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'ztoa' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'ztoa') }
|
let(:params) { super().merge(sort: 'ztoa') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all active projects, sorted by descending name ' \
|
it 'returns all active projects, sorted by descending name ' \
|
||||||
' attribute' do
|
' attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
expect(projects.length).to eq PROJECTS_CNT / 2 - 1
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(2)).to eq [project_1, project_3]
|
expect(projects.last(2)).to eq [project_1, project_3]
|
||||||
|
@ -135,73 +127,63 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { filter: 'archived' }" do
|
||||||
before(:all) { @params1 = @params.merge(filter: 'archived') }
|
let(:params) { super().merge(filter: 'archived') }
|
||||||
|
|
||||||
context "with #{@params1} request parameters" do
|
|
||||||
it 'returns all archived projects' do
|
it 'returns all archived projects' do
|
||||||
projects = projects_overview.project_cards(@params1)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2
|
expect(projects.length).to eq PROJECTS_CNT / 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).to include(project_2, project_4, project_5)
|
expect(projects).to include(project_2, project_4, project_5)
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'old' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'old') }
|
let(:params) { super().merge(sort: 'old') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all archived projects, sorted by ascending creation ' \
|
it 'returns all archived projects, sorted by ascending creation ' \
|
||||||
'time attribute' do
|
'time attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2
|
expect(projects.length).to eq PROJECTS_CNT / 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.first(3)).to eq [project_2, project_4, project_5]
|
expect(projects.first(3)).to eq [project_2, project_4, project_5]
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'new' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'new') }
|
let(:params) { super().merge(sort: 'new') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all archived projects, sorted by descending creation ' \
|
it 'returns all archived projects, sorted by descending creation ' \
|
||||||
'time attribute' do
|
'time attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2
|
expect(projects.length).to eq PROJECTS_CNT / 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(3)).to eq [project_5, project_4, project_2]
|
expect(projects.last(3)).to eq [project_5, project_4, project_2]
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'atoz' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'atoz') }
|
let(:params) { super().merge(sort: 'atoz') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all archived projects, sorted by ascending name ' \
|
it 'returns all archived projects, sorted by ascending name ' \
|
||||||
' attribute' do
|
' attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2
|
expect(projects.length).to eq PROJECTS_CNT / 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.first(3)).to eq [project_4, project_2, project_5]
|
expect(projects.first(3)).to eq [project_4, project_2, project_5]
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { sort: 'ztoa' }" do
|
||||||
before(:all) { @params2 = @params1.merge(sort: 'ztoa') }
|
let(:params) { super().merge(sort: 'ztoa') }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns all archived projects, sorted by descending name ' \
|
it 'returns all archived projects, sorted by descending name ' \
|
||||||
' attribute' do
|
' attribute' do
|
||||||
projects = projects_overview.project_cards(@params2)
|
projects = projects_overview.project_cards(params)
|
||||||
expect(projects.length).to eq PROJECTS_CNT / 2
|
expect(projects.length).to eq PROJECTS_CNT / 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(3)).to eq [project_5, project_2, project_4]
|
expect(projects.last(3)).to eq [project_5, project_2, project_4]
|
||||||
|
@ -210,18 +192,14 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe '#projects_datatable' do
|
describe '#projects_datatable' do
|
||||||
before(:all) { @params = {} }
|
let(:params) { {} }
|
||||||
|
|
||||||
context 'with no request parameters' do
|
context 'with request parameters { {} }' do
|
||||||
it 'returns projects, sorted by ascending archivation attribute (active' \
|
it 'returns projects, sorted by ascending archivation attribute (active' \
|
||||||
' first), offset by 0, paginated by 10' do
|
' first), offset by 0, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_2, project_4, project_5,
|
expect(projects).not_to include(project_2, project_4, project_5,
|
||||||
|
@ -231,13 +209,12 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context "with request parameters { filter: 'active' }" do
|
||||||
before(:all) { @params1 = @params.merge(filter: 'active') }
|
let(:params) { super().merge(filter: 'active') }
|
||||||
|
|
||||||
context "with #{@params1} request parameters" do
|
|
||||||
it 'returns active projects, sorted by ascending archivation ' \
|
it 'returns active projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 0, paginated by 10' do
|
'attribute (active first), offset by 0, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params1)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_2, project_4, project_5,
|
expect(projects).not_to include(project_2, project_4, project_5,
|
||||||
|
@ -246,13 +223,12 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context 'with request parameters { start: 15 }' do
|
||||||
before(:all) { @params2 = @params1.merge(start: 15) }
|
let(:params) { super().merge(start: 15) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns active projects, sorted by ascending archivation ' \
|
it 'returns active projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 15, paginated by 10' do
|
'attribute (active first), offset by 15, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 2
|
expect(projects.length).to eq 2
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_2, project_3,
|
expect(projects).not_to include(project_1, project_2, project_3,
|
||||||
|
@ -261,15 +237,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 2
|
expect(projects1.length).to eq 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context 'with request parameters { length: 5 }' do
|
||||||
before(:all) { @params2 = @params1.merge(length: 5) }
|
let(:params) { super().merge(length: 5) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns active projects, sorted by ascending archivation ' \
|
it 'returns active projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 0, paginated by 5' do
|
'attribute (active first), offset by 0, paginated by 5' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 5
|
expect(projects.length).to eq 5
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_2, project_4, project_5,
|
expect(projects).not_to include(project_2, project_4, project_5,
|
||||||
|
@ -278,17 +252,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 5
|
expect(projects1.length).to eq 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { order: { '0': { dir: 'ASC' } } }" do
|
||||||
before(:all) do
|
let(:params) { super().merge(order: { '0': { dir: 'ASC' } }) }
|
||||||
@params2 = @params1.merge(order: { '0': { dir: 'ASC' } })
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns active projects, sorted by ascending archivation ' \
|
it 'returns active projects, sorted by ascending archivation ' \
|
||||||
'attribute (archived first), offset by 0, paginated by 10' do
|
'attribute (archived first), offset by 0, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_2, project_4, project_5,
|
expect(projects).not_to include(project_2, project_4, project_5,
|
||||||
|
@ -297,18 +267,14 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { order: { '0': { dir: 'DESC' } } }" do
|
||||||
before(:all) do
|
let(:params) { super().merge(order: { '0': { dir: 'DESC' } }) }
|
||||||
@params2 = @params1.merge(order: { '0': { dir: 'DESC' } })
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns active projects, sorted by descending ' \
|
it 'returns active projects, sorted by descending ' \
|
||||||
'archivation attribute (archived first), offset by 0, ' \
|
'archivation attribute (archived first), offset by 0, ' \
|
||||||
'paginated by 10' do
|
'paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_2, project_4, project_5,
|
expect(projects).not_to include(project_2, project_4, project_5,
|
||||||
|
@ -317,15 +283,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context 'with request parameters { start: 13, length: 4 }' do
|
||||||
before(:all) { @params2 = @params1.merge(start: 13, length: 4) }
|
let(:params) { super().merge(start: 13, length: 4) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns active projects, sorted by ascending archivation ' \
|
it 'returns active projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 13, paginated by 4' do
|
'attribute (active first), offset by 13, paginated by 4' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 0
|
expect(projects.length).to eq 0
|
||||||
expect(projects).not_to include(project_1, project_2, project_3,
|
expect(projects).not_to include(project_1, project_2, project_3,
|
||||||
project_4, project_5, project_6)
|
project_4, project_5, project_6)
|
||||||
|
@ -333,36 +297,34 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 0
|
expect(projects1.length).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { start: 1, length: 2, " \
|
||||||
before(:all) do
|
"order: { '0': { dir: 'ASC', column: '2' } } }" do
|
||||||
@params2 = @params1.merge(start: 1, length: 2,
|
let(:params) do
|
||||||
|
super().merge(start: 1, length: 2,
|
||||||
order: { '0': { dir: 'ASC', column: '2' } })
|
order: { '0': { dir: 'ASC', column: '2' } })
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending name ' \
|
it 'returns archived projects, sorted by ascending name ' \
|
||||||
'attribute (hidden first), offset by 1, paginated by ' \
|
'attribute (hidden first), offset by 1, paginated by ' \
|
||||||
'2' do
|
'2' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 2
|
expect(projects.length).to eq 2
|
||||||
expect(projects).to eq [project_3, project_1]
|
expect(projects).to eq [project_3, project_1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { start: 3, length: 12, " \
|
||||||
before(:all) do
|
"order: { '0': { dir: 'DESC', column: '2' } } }" do
|
||||||
@params2 = @params1.merge(start: 3, length: 12,
|
let(:params) do
|
||||||
|
super().merge(start: 3, length: 12,
|
||||||
order: { '0': { dir: 'DESC', column: '2' } })
|
order: { '0': { dir: 'DESC', column: '2' } })
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by descending name ' \
|
it 'returns archived projects, sorted by descending name ' \
|
||||||
'attribute (visible first), offset by 3, paginated by ' \
|
'attribute (visible first), offset by 3, paginated by ' \
|
||||||
'12' do
|
'12' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 12
|
expect(projects.length).to eq 12
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(2)).to eq [project_1, project_3]
|
expect(projects.last(2)).to eq [project_1, project_3]
|
||||||
|
@ -374,16 +336,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects2.length).to eq 12
|
expect(projects2.length).to eq 12
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { filter: 'archived' }" do
|
||||||
before(:all) { @params1 = @params.merge(filter: 'archived') }
|
let(:params) { super().merge(filter: 'archived') }
|
||||||
|
|
||||||
context "with #{@params1} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending archivation ' \
|
it 'returns archived projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 0, paginated by 10' do
|
'attribute (active first), offset by 0, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params1)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
|
@ -391,13 +350,12 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
context do
|
context 'with request parameters { start: 15 }' do
|
||||||
before(:all) { @params2 = @params1.merge(start: 15) }
|
let(:params) { super().merge(start: 15) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending archivation ' \
|
it 'returns archived projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 15, paginated by 10' do
|
'attribute (active first), offset by 15, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 3
|
expect(projects.length).to eq 3
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_2, project_3,
|
expect(projects).not_to include(project_1, project_2, project_3,
|
||||||
|
@ -406,15 +364,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 3
|
expect(projects1.length).to eq 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context 'with request parameters { length: 5 }' do
|
||||||
before(:all) { @params2 = @params1.merge(length: 5) }
|
let(:params) { super().merge(length: 5) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending archivation ' \
|
it 'returns archived projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 0, paginated by 5' do
|
'attribute (active first), offset by 0, paginated by 5' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 5
|
expect(projects.length).to eq 5
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
|
@ -422,17 +378,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 5
|
expect(projects1.length).to eq 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { order: { '0': { dir: 'ASC' } } }" do
|
||||||
before(:all) do
|
let(:params) { super().merge(order: { '0': { dir: 'ASC' } }) }
|
||||||
@params2 = @params1.merge(order: { '0': { dir: 'ASC' } })
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending archivation ' \
|
it 'returns archived projects, sorted by ascending archivation ' \
|
||||||
'attribute (archived first), offset by 0, paginated by 10' do
|
'attribute (archived first), offset by 0, paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
|
@ -440,18 +392,14 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { order: { '0': { dir: 'DESC' } } }" do
|
||||||
before(:all) do
|
let(:params) { super().merge(order: { '0': { dir: 'DESC' } }) }
|
||||||
@params2 = @params1.merge(order: { '0': { dir: 'DESC' } })
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by descending ' \
|
it 'returns archived projects, sorted by descending ' \
|
||||||
'archivation attribute (archived first), offset by 0, ' \
|
'archivation attribute (archived first), offset by 0, ' \
|
||||||
'paginated by 10' do
|
'paginated by 10' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 10
|
expect(projects.length).to eq 10
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects).not_to include(project_1, project_3, project_6)
|
expect(projects).not_to include(project_1, project_3, project_6)
|
||||||
|
@ -459,15 +407,13 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 10
|
expect(projects1.length).to eq 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context 'with request parameters { start: 13, length: 4 }' do
|
||||||
before(:all) { @params2 = @params1.merge(start: 13, length: 4) }
|
let(:params) { super().merge(start: 13, length: 4) }
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by ascending archivation ' \
|
it 'returns archived projects, sorted by ascending archivation ' \
|
||||||
'attribute (active first), offset by 13, paginated by 4' do
|
'attribute (active first), offset by 13, paginated by 4' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 1
|
expect(projects.length).to eq 1
|
||||||
expect(projects).not_to include(project_1, project_2, project_3,
|
expect(projects).not_to include(project_1, project_2, project_3,
|
||||||
project_4, project_5, project_6)
|
project_4, project_5, project_6)
|
||||||
|
@ -475,19 +421,18 @@ describe ProjectsOverviewService do
|
||||||
expect(projects1.length).to eq 1
|
expect(projects1.length).to eq 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context do
|
context "with request parameters { start: 7, length: 6, " \
|
||||||
before(:all) do
|
"order: { '0': { dir: 'DESC', column: '3' } } }" do
|
||||||
@params2 = @params1.merge(start: 7, length: 6,
|
let(:params) do
|
||||||
|
super().merge(start: 7, length: 6,
|
||||||
order: { '0': { dir: 'DESC', column: '3' } })
|
order: { '0': { dir: 'DESC', column: '3' } })
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with #{@params2} request parameters" do
|
|
||||||
it 'returns archived projects, sorted by descending creation ' \
|
it 'returns archived projects, sorted by descending creation ' \
|
||||||
'time attribute (active first), offset by 7, paginated by ' \
|
'time attribute (active first), offset by 7, paginated by ' \
|
||||||
'6' do
|
'6' do
|
||||||
projects = projects_overview.projects_datatable(@params2)
|
projects = projects_overview.projects_datatable(params)
|
||||||
expect(projects.length).to eq 6
|
expect(projects.length).to eq 6
|
||||||
expect(projects.uniq.length).to eq projects.length
|
expect(projects.uniq.length).to eq projects.length
|
||||||
expect(projects.last(2)).to eq [project_5, project_4]
|
expect(projects.last(2)).to eq [project_5, project_4]
|
||||||
|
@ -499,6 +444,4 @@ describe ProjectsOverviewService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue