Commit 0fb5ffd8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix-group-member' into 'master'

Fix 500 error when update group member permission
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Fixes #3578 

See merge request !1884
parents 6d5d45ad cbaa33db
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.3.0 (unreleased) v 8.3.0 (unreleased)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera) - Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Fix 500 error when update group member permission
v 8.2.1 v 8.2.1
- Forcefully update builds that didn't want to update with state machine - Forcefully update builds that didn't want to update with state machine
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- if should_user_see_group_roles?(current_user, @group) - if should_user_see_group_roles?(current_user, @group)
%span.pull-right %span.pull-right
%strong= member.human_access %strong.member-access-level= member.human_access
- if show_controls - if show_controls
- if can?(current_user, :update_group_member, member) - if can?(current_user, :update_group_member, member)
= button_tag class: "btn-xs btn js-toggle-button", = button_tag class: "btn-xs btn js-toggle-button",
......
:plain :plain
$("##{dom_id(@member)}").replaceWith('#{escape_javascript(render(@member, member: @member, show_controls: true))}'); $("##{dom_id(@group_member)}").replaceWith('#{escape_javascript(render(@group_member, member: @group_member, show_controls: true))}');
...@@ -74,6 +74,13 @@ Feature: Groups ...@@ -74,6 +74,13 @@ Feature: Groups
When I select "sjobs@apple.com" as "Reporter" When I select "sjobs@apple.com" as "Reporter"
Then I should see "sjobs@apple.com" in team list as invited "Reporter" Then I should see "sjobs@apple.com" in team list as invited "Reporter"
@javascript
Scenario: Edit group member permissions
Given "Mary Jane" is guest of group "Owned"
And I visit group "Owned" members page
When I change the "Mary Jane" role to "Developer"
Then I should see "Mary Jane" as "Developer"
# Leave # Leave
@javascript @javascript
......
...@@ -26,7 +26,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -26,7 +26,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end end
step 'Group "Owned" has a public project "Public-project"' do step 'Group "Owned" has a public project "Public-project"' do
group = Group.find_by(name: "Owned") group = owned_group
@project = create :empty_project, :public, @project = create :empty_project, :public,
group: group, group: group,
...@@ -91,7 +91,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -91,7 +91,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end end
step 'I should see group "Owned" projects list' do step 'I should see group "Owned" projects list' do
Group.find_by(name: "Owned").projects.each do |project| owned_group.projects.each do |project|
expect(page).to have_link project.name expect(page).to have_link project.name
end end
end end
...@@ -172,12 +172,12 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -172,12 +172,12 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I change group "Owned" avatar' do step 'I change group "Owned" avatar' do
attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')) attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
click_button "Save group" click_button "Save group"
Group.find_by(name: "Owned").reload owned_group.reload
end end
step 'I should see new group "Owned" avatar' do step 'I should see new group "Owned" avatar' do
expect(Group.find_by(name: "Owned").avatar).to be_instance_of AvatarUploader expect(owned_group.avatar).to be_instance_of AvatarUploader
expect(Group.find_by(name: "Owned").avatar.url).to eq "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/banana_sample.gif" expect(owned_group.avatar.url).to eq "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/banana_sample.gif"
end end
step 'I should see the "Remove avatar" button' do step 'I should see the "Remove avatar" button' do
...@@ -187,16 +187,16 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -187,16 +187,16 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I have group "Owned" avatar' do step 'I have group "Owned" avatar' do
attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')) attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
click_button "Save group" click_button "Save group"
Group.find_by(name: "Owned").reload owned_group.reload
end end
step 'I remove group "Owned" avatar' do step 'I remove group "Owned" avatar' do
click_link "Remove avatar" click_link "Remove avatar"
Group.find_by(name: "Owned").reload owned_group.reload
end end
step 'I should not see group "Owned" avatar' do step 'I should not see group "Owned" avatar' do
expect(Group.find_by(name: "Owned").avatar?).to eq false expect(owned_group.avatar?).to eq false
end end
step 'I should not see the "Remove avatar" button' do step 'I should not see the "Remove avatar" button' do
...@@ -295,18 +295,49 @@ class Spinach::Features::Groups < Spinach::FeatureSteps ...@@ -295,18 +295,49 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end end
end end
step 'I change the "Mary Jane" role to "Developer"' do
member = mary_jane_member
page.within "#group_member_#{member.id}" do
find(".js-toggle-button").click
page.within "#edit_group_member_#{member.id}" do
select 'Developer', from: 'group_member_access_level'
click_on 'Save'
end
end
end
step 'I should see "Mary Jane" as "Developer"' do
member = mary_jane_member
page.within "#group_member_#{member.id}" do
page.within '.member-access-level' do
expect(page).to have_content "Developer"
end
end
end
protected protected
def owned_group
@owned_group ||= Group.find_by(name: "Owned")
end
def mary_jane_member
user = User.find_by(name: "Mary Jane")
owned_group.members.find_by(user_id: user.id)
end
def assigned_to_me(key) def assigned_to_me(key)
project.send(key).where(assignee_id: current_user.id) project.send(key).where(assignee_id: current_user.id)
end end
def project def project
Group.find_by(name: "Owned").projects.first owned_group.projects.first
end end
def group_milestone def group_milestone
group = Group.find_by(name: "Owned") group = owned_group
@project1 = create :project, @project1 = create :project,
group: group group: group
......
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