Skip to content

Commit

Permalink
Merge pull request #723 from alphagov/temporary-survey
Browse files Browse the repository at this point in the history
Run survey between 2016/02/01 and 2016/05/01
  • Loading branch information
boffbowsh committed Jan 29, 2016
2 parents e6425e4 + 21b161f commit 1a5a59d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/user-satisfaction-survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
setSurveyUrl: function(href) {
var $surveyLink = $('#take-survey');
var surveyUrl = $('#user-satisfaction-survey-container').data('survey-url');
var surveyStarts = new Date("January 26, 2016").getTime();
var surveyEnds = new Date("January 27, 2016 23:59:59").getTime();
var surveyStarts = new Date("February 1, 2016").getTime();
var surveyEnds = new Date("May 1, 2016 23:59:59").getTime();

if (userSatisfaction.currentDate() >= surveyStarts &&
userSatisfaction.currentDate() <= surveyEnds) {
Expand All @@ -81,7 +81,7 @@

$surveyLink.attr('href', surveyUrl);
},
currentDate: function() { new Date().getTime(); }
currentDate: function() { return new Date().getTime(); }
};

root.GOVUK.userSatisfaction = userSatisfaction;
Expand Down
12 changes: 8 additions & 4 deletions spec/javascripts/user-satisfaction-survey-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ describe("User Satisfaction Survey", function () {
expect($('#user-satisfaction-survey').attr('aria-hidden')).toBe('false');
});

it("uses the temporary survey URL on 26/01/2016", function() {
spyOn(survey, 'currentDate').and.returnValue(new Date("January 26, 2016").getTime());
it("actually returns a value from `currentDate`", function() {
expect(survey.currentDate()).not.toBe(undefined);
});

it("uses the temporary survey URL on 01/02/2016", function() {
spyOn(survey, 'currentDate').and.returnValue(new Date("February 1, 2016").getTime());
survey.showSurveyBar();
expect($('#take-survey').attr('href')).toMatch("https://www.surveymonkey.co.uk/r/2MRDLTW?");
});

it("uses the temporary survey URL on 27/01/2016", function() {
spyOn(survey, 'currentDate').and.returnValue(new Date("January 27, 2016 12:15:30").getTime());
it("uses the temporary survey URL on 01/05/2016", function() {
spyOn(survey, 'currentDate').and.returnValue(new Date("May 1, 2016 12:15:30").getTime());
survey.showSurveyBar();
expect($('#take-survey').attr('href')).toMatch("https://www.surveymonkey.co.uk/r/2MRDLTW?");
});
Expand Down

0 comments on commit 1a5a59d

Please sign in to comment.