]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5851 fix when load next page of filtered changelog
authorStas Vilchik <vilchiks@gmail.com>
Tue, 14 Apr 2015 13:45:17 +0000 (15:45 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 14 Apr 2015 13:45:17 +0000 (15:45 +0200)
server/sonar-web/src/main/js/quality-profiles/profile-changelog-view.js
server/sonar-web/src/main/js/quality-profiles/profile.js
server/sonar-web/src/test/js/quality-profiles.js

index 8c6ffae929d3a9ba41151b0113c8fb984aafb598..a07618999bd1d6a2198b3b662df2e383487b1fcc 100644 (file)
@@ -29,19 +29,14 @@ define([
       'click .js-show-more-changelog': 'onShowMoreChangelogClick'
     },
 
-    initialize: function () {
-      this.searchParameters = {};
-    },
-
     onFormSubmit: function (e) {
       e.preventDefault();
-      this.searchParameters = this.getSearchParameters();
-      this.model.fetchChangelog(this.searchParameters);
+      this.model.fetchChangelog(this.getSearchParameters());
     },
 
     onShowMoreChangelogClick: function (e) {
       e.preventDefault();
-      this.model.fetchMoreChangelog(this.searchParameters);
+      this.model.fetchMoreChangelog();
     },
 
     getSearchParameters: function () {
index 7d1c63e2c35bdeca338a7deb0523f94a14a3b668..d6b0450caf912136b2772be659b43f728fa3bbd2 100644 (file)
@@ -88,18 +88,18 @@ define(function () {
       });
     },
 
-    fetchMoreChangelog: function (options) {
+    fetchMoreChangelog: function () {
       var that = this,
           url = baseUrl + '/api/qualityprofiles/changelog',
           page = this.get('eventsPage') || 0,
-          opts = _.extend({}, options, { profileKey: this.id, p: page + 1 });
+          parameters = this.get('eventsParameters') || {},
+          opts = _.extend({}, parameters, { profileKey: this.id, p: page + 1 });
       return $.get(url, opts).done(function (r) {
         var events = that.get('events') || [];
         that.set({
           events: [].concat(events, r.events),
           eventsPage: r.p,
-          totalEvents: r.total,
-          eventsParameters: _.clone(options)
+          totalEvents: r.total
         });
       });
     }
index c330bc6de8000ec91e28a35a2e2d6cbb6f3702c3..7a248a27ac97e9fb06ef93b7037dce34034dee2e 100644 (file)
@@ -551,7 +551,8 @@ casper.test.begin(testName('Change Parent'), 1, function (test) {
 
         this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-change-parent.json');
         lib.mockRequestFromFile('/api/rules/search', 'rules.json');
-        this.inheritanceMock = lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance-change-parent.json');
+        this.inheritanceMock = lib.mockRequestFromFile('/api/qualityprofiles/inheritance',
+            'inheritance-change-parent.json');
         lib.mockRequest('/api/qualityprofiles/change_parent', '{}');
       })
 
@@ -717,39 +718,55 @@ casper.test.begin(testName('Changelog'), 21, function (test) {
 });
 
 
-casper.test.begin(testName('Changelog Permalink'), 1, function (test) {
-    casper
-        .start(lib.buildUrl('profiles#changelog?since=2015-03-25&key=java-sonar-way-67887&to=2015-03-26'), function () {
-            lib.setDefaultViewport();
-
-            lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
-            lib.mockRequestFromFile('/api/rules/search', 'rules.json');
-            lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
-            lib.mockRequestFromFile('/api/qualityprofiles/changelog', 'changelog.json', { data: {
-                since: '2015-03-25',
-                to: '2015-03-26'
-            }});
-        })
-
-        .then(function () {
-            casper.evaluate(function () {
-                require(['/js/quality-profiles/app.js']);
-            });
-        })
-
-        .then(function () {
-            casper.waitForSelector('.js-show-more-changelog');
-        })
-
-        .then(function () {
-            test.assertElementCount('#quality-profile-changelog tbody tr', 2);
-        })
-
-        .then(function () {
-            lib.sendCoverage();
-        })
-
-        .run(function () {
-            test.done();
+casper.test.begin(testName('Changelog Permalink'), 2, function (test) {
+  casper
+      .start(lib.buildUrl('profiles#changelog?since=2015-03-25&key=java-sonar-way-67887&to=2015-03-26'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+        lib.mockRequestFromFile('/api/rules/search', 'rules.json');
+        lib.mockRequestFromFile('/api/qualityprofiles/inheritance', 'inheritance.json');
+        lib.mockRequestFromFile('/api/qualityprofiles/changelog', 'changelog2.json', {
+          data: {
+            p: '2',
+            since: '2015-03-25',
+            to: '2015-03-26'
+          }
+        });
+        lib.mockRequestFromFile('/api/qualityprofiles/changelog', 'changelog.json', {
+          data: {
+            since: '2015-03-25',
+            to: '2015-03-26'
+          }
+        });
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/quality-profiles/app.js']);
         });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.js-show-more-changelog');
+      })
+
+      .then(function () {
+        test.assertElementCount('#quality-profile-changelog tbody tr', 2);
+
+        casper.click('.js-show-more-changelog');
+        lib.waitForElementCount('#quality-profile-changelog tbody tr', 3);
+      })
+
+      .then(function () {
+        test.assertDoesntExist('.js-show-more-changelog');
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
 });