Commit 77c64a9b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Replace project_access attribute with access_level in specs and API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 38ed0dea
...@@ -58,7 +58,7 @@ module API ...@@ -58,7 +58,7 @@ module API
if team_member.nil? if team_member.nil?
team_member = user_project.project_members.new( team_member = user_project.project_members.new(
user_id: params[:user_id], user_id: params[:user_id],
project_access: params[:access_level] access_level: params[:access_level]
) )
end end
...@@ -85,7 +85,7 @@ module API ...@@ -85,7 +85,7 @@ module API
team_member = user_project.project_members.find_by(user_id: params[:user_id]) team_member = user_project.project_members.find_by(user_id: params[:user_id])
not_found!("User can not be found") if team_member.nil? not_found!("User can not be found") if team_member.nil?
if team_member.update_attributes(project_access: params[:access_level]) if team_member.update_attributes(access_level: params[:access_level])
@member = team_member.user @member = team_member.user
present @member, with: Entities::ProjectMember, project: user_project present @member, with: Entities::ProjectMember, project: user_project
else else
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Table name: group_members # Table name: group_members
# #
# id :integer not null, primary key # id :integer not null, primary key
# group_access :integer not null # access_level :integer not null
# group_id :integer not null # group_id :integer not null
# user_id :integer not null # user_id :integer not null
# created_at :datetime # created_at :datetime
...@@ -17,7 +17,7 @@ describe GroupMember do ...@@ -17,7 +17,7 @@ describe GroupMember do
context 'notification' do context 'notification' do
describe "#after_create" do describe "#after_create" do
it "should send email to user" do it "should send email to user" do
membership = build(:users_group) membership = build(:group_member)
membership.stub(notification_service: double('NotificationService').as_null_object) membership.stub(notification_service: double('NotificationService').as_null_object)
membership.should_receive(:notification_service) membership.should_receive(:notification_service)
membership.save membership.save
...@@ -26,18 +26,18 @@ describe GroupMember do ...@@ -26,18 +26,18 @@ describe GroupMember do
describe "#after_update" do describe "#after_update" do
before do before do
@membership = create :users_group @membership = create :group_member
@membership.stub(notification_service: double('NotificationService').as_null_object) @membership.stub(notification_service: double('NotificationService').as_null_object)
end end
it "should send email to user" do it "should send email to user" do
@membership.should_receive(:notification_service) @membership.should_receive(:notification_service)
@membership.update_attribute(:group_access, GroupMember::MASTER) @membership.update_attribute(:access_level, GroupMember::MASTER)
end end
it "does not send an email when the access level has not changed" do it "does not send an email when the access level has not changed" do
@membership.should_not_receive(:notification_service) @membership.should_not_receive(:notification_service)
@membership.update_attribute(:group_access, GroupMember::OWNER) @membership.update_attribute(:access_level, GroupMember::OWNER)
end end
end end
end end
......
...@@ -321,8 +321,8 @@ describe Note do ...@@ -321,8 +321,8 @@ describe Note do
describe :read do describe :read do
before do before do
@p1.project_members.create(user: @u2, project_access: ProjectMember::GUEST) @p1.project_members.create(user: @u2, access_level: ProjectMember::GUEST)
@p2.project_members.create(user: @u3, project_access: ProjectMember::GUEST) @p2.project_members.create(user: @u3, access_level: ProjectMember::GUEST)
end end
it { @abilities.allowed?(@u1, :read_note, @p1).should be_false } it { @abilities.allowed?(@u1, :read_note, @p1).should be_false }
...@@ -332,8 +332,8 @@ describe Note do ...@@ -332,8 +332,8 @@ describe Note do
describe :write do describe :write do
before do before do
@p1.project_members.create(user: @u2, project_access: ProjectMember::DEVELOPER) @p1.project_members.create(user: @u2, access_level: ProjectMember::DEVELOPER)
@p2.project_members.create(user: @u3, project_access: ProjectMember::DEVELOPER) @p2.project_members.create(user: @u3, access_level: ProjectMember::DEVELOPER)
end end
it { @abilities.allowed?(@u1, :write_note, @p1).should be_false } it { @abilities.allowed?(@u1, :write_note, @p1).should be_false }
...@@ -343,9 +343,9 @@ describe Note do ...@@ -343,9 +343,9 @@ describe Note do
describe :admin do describe :admin do
before do before do
@p1.project_members.create(user: @u1, project_access: ProjectMember::REPORTER) @p1.project_members.create(user: @u1, access_level: ProjectMember::REPORTER)
@p1.project_members.create(user: @u2, project_access: ProjectMember::MASTER) @p1.project_members.create(user: @u2, access_level: ProjectMember::MASTER)
@p2.project_members.create(user: @u3, project_access: ProjectMember::MASTER) @p2.project_members.create(user: @u3, access_level: ProjectMember::MASTER)
end end
it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false } it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false }
......
...@@ -30,7 +30,7 @@ describe Project do ...@@ -30,7 +30,7 @@ describe Project do
describe "Guest Rules" do describe "Guest Rules" do
before do before do
@p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::GUEST) @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::GUEST)
end end
it "should allow for project user any guest actions" do it "should allow for project user any guest actions" do
...@@ -42,7 +42,7 @@ describe Project do ...@@ -42,7 +42,7 @@ describe Project do
describe "Report Rules" do describe "Report Rules" do
before do before do
@p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::REPORTER) @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER)
end end
it "should allow for project user any report actions" do it "should allow for project user any report actions" do
...@@ -54,8 +54,8 @@ describe Project do ...@@ -54,8 +54,8 @@ describe Project do
describe "Developer Rules" do describe "Developer Rules" do
before do before do
@p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::REPORTER) @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER)
@p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::DEVELOPER) @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::DEVELOPER)
end end
it "should deny for developer master-specific actions" do it "should deny for developer master-specific actions" do
...@@ -73,8 +73,8 @@ describe Project do ...@@ -73,8 +73,8 @@ describe Project do
describe "Master Rules" do describe "Master Rules" do
before do before do
@p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::DEVELOPER) @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::DEVELOPER)
@p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::MASTER) @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
end end
it "should deny for developer master-specific actions" do it "should deny for developer master-specific actions" do
...@@ -92,8 +92,8 @@ describe Project do ...@@ -92,8 +92,8 @@ describe Project do
describe "Admin Rules" do describe "Admin Rules" do
before do before do
@p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::DEVELOPER) @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::DEVELOPER)
@p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::MASTER) @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
end end
it "should deny for masters admin-specific actions" do it "should deny for masters admin-specific actions" do
......
...@@ -7,8 +7,8 @@ describe API::API, api: true do ...@@ -7,8 +7,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) }
let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) }
let!(:branch_name) { 'feature' } let!(:branch_name) { 'feature' }
let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
......
...@@ -6,8 +6,8 @@ describe API::API, api: true do ...@@ -6,8 +6,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) }
let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) }
before { project.team << [user, :reporter] } before { project.team << [user, :reporter] }
......
...@@ -6,8 +6,8 @@ describe API::API, api: true do ...@@ -6,8 +6,8 @@ describe API::API, api: true do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let(:project_member) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } let(:project_member) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) }
let(:project_member2) { create(:project_member, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } let(:project_member2) { create(:project_member, user: user3, project: project, access_level: ProjectMember::DEVELOPER) }
describe "GET /projects/:id/members" do describe "GET /projects/:id/members" do
before { project_member } before { project_member }
......
...@@ -8,8 +8,8 @@ describe API::API, api: true do ...@@ -8,8 +8,8 @@ describe API::API, api: true do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') }
let(:project_member) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } let(:project_member) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) }
let(:project_member2) { create(:project_member, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } let(:project_member2) { create(:project_member, user: user3, project: project, access_level: ProjectMember::DEVELOPER) }
describe "GET /projects" do describe "GET /projects" do
before { project } before { project }
......
...@@ -8,8 +8,8 @@ describe API::API, api: true do ...@@ -8,8 +8,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) }
let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) }
before { project.team << [user, :reporter] } before { project.team << [user, :reporter] }
......
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