diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 7b84be54a3a..42a7e5a2c30 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -99,7 +99,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController protected def member_params - params.require(:project_member).permit(:user_id, :access_level) + params.require(:project_member).permit(:user_id, :access_level, :expires_at) end # MembershipActions concern diff --git a/app/views/shared/members/_member.html.haml b/app/views/shared/members/_member.html.haml index 74af31f3252..ae487f86e50 100644 --- a/app/views/shared/members/_member.html.haml +++ b/app/views/shared/members/_member.html.haml @@ -16,7 +16,7 @@ = button_tag icon('pencil'), type: 'button', class: 'btn inline js-toggle-button', - title: 'Edit access level' + title: 'Edit' - if member.request? = link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]), @@ -80,5 +80,7 @@ = form_for member, remote: true do |f| .prepend-top-10 = f.select :access_level, options_for_select(member.class.access_level_roles, member.access_level), {}, class: 'form-control' + .prepend-top-10 + = f.text_field :expires_at, class: 'form-control', placeholder: 'Access expiration date' .prepend-top-10 = f.submit 'Save', class: 'btn btn-save btn-sm' diff --git a/features/steps/group/members.rb b/features/steps/group/members.rb index dfa2fa75def..956a0026e1a 100644 --- a/features/steps/group/members.rb +++ b/features/steps/group/members.rb @@ -116,7 +116,7 @@ class Spinach::Features::GroupMembers < Spinach::FeatureSteps member = mary_jane_member page.within "#group_member_#{member.id}" do - click_button "Edit access level" + click_button 'Edit' select 'Developer', from: 'group_member_access_level' click_on 'Save' end diff --git a/features/steps/project/team_management.rb b/features/steps/project/team_management.rb index f32576d2cb1..334ce7dd3db 100644 --- a/features/steps/project/team_management.rb +++ b/features/steps/project/team_management.rb @@ -65,7 +65,7 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps user = User.find_by(name: 'Dmitriy') project_member = project.project_members.find_by(user_id: user.id) page.within "#project_member_#{project_member.id}" do - click_button "Edit access level" + click_button 'Edit' select "Reporter", from: "project_member_access_level" click_button "Save" end diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 242919ee113..8d706f015cf 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -10,18 +10,31 @@ feature 'Projects > Members > Master adds member with expiration date', feature: background do project.team << [master, :master] login_as(master) - visit namespace_project_project_members_path(project.namespace, project) end scenario 'expiration date is displayed in the members list' do - page.within ".users-project-form" do - select2(new_member.id, from: "#user_ids", multiple: true) - fill_in "Access expiration date", with: 4.days.from_now - click_on "Add users to project" + visit namespace_project_project_members_path(project.namespace, project) + + page.within '.users-project-form' do + select2(new_member.id, from: '#user_ids', multiple: true) + fill_in 'Access expiration date', with: 4.days.from_now + click_on 'Add users to project' end - page.within ".project_member:first-child" do - expect(page).to have_content("Expires in 4 days") + page.within '.project_member:first-child' do + expect(page).to have_content('Expires in 4 days') + end + end + + scenario 'change expiration date' do + project.team.add_users([new_member.id], :developer, expires_at: 1.month.from_now) + visit namespace_project_project_members_path(project.namespace, project) + + page.within '.project_member:first-child' do + click_on 'Edit' + fill_in 'Access expiration date', with: 2.days.from_now + click_on 'Save' + expect(page).to have_content('Expires in 2 days') end end end