Commit 54ee0df7 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not use absolute URLS in entities use relative

parent 73a5f331
...@@ -4,21 +4,21 @@ class BuildEntity < Grape::Entity ...@@ -4,21 +4,21 @@ class BuildEntity < Grape::Entity
expose :id expose :id
expose :name expose :name
expose :build_url do |build| expose :build_path do |build|
url_to(:namespace_project_build, build) path_to(:namespace_project_build, build)
end end
expose :retry_url do |build| expose :retry_path do |build|
url_to(:retry_namespace_project_build, build) path_to(:retry_namespace_project_build, build)
end end
expose :play_url, if: ->(build, _) { build.manual? } do |build| expose :play_path, if: ->(build, _) { build.manual? } do |build|
url_to(:play_namespace_project_build, build) path_to(:play_namespace_project_build, build)
end end
private private
def url_to(route, build) def path_to(route, build)
send("#{route}_url", build.project.namespace, build.project, build) send("#{route}_path", build.project.namespace, build.project, build)
end end
end end
...@@ -3,8 +3,8 @@ class CommitEntity < API::Entities::RepoCommit ...@@ -3,8 +3,8 @@ class CommitEntity < API::Entities::RepoCommit
expose :author, using: UserEntity expose :author, using: UserEntity
expose :commit_url do |commit| expose :commit_path do |commit|
namespace_project_tree_url( namespace_project_tree_path(
request.project.namespace, request.project.namespace,
request.project, request.project,
id: commit.id) id: commit.id)
......
...@@ -10,8 +10,8 @@ class DeploymentEntity < Grape::Entity ...@@ -10,8 +10,8 @@ class DeploymentEntity < Grape::Entity
deployment.ref deployment.ref
end end
expose :ref_url do |deployment| expose :ref_path do |deployment|
namespace_project_tree_url( namespace_project_tree_path(
deployment.project.namespace, deployment.project.namespace,
deployment.project, deployment.project,
id: deployment.ref) id: deployment.ref)
......
...@@ -9,8 +9,8 @@ class EnvironmentEntity < Grape::Entity ...@@ -9,8 +9,8 @@ class EnvironmentEntity < Grape::Entity
expose :last_deployment, using: DeploymentEntity expose :last_deployment, using: DeploymentEntity
expose :stoppable? expose :stoppable?
expose :environment_url do |environment| expose :environment_path do |environment|
namespace_project_environment_url( namespace_project_environment_path(
environment.project.namespace, environment.project.namespace,
environment.project, environment.project,
environment) environment)
......
...@@ -10,9 +10,9 @@ describe BuildEntity do ...@@ -10,9 +10,9 @@ describe BuildEntity do
context 'when build is a regular job' do context 'when build is a regular job' do
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
it 'contains url to build page and retry action' do it 'contains paths to build page and retry action' do
expect(subject).to include(:build_url, :retry_url) expect(subject).to include(:build_path, :retry_path)
expect(subject).not_to include(:play_url) expect(subject).not_to include(:play_path)
end end
it 'does not contain sensitive information' do it 'does not contain sensitive information' do
...@@ -24,8 +24,8 @@ describe BuildEntity do ...@@ -24,8 +24,8 @@ describe BuildEntity do
context 'when build is a manual action' do context 'when build is a manual action' do
let(:build) { create(:ci_build, :manual) } let(:build) { create(:ci_build, :manual) }
it 'contains url to play action' do it 'contains path to play action' do
expect(subject).to include(:play_url) expect(subject).to include(:play_path)
end end
end end
end end
...@@ -31,8 +31,8 @@ describe CommitEntity do ...@@ -31,8 +31,8 @@ describe CommitEntity do
end end
end end
it 'contains commit URL' do it 'contains path to commit' do
expect(subject).to include(:commit_url) expect(subject).to include(:commit_path)
end end
it 'needs to receive project in the request' do it 'needs to receive project in the request' do
......
...@@ -15,6 +15,6 @@ describe DeploymentEntity do ...@@ -15,6 +15,6 @@ describe DeploymentEntity do
it 'exposes nested information about branch' do it 'exposes nested information about branch' do
expect(subject[:ref][:name]).to eq 'master' expect(subject[:ref][:name]).to eq 'master'
expect(subject[:ref][:ref_url]).not_to be_empty expect(subject[:ref][:ref_path]).not_to be_empty
end end
end end
...@@ -13,6 +13,6 @@ describe EnvironmentEntity do ...@@ -13,6 +13,6 @@ describe EnvironmentEntity do
end end
it 'exposes core elements of environment' do it 'exposes core elements of environment' do
expect(subject).to include(:id, :name, :state, :environment_url) expect(subject).to include(:id, :name, :state, :environment_path)
end end
end end
...@@ -33,7 +33,7 @@ describe EnvironmentSerializer do ...@@ -33,7 +33,7 @@ describe EnvironmentSerializer do
it 'contains important elements of environment' do it 'contains important elements of environment' do
expect(json) expect(json)
.to include(:name, :external_url, :environment_url, :last_deployment) .to include(:name, :external_url, :environment_path, :last_deployment)
end end
it 'contains relevant information about last deployment' do it 'contains relevant information about last deployment' do
......
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