Skip to content

Commit 0d2f2bd

Browse files
authored
Merge pull request #14 from ideal-postcodes/check_key_fix
Fix for check_key in present of licensee
2 parents ced7662 + 5d3ef98 commit 0d2f2bd

9 files changed

Lines changed: 49 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [3.0.6] 2017-11-02
4+
- Fix: Sublicensee key now passed into key checking API calls if `check_key: true`
5+
36
## [3.0.5] 2017-11-02
47
- Added placeholder to input field. The placeholder is determined by the `placeholder_label` attribute
58
- Added `onDropdownDestroyed` destroyed callback, invoked when dropdown is removed from DOM following a new search

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.postcodes",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"authors": [
55
"support@ideal-postcodes.co.uk"
66
],

dist/postcodes.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Ideal Postcodes jQuery Plugin - v3.0.5 - 2017-11-16
1+
/*! Ideal Postcodes jQuery Plugin - v3.0.6 - 2017-11-17
22
* https://github.com/ideal-postcodes/jquery.postcodes
33
2017 Ideal Postcodes; Licensed MIT */
44
(function($) {
@@ -816,9 +816,11 @@
816816

817817
// Check if key is usable if necessary
818818
if (options.check_key) {
819-
$.idealPostcodes.checkKey({
820-
api_key: options.api_key
821-
}, initPlugin, failedKeyCheck);
819+
var keyOptions = { api_key: options.api_key };
820+
if (options.licensee) {
821+
keyOptions.licensee = options.licensee;
822+
}
823+
$.idealPostcodes.checkKey(keyOptions, initPlugin, failedKeyCheck);
822824
} else {
823825
initPlugin();
824826
}

dist/postcodes.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/fake/webservices.fake.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,11 @@ fake.registerWebservice('https://api.ideal-postcodes.co.uk/v1/keys/idklicensees'
15621562
return (data.licensee === "testlicensee") ? keyCheckPass : uncataloguedError;
15631563
});
15641564

1565+
// Mocked Licensees Requests
1566+
fake.registerWebservice('https://api.ideal-postcodes.co.uk/v1/keys/iddlicensees', function(data) {
1567+
return (data.licensee === "testlicensee") ? keyCheckPass : keyCheckFail;
1568+
});
1569+
15651570
fake.registerWebservice('https://api.ideal-postcodes.co.uk/v1/postcodes/id11li', function(data) {
15661571
return (data.licensee === "testlicensee") ? testPostcodeResult : uncataloguedError;
15671572
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-postcodes",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"engines": {
55
"node": ">= 0.8.0"
66
},

postcodes.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "postcodes",
33
"title": "Ideal Postcodes jQuery Plugin",
44
"description": "Add UK Address lookups using postcodes on any address form using Royal Mail's addressing database",
5-
"version": "3.0.5",
5+
"version": "3.0.6",
66
"homepage": "https://github.com/ideal-postcodes/jquery.postcodes",
77
"author": {
88
"name": "Ideal Postcodes",

src/jquery.postcodes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,11 @@
824824

825825
// Check if key is usable if necessary
826826
if (options.check_key) {
827-
$.idealPostcodes.checkKey({
828-
api_key: options.api_key
829-
}, initPlugin, failedKeyCheck);
827+
var keyOptions = { api_key: options.api_key };
828+
if (options.licensee) {
829+
keyOptions.licensee = options.licensee;
830+
}
831+
$.idealPostcodes.checkKey(keyOptions, initPlugin, failedKeyCheck);
830832
} else {
831833
initPlugin();
832834
}

test/test/plugin_basic.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,29 @@
185185
equal($lookup_button.length, 0, "there is no button");
186186
});
187187

188+
module("Sublicensee: Pre-initialisation check", {
189+
setup: function () {
190+
stop();
191+
var startTests = function () {
192+
$input_field = $("#"+defaults.input_id);
193+
$lookup_button = $("#"+defaults.button_id);
194+
start();
195+
};
196+
$("#postcode_lookup_field").setupPostcodeLookup({
197+
// Test key which will return false
198+
api_key: "iddlicensees",
199+
licensee: "testlicensee",
200+
check_key: true,
201+
disable_interval: 0,
202+
onFailedCheck: startTests,
203+
onLoaded: startTests
204+
});
205+
}
206+
});
207+
208+
test("has postcode lookup tools setup", 2, function () {
209+
equal($input_field.length, 1, "there is postcode input");
210+
equal($lookup_button.length, 1, "there is button");
211+
});
212+
188213
}(jQuery));

0 commit comments

Comments
 (0)