Commit d38322b8 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Change `.map{...}.inject{...}` to `any?{...}` for searching shared runners

parent 957c4de9
...@@ -37,7 +37,7 @@ describe API::API, api: true do ...@@ -37,7 +37,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return user available runners' do it 'should return user available runners' do
get api('/runners', user) get api('/runners', user)
shared = json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr} shared = json_response.any?{ |r| r['is_shared'] }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -46,7 +46,7 @@ describe API::API, api: true do ...@@ -46,7 +46,7 @@ describe API::API, api: true do
it 'should filter runners by scope' do it 'should filter runners by scope' do
get api('/runners?scope=active', user) get api('/runners?scope=active', user)
shared = json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr} shared = json_response.any?{ |r| r['is_shared'] }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -73,7 +73,7 @@ describe API::API, api: true do ...@@ -73,7 +73,7 @@ describe API::API, api: true do
context 'with admin privileges' do context 'with admin privileges' do
it 'should return all runners' do it 'should return all runners' do
get api('/runners/all', admin) get api('/runners/all', admin)
shared = json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr} shared = json_response.any?{ |r| r['is_shared'] }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -91,7 +91,7 @@ describe API::API, api: true do ...@@ -91,7 +91,7 @@ describe API::API, api: true do
it 'should filter runners by scope' do it 'should filter runners by scope' do
get api('/runners/all?scope=specific', admin) get api('/runners/all?scope=specific', admin)
shared = json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr} shared = json_response.any?{ |r| r['is_shared'] }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -326,7 +326,7 @@ describe API::API, api: true do ...@@ -326,7 +326,7 @@ describe API::API, api: true do
context 'authorized user with master privileges' do context 'authorized user with master privileges' do
it "should return project's runners" do it "should return project's runners" do
get api("/projects/#{project.id}/runners", user) get api("/projects/#{project.id}/runners", user)
shared = json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr} shared = json_response.any?{ |r| r['is_shared'] }
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment