]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8992 Fix the number of groups for new members
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 13 Apr 2017 11:43:09 +0000 (13:43 +0200)
committerGrégoire Aubert <gregaubert@users.noreply.github.com>
Thu, 13 Apr 2017 15:45:34 +0000 (17:45 +0200)
it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java
server/sonar-web/src/main/js/api/organizations.js
server/sonar-web/src/main/js/apps/organizations/actions.js

index 0b05b0ef264e66ffedaaa7f2e0f8e289a50f8bc6..e2476ee8df1d90c2ee9fd132e0cbc4314f8fd382 100644 (file)
@@ -204,7 +204,7 @@ public class OrganizationMembershipTest {
       .addMember("foo")
       .shouldHaveTotal(2);
     page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator").shouldHaveGroups(2);
-    page.getMembersByIdx(1).shouldBeNamed("foo", "foo").shouldHaveGroups(0);
+    page.getMembersByIdx(1).shouldBeNamed("foo", "foo").shouldHaveGroups(1);
   }
 
   @Test
@@ -245,7 +245,6 @@ public class OrganizationMembershipTest {
   }
 
   @Test
-  @Ignore("To be fixed by SONAR-8992")
   public void groups_count_should_be_updated_when_a_member_was_just_added() {
     String orgKey = createOrganization();
     userRule.createUser("foo", "pwd");
index df7a1569d47f0565675859401b071c4d87a283be..25fb80bcaf87ae66491f976c8264dfc27e7282ce 100644 (file)
@@ -64,7 +64,7 @@ export const searchMembers = (
 ) => getJSON('/api/organizations/search_members', data);
 
 export const addMember = (data: { login: string, organization: string }) =>
-  post('/api/organizations/add_member', data);
+  postJSON('/api/organizations/add_member', data).then(r => r.user);
 
 export const removeMember = (data: { login: string, organization: string }) =>
   post('/api/organizations/remove_member', data);
index db5727bdd36244ccf83494675eef250bd5eee2b5..4765ec0d5aa4e83864a8b0496319a4ab619e9fd7 100644 (file)
@@ -149,11 +149,9 @@ export const fetchMoreOrganizationMembers = (key: string, query?: string) =>
 
 export const addOrganizationMember = (key: string, member: Member) =>
   (dispatch: Function) => {
-    dispatch(membersActions.addMember(key, member));
-    return api.addMember({ login: member.login, organization: key }).catch((error: Object) => {
-      onFail(dispatch)(error);
-      dispatch(membersActions.removeMember(key, member));
-    });
+    return api
+      .addMember({ login: member.login, organization: key })
+      .then(user => dispatch(membersActions.addMember(key, user)), onFail(dispatch));
   };
 
 export const removeOrganizationMember = (key: string, member: Member) =>