GitLab wurde erfolgreich aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Danke für Ihre Geduld.

Add tests for API project permissions info

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 0ea0e542
...@@ -181,7 +181,9 @@ class ProjectWithAccess < Project ...@@ -181,7 +181,9 @@ class ProjectWithAccess < Project
end end
expose :group_access, using: Entities::GroupAccess do |project, options| expose :group_access, using: Entities::GroupAccess do |project, options|
project.group.users_groups.find_by(user_id: options[:user].id) if project.group
project.group.users_groups.find_by(user_id: options[:user].id)
end
end end
end end
end end
......
...@@ -259,6 +259,7 @@ ...@@ -259,6 +259,7 @@
describe "GET /projects/:id" do describe "GET /projects/:id" do
before { project } before { project }
before { users_project }
it "should return a project by id" do it "should return a project by id" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
...@@ -284,6 +285,28 @@ ...@@ -284,6 +285,28 @@
get api("/projects/#{project.id}", other_user) get api("/projects/#{project.id}", other_user)
response.status.should == 404 response.status.should == 404
end end
describe 'permissions' do
context 'personal project' do
before { get api("/projects/#{project.id}", user) }
it { response.status.should == 200 }
it { json_response['permissions']["project_access"]["access_level"].should == Gitlab::Access::MASTER }
it { json_response['permissions']["group_access"].should be_nil }
end
context 'group project' do
before do
project2 = create(:project, group: create(:group))
project2.group.add_owner(user)
get api("/projects/#{project2.id}", user)
end
it { response.status.should == 200 }
it { json_response['permissions']["project_access"].should be_nil }
it { json_response['permissions']["group_access"]["access_level"].should == Gitlab::Access::OWNER }
end
end
end end
describe "GET /projects/:id/events" do describe "GET /projects/:id/events" 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