diff options
| author | Basil L. Contovounesios | 2019-07-22 21:57:39 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-08-02 16:33:30 +0300 |
| commit | eddf4664d786e16b34f6bd0af238a567feb5012c (patch) | |
| tree | c4da65620a382bbe612e7631d51a1044ce38c144 /test/lisp | |
| parent | b4b1eda7fbf4c4f3fa6377bd18d1d1a22e6e4b42 (diff) | |
| download | emacs-eddf4664d786e16b34f6bd0af238a567feb5012c.tar.gz emacs-eddf4664d786e16b34f6bd0af238a567feb5012c.zip | |
Make gravatar.el more configurable
For discussion, see the following thread:
https://lists.gnu.org/archive/html/emacs-devel/2019-07/msg00528.html
* etc/NEWS: Announce changes in gravatar.el user options.
* lisp/image/gravatar.el (gravatar-cache-ttl): Change :type to
number of seconds without changing the default value and while still
accepting other timestamp formats.
(gravatar-rating): Restrict :type to ratings recognized by Gravatar.
(gravatar-size): Allow nil as a value, in which case Gravatar's
default size is used.
(gravatar-default-image, gravatar-force-default): New user options
controlling the Gravatar query parameters 'default' and
'forcedefault', respectively.
(gravatar-base-url): Use HTTPS.
(gravatar--query-string): New helper function to facilitate testing.
(gravatar-build-url): Use it.
* test/lisp/image/gravatar-tests.el (gravatar-size)
(gravatar-default-image, gravatar-force-default)
(gravatar-build-url): New tests.
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/image/gravatar-tests.el | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lisp/image/gravatar-tests.el b/test/lisp/image/gravatar-tests.el index e6239da0084..bd61663f0e8 100644 --- a/test/lisp/image/gravatar-tests.el +++ b/test/lisp/image/gravatar-tests.el | |||
| @@ -31,4 +31,42 @@ | |||
| 31 | (should (equal (gravatar-hash " foo") hash)) | 31 | (should (equal (gravatar-hash " foo") hash)) |
| 32 | (should (equal (gravatar-hash " foo ") hash)))) | 32 | (should (equal (gravatar-hash " foo ") hash)))) |
| 33 | 33 | ||
| 34 | (ert-deftest gravatar-size () | ||
| 35 | "Test query strings for `gravatar-size'." | ||
| 36 | (let ((gravatar-default-image nil) | ||
| 37 | (gravatar-force-default nil)) | ||
| 38 | (let ((gravatar-size 2048)) | ||
| 39 | (should (equal (gravatar--query-string) "r=g&s=2048"))) | ||
| 40 | (let ((gravatar-size nil)) | ||
| 41 | (should (equal (gravatar--query-string) "r=g"))))) | ||
| 42 | |||
| 43 | (ert-deftest gravatar-default-image () | ||
| 44 | "Test query strings for `gravatar-default-image'." | ||
| 45 | (let ((gravatar-force-default nil) | ||
| 46 | (gravatar-size nil)) | ||
| 47 | (let ((gravatar-default-image nil)) | ||
| 48 | (should (equal (gravatar--query-string) "r=g"))) | ||
| 49 | (let ((gravatar-default-image "404")) | ||
| 50 | (should (equal (gravatar--query-string) "r=g&d=404"))) | ||
| 51 | (let ((gravatar-default-image "https://foo/bar.png")) | ||
| 52 | (should (equal (gravatar--query-string) | ||
| 53 | "r=g&d=https%3A%2F%2Ffoo%2Fbar.png"))))) | ||
| 54 | |||
| 55 | (ert-deftest gravatar-force-default () | ||
| 56 | "Test query strings for `gravatar-force-default'." | ||
| 57 | (let ((gravatar-default-image nil) | ||
| 58 | (gravatar-size nil)) | ||
| 59 | (let ((gravatar-force-default nil)) | ||
| 60 | (should (equal (gravatar--query-string) "r=g"))) | ||
| 61 | (let ((gravatar-force-default t)) | ||
| 62 | (should (equal (gravatar--query-string) "r=g&f=y"))))) | ||
| 63 | |||
| 64 | (ert-deftest gravatar-build-url () | ||
| 65 | "Test `gravatar-build-url'." | ||
| 66 | (let ((gravatar-default-image nil) | ||
| 67 | (gravatar-force-default nil) | ||
| 68 | (gravatar-size nil)) | ||
| 69 | (should (equal (gravatar-build-url "foo") "\ | ||
| 70 | https://www.gravatar.com/avatar/acbd18db4cc2f85cedef654fccc4a4d8?r=g")))) | ||
| 71 | |||
| 34 | ;;; gravatar-tests.el ends here | 72 | ;;; gravatar-tests.el ends here |