From 0feed2d35946dda9b0e2af57c382ec145124fabe Mon Sep 17 00:00:00 2001 From: deppbot Date: Sun, 24 Dec 2017 08:09:48 +0800 Subject: [PATCH 001/101] Bundle Update on 2017-12-24 --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b9a7ee954..31113ea38 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,8 +181,8 @@ GEM factory_bot_rails (4.8.2) factory_bot (~> 4.8.2) railties (>= 3.0.0) - faker (1.8.5) - i18n (~> 0.9.1) + faker (1.8.7) + i18n (>= 0.7) faraday (0.12.2) multipart-post (>= 1.2, < 3) ffi (1.9.18) @@ -238,7 +238,7 @@ GEM rake (>= 10, < 13) rubocop (>= 0.49.0) sysexits (~> 1.1) - hashie (3.5.6) + hashie (3.5.7) heroics (0.0.24) erubis (~> 2.0) excon @@ -276,7 +276,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) railties (>= 3.2.16) - js-routes (1.4.2) + js-routes (1.4.3) railties (>= 3.2) sprockets-rails json (2.1.0) @@ -329,7 +329,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (4.6.0.338) + newrelic_rpm (4.7.1.340) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) notiffany (0.1.1) @@ -408,8 +408,8 @@ GEM rails-assets-leaflet (>= 1.0.3) rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.8) - activesupport (>= 4.2.0.beta, < 5.0) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) @@ -528,7 +528,7 @@ GEM uglifier (4.0.2) execjs (>= 0.3.0, < 3) unicode-display_width (1.3.0) - unicorn (5.3.1) + unicorn (5.4.0) kgio (~> 2.6) raindrops (~> 0.7) uniform_notifier (1.10.0) From 8d3d8f3c91ffdc9c76eba991e8c2f3acad2db7ec Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 11:26:08 +1300 Subject: [PATCH 002/101] Adding package lock, and eslint --- .eslintrc.js | 3 + .overcommit.yml | 8 +- package-lock.json | 814 ++++++++++++++++++++++------------------------ package.json | 3 +- 4 files changed, 400 insertions(+), 428 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..f2ddd9cea --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + "extends": "google" +}; \ No newline at end of file diff --git a/.overcommit.yml b/.overcommit.yml index 505c8e2e6..d7899885f 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -46,7 +46,9 @@ PreCommit: required_executable: 'npm' HamlLint: enabled: true - command: ['bundle', 'exec', 'haml-lint', 'app/views'] + include: + - 'app/views/**' + command: ['bundle', 'exec', 'haml-lint'] JsonSyntax: enabled: true BundleOutdated: @@ -55,13 +57,13 @@ PreCommit: BundleAudit: enabled: true on_warn: warn - JsHint: + EsLint: enabled: true exclude: - 'app/assets/**' - 'spec/javascripts/support/vendor/**' - '**/bootstrap*' - command: ['npm', 'run', 'jshint'] + command: ['./node_modules/.bin/eslint'] required_executable: 'npm' ScssLint: enabled: true diff --git a/package-lock.json b/package-lock.json index 013886a6b..baf5adb61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", - "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", "dev": true }, "acorn-jsx": { @@ -28,25 +28,27 @@ } }, "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", "dev": true }, "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", "dev": true }, "ansi-regex": { @@ -100,6 +102,30 @@ "chalk": "1.1.3", "esutils": "2.0.2", "js-tokens": "3.0.2" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + } } }, "balanced-match": { @@ -134,22 +160,46 @@ "dev": true }, "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { - "ansi-styles": "2.2.1", + "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "supports-color": "4.5.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", "dev": true }, "cli": { @@ -163,12 +213,12 @@ } }, "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "restore-cursor": "2.0.0" } }, "cli-width": { @@ -189,12 +239,6 @@ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "dev": true }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, "coffeelint": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-2.0.7.tgz", @@ -212,7 +256,22 @@ "coffeescript": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.0.3.tgz", - "integrity": "sha512-iIfUN+71IyI2FQABXh1luzZeQgqwUPeWh6lDovJatQQs+30bvyGnBY0r4BnD0hoMAasNuZVHlL1U09Oy1ZfSeg==", + "integrity": "sha1-dg8Cck9fCRG+fO+jSo4OEMXYUSo=", + "dev": true + }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "concat-map": { @@ -247,6 +306,17 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "4.1.1", + "shebang-command": "1.2.0", + "which": "1.3.0" + } + }, "csslint": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/csslint/-/csslint-1.0.5.tgz", @@ -257,15 +327,6 @@ "parserlib": "1.1.1" } }, - "d": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", - "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", - "dev": true, - "requires": { - "es5-ext": "0.10.35" - } - }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -273,9 +334,9 @@ "dev": true }, "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { "ms": "2.0.0" @@ -303,13 +364,12 @@ } }, "doctrine": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.2.tgz", + "integrity": "sha512-y0tm5Pq6ywp3qSTZ1vPgVdAnbDEoeoc5wlOHXoY1c4Wug/a7JvqHIl7BTvwodaHmejWkK/9dSb3sCYfyo/om8A==", "dev": true, "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "esutils": "2.0.2" } }, "dom-serializer": { @@ -367,135 +427,55 @@ "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, - "es5-ext": { - "version": "0.10.35", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.35.tgz", - "integrity": "sha1-GO6FjOajxFx9eekcFfzKnsVoSU8=", - "dev": true, - "requires": { - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-symbol": "3.1.1" - } - }, - "es6-map": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", - "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.3", - "es6-set": "0.1.5", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" - } - }, - "es6-set": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", - "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" - } - }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35" - } - }, - "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" - } - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "escope": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", - "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", - "dev": true, - "requires": { - "es6-map": "0.1.5", - "es6-weak-map": "2.0.2", - "esrecurse": "4.2.0", - "estraverse": "4.2.0" - } - }, "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.14.0.tgz", + "integrity": "sha512-Ul6CSGRjKscEyg0X/EeNs7o2XdnbTEOD1OM8cTjmx85RPcBJQrEhZLevhuJZNAE/vS2iVl5Uhgiqf3h5uLMCJQ==", "dev": true, "requires": { + "ajv": "5.5.2", "babel-code-frame": "6.26.0", - "chalk": "1.1.3", + "chalk": "2.3.0", "concat-stream": "1.6.0", - "debug": "2.6.9", - "doctrine": "2.0.0", - "escope": "3.6.0", - "espree": "3.5.1", + "cross-spawn": "5.1.0", + "debug": "3.1.0", + "doctrine": "2.0.2", + "eslint-scope": "3.7.1", + "eslint-visitor-keys": "1.0.0", + "espree": "3.5.2", "esquery": "1.0.0", - "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", "glob": "7.1.2", - "globals": "9.18.0", + "globals": "11.1.0", "ignore": "3.3.7", "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.16.1", - "is-resolvable": "1.0.0", + "inquirer": "3.3.0", + "is-resolvable": "1.0.1", "js-yaml": "3.10.0", - "json-stable-stringify": "1.0.1", + "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.3.0", "lodash": "4.17.4", + "minimatch": "3.0.4", "mkdirp": "0.5.1", "natural-compare": "1.4.0", "optionator": "0.8.2", "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", + "pluralize": "7.0.0", + "progress": "2.0.0", "require-uncached": "1.0.3", - "shelljs": "0.7.8", - "strip-bom": "3.0.0", + "semver": "5.4.1", + "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" + "table": "4.0.2", + "text-table": "0.2.0" }, "dependencies": { "strip-json-comments": { @@ -506,20 +486,42 @@ } } }, - "espree": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.1.tgz", - "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=", + "eslint-config-google": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.9.1.tgz", + "integrity": "sha512-5A83D+lH0PA81QMESKbLJd/a3ic8tPZtwUmqNrxMRo54nfFaUvtt89q/+icQ+fd66c2xQHn0KyFkzJDoAUfpZA==", + "dev": true + }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", "dev": true, "requires": { - "acorn": "5.2.1", + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha1-PzGA+y4pEBdxastMnW1bXDSmqB0=", + "dev": true + }, + "espree": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", + "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", + "dev": true, + "requires": { + "acorn": "5.3.0", "acorn-jsx": "3.0.1" } }, "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", "dev": true }, "esquery": { @@ -553,26 +555,33 @@ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.35" - } - }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "external-editor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha1-PQJqIbf5W1cmOH1CAKwWDTcsO0g=", + "dev": true, + "requires": { + "chardet": "0.4.2", + "iconv-lite": "0.4.19", + "tmp": "0.0.33" + } + }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, "fast-levenshtein": { @@ -582,13 +591,12 @@ "dev": true }, "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "1.0.5" } }, "file-entry-cache": { @@ -619,21 +627,12 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "1.0.2" - } - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -649,9 +648,9 @@ } }, "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.1.0.tgz", + "integrity": "sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ==", "dev": true }, "globby": { @@ -683,6 +682,12 @@ "ansi-regex": "2.1.1" } }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, "htmlparser2": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", @@ -722,6 +727,12 @@ } } }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha1-90aPYBNfXl2tM5nAqBvpoWA6CCs=", + "dev": true + }, "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", @@ -751,52 +762,32 @@ "dev": true }, "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", + "ansi-escapes": "3.0.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", "cli-width": "2.2.0", - "figures": "1.7.0", + "external-editor": "2.1.0", + "figures": "2.0.0", "lodash": "4.17.4", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", "through": "2.3.8" } }, - "interpret": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.4.tgz", - "integrity": "sha1-ggzdWIuGj/sZGoCVBtbJyPISsbA=", - "dev": true - }, "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-my-json-valid": { - "version": "2.16.1", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz", - "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==", - "dev": true, - "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true }, "is-path-cwd": { "version": "1.0.0", @@ -810,32 +801,29 @@ "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", "dev": true, "requires": { - "is-path-inside": "1.0.0" + "is-path-inside": "1.0.1" } }, "is-path-inside": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { "path-is-inside": "1.0.2" } }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, "is-resolvable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", - "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", - "dev": true, - "requires": { - "tryit": "1.0.3" - } + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.1.tgz", + "integrity": "sha512-y5CXYbzvB3jTnWAZH1Nl7ykUWb6T3BcTs56HUruwBf8MhF56n1HWqhDWnVFo8GHrUPDgvUUNVhrc2U8W7iqz5g==", + "dev": true }, "isarray": { "version": "1.0.0", @@ -843,6 +831,12 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -852,7 +846,7 @@ "js-yaml": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", - "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "integrity": "sha1-LnhEFka9RoLpY/IrbpKCPDCcYtw=", "dev": true, "requires": { "argparse": "1.0.9", @@ -889,25 +883,16 @@ } } }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", "dev": true }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, "levn": { @@ -926,6 +911,22 @@ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha1-Yi4y6CSItJJ5EUpPns9F581rulU=", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, + "mimic-fn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", + "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -965,9 +966,9 @@ "dev": true }, "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, "natural-compare": { @@ -976,12 +977,6 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -998,10 +993,13 @@ } }, "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "1.1.0" + } }, "optimist": { "version": "0.6.1", @@ -1035,10 +1033,10 @@ } } }, - "os-homedir": { + "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, "parserlib": { @@ -1059,12 +1057,6 @@ "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -1087,9 +1079,9 @@ } }, "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", "dev": true }, "prelude-ls": { @@ -1105,15 +1097,21 @@ "dev": true }, "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -1125,37 +1123,6 @@ "util-deprecate": "1.0.2" } }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "mute-stream": "0.0.5" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "1.5.0" - }, - "dependencies": { - "resolve": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - } - } - }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -1179,62 +1146,90 @@ "dev": true }, "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "onetime": "2.0.1", + "signal-exit": "3.0.2" } }, "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", "dev": true, "requires": { "glob": "7.1.2" } }, "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "dev": true, "requires": { - "once": "1.4.0" + "is-promise": "2.1.0" } }, "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", "dev": true }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "4.0.8" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", "dev": true }, - "shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha1-4FnAnYVx8FQII3M0M1BdOi8AsY4=", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { - "glob": "7.1.2", - "interpret": "1.0.4", - "rechoir": "0.6.2" + "shebang-regex": "1.0.0" } }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -1242,40 +1237,41 @@ "dev": true }, "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", "dev": true, "requires": { "safe-buffer": "5.1.1" } }, "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + } } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -1289,50 +1285,17 @@ "dev": true }, "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "dev": true, "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", + "chalk": "2.3.0", "lodash": "4.17.4", - "slice-ansi": "0.0.4", + "slice-ansi": "1.0.0", "string-width": "2.1.1" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - } } }, "text-table": { @@ -1347,11 +1310,14 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "tryit": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", - "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", - "dev": true + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } }, "type-check": { "version": "0.3.2", @@ -1368,21 +1334,21 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true, - "requires": { - "os-homedir": "1.0.2" - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -1404,10 +1370,10 @@ "mkdirp": "0.5.1" } }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true } } diff --git a/package.json b/package.json index f41b67b64..b0943cb2c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "devDependencies": { "coffeelint": "^2.0.7", "csslint": "^1.0.5", - "eslint": "^3.17.1", + "eslint": "^4.14.0", + "eslint-config-google": "^0.9.1", "jshint": "^2.9.4" }, "repository": { From 9f1c064900ce0aaf9d1558e2298776bf9936d45e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 11:49:06 +1300 Subject: [PATCH 003/101] Use the old "var" syntax, and max line 120 --- .eslintrc.js | 3 --- .eslintrc.json | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 .eslintrc.json diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index f2ddd9cea..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - "extends": "google" -}; \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..a2035e465 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "extends": "google", + "env": { + "browser": true, + "node": true + }, + "rules": { + "no-var": "off", + "max-len": ["error", { "code": 120, "tabWidth": 4 }] + } +} \ No newline at end of file From e009d9532ad2f6f4eda78948a0fa125c958485b8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 11:51:14 +1300 Subject: [PATCH 004/101] Updating javascript style --- spec/javascripts/graphs/bar_group_spec.js | 52 ++++----- .../graphs/bar_label_group_spec.js | 26 ++--- spec/javascripts/graphs/height_scale_spec.js | 16 ++- .../graphs/horizontal_bar_graph_spec.js | 110 +++++++++--------- spec/javascripts/graphs/width_scale_spec.js | 17 ++- 5 files changed, 104 insertions(+), 117 deletions(-) diff --git a/spec/javascripts/graphs/bar_group_spec.js b/spec/javascripts/graphs/bar_group_spec.js index 6358d1d26..50af8d3a8 100644 --- a/spec/javascripts/graphs/bar_group_spec.js +++ b/spec/javascripts/graphs/bar_group_spec.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; /* @@ -6,31 +6,30 @@ */ describe('when drawing the group of bars', function() { - var BarGroup, subject, widthScale, bars, data; + var BarGroup; var subject; var widthScale; var bars; var data; - beforeEach(function() { + beforeEach(function() { + var WidthScale = growstuff.WidthScale; + BarGroup = growstuff.BarGroup; - var WidthScale = growstuff.WidthScale; - BarGroup = growstuff.BarGroup; + bars = [ + {name: 'Shade', value: 0.2}, + {name: 'Half Shade', value: 0.5}, + ]; - bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5} - ]; + data = { + bars: bars, + bar_color: 'steelblue', + width: {size: 300, scale: 'linear'}, + height: {size: 400, scale: 'ordinal'}, + }; - data = { - bars: bars, - bar_color: 'steelblue', - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'} - }; + widthScale = new WidthScale(data); + subject = new BarGroup(data); + subject.render(d3.select('#jasmine_content').append('svg')); + }); - widthScale = new WidthScale(data); - subject = new BarGroup(data); - subject.render(d3.select('#jasmine_content').append('svg')); - }); - - it('draws a group', function(){ + it('draws a group', function() { expect($('g.bar')).toExist(); }); @@ -38,23 +37,20 @@ expect($('g.bar rect')).toHaveLength(2); }); - it('fills the bars with color', function(){ + it('fills the bars with color', function() { expect($('g.bar rect')).toHaveAttr('fill', 'steelblue'); }); - it('shows a tooltip on hover', function(){ + it('shows a tooltip on hover', function() { var i; - //get all of the title nodes for the bars + // get all of the title nodes for the bars var barNodes = $('g.bar rect title'); - for (i = 0; i < bars.length; i++){ + for (i = 0; i < bars.length; i++) { expect(barNodes[i].textContent) .toBe('This value is ' + bars[i].value + '' + '.'); } }); - - }); - }()); diff --git a/spec/javascripts/graphs/bar_label_group_spec.js b/spec/javascripts/graphs/bar_label_group_spec.js index aaaf680c7..7cb6e5537 100644 --- a/spec/javascripts/graphs/bar_label_group_spec.js +++ b/spec/javascripts/graphs/bar_label_group_spec.js @@ -1,42 +1,38 @@ -(function(){ +(function() { 'use strict'; /* This file contains tests for the labels that get rendered next to each bar */ - describe('BarLabelGroup', function(){ + describe('BarLabelGroup', function() { + var BarLabelGroup; var subject; var data; - var BarLabelGroup, subject, data; - - beforeEach(function(){ + beforeEach(function() { BarLabelGroup = growstuff.BarLabelGroup; var bars = [ {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5} + {name: 'Half Shade', value: 0.5}, ]; data = { - bars: bars + bars: bars, }; subject = new BarLabelGroup(data); subject.render(d3.select('#jasmine_content').append('svg')); }); - it('draws a group for labels', function(){ + it('draws a group for labels', function() { expect($('g.bar-label')).toExist(); }); - it('draws 2 bar labels', function(){ + it('draws 2 bar labels', function() { expect($('g.bar-label text')).toHaveLength(2); }); - it ('has text for 2 bar labels', function(){ - //jquery jasmine appends text from all text elements + it('has text for 2 bar labels', function() { + // jquery jasmine appends text from all text elements // into one string expect($('g.bar-label text')).toHaveText('ShadeHalf Shade'); - }); - }); - -}()); \ No newline at end of file +}()); diff --git a/spec/javascripts/graphs/height_scale_spec.js b/spec/javascripts/graphs/height_scale_spec.js index 0de6a987a..3a257400c 100644 --- a/spec/javascripts/graphs/height_scale_spec.js +++ b/spec/javascripts/graphs/height_scale_spec.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; /* @@ -6,18 +6,18 @@ */ describe('HeightScale when specifying height', function() { - var data, bars, HeightScale, subject, mockD3; + var data; var bars; var HeightScale; var subject; var mockD3; - beforeEach(function(){ + beforeEach(function() { HeightScale = growstuff.HeightScale; bars = [ {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5} + {name: 'Half Shade', value: 0.5}, ]; data = { bars: bars, width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'} + height: {size: 400, scale: 'ordinal'}, }; subject = new HeightScale(data); @@ -26,12 +26,10 @@ mockD3.rangeRoundBands.and.returnValue(mockD3); spyOn(d3.scale, 'ordinal').and.returnValue(mockD3); subject.render(); - }); - it('calls the d3 range round bands function to draw the height', function(){ + it('calls the d3 range round bands function to draw the height', function() { expect(mockD3.rangeRoundBands).toHaveBeenCalledWith([0, 400], 0.05, 0); }); }); - -}()); \ No newline at end of file +}()); diff --git a/spec/javascripts/graphs/horizontal_bar_graph_spec.js b/spec/javascripts/graphs/horizontal_bar_graph_spec.js index 8e6b62a48..b8fbed1a3 100644 --- a/spec/javascripts/graphs/horizontal_bar_graph_spec.js +++ b/spec/javascripts/graphs/horizontal_bar_graph_spec.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; /* @@ -6,70 +6,68 @@ are more integration-y type tests that require the full graph. */ - describe('HorizontalBarGraph', function() { - var BarLabelGroup, BarGroup, subject, data; + describe('HorizontalBarGraph', function() { + var BarLabelGroup; var BarGroup; var subject; var data; - beforeEach(function() { - var HorizontalBarGraph = growstuff.HorizontalBarGraph; - var bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5} - ]; - data = { - bars: bars, - bar_color: 'steelblue', - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'}, - //left is used to shift the bars over so that there is - //room for the labels - margin: {top: 0, right: 0, bottom: 0, left: 100} - }; + beforeEach(function() { + var HorizontalBarGraph = growstuff.HorizontalBarGraph; + var bars = [ + {name: 'Shade', value: 0.2}, + {name: 'Half Shade', value: 0.5}, + ]; + data = { + bars: bars, + bar_color: 'steelblue', + width: {size: 300, scale: 'linear'}, + height: {size: 400, scale: 'ordinal'}, + // left is used to shift the bars over so that there is + // room for the labels + margin: {top: 0, right: 0, bottom: 0, left: 100}, + }; - subject = new HorizontalBarGraph(data); - BarGroup = growstuff.BarGroup; - BarLabelGroup = growstuff.BarLabelGroup; - expect(BarLabelGroup).toExist(); - spyOn(BarGroup.prototype, 'render').and.callThrough(); - spyOn(BarLabelGroup.prototype, 'render').and.callThrough(); - subject.render(d3.select($('#jasmine_content')[0])); - }); + subject = new HorizontalBarGraph(data); + BarGroup = growstuff.BarGroup; + BarLabelGroup = growstuff.BarLabelGroup; + expect(BarLabelGroup).toExist(); + spyOn(BarGroup.prototype, 'render').and.callThrough(); + spyOn(BarLabelGroup.prototype, 'render').and.callThrough(); + subject.render(d3.select($('#jasmine_content')[0])); + }); - it('draws a graph', function() { - expect($('#jasmine_content svg')).toExist(); - }); + it('draws a graph', function() { + expect($('#jasmine_content svg')).toExist(); + }); - it('draws a group for the whole graph', function(){ - expect($('g.bar-graph')).toExist(); - }); + it('draws a group for the whole graph', function() { + expect($('g.bar-graph')).toExist(); + }); - it('draws a bar group', function(){ - expect(BarGroup.prototype.render).toHaveBeenCalled(); - }); + it('draws a bar group', function() { + expect(BarGroup.prototype.render).toHaveBeenCalled(); + }); - it('draws a group of bar labels', function() { - expect(BarLabelGroup.prototype.render).toHaveBeenCalled(); - }); + it('draws a group of bar labels', function() { + expect(BarLabelGroup.prototype.render).toHaveBeenCalled(); + }); - it('has the expected width and height', function() { - var $svg = $('svg'); - var margin = data.margin; - expect($svg).toHaveAttr('width', (data.width.size + margin.left + margin.right) + ''); - expect($svg).toHaveAttr('height', (data.height.size + margin.top + margin.bottom) + ''); - }); + it('has the expected width and height', function() { + var $svg = $('svg'); + var margin = data.margin; + expect($svg).toHaveAttr('width', (data.width.size + margin.left + margin.right) + ''); + expect($svg).toHaveAttr('height', (data.height.size + margin.top + margin.bottom) + ''); + }); - it('draws the graph shifted to the right to accommodate for labels', function(){ - expect('g.bar-graph').toHaveAttr('transform', 'translate(100,0)'); - }); + it('draws the graph shifted to the right to accommodate for labels', function() { + expect('g.bar-graph').toHaveAttr('transform', 'translate(100,0)'); + }); - it ('on the x axis, draws at least one bar at max width less margin width because of domain and range mapping', function(){ - expect('g.bar rect:eq(1)').toHaveAttr('width', '300' ); - }); - - it ('on the y axis, all bars are the same height', function(){ - expect('g.bar rect:eq(0)').toHaveAttr('height', '195'); - expect('g.bar rect:eq(1)').toHaveAttr('height', '195'); - }); + it('on the x axis, draws at least one bar at max width less margin width because of domain and range mapping', function() { + expect('g.bar rect:eq(1)').toHaveAttr('width', '300' ); + }); + it('on the y axis, all bars are the same height', function() { + expect('g.bar rect:eq(0)').toHaveAttr('height', '195'); + expect('g.bar rect:eq(1)').toHaveAttr('height', '195'); + }); }); - }()); diff --git a/spec/javascripts/graphs/width_scale_spec.js b/spec/javascripts/graphs/width_scale_spec.js index c6ca9204a..d8e34234a 100644 --- a/spec/javascripts/graphs/width_scale_spec.js +++ b/spec/javascripts/graphs/width_scale_spec.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; /* @@ -6,19 +6,19 @@ the length of a bar so that it is the correct size for the screen */ - describe('GraphScale, when specifying width', function(){ - var data, WidthScale, subject, mockD3; + describe('GraphScale, when specifying width', function() { + var data; var WidthScale; var subject; var mockD3; - beforeEach(function(){ + beforeEach(function() { WidthScale = growstuff.WidthScale; var bars = [ {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5} + {name: 'Half Shade', value: 0.5}, ]; data = { bars: bars, width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'} + height: {size: 400, scale: 'ordinal'}, }; subject = new WidthScale(data, 'width'); @@ -29,13 +29,12 @@ subject.render(); }); - it ('gets the value of the longest bar', function(){ + it('gets the value of the longest bar', function() { expect(subject.getMaxValue()).toEqual(0.5); }); - it ('calls the d3 range function to draw the width', function(){ + it('calls the d3 range function to draw the width', function() { expect(mockD3.range).toHaveBeenCalledWith([0, 300]); }); }); - }()); From 9906036faf3ca0bfd4072f6a73b657acc1f61c39 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:02:21 +1300 Subject: [PATCH 005/101] Add bootstrap js to codeclimate excludes --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index ca784c7a0..32904c026 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -42,3 +42,4 @@ exclude_paths: - spec/ - public/ - app/assets/stylesheets/bootstrap-accessibility.css +- app/assets/javascripts/bootstrap* From 61408d7e4e88aabec4fb4a805a4c59241c68a202 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:35:30 +1300 Subject: [PATCH 006/101] Some js cleanups --- app/assets/javascripts/application.js | 18 +++++----- app/assets/javascripts/graphs/bar_group.js | 33 +++++++++---------- .../javascripts/graphs/bar_label_group.js | 30 +++++++++-------- app/assets/javascripts/graphs/height_scale.js | 14 ++++---- .../graphs/horizontal_bar_graph.js | 24 ++++++++------ app/assets/javascripts/graphs/width_scale.js | 13 ++++---- app/assets/javascripts/posts.js | 16 ++++----- 7 files changed, 78 insertions(+), 70 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0ad04350c..fc3369264 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,12 +10,12 @@ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // -//= require leaflet -//= require leaflet.markercluster -//= require js-routes -//= require jquery -//= require jquery_ujs -//= require jquery-ui/autocomplete -//= require bootstrap-sprockets -//= require bootstrap-datepicker -//= require_tree . +// = require leaflet +// = require leaflet.markercluster +// = require js-routes +// = require jquery +// = require jquery_ujs +// = require jquery-ui/autocomplete +// = require bootstrap-sprockets +// = require bootstrap-datepicker +// = require_tree . diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js index ceff6afdf..a6abaa150 100644 --- a/app/assets/javascripts/graphs/bar_group.js +++ b/app/assets/javascripts/graphs/bar_group.js @@ -1,7 +1,7 @@ -//= require graphs/width_scale -//= require graphs/height_scale +// = require graphs/width_scale +// = require graphs/height_scale -(function(){ +(function() { 'use strict'; /* @@ -17,34 +17,33 @@ function BarGroup(data) { this._data = data; } -BarGroup.prototype.render = function(root){ - +BarGroup.prototype.render = function(root) { var data = this._data; var bars = this._data.bars; var widthScale = new WidthScale(data).render(); var heightScale = new HeightScale(data).render(); return root.append('g') - .attr("class", "bar") - .selectAll("rect") - .data(bars.map(function(bar) { return bar.value; })) + .attr('class', 'bar') + .selectAll('rect') + .data(bars.map(function(bar) { + return bar.value; +})) .enter() - .append("rect") - .attr("y", function(d, i){ + .append('rect') + .attr('y', function(d, i) { return heightScale(i); - }) - .attr("height", heightScale.rangeBand()) - .attr("fill", data.bar_color) - .attr("width", function(d){ + .attr('height', heightScale.rangeBand()) + .attr('fill', data.bar_color) + .attr('width', function(d) { return widthScale(d); }) - .append("title") - .text(function(d){ + .append('title') + .text(function(d) { return 'This value is ' + d + '.'; }); }; growstuff.BarGroup = BarGroup; - }()); diff --git a/app/assets/javascripts/graphs/bar_label_group.js b/app/assets/javascripts/graphs/bar_label_group.js index bfe2eee51..e60073743 100644 --- a/app/assets/javascripts/graphs/bar_label_group.js +++ b/app/assets/javascripts/graphs/bar_label_group.js @@ -11,30 +11,32 @@ This file draws the labels to the left of each bar. this._data = data; } - BarLabelGroup.prototype.render = function(d3){ + BarLabelGroup.prototype.render = function(d3) { var bars = this._data.bars; - //vvcopy pasta from spike vv -- this is a good candidate for refactor + // vvcopy pasta from spike vv -- this is a good candidate for refactor var barHeight = 40; return d3.append('g') - .attr("class", "bar-label") - .selectAll("text") - .data(bars.map(function(bar){ return bar.name;})) + .attr('class', 'bar-label') + .selectAll('text') + .data(bars.map(function(bar) { + return bar.name; +})) .enter() - .append("text") + .append('text') .attr('x', -80) - .attr('y', function(d, i){ - //shrink the margin between each label to give them an even spread with - //bars + .attr('y', function(d, i) { + // shrink the margin between each label to give them an even spread with + // bars var barLabelSpread = 2/3; - //move them downward to line up with bars + // move them downward to line up with bars var barLabelTopEdge = 17; return i * barHeight * (barLabelSpread) + barLabelTopEdge; }) - .text(function(d){return d;}); - + .text(function(d) { +return d; +}); }; growstuff.BarLabelGroup = BarLabelGroup; - -}()); \ No newline at end of file +}()); diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js index 7521d50f0..8abc636c9 100644 --- a/app/assets/javascripts/graphs/height_scale.js +++ b/app/assets/javascripts/graphs/height_scale.js @@ -1,20 +1,23 @@ -//=require d3 +// =require d3 /* Height Scale is used to map the number of bars to the display size of the svg */ -(function(){ +(function() { 'use strict'; var growstuff = (window.growstuff = window.growstuff || {}); - function HeightScale(data){ + /** + * new heighscale object + */ + function HeightScale(data) { this._data = data; } - HeightScale.prototype.render = function(){ + HeightScale.prototype.render = function() { var data = this._data; var scaleType = data.height.scale; var axisSize = data.height.size; @@ -25,5 +28,4 @@ the svg }; growstuff.HeightScale = HeightScale; - -}()); \ No newline at end of file +}()); diff --git a/app/assets/javascripts/graphs/horizontal_bar_graph.js b/app/assets/javascripts/graphs/horizontal_bar_graph.js index 9760138fb..856bca885 100644 --- a/app/assets/javascripts/graphs/horizontal_bar_graph.js +++ b/app/assets/javascripts/graphs/horizontal_bar_graph.js @@ -1,6 +1,6 @@ -//= require d3 -//= require graphs/bar_group -//= require graphs/bar_label_group +// = require d3 +// = require graphs/bar_group +// = require graphs/bar_label_group /* Horizontal Bar Graph represents sum total of the graph including all of the parts: @@ -17,6 +17,10 @@ The main dimensions of the graph are rendered here. var BarGroup = growstuff.BarGroup; var BarLabelGroup = growstuff.BarLabelGroup; + /** + * create a new graph object + * @param {??} bar graph data + */ function HorizontalBarGraph(data) { this._data = data; this._d3 = d3; @@ -33,12 +37,12 @@ The main dimensions of the graph are rendered here. var barGroup = new BarGroup(this._data); var svg = root - .append("svg") - .attr("width", width.size + margin.left + margin.right) - .attr("height", height.size + margin.top + margin.bottom) - .append("g") - .attr("class","bar-graph") - .attr("transform","translate(" + margin.left + "," + margin.top + ")"); + .append('svg') + .attr('width', width.size + margin.left + margin.right) + .attr('height', height.size + margin.top + margin.bottom) + .append('g') + .attr('class', 'bar-graph') + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); barGroup.render(svg); @@ -48,4 +52,4 @@ The main dimensions of the graph are rendered here. }; growstuff.HorizontalBarGraph = HorizontalBarGraph; -}()); \ No newline at end of file +}()); diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js index d8997c8c9..4a5c71e19 100644 --- a/app/assets/javascripts/graphs/width_scale.js +++ b/app/assets/javascripts/graphs/width_scale.js @@ -1,16 +1,16 @@ -//=require d3 +// =require d3 /* Width scale is used to map the value for the length of each bar to the display size of the svg */ -(function(){ +(function() { 'use strict'; var growstuff = (window.growstuff = window.growstuff || {}); - function WidthScale (data){ + function WidthScale(data) { this._data = data; } @@ -24,10 +24,11 @@ to the display size of the svg .range([0, axisSize]); }; - WidthScale.prototype.getMaxValue = function(){ - return d3.max(this._data.bars.map(function(bar) { return bar.value; })); + WidthScale.prototype.getMaxValue = function() { + return d3.max(this._data.bars.map(function(bar) { + return bar.value; +})); }; growstuff.WidthScale = WidthScale; - }()); diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index c2cf3ff4e..94fe0fb92 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -1,4 +1,4 @@ -$(document).ready(function () { +$(document).ready(function() { $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { @@ -6,13 +6,13 @@ $(document).ready(function () { $('#post-' + data.id + ' .like-count').text(data.description); if (data.liked_by_member) { - like_control.data("method", "delete"); - like_control.attr("href", data.url); - like_control.text("Unlike"); + like_control.data('method', 'delete'); + like_control.attr('href', data.url); + like_control.text('Unlike'); } else { - like_control.data("method", "post"); - like_control.attr("href", '/likes.json?post_id=' + data.id); - like_control.text("Like"); + like_control.data('method', 'post'); + like_control.attr('href', '/likes.json?post_id=' + data.id); + like_control.text('Like'); } }); -}); \ No newline at end of file +}); From a4c7de381e106bfa7f6e977520fd15d32978ab98 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:42:20 +1300 Subject: [PATCH 007/101] converted variable to camel case --- app/assets/javascripts/posts.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 94fe0fb92..37269e78e 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -2,17 +2,17 @@ $(document).ready(function() { $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { - var like_control = $('#post-' + data.id + ' .post-like'); + var likeControl = $('#post-' + data.id + ' .post-like'); $('#post-' + data.id + ' .like-count').text(data.description); if (data.liked_by_member) { - like_control.data('method', 'delete'); - like_control.attr('href', data.url); - like_control.text('Unlike'); + likeControl.data('method', 'delete'); + likeControl.attr('href', data.url); + likeControl.text('Unlike'); } else { - like_control.data('method', 'post'); - like_control.attr('href', '/likes.json?post_id=' + data.id); - like_control.text('Like'); + likeControl.data('method', 'post'); + likeControl.attr('href', '/likes.json?post_id=' + data.id); + likeControl.text('Like'); } }); }); From 49444edc61692b6d3c43d1fd49c260d36e8827e4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:48:13 +1300 Subject: [PATCH 008/101] contributors/commits update --- CONTRIBUTORS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 69c9fd2e4..f984400ae 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,14 +8,15 @@ submit the change with your pull request. ## Committers -- Alex Bayley / [Skud](https://github.com/Skud) - Cesy / [cesy](https://github.com/cesy) - Miles Gould / [pozorvlak](https://github.com/pozorvlak) -- Taylor Griffin / [tygriffin](https://github.com/tygriffin) - Mackenzie Morgan / [maco](https://github.com/maco) +- Brenda Wallace / [br3nda](https://github.com/br3nda) ## Contributors +- Alex Bayley / [Skud](https://github.com/Skud) +- Taylor Griffin / [tygriffin](https://github.com/tygriffin) - Joseph Caudle / [jcaudle](https://github.com/jcaudle) - Ricky Amianym / [amianym](https://github.com/amianym) - Juliet Kemp / [julietk](https://github.com/julietk) @@ -73,7 +74,6 @@ submit the change with your pull request. - Lucas Nogueira / [lucasnogueira](https://github.com/lucasnogueira) - Charley Lewittes / [ctlewitt](https://github.com/ctlewitt) - Kristine Nicole Polvoriza / [polveenomials](https://github.com/polveenomials) -- Brenda Wallace / [br3nda](https://github.com/br3nda) - Jim Stallings / [jestallin](https://github.com/jestallin) - Alyssa Ransbury / [alran](https://github.com/alran) - Thomas Countz / [thomascountz](https://github.com/thomascountz) From d898f926d5e1be35dd576d883ec4e36939fb41ff Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:54:33 +1300 Subject: [PATCH 009/101] added JSDoc --- app/assets/javascripts/graphs/bar_group.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js index a6abaa150..312fcd6f3 100644 --- a/app/assets/javascripts/graphs/bar_group.js +++ b/app/assets/javascripts/graphs/bar_group.js @@ -13,6 +13,10 @@ var WidthScale = growstuff.WidthScale; var HeightScale = growstuff.HeightScale; +/** + * data object for bar group + * @param {int} data The graph data + */ function BarGroup(data) { this._data = data; } From d2a060ad49dcef8acf4d02fb37a3c4dbe7823263 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 12:56:52 +1300 Subject: [PATCH 010/101] added JSDoc --- app/assets/javascripts/graphs/width_scale.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js index 4a5c71e19..891cfaf96 100644 --- a/app/assets/javascripts/graphs/width_scale.js +++ b/app/assets/javascripts/graphs/width_scale.js @@ -10,6 +10,10 @@ to the display size of the svg var growstuff = (window.growstuff = window.growstuff || {}); + /** + * Object for WidthScale + * @param {?} data Graph data + */ function WidthScale(data) { this._data = data; } From 4a696af9ba81c18f29fe3087329a730633ac6292 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 13:00:09 +1300 Subject: [PATCH 011/101] Fix up JSDoc --- app/assets/javascripts/graphs/bar_group.js | 2 +- app/assets/javascripts/graphs/height_scale.js | 1 + app/assets/javascripts/graphs/horizontal_bar_graph.js | 2 +- app/assets/javascripts/graphs/width_scale.js | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js index 312fcd6f3..cb6bf0ef6 100644 --- a/app/assets/javascripts/graphs/bar_group.js +++ b/app/assets/javascripts/graphs/bar_group.js @@ -15,7 +15,7 @@ /** * data object for bar group - * @param {int} data The graph data + * @param {Object} graph configuration */ function BarGroup(data) { this._data = data; diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js index 8abc636c9..c4034a349 100644 --- a/app/assets/javascripts/graphs/height_scale.js +++ b/app/assets/javascripts/graphs/height_scale.js @@ -12,6 +12,7 @@ the svg /** * new heighscale object + * @param {Object} data Graph configuration */ function HeightScale(data) { this._data = data; diff --git a/app/assets/javascripts/graphs/horizontal_bar_graph.js b/app/assets/javascripts/graphs/horizontal_bar_graph.js index 856bca885..12dcae588 100644 --- a/app/assets/javascripts/graphs/horizontal_bar_graph.js +++ b/app/assets/javascripts/graphs/horizontal_bar_graph.js @@ -19,7 +19,7 @@ The main dimensions of the graph are rendered here. /** * create a new graph object - * @param {??} bar graph data + * @param {Object} data Graph configuration */ function HorizontalBarGraph(data) { this._data = data; diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js index 891cfaf96..3ddd0decf 100644 --- a/app/assets/javascripts/graphs/width_scale.js +++ b/app/assets/javascripts/graphs/width_scale.js @@ -12,7 +12,7 @@ to the display size of the svg /** * Object for WidthScale - * @param {?} data Graph data + * @param {Object} data Graph configuration */ function WidthScale(data) { this._data = data; From 580fac6aa1d6362a1e1c509dff5b085903926a93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 13:03:10 +1300 Subject: [PATCH 012/101] removed 2 unused variable in js --- app/assets/javascripts/graphs/height_scale.js | 1 - app/assets/javascripts/graphs/horizontal_bar_graph.js | 1 - 2 files changed, 2 deletions(-) diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js index c4034a349..6a4f29528 100644 --- a/app/assets/javascripts/graphs/height_scale.js +++ b/app/assets/javascripts/graphs/height_scale.js @@ -21,7 +21,6 @@ the svg HeightScale.prototype.render = function() { var data = this._data; var scaleType = data.height.scale; - var axisSize = data.height.size; return d3.scale[scaleType]() .domain(d3.range(data.bars.length)) diff --git a/app/assets/javascripts/graphs/horizontal_bar_graph.js b/app/assets/javascripts/graphs/horizontal_bar_graph.js index 12dcae588..ea3853e94 100644 --- a/app/assets/javascripts/graphs/horizontal_bar_graph.js +++ b/app/assets/javascripts/graphs/horizontal_bar_graph.js @@ -27,7 +27,6 @@ The main dimensions of the graph are rendered here. } HorizontalBarGraph.prototype.render = function(root) { - var bars = this._data.bars; var width = this._data.width; var height = this._data.height; From a4c06207e33d19009c5fad1781a535f34cb02d1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:20:01 +1300 Subject: [PATCH 013/101] more JSDoc --- app/assets/javascripts/graphs/bar_group.js | 2 +- app/assets/javascripts/graphs/bar_label_group.js | 4 ++++ app/assets/javascripts/graphs/height_scale.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js index cb6bf0ef6..a0d18050d 100644 --- a/app/assets/javascripts/graphs/bar_group.js +++ b/app/assets/javascripts/graphs/bar_group.js @@ -15,7 +15,7 @@ /** * data object for bar group - * @param {Object} graph configuration + * @param {Object} data Graph configuration */ function BarGroup(data) { this._data = data; diff --git a/app/assets/javascripts/graphs/bar_label_group.js b/app/assets/javascripts/graphs/bar_label_group.js index e60073743..3c574d6ad 100644 --- a/app/assets/javascripts/graphs/bar_label_group.js +++ b/app/assets/javascripts/graphs/bar_label_group.js @@ -7,6 +7,10 @@ This file draws the labels to the left of each bar. var growstuff = (window.growstuff = window.growstuff || {}); + /** + * new bar label object + * @param {Object} data Graph configuration + */ function BarLabelGroup(data) { this._data = data; } diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js index 6a4f29528..f4b76a044 100644 --- a/app/assets/javascripts/graphs/height_scale.js +++ b/app/assets/javascripts/graphs/height_scale.js @@ -11,7 +11,7 @@ the svg var growstuff = (window.growstuff = window.growstuff || {}); /** - * new heighscale object + * new height scale object * @param {Object} data Graph configuration */ function HeightScale(data) { From b205f3539923b33e7378fad9ef99b205743e7834 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:21:29 +1300 Subject: [PATCH 014/101] Wrapped a long line --- spec/javascripts/graphs/horizontal_bar_graph_spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/javascripts/graphs/horizontal_bar_graph_spec.js b/spec/javascripts/graphs/horizontal_bar_graph_spec.js index b8fbed1a3..16f35f018 100644 --- a/spec/javascripts/graphs/horizontal_bar_graph_spec.js +++ b/spec/javascripts/graphs/horizontal_bar_graph_spec.js @@ -61,7 +61,8 @@ expect('g.bar-graph').toHaveAttr('transform', 'translate(100,0)'); }); - it('on the x axis, draws at least one bar at max width less margin width because of domain and range mapping', function() { + it('on the x axis, draws at least one bar at max width less margin width', function() { + // because of domain and range mapping expect('g.bar rect:eq(1)').toHaveAttr('width', '300' ); }); From 2cf335a0642a3e7af191e82e81322920dc92887f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:24:08 +1300 Subject: [PATCH 015/101] Removed unused variables in js --- spec/javascripts/graphs/bar_group_spec.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/javascripts/graphs/bar_group_spec.js b/spec/javascripts/graphs/bar_group_spec.js index 50af8d3a8..a76992a6c 100644 --- a/spec/javascripts/graphs/bar_group_spec.js +++ b/spec/javascripts/graphs/bar_group_spec.js @@ -6,10 +6,9 @@ */ describe('when drawing the group of bars', function() { - var BarGroup; var subject; var widthScale; var bars; var data; + var BarGroup; var subject; var bars; var data; beforeEach(function() { - var WidthScale = growstuff.WidthScale; BarGroup = growstuff.BarGroup; bars = [ @@ -24,7 +23,6 @@ height: {size: 400, scale: 'ordinal'}, }; - widthScale = new WidthScale(data); subject = new BarGroup(data); subject.render(d3.select('#jasmine_content').append('svg')); }); From 87708f1765fd48f9393ab5ad29ea3043e0ddc2d9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:40:22 +1300 Subject: [PATCH 016/101] Tabulation and jsdoc fixes --- app/assets/javascripts/graphs/bar_group.js | 36 +++++++++---------- .../javascripts/graphs/bar_label_group.js | 17 +++++---- app/assets/javascripts/graphs/height_scale.js | 6 ++-- .../graphs/horizontal_bar_graph.js | 12 +++---- app/assets/javascripts/graphs/width_scale.js | 7 ++-- 5 files changed, 38 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js index a0d18050d..e8a90c20a 100644 --- a/app/assets/javascripts/graphs/bar_group.js +++ b/app/assets/javascripts/graphs/bar_group.js @@ -1,13 +1,14 @@ +// =require d3 // = require graphs/width_scale // = require graphs/height_scale +/* + * This represents bars for a bar graph. + * Currently these are used for HorizontalBarGraph. + */ (function() { 'use strict'; - /* - This represents bars for a bar graph. - Currently these are used for HorizontalBarGraph. - */ var growstuff = (window.growstuff = window.growstuff || {}); var WidthScale = growstuff.WidthScale; @@ -20,19 +21,18 @@ function BarGroup(data) { this._data = data; } + BarGroup.prototype.render = function(root) { + var data = this._data; + var bars = this._data.bars; + var widthScale = new WidthScale(data).render(); + var heightScale = new HeightScale(data).render(); -BarGroup.prototype.render = function(root) { - var data = this._data; - var bars = this._data.bars; - var widthScale = new WidthScale(data).render(); - var heightScale = new HeightScale(data).render(); - - return root.append('g') - .attr('class', 'bar') - .selectAll('rect') - .data(bars.map(function(bar) { - return bar.value; -})) + return root.append('g') + .attr('class', 'bar') + .selectAll('rect') + .data(bars.map(function(bar) { + return bar.value; + })) .enter() .append('rect') .attr('y', function(d, i) { @@ -47,7 +47,7 @@ BarGroup.prototype.render = function(root) { .text(function(d) { return 'This value is ' + d + '.'; }); -}; + }; -growstuff.BarGroup = BarGroup; + growstuff.BarGroup = BarGroup; }()); diff --git a/app/assets/javascripts/graphs/bar_label_group.js b/app/assets/javascripts/graphs/bar_label_group.js index 3c574d6ad..2da31f567 100644 --- a/app/assets/javascripts/graphs/bar_label_group.js +++ b/app/assets/javascripts/graphs/bar_label_group.js @@ -1,12 +1,11 @@ +// =require d3 +/** + * This file draws the labels to the left of each bar. + */ (function() { 'use strict'; -/* -This file draws the labels to the left of each bar. - */ - var growstuff = (window.growstuff = window.growstuff || {}); - /** * new bar label object * @param {Object} data Graph configuration @@ -24,8 +23,8 @@ This file draws the labels to the left of each bar. .attr('class', 'bar-label') .selectAll('text') .data(bars.map(function(bar) { - return bar.name; -})) + return bar.name; + })) .enter() .append('text') .attr('x', -80) @@ -38,8 +37,8 @@ This file draws the labels to the left of each bar. return i * barHeight * (barLabelSpread) + barLabelTopEdge; }) .text(function(d) { -return d; -}); + return d; + }); }; growstuff.BarLabelGroup = BarLabelGroup; diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js index f4b76a044..5189ef800 100644 --- a/app/assets/javascripts/graphs/height_scale.js +++ b/app/assets/javascripts/graphs/height_scale.js @@ -1,8 +1,8 @@ // =require d3 -/* -Height Scale is used to map the number of bars to the display size of -the svg +/** + * Height Scale is used to map the number of bars to the display size of + * the svg */ (function() { diff --git a/app/assets/javascripts/graphs/horizontal_bar_graph.js b/app/assets/javascripts/graphs/horizontal_bar_graph.js index ea3853e94..ef2333ef1 100644 --- a/app/assets/javascripts/graphs/horizontal_bar_graph.js +++ b/app/assets/javascripts/graphs/horizontal_bar_graph.js @@ -2,12 +2,12 @@ // = require graphs/bar_group // = require graphs/bar_label_group -/* -Horizontal Bar Graph represents sum total of the graph including all of the parts: -Bars -Bar Labels - -The main dimensions of the graph are rendered here. +/** + * Horizontal Bar Graph represents sum total of the graph including all of the parts: + * Bars + * Bar Labels + * + * The main dimensions of the graph are rendered here. */ (function() { diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js index 3ddd0decf..4ba275eda 100644 --- a/app/assets/javascripts/graphs/width_scale.js +++ b/app/assets/javascripts/graphs/width_scale.js @@ -1,10 +1,9 @@ // =require d3 -/* -Width scale is used to map the value for the length of each bar -to the display size of the svg +/** + * Width scale is used to map the value for the length of each bar + * to the display size of the svg */ - (function() { 'use strict'; From 4b65f28461df2413f43c5a373fdc49b968d58c54 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:43:29 +1300 Subject: [PATCH 017/101] Added new line at end of file --- spec/javascripts/support/spec_helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/javascripts/support/spec_helper.js b/spec/javascripts/support/spec_helper.js index 465207cf3..f9d26ae25 100644 --- a/spec/javascripts/support/spec_helper.js +++ b/spec/javascripts/support/spec_helper.js @@ -3,4 +3,4 @@ beforeEach(function() { $(document).off(); $('body').off(); $('#jasmine_content').replaceWith($('
')); -}); \ No newline at end of file +}); From 121deb4f4854ff2b36aa254fc029880414150978 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 15:06:55 +1300 Subject: [PATCH 018/101] Fix ordering of crops' parent on form --- app/views/crops/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index c391c79d2..a8cfe0bea 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -51,7 +51,7 @@ .form-group = f.label :parent_id, 'Parent crop', class: 'control-label col-md-2' .col-md-8 - = collection_select(:crop, :parent_id, Crop.all, :id, :name, { include_blank: true }, class: 'form-control') + = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, { include_blank: true }, class: 'form-control') %span.help-block Optional. For setting up crop hierarchies for varieties etc. From 308e834713d96e3f6f625d9dc81567d4b55a70dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 15:12:09 +1300 Subject: [PATCH 019/101] Wrap long line --- app/views/crops/_form.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index a8cfe0bea..c16041f97 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -51,7 +51,8 @@ .form-group = f.label :parent_id, 'Parent crop', class: 'control-label col-md-2' .col-md-8 - = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, { include_blank: true }, class: 'form-control') + = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, + { include_blank: true }, class: 'form-control') %span.help-block Optional. For setting up crop hierarchies for varieties etc. From e6e88fa0c71ce1b0ca23aca7cb0f99f8a308185e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 4 Jan 2018 15:11:36 +1300 Subject: [PATCH 020/101] Fixed up tabulation --- app/assets/javascripts/graphs/width_scale.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js index 4ba275eda..7f2b9dda2 100644 --- a/app/assets/javascripts/graphs/width_scale.js +++ b/app/assets/javascripts/graphs/width_scale.js @@ -29,8 +29,8 @@ WidthScale.prototype.getMaxValue = function() { return d3.max(this._data.bars.map(function(bar) { - return bar.value; -})); + return bar.value; + })); }; growstuff.WidthScale = WidthScale; From 1bf05f81ab20ffc5cab81e7b4dc0b688b2876375 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 7 Jan 2018 17:25:16 +1300 Subject: [PATCH 021/101] Convert to use chartkick gem Conflicts: Gemfile Gemfile.lock config/initializers/assets.rb --- .overcommit.yml | 1 + Gemfile | 3 +- Gemfile.lock | 5 +- app/assets/javascripts/charts.js | 2 + app/assets/javascripts/crops.js.erb | 37 -- app/assets/javascripts/graphs/bar_group.js | 53 --- .../javascripts/graphs/bar_label_group.js | 45 -- app/assets/javascripts/graphs/height_scale.js | 31 -- .../graphs/horizontal_bar_graph.js | 54 --- app/assets/javascripts/graphs/width_scale.js | 37 -- app/assets/javascripts/highcharts.js | 389 ++++++++++++++++++ app/assets/stylesheets/application.sass | 1 + .../custom_bootstrap/variables.sass | 1 + app/assets/stylesheets/overrides.sass | 19 - app/assets/stylesheets/predictions.sass | 11 + app/controllers/crops_controller.rb | 14 +- app/views/crops/_predictions.html.haml | 55 +-- app/views/crops/show.html.haml | 35 +- app/views/layouts/application.html.haml | 1 + config/initializers/assets.rb | 15 + config/routes.rb | 1 + 21 files changed, 484 insertions(+), 326 deletions(-) create mode 100644 app/assets/javascripts/charts.js delete mode 100644 app/assets/javascripts/graphs/bar_group.js delete mode 100644 app/assets/javascripts/graphs/bar_label_group.js delete mode 100644 app/assets/javascripts/graphs/height_scale.js delete mode 100644 app/assets/javascripts/graphs/horizontal_bar_graph.js delete mode 100644 app/assets/javascripts/graphs/width_scale.js create mode 100644 app/assets/javascripts/highcharts.js create mode 100644 app/assets/stylesheets/predictions.sass create mode 100644 config/initializers/assets.rb diff --git a/.overcommit.yml b/.overcommit.yml index d7899885f..200a90e42 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -61,6 +61,7 @@ PreCommit: enabled: true exclude: - 'app/assets/**' + - 'app/assets/javascripts/highcharts.js' - 'spec/javascripts/support/vendor/**' - '**/bootstrap*' command: ['./node_modules/.bin/eslint'] diff --git a/Gemfile b/Gemfile index c5d5d1fe1..1e26e67fc 100644 --- a/Gemfile +++ b/Gemfile @@ -78,8 +78,7 @@ gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' -# For charting data -gem 'd3-rails', '~> 3.5' # 4.* produces Error: : could not find an object to spy upon for linear() - see https://travis-ci.org/Growstuff/growstuff/jobs/204461482 +gem "chartkick" # client for Elasticsearch. Elasticsearch is a flexible # and powerful, distributed, real-time search and analytics engine. diff --git a/Gemfile.lock b/Gemfile.lock index 31113ea38..637ee3f44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,6 +99,7 @@ GEM capybara-screenshot (1.0.18) capybara (>= 1.0, < 3) launchy + chartkick (2.2.5) childprocess (0.8.0) ffi (~> 1.0, >= 1.0.11) climate_control (0.2.0) @@ -143,8 +144,6 @@ GEM crass (1.0.3) csv_shaper (1.3.0) activesupport (>= 3.0.0) - d3-rails (3.5.17) - railties (>= 3.1) dalli (2.7.6) database_cleaner (1.6.2) debug_inspector (0.0.3) @@ -569,12 +568,12 @@ DEPENDENCIES capybara capybara-email capybara-screenshot + chartkick codeclimate-test-reporter coffee-rails comfortable_mexican_sofa coveralls csv_shaper - d3-rails (~> 3.5) dalli database_cleaner devise diff --git a/app/assets/javascripts/charts.js b/app/assets/javascripts/charts.js new file mode 100644 index 000000000..1c42da456 --- /dev/null +++ b/app/assets/javascripts/charts.js @@ -0,0 +1,2 @@ +// = require Chart.bundle +// = require chartkick diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index afa16a009..9a60dd60c 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -1,5 +1,3 @@ -//= require graphs/horizontal_bar_graph - if (document.getElementById("cropmap") !== null) { mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; @@ -51,41 +49,6 @@ function showCropMap(cropmap) { cropmap.addLayer(markers); } -function plantingStats(crop) { - var sunniness_counts = { 'empty': 0, 'sun': 0, 'semi-shade': 0, 'shade': 0 }; - $.each(crop.plantings, function(i, planting) { - if (planting.sunniness) { - sunniness_counts[planting.sunniness]++; - } else { - sunniness_counts['Empty']++; - } - }); - return [ - {name: 'Empty', value: sunniness_counts['empty']}, - {name: 'Sun', value: sunniness_counts['sun']}, - {name: 'Semi-shade', value: sunniness_counts['semi-shade']}, - {name: 'Shade', value: sunniness_counts['shade']} - ]; -} - -if ($("#sunchart")[0] !== null) { - var HorizontalBarGraph = growstuff.HorizontalBarGraph; - $.getJSON(location.pathname + '.json', function (crop) { - data = { - bars: plantingStats(crop), - bar_color: 'steelblue', - width: {size: 300, scale: 'linear'}, - height: {size: 100, scale: 'ordinal'}, - //left is used to shift the bars over so that there is - //room for the labels - margin: {top: 0, right: 0, bottom: 0, left: 100} - }; - - var graph = new HorizontalBarGraph(data); - graph.render(d3.select($('#sunchart')[0])); - }); -} - $('.btn.toggle.crop-hierarchy').click(function () { $('.toggle.crop-hierarchy').toggleClass('hide'); }); diff --git a/app/assets/javascripts/graphs/bar_group.js b/app/assets/javascripts/graphs/bar_group.js deleted file mode 100644 index e8a90c20a..000000000 --- a/app/assets/javascripts/graphs/bar_group.js +++ /dev/null @@ -1,53 +0,0 @@ -// =require d3 -// = require graphs/width_scale -// = require graphs/height_scale - -/* - * This represents bars for a bar graph. - * Currently these are used for HorizontalBarGraph. - */ -(function() { - 'use strict'; - - - var growstuff = (window.growstuff = window.growstuff || {}); - var WidthScale = growstuff.WidthScale; - var HeightScale = growstuff.HeightScale; - -/** - * data object for bar group - * @param {Object} data Graph configuration - */ -function BarGroup(data) { - this._data = data; -} - BarGroup.prototype.render = function(root) { - var data = this._data; - var bars = this._data.bars; - var widthScale = new WidthScale(data).render(); - var heightScale = new HeightScale(data).render(); - - return root.append('g') - .attr('class', 'bar') - .selectAll('rect') - .data(bars.map(function(bar) { - return bar.value; - })) - .enter() - .append('rect') - .attr('y', function(d, i) { - return heightScale(i); - }) - .attr('height', heightScale.rangeBand()) - .attr('fill', data.bar_color) - .attr('width', function(d) { - return widthScale(d); - }) - .append('title') - .text(function(d) { - return 'This value is ' + d + '.'; - }); - }; - - growstuff.BarGroup = BarGroup; -}()); diff --git a/app/assets/javascripts/graphs/bar_label_group.js b/app/assets/javascripts/graphs/bar_label_group.js deleted file mode 100644 index 2da31f567..000000000 --- a/app/assets/javascripts/graphs/bar_label_group.js +++ /dev/null @@ -1,45 +0,0 @@ -// =require d3 -/** - * This file draws the labels to the left of each bar. - */ -(function() { - 'use strict'; - - var growstuff = (window.growstuff = window.growstuff || {}); - /** - * new bar label object - * @param {Object} data Graph configuration - */ - function BarLabelGroup(data) { - this._data = data; - } - - BarLabelGroup.prototype.render = function(d3) { - var bars = this._data.bars; - // vvcopy pasta from spike vv -- this is a good candidate for refactor - var barHeight = 40; - - return d3.append('g') - .attr('class', 'bar-label') - .selectAll('text') - .data(bars.map(function(bar) { - return bar.name; - })) - .enter() - .append('text') - .attr('x', -80) - .attr('y', function(d, i) { - // shrink the margin between each label to give them an even spread with - // bars - var barLabelSpread = 2/3; - // move them downward to line up with bars - var barLabelTopEdge = 17; - return i * barHeight * (barLabelSpread) + barLabelTopEdge; - }) - .text(function(d) { - return d; - }); - }; - - growstuff.BarLabelGroup = BarLabelGroup; -}()); diff --git a/app/assets/javascripts/graphs/height_scale.js b/app/assets/javascripts/graphs/height_scale.js deleted file mode 100644 index 5189ef800..000000000 --- a/app/assets/javascripts/graphs/height_scale.js +++ /dev/null @@ -1,31 +0,0 @@ -// =require d3 - -/** - * Height Scale is used to map the number of bars to the display size of - * the svg - */ - -(function() { - 'use strict'; - - var growstuff = (window.growstuff = window.growstuff || {}); - - /** - * new height scale object - * @param {Object} data Graph configuration - */ - function HeightScale(data) { - this._data = data; - } - - HeightScale.prototype.render = function() { - var data = this._data; - var scaleType = data.height.scale; - - return d3.scale[scaleType]() - .domain(d3.range(data.bars.length)) - .rangeRoundBands([0, data.height.size], 0.05, 0); - }; - - growstuff.HeightScale = HeightScale; -}()); diff --git a/app/assets/javascripts/graphs/horizontal_bar_graph.js b/app/assets/javascripts/graphs/horizontal_bar_graph.js deleted file mode 100644 index ef2333ef1..000000000 --- a/app/assets/javascripts/graphs/horizontal_bar_graph.js +++ /dev/null @@ -1,54 +0,0 @@ -// = require d3 -// = require graphs/bar_group -// = require graphs/bar_label_group - -/** - * Horizontal Bar Graph represents sum total of the graph including all of the parts: - * Bars - * Bar Labels - * - * The main dimensions of the graph are rendered here. - */ - -(function() { - 'use strict'; - - var growstuff = (window.growstuff = window.growstuff || {}); - var BarGroup = growstuff.BarGroup; - var BarLabelGroup = growstuff.BarLabelGroup; - - /** - * create a new graph object - * @param {Object} data Graph configuration - */ - function HorizontalBarGraph(data) { - this._data = data; - this._d3 = d3; - } - - HorizontalBarGraph.prototype.render = function(root) { - var width = this._data.width; - var height = this._data.height; - - var barLabelGroup = new BarLabelGroup(this._data); - var margin = this._data.margin; - - var barGroup = new BarGroup(this._data); - - var svg = root - .append('svg') - .attr('width', width.size + margin.left + margin.right) - .attr('height', height.size + margin.top + margin.bottom) - .append('g') - .attr('class', 'bar-graph') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - barGroup.render(svg); - barLabelGroup.render(svg); - - return svg; - }; - - growstuff.HorizontalBarGraph = HorizontalBarGraph; -}()); diff --git a/app/assets/javascripts/graphs/width_scale.js b/app/assets/javascripts/graphs/width_scale.js deleted file mode 100644 index 7f2b9dda2..000000000 --- a/app/assets/javascripts/graphs/width_scale.js +++ /dev/null @@ -1,37 +0,0 @@ -// =require d3 - -/** - * Width scale is used to map the value for the length of each bar - * to the display size of the svg - */ -(function() { - 'use strict'; - - var growstuff = (window.growstuff = window.growstuff || {}); - - /** - * Object for WidthScale - * @param {Object} data Graph configuration - */ - function WidthScale(data) { - this._data = data; - } - - WidthScale.prototype.render = function() { - var data = this._data; - var scaleType = data.width.scale; - var axisSize = data.width.size; - - return d3.scale[scaleType]() - .domain([0, this.getMaxValue()]) - .range([0, axisSize]); - }; - - WidthScale.prototype.getMaxValue = function() { - return d3.max(this._data.bars.map(function(bar) { - return bar.value; - })); - }; - - growstuff.WidthScale = WidthScale; -}()); diff --git a/app/assets/javascripts/highcharts.js b/app/assets/javascripts/highcharts.js new file mode 100644 index 000000000..9554ef58b --- /dev/null +++ b/app/assets/javascripts/highcharts.js @@ -0,0 +1,389 @@ +/* + Highcharts JS v6.0.4 (2017-12-15) + + (c) 2009-2016 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(S,M){"object"===typeof module&&module.exports?module.exports=S.document?M(S):M:S.Highcharts=M(S)})("undefined"!==typeof window?window:this,function(S){var M=function(){var a="undefined"===typeof S?window:S,E=a.document,D=a.navigator&&a.navigator.userAgent||"",H=E&&E.createElementNS&&!!E.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,p=/(edge|msie|trident)/i.test(D)&&!a.opera,f=/Firefox/.test(D),l=f&&4>parseInt(D.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16, +!0):{product:"Highcharts",version:"6.0.4",deg2rad:2*Math.PI/360,doc:E,hasBidiBug:l,hasTouch:E&&void 0!==E.documentElement.ontouchstart,isMS:p,isWebKit:/AppleWebKit/.test(D),isFirefox:f,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(D),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:H,win:a,marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){},charts:[]}}();(function(a){a.timers=[];var E=a.charts,D=a.doc,H=a.win;a.error=function(p, +f){p=a.isNumber(p)?"Highcharts error #"+p+": www.highcharts.com/errors/"+p:p;if(f)throw Error(p);H.console&&console.log(p)};a.Fx=function(a,f,l){this.options=f;this.elem=a;this.prop=l};a.Fx.prototype={dSetter:function(){var a=this.paths[0],f=this.paths[1],l=[],r=this.now,n=a.length,w;if(1===r)l=this.toD;else if(n===f.length&&1>r)for(;n--;)w=parseFloat(a[n]),l[n]=isNaN(w)?f[n]:r*parseFloat(f[n]-w)+w;else l=f;this.elem.attr("d",l,null,!0)},update:function(){var a=this.elem,f=this.prop,l=this.now,r= +this.options.step;if(this[f+"Setter"])this[f+"Setter"]();else a.attr?a.element&&a.attr(f,l,null,!0):a.style[f]=l+this.unit;r&&r.call(a,l,this)},run:function(p,f,l){var r=this,n=r.options,w=function(a){return w.stopped?!1:r.step(a)},u=H.requestAnimationFrame||function(a){setTimeout(a,13)},e=function(){for(var h=0;h=u+this.startTime?(this.now=this.end,this.pos=1,this.update(),l=e[this.prop]=!0,a.objectEach(e,function(a){!0!==a&&(l=!1)}),l&&w&&w.call(n),p=!1):(this.pos=r.easing((f-this.startTime)/u),this.now=this.start+(this.end- +this.start)*this.pos,this.update(),p=!0);return p},initPath:function(p,f,l){function r(a){var b,c;for(k=a.length;k--;)b="M"===a[k]||"L"===a[k],c=/[a-zA-Z]/.test(a[k+3]),b&&c&&a.splice(k+1,0,a[k+1],a[k+2],a[k+1],a[k+2])}function n(a,b){for(;a.lengtha&&-Infinityw?"AM":"PM",P:12>w?"am":"pm",S:k(n.getSeconds()),L:k(Math.round(f%1E3),3)},a.dateFormats);a.objectEach(r,function(a,b){for(;-1!==p.indexOf("%"+b);)p=p.replace("%"+b,"function"===typeof a?a(f):a)});return l?p.substr(0,1).toUpperCase()+p.substr(1):p};a.formatSingle=function(p,f){var l=/\.([0-9])/,r=a.defaultOptions.lang;/f$/.test(p)?(l=(l=p.match(l))?l[1]:-1,null!==f&&(f=a.numberFormat(f,l,r.decimalPoint,-1=l&&(f=[1/l])));for(r=0;r=p||!n&&w<=(f[r]+(f[r+1]||f[r]))/2);r++);return u=a.correctFloat(u*l,-Math.round(Math.log(.001)/Math.LN10))};a.stableSort=function(a,f){var l=a.length,p,n;for(n=0;nl&&(l=a[f]);return l};a.destroyObjectProperties=function(p,f){a.objectEach(p,function(a,r){a&&a!==f&&a.destroy&&a.destroy();delete p[r]})};a.discardElement=function(p){var f=a.garbageBin;f||(f=a.createElement("div"));p&&f.appendChild(p);f.innerHTML=""};a.correctFloat=function(a,f){return parseFloat(a.toPrecision(f||14))};a.setAnimation=function(p,f){f.renderer.globalAnimation=a.pick(p,f.options.chart.animation, +!0)};a.animObject=function(p){return a.isObject(p)?a.merge(p):{duration:p?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat=function(p,f,l,r){p=+p||0;f=+f;var n=a.defaultOptions.lang,w=(p.toString().split(".")[1]||"").split("e")[0].length,u,e,h=p.toString().split("e");-1===f?f=Math.min(w,20):a.isNumber(f)?f&&h[1]&&0>h[1]&&(u=f+ +h[1],0<=u?(h[0]=(+h[0]).toExponential(u).split("e")[0],f=u):(h[0]=h[0].split(".")[0]||0, +p=20>f?(h[0]*Math.pow(10,h[1])).toFixed(f):0,h[1]=0)):f=2;e=(Math.abs(h[1]?h[0]:p)+Math.pow(10,-Math.max(f,w)-1)).toFixed(f);w=String(a.pInt(e));u=3p?"-":"")+(u?w.substr(0,u)+r:"");p+=w.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+r);f&&(p+=l+e.slice(-f));h[1]&&0!==+p&&(p+="e"+h[1]);return p};Math.easeInOutSine=function(a){return-.5*(Math.cos(Math.PI*a)-1)};a.getStyle=function(p,f,l){if("width"===f)return Math.min(p.offsetWidth, +p.scrollWidth)-a.getStyle(p,"padding-left")-a.getStyle(p,"padding-right");if("height"===f)return Math.min(p.offsetHeight,p.scrollHeight)-a.getStyle(p,"padding-top")-a.getStyle(p,"padding-bottom");H.getComputedStyle||a.error(27,!0);if(p=H.getComputedStyle(p,void 0))p=p.getPropertyValue(f),a.pick(l,"opacity"!==f)&&(p=a.pInt(p));return p};a.inArray=function(p,f){return(a.indexOfPolyfill||Array.prototype.indexOf).call(f,p)};a.grep=function(p,f){return(a.filterPolyfill||Array.prototype.filter).call(p, +f)};a.find=Array.prototype.find?function(a,f){return a.find(f)}:function(a,f){var l,r=a.length;for(l=0;l>16,(l&65280)>> +8,l&255,1]:4===f&&(n=[(l&3840)>>4|(l&3840)>>8,(l&240)>>4|l&240,(l&15)<<4|l&15,1])),!n)for(w=this.parsers.length;w--&&!n;)u=this.parsers[w],(f=u.regex.exec(l))&&(n=u.parse(f));this.rgba=n||[]},get:function(a){var f=this.input,n=this.rgba,l;this.stops?(l=p(f),l.stops=[].concat(l.stops),E(this.stops,function(n,e){l.stops[e]=[l.stops[e][0],n.get(a)]})):l=n&&D(n[0])?"rgb"===a||!a&&1===n[3]?"rgb("+n[0]+","+n[1]+","+n[2]+")":"a"===a?n[3]:"rgba("+n.join(",")+")":f;return l},brighten:function(a){var l,n=this.rgba; +if(this.stops)E(this.stops,function(n){n.brighten(a)});else if(D(a)&&0!==a)for(l=0;3>l;l++)n[l]+=f(255*a),0>n[l]&&(n[l]=0),255y.width)y={width:0,height:0}}else y=this.htmlGetBBox();b.isSVG&& +(a=y.width,b=y.height,q&&"11px"===q.fontSize&&17===Math.round(b)&&(y.height=b=14),g&&(y.width=Math.abs(b*Math.sin(v))+Math.abs(a*Math.cos(v)),y.height=Math.abs(b*Math.cos(v))+Math.abs(a*Math.sin(v))));if(A&&0]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a,g,b){"string"===typeof a?b.setAttribute(g,a):a&&this.colorGradient(a,g,b)},visibilitySetter:function(a,g,b){"inherit"===a?b.removeAttribute(g):this[g]!==a&&b.setAttribute(g,a);this[g]=a},zIndexSetter:function(a,b){var v=this.renderer,y=this.parentGroup,c=(y||v).element||v.box,k,d=this.element,q,e,v=c===v.box;k=this.added;var z;u(a)&& +(d.zIndex=a,a=+a,this[b]===a&&(k=!1),this[b]=a);if(k){(a=this.zIndex)&&y&&(y.handleZ=!0);b=c.childNodes;for(z=b.length-1;0<=z&&!q;z--)if(y=b[z],k=y.zIndex,e=!u(k),y!==d)if(0>a&&e&&!v&&!z)c.insertBefore(d,b[z]),q=!0;else if(g(k)<=a||e&&(!u(a)||0<=a))c.insertBefore(d,b[z+1]||null),q=!0;q||(c.insertBefore(d,b[v?3:0]||null),q=!0)}return q},_defaultSetter:function(a,g,b){b.setAttribute(g,a)}});E.prototype.yGetter=E.prototype.xGetter;E.prototype.translateXSetter=E.prototype.translateYSetter=E.prototype.rotationSetter= +E.prototype.verticalAlignSetter=E.prototype.rotationOriginXSetter=E.prototype.rotationOriginYSetter=E.prototype.scaleXSetter=E.prototype.scaleYSetter=E.prototype.matrixSetter=function(a,g){this[g]=a;this.doTransform=!0};E.prototype["stroke-widthSetter"]=E.prototype.strokeSetter=function(a,g,b){this[g]=a;this.stroke&&this["stroke-width"]?(E.prototype.fillSetter.call(this,this.stroke,"stroke",b),b.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&& +(b.removeAttribute("stroke"),this.hasStroke=!1)};D=a.SVGRenderer=function(){this.init.apply(this,arguments)};c(D.prototype,{Element:E,SVG_NS:P,init:function(a,g,b,v,c,k){var y;v=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(v));y=v.element;a.appendChild(y);f(a,"dir","ltr");-1===a.innerHTML.indexOf("xmlns")&&f(y,"xmlns",this.SVG_NS);this.isSVG=!0;this.box=y;this.boxWrapper=v;this.alignedObjects=[];this.url=(x||N)&&m.getElementsByTagName("base").length? +R.location.href.replace(/#.*?$/,"").replace(/<[^>]*>/g,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(m.createTextNode("Created with Highcharts 6.0.4"));this.defs=this.createElement("defs").add();this.allowHTML=k;this.forExport=c;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,b,!1);var d;x&&a.getBoundingClientRect&&(g=function(){n(a,{left:0,top:0});d=a.getBoundingClientRect();n(a,{left:Math.ceil(d.left)- +d.left+"px",top:Math.ceil(d.top)-d.top+"px"})},g(),this.unSubPixelFix=H(R,"resize",g))},getStyle:function(a){return this.style=c({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();h(this.gradients||{});this.gradients=null;a&&(this.defs=a.destroy()); +this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:A,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},getSpanWidth:function(a,g){var b=a.getBBox(!0).width;!L&&this.forExport&&(b=this.measureSpanWidth(g.firstChild.data,a.styles));return b},applyEllipsis:function(a,g,b,v){var c=a.rotation,y=b,k,d=0,q=b.length,e=function(a){g.removeChild(g.firstChild); +a&&g.appendChild(m.createTextNode(a))},z;a.rotation=0;y=this.getSpanWidth(a,g);if(z=y>v){for(;d<=q;)k=Math.ceil((d+q)/2),y=b.substring(0,k)+"\u2026",e(y),y=this.getSpanWidth(a,g),d===q?d=q+1:y>v?q=k-1:d=k;0===q&&e("")}a.rotation=c;return z},escapes:{"\x26":"\x26amp;","\x3c":"\x26lt;","\x3e":"\x26gt;","'":"\x26#39;",'"':"\x26quot;"},buildText:function(a){var b=a.element,v=this,c=v.forExport,y=G(a.textStr,"").toString(),q=-1!==y.indexOf("\x3c"),e=b.childNodes,z,h,A,J,t=f(b,"x"),x=a.styles,B=a.textWidth, +l=x&&x.lineHeight,C=x&&x.textOutline,u=x&&"ellipsis"===x.textOverflow,Q=x&&"nowrap"===x.whiteSpace,w=x&&x.fontSize,R,I,r=e.length,x=B&&!a.added&&this.box,p=function(a){var c;c=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:w||v.style.fontSize||12;return l?g(l):v.fontMetrics(c,a.getAttribute("style")?a:b).h},K=function(a){F(v.escapes,function(g,b){a=a.replace(new RegExp(g,"g"),b)});return a};R=[y,u,Q,l,C,w,B].join();if(R!==a.textCache){for(a.textCache=R;r--;)b.removeChild(e[r]);q||C||u||B|| +-1!==y.indexOf(" ")?(z=/<.*class="([^"]+)".*>/,h=/<.*style="([^"]+)".*>/,A=/<.*href="([^"]+)".*>/,x&&x.appendChild(b),y=q?y.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g,'\x3cspan style\x3d"font-style:italic"\x3e').replace(//g,"\x3c/span\x3e").split(//g):[y],y=k(y,function(a){return""!==a}),d(y,function(g,y){var k,q=0;g=g.replace(/^\s+|\s+$/g,"").replace(//g,"\x3c/span\x3e|||"); +k=g.split("|||");d(k,function(g){if(""!==g||1===k.length){var d={},e=m.createElementNS(v.SVG_NS,"tspan"),x,F;z.test(g)&&(x=g.match(z)[1],f(e,"class",x));h.test(g)&&(F=g.match(h)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),f(e,"style",F));A.test(g)&&!c&&(f(e,"onclick",'location.href\x3d"'+g.match(A)[1]+'"'),f(e,"class","highcharts-anchor"),n(e,{cursor:"pointer"}));g=K(g.replace(/<[a-zA-Z\/](.|\n)*?>/g,"")||" ");if(" "!==g){e.appendChild(m.createTextNode(g));q?d.dx=0:y&&null!==t&&(d.x=t);f(e,d);b.appendChild(e); +!q&&I&&(!L&&c&&n(e,{display:"block"}),f(e,"dy",p(e)));if(B){d=g.replace(/([^\^])-/g,"$1- ").split(" ");x=1B,void 0===J&&(J=g),g&&1!==d.length?(e.removeChild(e.firstChild),O.unshift(d.pop())):(d=O,O=[],d.length&&!Q&&(e=m.createElementNS(P,"tspan"),f(e,{dy:C,x:t}),F&&f(e,"style",F),b.appendChild(e)),l>B&&(B=l)),d.length&&e.appendChild(m.createTextNode(d.join(" ").replace(/- /g, +"-")));a.rotation=G}q++}}});I=I||b.childNodes.length}),J&&a.attr("title",a.textStr),x&&x.removeChild(b),C&&a.applyTextOutline&&a.applyTextOutline(C)):b.appendChild(m.createTextNode(K(y)))}},getContrast:function(a){a=r(a).rgba;return 510Math.abs(c.end-c.start-2*Math.PI));var y=Math.cos(k),z=Math.sin(k),h=Math.cos(e),e=Math.sin(e);c=.001>c.end-k-Math.PI?0:1;d=["M",a+d*y,g+q*z,"A",d,q,0,c,1,a+d*h,g+q*e];u(b)&&d.push(v?"M":"L",a+b* +h,g+b*e,"A",b,b,0,c,0,a+b*y,g+b*z);d.push(v?"":"Z");return d},callout:function(a,g,b,v,c){var d=Math.min(c&&c.r||0,b,v),k=d+6,q=c&&c.anchorX;c=c&&c.anchorY;var e;e=["M",a+d,g,"L",a+b-d,g,"C",a+b,g,a+b,g,a+b,g+d,"L",a+b,g+v-d,"C",a+b,g+v,a+b,g+v,a+b-d,g+v,"L",a+d,g+v,"C",a,g+v,a,g+v,a,g+v-d,"L",a,g+d,"C",a,g,a,g,a+d,g];q&&q>b?c>g+k&&cq?c>g+k&&cv&&q>a+k&&qc&&q>a+k&&qa?a+3:Math.round(1.2*a);return{h:b,b:Math.round(.8* +b),f:a}},rotCorr:function(a,g,b){var v=a;g&&b&&(v=Math.max(v*Math.cos(g*e),4));return{x:-a/3*Math.sin(g*e),y:v}},label:function(g,b,k,e,z,h,m,A,L){var y=this,J=y.g("button"!==L&&"label"),t=J.text=y.text("",0,0,m).attr({zIndex:1}),x,F,n=0,B=3,l=0,C,f,Q,G,w,R={},I,P,r=/^url\((.*?)\)$/.test(e),p=r,K,O,N,T;L&&J.addClass("highcharts-"+L);p=r;K=function(){return(I||0)%2/2};O=function(){var a=t.element.style,g={};F=(void 0===C||void 0===f||w)&&u(t.textStr)&&t.getBBox();J.width=(C||F.width||0)+2*B+l;J.height= +(f||F.height||0)+2*B;P=B+y.fontMetrics(a&&a.fontSize,t).b;p&&(x||(J.box=x=y.symbols[e]||r?y.symbol(e):y.rect(),x.addClass(("button"===L?"":"highcharts-label-box")+(L?" highcharts-"+L+"-box":"")),x.add(J),a=K(),g.x=a,g.y=(A?-P:0)+a),g.width=Math.round(J.width),g.height=Math.round(J.height),x.attr(c(g,R)),R={})};N=function(){var a=l+B,g;g=A?0:P;u(C)&&F&&("center"===w||"right"===w)&&(a+={center:.5,right:1}[w]*(C-F.width));if(a!==t.x||g!==t.y)t.attr("x",a),void 0!==g&&t.attr("y",g);t.x=a;t.y=g};T=function(a, +g){x?x.attr(a,g):R[a]=g};J.onAdd=function(){t.add(J);J.attr({text:g||0===g?g:"",x:b,y:k});x&&u(z)&&J.attr({anchorX:z,anchorY:h})};J.widthSetter=function(g){C=a.isNumber(g)?g:null};J.heightSetter=function(a){f=a};J["text-alignSetter"]=function(a){w=a};J.paddingSetter=function(a){u(a)&&a!==B&&(B=J.padding=a,N())};J.paddingLeftSetter=function(a){u(a)&&a!==l&&(l=a,N())};J.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==n&&(n=a,F&&J.attr({x:Q}))};J.textSetter=function(a){void 0!==a&&t.textSetter(a); +O();N()};J["stroke-widthSetter"]=function(a,g){a&&(p=!0);I=this["stroke-width"]=a;T(g,a)};J.strokeSetter=J.fillSetter=J.rSetter=function(a,g){"r"!==g&&("fill"===g&&a&&(p=!0),J[g]=a);T(g,a)};J.anchorXSetter=function(a,g){z=J.anchorX=a;T(g,Math.round(a)-K()-Q)};J.anchorYSetter=function(a,g){h=J.anchorY=a;T(g,a-G)};J.xSetter=function(a){J.x=a;n&&(a-=n*((C||F.width)+2*B));Q=Math.round(a);J.attr("translateX",Q)};J.ySetter=function(a){G=J.y=Math.round(a);J.attr("translateY",G)};var U=J.css;return c(J,{css:function(a){if(a){var g= +{};a=q(a);d(J.textProps,function(b){void 0!==a[b]&&(g[b]=a[b],delete a[b])});t.css(g)}return U.call(J,a)},getBBox:function(){return{width:F.width+2*B,height:F.height+2*B,x:F.x-B,y:F.y-B}},shadow:function(a){a&&(O(),x&&x.shadow(a));return J},destroy:function(){v(J.element,"mouseenter");v(J.element,"mouseleave");t&&(t=t.destroy());x&&(x=x.destroy());E.prototype.destroy.call(J);J=y=O=N=T=null}})}});a.Renderer=D})(M);(function(a){var E=a.attr,D=a.createElement,H=a.css,p=a.defined,f=a.each,l=a.extend, +r=a.isFirefox,n=a.isMS,w=a.isWebKit,u=a.pick,e=a.pInt,h=a.SVGRenderer,m=a.win,d=a.wrap;l(a.SVGElement.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&"SPAN"===b.tagName&&a.width)delete a.width,this.textWidth=b,this.updateTransform();a&&"ellipsis"===a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=l(this.styles,a);H(this.element,a);return this},htmlGetBBox:function(){var a=this.element;return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}, +htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,d=this.translateX||0,z=this.translateY||0,h=this.x||0,m=this.y||0,x=this.textAlign||"left",n={left:0,center:.5,right:1}[x],t=this.styles;H(b,{marginLeft:d,marginTop:z});this.shadows&&f(this.shadows,function(a){H(a,{marginLeft:d+1,marginTop:z+1})});this.inverted&&f(b.childNodes,function(c){a.invertChild(c,b)});if("SPAN"===b.tagName){var l=this.rotation,u=e(this.textWidth),q=t&&t.whiteSpace,A=[l,x,b.innerHTML,this.textWidth, +this.textAlign].join();A!==this.cTT&&(t=a.fontMetrics(b.style.fontSize).b,p(l)&&this.setSpanRotation(l,n,t),H(b,{width:"",whiteSpace:q||"nowrap"}),b.offsetWidth>u&&/[ \-]/.test(b.textContent||b.innerText)&&H(b,{width:u+"px",display:"block",whiteSpace:q||"normal"}),this.getSpanCorrection(b.offsetWidth,t,n,l,x));H(b,{left:h+(this.xCorr||0)+"px",top:m+(this.yCorr||0)+"px"});w&&(t=b.offsetHeight);this.cTT=A}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,d){var c={},k=this.renderer.getTransformKey(); +c[k]=c.transform="rotate("+a+"deg)";c[k+(r?"Origin":"-origin")]=c.transformOrigin=100*b+"% "+d+"px";H(this.element,c)},getSpanCorrection:function(a,b,d){this.xCorr=-a*d;this.yCorr=-b}});l(h.prototype,{getTransformKey:function(){return n&&!/Edge/.test(m.navigator.userAgent)?"-ms-transform":w?"-webkit-transform":r?"MozTransform":m.opera?"-o-transform":""},html:function(a,b,k){var c=this.createElement("span"),e=c.element,h=c.renderer,m=h.isSVG,w=function(a,b){f(["opacity","visibility"],function(c){d(a, +c+"Setter",function(a,c,d,k){a.call(this,c,d,k);b[d]=c})})};c.textSetter=function(a){a!==e.innerHTML&&delete this.bBox;this.textStr=a;e.innerHTML=u(a,"");c.htmlUpdateTransform()};m&&w(c,c.element.style);c.xSetter=c.ySetter=c.alignSetter=c.rotationSetter=function(a,b){"align"===b&&(b="textAlign");c[b]=a;c.htmlUpdateTransform()};c.attr({text:a,x:Math.round(b),y:Math.round(k)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});e.style.whiteSpace="nowrap";c.css= +c.htmlCss;m&&(c.add=function(a){var b,d=h.box.parentNode,k=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)k.push(a),a=a.parentGroup;f(k.reverse(),function(a){function e(g,b){a[b]=g;n?q[h.getTransformKey()]="translate("+(a.x||a.translateX)+"px,"+(a.y||a.translateY)+"px)":"translateX"===b?q.left=g+"px":q.top=g+"px";a.doTransform=!0}var q,g=E(a.element,"class");g&&(g={className:g});b=a.div=a.div||D("div",g,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display, +opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||d);q=b.style;l(a,{classSetter:function(a){return function(g){this.element.setAttribute("class",g);a.className=g}}(b),on:function(){k[0].div&&c.on.apply({element:k[0].div},arguments);return a},translateXSetter:e,translateYSetter:e});w(a,q)})}}else b=d;b.appendChild(e);c.added=!0;c.alignOnAdd&&c.htmlUpdateTransform();return c});return c}})})(M);(function(a){function E(){var n=a.defaultOptions.global,l=r.moment;if(n.timezone){if(l)return function(a){return-l.tz(a, +n.timezone).utcOffset()};a.error(25)}return n.useUTC&&n.getTimezoneOffset}function D(){var n=a.defaultOptions.global,f,u=n.useUTC,e=u?"getUTC":"get",h=u?"setUTC":"set",m="Minutes Hours Day Date Month FullYear".split(" "),d=m.concat(["Milliseconds","Seconds"]);a.Date=f=n.Date||r.Date;f.hcTimezoneOffset=u&&n.timezoneOffset;f.hcGetTimezoneOffset=E();f.hcHasTimeZone=!(!f.hcTimezoneOffset&&!f.hcGetTimezoneOffset);f.hcMakeTime=function(a,b,d,e,h,m){var c;u?(c=f.UTC.apply(0,arguments),c+=p(c)):c=(new f(a, +b,l(d,1),l(e,0),l(h,0),l(m,0))).getTime();return c};for(n=0;nb&&e-k*zm&&(p=Math.round((h-e)/Math.cos(b*r)));else if(h=e+(1-k)*z,e-k*zm&&(I=m-a.x+I*k,x=-1),I=Math.min(B,I),II||f.autoRotation&&(c.styles||{}).width)p=I;p&&(t.width=p,(n.style||{}).textOverflow||(t.textOverflow="ellipsis"),c.css(t))},getPosition:function(a,f,l,e){var h=this.axis,m=h.chart,d=e&&m.oldChartHeight||m.chartHeight;return{x:a?h.translate(f+l,null,null,e)+h.transB:h.left+h.offset+(h.opposite?(e&&m.oldChartWidth||m.chartWidth)-h.right-h.left:0),y:a?d-h.bottom+h.offset-(h.opposite?h.height:0):d-h.translate(f+l,null,null,e)-h.transB}},getLabelPosition:function(a, +f,l,e,h,m,d,c){var b=this.axis,k=b.transA,z=b.reversed,B=b.staggerLines,n=b.tickRotCorr||{x:0,y:0},x=h.y,u=e||b.reserveSpaceDefault?0:-b.labelOffset*("center"===b.labelAlign?.5:1);D(x)||(x=0===b.side?l.rotation?-8:-l.getBBox().height:2===b.side?n.y+8:Math.cos(l.rotation*r)*(n.y-l.getBBox(!1,0).height/2));a=a+h.x+u+n.x-(m&&e?m*k*(z?-1:1):0);f=f+x-(m&&!e?m*k*(z?1:-1):0);B&&(l=d/(c||1)%B,b.opposite&&(l=B-l-1),f+=b.labelOffset/B*l);return{x:a,y:Math.round(f)}},getMarkPath:function(a,f,l,e,h,m){return m.crispLine(["M", +a,f,"L",a+(h?0:-l),f+(h?l:0)],e)},renderGridLine:function(a,f,l){var e=this.axis,h=e.options,m=this.gridLine,d={},c=this.pos,b=this.type,k=e.tickmarkOffset,z=e.chart.renderer,B=b?b+"Grid":"grid",n=h[B+"LineWidth"],x=h[B+"LineColor"],h=h[B+"LineDashStyle"];m||(d.stroke=x,d["stroke-width"]=n,h&&(d.dashstyle=h),b||(d.zIndex=1),a&&(d.opacity=0),this.gridLine=m=z.path().attr(d).addClass("highcharts-"+(b?b+"-":"")+"grid-line").add(e.gridGroup));if(!a&&m&&(a=e.getPlotLinePath(c+k,m.strokeWidth()*l,a,!0)))m[this.isNew? +"attr":"animate"]({d:a,opacity:f})},renderMark:function(a,f,u){var e=this.axis,h=e.options,m=e.chart.renderer,d=this.type,c=d?d+"Tick":"tick",b=e.tickSize(c),k=this.mark,z=!k,B=a.x;a=a.y;var n=l(h[c+"Width"],!d&&e.isXAxis?1:0),h=h[c+"Color"];b&&(e.opposite&&(b[0]=-b[0]),z&&(this.mark=k=m.path().addClass("highcharts-"+(d?d+"-":"")+"tick").add(e.axisGroup),k.attr({stroke:h,"stroke-width":n})),k[z?"attr":"animate"]({d:this.getMarkPath(B,a,b[0],k.strokeWidth()*u,e.horiz,m),opacity:f}))},renderLabel:function(a, +f,u,e){var h=this.axis,m=h.horiz,d=h.options,c=this.label,b=d.labels,k=b.step,h=h.tickmarkOffset,z=!0,B=a.x;a=a.y;c&&p(B)&&(c.xy=a=this.getLabelPosition(B,a,c,m,b,h,e,k),this.isFirst&&!this.isLast&&!l(d.showFirstLabel,1)||this.isLast&&!this.isFirst&&!l(d.showLastLabel,1)?z=!1:!m||b.step||b.rotation||f||0===u||this.handleOverflow(a),k&&e%k&&(z=!1),z&&p(a.y)?(a.opacity=u,c[this.isNewLabel?"attr":"animate"](a),this.isNewLabel=!1):(c.attr("y",-9999),this.isNewLabel=!0))},render:function(a,f,u){var e= +this.axis,h=e.horiz,m=this.getPosition(h,this.pos,e.tickmarkOffset,f),d=m.x,c=m.y,e=h&&d===e.pos+e.len||!h&&c===e.pos?-1:1;u=l(u,1);this.isActive=!0;this.renderGridLine(f,u,e);this.renderMark(m,u,e);this.renderLabel(m,f,u,a);this.isNew=!1},destroy:function(){H(this,this.axis)}}})(M);var V=function(a){var E=a.addEvent,D=a.animObject,H=a.arrayMax,p=a.arrayMin,f=a.color,l=a.correctFloat,r=a.defaultOptions,n=a.defined,w=a.deg2rad,u=a.destroyObjectProperties,e=a.each,h=a.extend,m=a.fireEvent,d=a.format, +c=a.getMagnitude,b=a.grep,k=a.inArray,z=a.isArray,B=a.isNumber,I=a.isString,x=a.merge,K=a.normalizeTickInterval,t=a.objectEach,C=a.pick,N=a.removeEvent,q=a.splat,A=a.syncTimeout,F=a.Tick,G=function(){this.init.apply(this,arguments)};a.extend(G.prototype,{defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"}, +x:0},maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",minPadding:.01,startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",lineColor:"#ccd6eb",lineWidth:1,gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05, +minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{allowOverlap:!1,enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45], +x:0},title:{rotation:0}},init:function(a,b){var g=b.isX,v=this;v.chart=a;v.horiz=a.inverted&&!v.isZAxis?!g:g;v.isXAxis=g;v.coll=v.coll||(g?"xAxis":"yAxis");v.opposite=b.opposite;v.side=b.side||(v.horiz?v.opposite?0:2:v.opposite?1:3);v.setOptions(b);var c=this.options,d=c.type;v.labelFormatter=c.labels.formatter||v.defaultLabelFormatter;v.userOptions=b;v.minPixelPadding=0;v.reversed=c.reversed;v.visible=!1!==c.visible;v.zoomEnabled=!1!==c.zoomEnabled;v.hasNames="category"===d||!0===c.categories;v.categories= +c.categories||v.hasNames;v.names=v.names||[];v.plotLinesAndBandsGroups={};v.isLog="logarithmic"===d;v.isDatetimeAxis="datetime"===d;v.positiveValuesOnly=v.isLog&&!v.allowNegativeLog;v.isLinked=n(c.linkedTo);v.ticks={};v.labelEdge=[];v.minorTicks={};v.plotLinesAndBands=[];v.alternateBands={};v.len=0;v.minRange=v.userMinRange=c.minRange||c.maxZoom;v.range=c.range;v.offset=c.offset||0;v.stacks={};v.oldStacks={};v.stacksTouched=0;v.max=null;v.min=null;v.crosshair=C(c.crosshair,q(a.options.tooltip.crosshairs)[g? +0:1],!1);b=v.options.events;-1===k(v,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,v):a.axes.push(v),a[v.coll].push(v));v.series=v.series||[];a.inverted&&!v.isZAxis&&g&&void 0===v.reversed&&(v.reversed=!0);t(b,function(a,g){E(v,g,a)});v.lin2log=c.linearToLogConverter||v.lin2log;v.isLog&&(v.val2lin=v.log2lin,v.lin2val=v.lin2log)},setOptions:function(a){this.options=x(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions, +this.defaultLeftAxisOptions][this.side],x(r[this.coll],a))},defaultLabelFormatter:function(){var g=this.axis,b=this.value,c=g.categories,k=this.dateTimeLabelFormat,e=r.lang,q=e.numericSymbols,e=e.numericSymbolMagnitude||1E3,h=q&&q.length,m,z=g.options.labels.format,g=g.isLog?Math.abs(b):g.tickInterval;if(z)m=d(z,this);else if(c)m=b;else if(k)m=a.dateFormat(k,b);else if(h&&1E3<=g)for(;h--&&void 0===m;)c=Math.pow(e,h+1),g>=c&&0===10*b%c&&null!==q[h]&&0!==b&&(m=a.numberFormat(b/c,-1)+q[h]);void 0=== +m&&(m=1E4<=Math.abs(b)?a.numberFormat(b,-1):a.numberFormat(b,-1,void 0,""));return m},getSeriesExtremes:function(){var a=this,v=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();e(a.series,function(g){if(g.visible||!v.options.chart.ignoreHiddenSeries){var c=g.options,d=c.threshold,k;a.hasVisibleSeries=!0;a.positiveValuesOnly&&0>=d&&(d=null);if(a.isXAxis)c=g.xData,c.length&&(g=p(c),k=H(c),B(g)||g instanceof Date||(c=b(c,B), +g=p(c)),a.dataMin=Math.min(C(a.dataMin,c[0],g),g),a.dataMax=Math.max(C(a.dataMax,c[0],k),k));else if(g.getExtremes(),k=g.dataMax,g=g.dataMin,n(g)&&n(k)&&(a.dataMin=Math.min(C(a.dataMin,g),g),a.dataMax=Math.max(C(a.dataMax,k),k)),n(d)&&(a.threshold=d),!c.softThreshold||a.positiveValuesOnly)a.softThreshold=!1}})},translate:function(a,b,c,d,k,e){var g=this.linkedParent||this,v=1,q=0,h=d?g.oldTransA:g.transA;d=d?g.oldMin:g.min;var m=g.minPixelPadding;k=(g.isOrdinal||g.isBroken||g.isLog&&k)&&g.lin2val; +h||(h=g.transA);c&&(v*=-1,q=g.len);g.reversed&&(v*=-1,q-=v*(g.sector||g.len));b?(a=(a*v+q-m)/h+d,k&&(a=g.lin2val(a))):(k&&(a=g.val2lin(a)),a=B(d)?v*(a-d)*h+q+v*m+(B(e)?h*e:0):void 0);return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,k){var g=this.chart,v=this.left,q=this.top,e,h,m=c&&g.oldChartHeight||g.chartHeight,z=c&&g.oldChartWidth|| +g.chartWidth,A;e=this.transB;var t=function(a,g,b){if(ab)d?a=Math.min(Math.max(g,a),b):A=!0;return a};k=C(k,this.translate(a,null,null,c));a=c=Math.round(k+e);e=h=Math.round(m-k-e);B(k)?this.horiz?(e=q,h=m-this.bottom,a=c=t(a,v,v+this.width)):(a=v,c=z-this.right,e=h=t(e,q,q+this.height)):(A=!0,d=!1);return A&&!d?null:g.renderer.crispLine(["M",a,e,"L",c,h],b||1)},getLinearTickPositions:function(a,b,c){var g,v=l(Math.floor(b/a)*a);c=l(Math.ceil(c/a)*a);var d=[],k;l(v+a)===v&&(k=20);if(this.single)return[b]; +for(b=v;b<=c;){d.push(b);b=l(b+a,k);if(b===g)break;g=b}return d},getMinorTickInterval:function(){var a=this.options;return!0===a.minorTicks?C(a.minorTickInterval,"auto"):!1===a.minorTicks?null:a.minorTickInterval},getMinorTickPositions:function(){var a=this,b=a.options,c=a.tickPositions,d=a.minorTickInterval,k=[],q=a.pointRangePadding||0,h=a.min-q,q=a.max+q,m=q-h;if(m&&m/d=this.minRange,t=this.minRange,d=(t-c+b)/2,d=[b-d,C(a.min,b-d)],k&&(d[2]=this.isLog?this.log2lin(this.dataMin):this.dataMin),b=H(d),c=[b+t,C(a.max,b+t)],k&&(c[2]=this.isLog?this.log2lin(this.dataMax):this.dataMax),c=p(c),c-b=p?(r=p,f=0):b.dataMax<=p&&(w=p,x=0)),b.min= +C(N,r,b.dataMin),b.max=C(D,w,b.dataMax));q&&(b.positiveValuesOnly&&!g&&0>=Math.min(b.min,C(b.dataMin,b.min))&&a.error(10,1),b.min=l(h(b.min),15),b.max=l(h(b.max),15));b.range&&n(b.max)&&(b.userMin=b.min=N=Math.max(b.dataMin,b.minFromRange()),b.userMax=D=b.max,b.range=null);m(b,"foundExtremes");b.beforePadding&&b.beforePadding();b.adjustForMinRange();!(G||b.axisPointRange||b.usePercentage||t)&&n(b.min)&&n(b.max)&&(h=b.max-b.min)&&(!n(N)&&f&&(b.min-=h*f),!n(D)&&x&&(b.max+=h*x));B(k.softMin)&&!B(b.userMin)&& +(b.min=Math.min(b.min,k.softMin));B(k.softMax)&&!B(b.userMax)&&(b.max=Math.max(b.max,k.softMax));B(k.floor)&&(b.min=Math.max(b.min,k.floor));B(k.ceiling)&&(b.max=Math.min(b.max,k.ceiling));I&&n(b.dataMin)&&(p=p||0,!n(N)&&b.min=p?b.min=p:!n(D)&&b.max>p&&b.dataMax<=p&&(b.max=p));b.tickInterval=b.min===b.max||void 0===b.min||void 0===b.max?1:t&&!F&&u===b.linkedParent.options.tickPixelInterval?F=b.linkedParent.tickInterval:C(F,this.tickAmount?(b.max-b.min)/Math.max(this.tickAmount-1,1): +void 0,G?1:(b.max-b.min)*u/Math.max(b.len,u));A&&!g&&e(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();b.postProcessTickInterval&&(b.tickInterval=b.postProcessTickInterval(b.tickInterval));b.pointRange&&!F&&(b.tickInterval=Math.max(b.pointRange,b.tickInterval));g=C(k.minTickInterval,b.isDatetimeAxis&&b.closestPointRange);!F&&b.tickIntervalb.tickInterval&&1E3b.max)),!!this.tickAmount));this.tickAmount||(b.tickInterval=b.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions;b=this.getMinorTickInterval();var d=a.tickPositioner,k=a.startOnTick,q=a.endOnTick;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval="auto"===b&&this.tickInterval?this.tickInterval/ +5:b;this.single=this.min===this.max&&n(this.min)&&!this.tickAmount&&(parseInt(this.min,10)===this.min||!1!==a.allowDecimals);this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,this.min,this.max),b.length>this.len&&(b= +[b[0],b.pop()],b[0]===b[1]&&(b.length=1)),this.tickPositions=b,d&&(d=d.apply(this,[this.min,this.max])))&&(this.tickPositions=b=d);this.paddedTicks=b.slice(0);this.trimTicks(b,k,q);this.isLinked||(this.single&&2>b.length&&(this.min-=.5,this.max+=.5),c||d||this.adjustTickAmount())},trimTicks:function(a,b,c){var g=a[0],d=a[a.length-1],k=this.minPointOffset||0;if(!this.isLinked){if(b&&-Infinity!==g)this.min=g;else for(;this.min-k>a[0];)a.shift();if(c)this.max=d;else for(;this.max+kb&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,d=this.finalTickAmt,k=b&&b.length,q=C(this.threshold,this.softThreshold?0:null);if(this.hasData()){if(kc&&(this.tickInterval*= +2,this.setTickPositions());if(n(d)){for(a=c=b.length;a--;)(3===d&&1===a%2||2>=d&&0d&&(a=d)),n(c)&&(bd&&(b=d))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var b=this.chart,c=this.options,d=c.offsets||[0,0,0,0],k=this.horiz,q=this.width=Math.round(a.relativeLength(C(c.width,b.plotWidth-d[3]+d[1]),b.plotWidth)),e=this.height=Math.round(a.relativeLength(C(c.height, +b.plotHeight-d[0]+d[2]),b.plotHeight)),h=this.top=Math.round(a.relativeLength(C(c.top,b.plotTop+d[0]),b.plotHeight,b.plotTop)),c=this.left=Math.round(a.relativeLength(C(c.left,b.plotLeft+d[3]),b.plotWidth,b.plotLeft));this.bottom=b.chartHeight-e-h;this.right=b.chartWidth-q-c;this.len=Math.max(k?q:e,0);this.pos=k?c:h},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?l(b(this.min)):this.min,max:a?l(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin, +userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,g=this.lin2log,c=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=c:c>a?a=c:ba?"right":195a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],c=C(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(c&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,c]},labelMetrics:function(){var a= +this.tickPositions&&this.tickPositions[0]||0;return this.chart.renderer.fontMetrics(this.options.labels.style&&this.options.labels.style.fontSize,this.ticks[a]&&this.ticks[a].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,c=this.tickInterval,d=c,k=this.len/(((this.categories?1:0)+this.max-this.min)/c),q,h=a.rotation,m=this.labelMetrics(),z,A=Number.MAX_VALUE,t,x=function(a){a/=k||1;a=1=a)z=x(Math.abs(m.h/Math.sin(w*a))),b=z+Math.abs(a/360),b(c.step||0)&&!c.rotation&&(this.staggerLines||1)*this.len/d||!b&&(c.style&&parseInt(c.style.width,10)||k&&k-a.spacing[3]|| +.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,c=this.tickPositions,d=this.ticks,k=this.options.labels,q=this.horiz,h=this.getSlotWidth(),m=Math.max(1,Math.round(h-2*(k.padding||5))),z={},A=this.labelMetrics(),t=k.style&&k.style.textOverflow,f,F=0,l,B;I(k.rotation)||(z.rotation=k.rotation||0);e(c,function(a){(a=d[a])&&a.labelLength>F&&(F=a.labelLength)});this.maxLabelLength=F;if(this.autoRotation)F>m&&F>A.h?z.rotation=this.labelRotation:this.labelRotation=0;else if(h&& +(f={width:m+"px"},!t))for(f.textOverflow="clip",l=c.length;!q&&l--;)if(B=c[l],m=d[B].label)m.styles&&"ellipsis"===m.styles.textOverflow?m.css({textOverflow:"clip"}):d[B].labelLength>h&&m.css({width:h+"px"}),m.getBBox().height>this.len/c.length-(A.h-A.f)&&(m.specCss={textOverflow:"ellipsis"});z.rotation&&(f={width:(F>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},t||(f.textOverflow="ellipsis"));if(this.labelAlign=k.align||this.autoLabelAlign(this.labelRotation))z.align=this.labelAlign;e(c, +function(a){var b=(a=d[a])&&a.label;b&&(b.attr(z),f&&b.css(x(f,b.specCss)),delete b.specCss,a.rotation=z.rotation)});this.tickRotCorr=b.rotCorr(A.b,this.labelRotation||0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||n(this.min)&&n(this.max)&&this.tickPositions&&0=this.min&&a<=this.max)g[a]||(g[a]=new F(this,a)),d&&g[a].isNew&&g[a].render(b,!0,.1),g[a].render(b)},render:function(){var b= +this,c=b.chart,d=b.options,k=b.isLog,q=b.lin2log,h=b.isLinked,m=b.tickPositions,z=b.axisTitle,x=b.ticks,f=b.minorTicks,l=b.alternateBands,C=d.stackLabels,n=d.alternateGridColor,u=b.tickmarkOffset,G=b.axisLine,p=b.showAxis,I=D(c.renderer.globalAnimation),r,w;b.labelEdge.length=0;b.overlap=!1;e([x,f,l],function(a){t(a,function(a){a.isActive=!1})});if(b.hasData()||h)b.minorTickInterval&&!b.categories&&e(b.getMinorTickPositions(),function(a){b.renderMinorTick(a)}),m.length&&(e(m,function(a,c){b.renderTick(a, +c)}),u&&(0===b.min||b.single)&&(x[-1]||(x[-1]=new F(b,-1,null,!0)),x[-1].render(-1))),n&&e(m,function(d,g){w=void 0!==m[g+1]?m[g+1]+u:b.max-u;0===g%2&&d=h.second?0:C*Math.floor(x.getMilliseconds()/C));if(t>=h.second)x[D.hcSetSeconds](t>=h.minute? +0:C*Math.floor(x.getSeconds()/C));if(t>=h.minute)x[D.hcSetMinutes](t>=h.hour?0:C*Math.floor(x[D.hcGetMinutes]()/C));if(t>=h.hour)x[D.hcSetHours](t>=h.day?0:C*Math.floor(x[D.hcGetHours]()/C));if(t>=h.day)x[D.hcSetDate](t>=h.month?1:C*Math.floor(x[D.hcGetDate]()/C));t>=h.month&&(x[D.hcSetMonth](t>=h.year?0:C*Math.floor(x[D.hcGetMonth]()/C)),n=x[D.hcGetFullYear]());if(t>=h.year)x[D.hcSetFullYear](n-n%C);if(t===h.week)x[D.hcSetDate](x[D.hcGetDate]()-x[D.hcGetDay]()+e(b,1));n=x[D.hcGetFullYear]();b=x[D.hcGetMonth](); +var A=x[D.hcGetDate](),F=x[D.hcGetHours]();d=x.getTime();D.hcHasTimeZone&&(q=(!B||!!D.hcGetTimezoneOffset)&&(c-d>4*h.month||w(d)!==w(c)),N=w(x),x=new D(d+N));B=x.getTime();for(d=1;Bk.length&&l(k,function(a){0===a%18E5&&"000000000"===H("%H%M%S%L",a)&&(m[a]="day")})}k.info=r(a,{higherRanks:m,totalRange:t*C});return k}; +E.prototype.normalizeTimeTickInterval=function(a,d){var c=d||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]];d=c[c.length-1];var b=h[d[0]],k=d[1],e;for(e=0;er&&(!w||z<=n)&&void 0!==z&&d.push(z),z>n&& +(B=!0),z=k;else r=h(r),n=h(n),a=w?this.getMinorTickInterval():l.tickInterval,a=f("auto"===a?null:a,this._minorAutoInterval,l.tickPixelInterval/(w?5:1)*(n-r)/((w?e/this.tickPositions.length:e)||1)),a=p(a,null,D(a)),d=H(this.getLinearTickPositions(a,r,n),m),w||(this._minorAutoInterval=a/5);w||(this.tickInterval=a);return d};E.prototype.log2lin=function(a){return Math.log(a)/Math.LN10};E.prototype.lin2log=function(a){return Math.pow(10,a)}})(M);(function(a,E){var D=a.arrayMax,H=a.arrayMin,p=a.defined, +f=a.destroyObjectProperties,l=a.each,r=a.erase,n=a.merge,w=a.pick;a.PlotLineOrBand=function(a,e){this.axis=a;e&&(this.options=e,this.id=e.id)};a.PlotLineOrBand.prototype={render:function(){var f=this,e=f.axis,h=e.horiz,m=f.options,d=m.label,c=f.label,b=m.to,k=m.from,z=m.value,l=p(k)&&p(b),r=p(z),x=f.svgElem,K=!x,t=[],C=m.color,N=w(m.zIndex,0),q=m.events,t={"class":"highcharts-plot-"+(l?"band ":"line ")+(m.className||"")},A={},F=e.chart.renderer,G=l?"bands":"lines",g=e.log2lin;e.isLog&&(k=g(k),b=g(b), +z=g(z));r?(t={stroke:C,"stroke-width":m.width},m.dashStyle&&(t.dashstyle=m.dashStyle)):l&&(C&&(t.fill=C),m.borderWidth&&(t.stroke=m.borderColor,t["stroke-width"]=m.borderWidth));A.zIndex=N;G+="-"+N;(C=e.plotLinesAndBandsGroups[G])||(e.plotLinesAndBandsGroups[G]=C=F.g("plot-"+G).attr(A).add());K&&(f.svgElem=x=F.path().attr(t).add(C));if(r)t=e.getPlotLinePath(z,x.strokeWidth());else if(l)t=e.getPlotBandPath(k,b,m);else return;K&&t&&t.length?(x.attr({d:t}),q&&a.objectEach(q,function(a,b){x.on(b,function(a){q[b].apply(f, +[a])})})):x&&(t?(x.show(),x.animate({d:t})):(x.hide(),c&&(f.label=c=c.destroy())));d&&p(d.text)&&t&&t.length&&0this.max&& +e>this.max;if(m&&h)for(a&&(k=m.toString()===h.toString(),b=0),a=0;aA-h?A:A-h);else if(z)k[a]=Math.max(e,g+h+d>c?g:g+h);else return!1},C=function(a,c,d,g){var e;gc-b?e=!1:k[a]=gc-d/2?c-d-2:g-d/2;return e},p=function(a){var b=f;f=x;x=b;m=a},q=function(){!1!==t.apply(0,f)?!1!==C.apply(0,x)||m||(p(!0),q()):m?k.x=k.y=0:(p(!0),q())};(c.inverted||1q&&(h=!1);a=(e.series&& +e.series.yAxis&&e.series.yAxis.pos)+(e.plotY||0);a-=b.plotTop;c.push({target:e.isHeader?b.plotHeight+l:a,rank:e.isHeader?1:0,size:z.tt.getBBox().height+1,point:e,x:q,tt:t})}});this.cleanSplit();a.distribute(c,b.plotHeight+l);D(c,function(a){var c=a.point,d=c.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:h||c.isHeader?a.x:c.plotX+b.plotLeft+n(f.distance,16),y:a.pos+b.plotTop,anchorX:c.isHeader?c.plotX+b.plotLeft:c.plotX+d.xAxis.pos,anchorY:c.isHeader?a.pos+b.plotTop-15:c.plotY+d.yAxis.pos})})}, +updatePosition:function(a){var e=this.chart,d=this.getLabel(),d=(this.options.positioner||this.getPosition).call(this,d.width,d.height,a);this.move(Math.round(d.x),Math.round(d.y||0),a.plotX+e.plotLeft,a.plotY+e.plotTop)},getDateFormat:function(a,m,d,c){var b=E("%m-%d %H:%M:%S.%L",m),k,h,f={millisecond:15,second:12,minute:9,hour:6,day:3},l="millisecond";for(h in e){if(a===e.week&&+E("%w",m)===d&&"00:00:00.000"===b.substr(6)){h="week";break}if(e[h]>a){h=l;break}if(f[h]&&b.substr(f[h])!=="01-01 00:00:00.000".substr(f[h]))break; +"week"!==h&&(l=h)}h&&(k=c[h]);return k},getXDateFormat:function(a,e,d){e=e.dateTimeLabelFormats;var c=d&&d.closestPointRange;return(c?this.getDateFormat(c,a.x,d.options.startOfWeek,e):e.day)||e.year},tooltipFooterHeaderFormatter:function(a,e){e=e?"footer":"header";var d=a.series,c=d.tooltipOptions,b=c.xDateFormat,k=d.xAxis,h=k&&"datetime"===k.options.type&&f(a.key),m=c[e+"Format"];h&&!b&&(b=this.getXDateFormat(a,c,k));h&&b&&D(a.point&&a.point.tooltipDateKeys||["key"],function(a){m=m.replace("{point."+ +a+"}","{point."+a+":"+b+"}")});return p(m,{point:a,series:d})},bodyFormatter:function(a){return l(a,function(a){var d=a.series.tooltipOptions;return(d[(a.point.formatPrefix||"point")+"Formatter"]||a.point.tooltipFormatter).call(a.point,d[(a.point.formatPrefix||"point")+"Format"])})}}})(M);(function(a){var E=a.addEvent,D=a.attr,H=a.charts,p=a.color,f=a.css,l=a.defined,r=a.each,n=a.extend,w=a.find,u=a.fireEvent,e=a.isObject,h=a.offset,m=a.pick,d=a.splat,c=a.Tooltip;a.Pointer=function(a,c){this.init(a, +c)};a.Pointer.prototype={init:function(a,d){this.options=d;this.chart=a;this.runChartClick=d.chart.events&&!!d.chart.events.click;this.pinchDown=[];this.lastValidTouch={};c&&(a.tooltip=new c(a,d.tooltip),this.followTouchMove=m(d.tooltip.followTouchMove,!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,c=b.options.chart,d=c.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=m(c.pinchType,d));this.zoomX=a=/x/.test(d);this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&& +!b||a&&b;this.hasZoom=a||d},normalize:function(a,c){var b;b=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;c||(this.chartPosition=c=h(this.chart.container));return n(a,{chartX:Math.round(b.pageX-c.left),chartY:Math.round(b.pageY-c.top)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};r(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},findNearestKDPoint:function(a,c,d){var b;r(a,function(a){var k= +!(a.noSharedTooltip&&c)&&0>a.options.findNearestPointBy.indexOf("y");a=a.searchPoint(d,k);if((k=e(a,!0))&&!(k=!e(b,!0)))var k=b.distX-a.distX,h=b.dist-a.dist,m=(a.series.group&&a.series.group.zIndex)-(b.series.group&&b.series.group.zIndex),k=0<(0!==k&&c?k:0!==h?h:0!==m?m:b.series.index>a.series.index?-1:1);k&&(b=a)});return b},getPointFromEvent:function(a){a=a.target;for(var b;a&&!b;)b=a.point,a=a.parentNode;return b},getChartCoordinatesFromPoint:function(a,c){var b=a.series,d=b.xAxis,b=b.yAxis,k= +m(a.clientX,a.plotX);if(d&&b)return c?{chartX:d.len+d.pos-k,chartY:b.len+b.pos-a.plotY}:{chartX:k+d.pos,chartY:a.plotY+b.pos}},getHoverData:function(b,c,d,h,f,l,n){var k,z=[],x=n&&n.isBoosting;h=!(!h||!b);n=c&&!c.stickyTracking?[c]:a.grep(d,function(a){return a.visible&&!(!f&&a.directTouch)&&m(a.options.enableMouseTracking,!0)&&a.stickyTracking});c=(k=h?b:this.findNearestKDPoint(n,f,l))&&k.series;k&&(f&&!c.noSharedTooltip?(n=a.grep(d,function(a){return a.visible&&!(!f&&a.directTouch)&&m(a.options.enableMouseTracking, +!0)&&!a.noSharedTooltip}),r(n,function(a){var b=w(a.points,function(a){return a.x===k.x&&!a.isNull});e(b)&&(x&&(b=a.getPoint(b)),z.push(b))})):z.push(k));return{hoverPoint:k,hoverSeries:c,hoverPoints:z}},runPointActions:function(b,c){var d=this.chart,k=d.tooltip&&d.tooltip.options.enabled?d.tooltip:void 0,e=k?k.shared:!1,h=c||d.hoverPoint,f=h&&h.series||d.hoverSeries,f=this.getHoverData(h,f,d.series,!!c||f&&f.directTouch&&this.isDirectTouch,e,b,{isBoosting:d.isBoosting}),l,h=f.hoverPoint;l=f.hoverPoints; +c=(f=f.hoverSeries)&&f.tooltipOptions.followPointer;e=e&&f&&!f.noSharedTooltip;if(h&&(h!==d.hoverPoint||k&&k.isHidden)){r(d.hoverPoints||[],function(b){-1===a.inArray(b,l)&&b.setState()});r(l||[],function(a){a.setState("hover")});if(d.hoverSeries!==f)f.onMouseOver();d.hoverPoint&&d.hoverPoint.firePointEvent("mouseOut");if(!h.series)return;h.firePointEvent("mouseOver");d.hoverPoints=l;d.hoverPoint=h;k&&k.refresh(e?l:h,b)}else c&&k&&!k.isHidden&&(h=k.getAnchor([{}],b),k.updatePosition({plotX:h[0],plotY:h[1]})); +this.unDocMouseMove||(this.unDocMouseMove=E(d.container.ownerDocument,"mousemove",function(b){var c=H[a.hoverChartIndex];if(c)c.pointer.onDocumentMouseMove(b)}));r(d.axes,function(c){var d=m(c.crosshair.snap,!0),k=d?a.find(l,function(a){return a.series[c.coll]===c}):void 0;k||!d?c.drawCrosshair(b,k):c.hideCrosshair()})},reset:function(a,c){var b=this.chart,k=b.hoverSeries,e=b.hoverPoint,h=b.hoverPoints,m=b.tooltip,f=m&&m.shared?h:e;a&&f&&r(d(f),function(b){b.series.isCartesian&&void 0===b.plotX&& +(a=!1)});if(a)m&&f&&(m.refresh(f),e&&(e.setState(e.state,!0),r(b.axes,function(a){a.crosshair&&a.drawCrosshair(null,e)})));else{if(e)e.onMouseOut();h&&r(h,function(a){a.setState()});if(k)k.onMouseOut();m&&m.hide(c);this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove());r(b.axes,function(a){a.hideCrosshair()});this.hoverX=b.hoverPoints=b.hoverPoint=null}},scaleGroups:function(a,c){var b=this.chart,d;r(b.series,function(k){d=a||k.getPlotBox();k.xAxis&&k.xAxis.zoomEnabled&&k.group&&(k.group.attr(d), +k.markerGroup&&(k.markerGroup.attr(d),k.markerGroup.clip(c?b.clipRect:null)),k.dataLabelsGroup&&k.dataLabelsGroup.attr(d))});b.clipRect.attr(c||b.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,h=this.zoomHor,m=this.zoomVert,f=b.plotLeft,l=b.plotTop,n=b.plotWidth,q=b.plotHeight,A,F=this.selectionMarker,G=this.mouseDownX, +g=this.mouseDownY,v=c.panKey&&a[c.panKey+"Key"];F&&F.touch||(df+n&&(d=f+n),el+q&&(e=l+q),this.hasDragged=Math.sqrt(Math.pow(G-d,2)+Math.pow(g-e,2)),10u.max&&(f=u.max-x,v=!0);v?(F-=.8*(F-m[b][0]),q||(g-=.8*(g-m[b][1])),l()):m[b]=[F,g];C||(h[b]=w-r,h[n]=x);h=C?1/t:t;e[n]=x;e[b]=f;p[C?a?"scaleY":"scaleX":"scale"+k]=t;p["translate"+k]=h*r+(F-h*A)},pinch:function(a){var n=this,r=n.chart,u=n.pinchDown,e=a.touches,h=e.length,m=n.lastValidTouch, +d=n.hasZoom,c=n.selectionMarker,b={},k=1===h&&(n.inClass(a.target,"highcharts-tracker")&&r.runTrackerClick||n.runChartClick),z={};1c-6&&h(q||c.spacingBox.width-2*t-d.x)&&(this.itemX=t,this.itemY+=F+this.lastLineHeight+A,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,m);this.lastItemY=F+this.itemY+A;this.lastLineHeight=Math.max(b,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];e?this.itemX+=m:(this.itemY+=F+b+A,this.lastLineHeight=b);this.offsetWidth=q||Math.max((e?this.itemX-t-(a.checkbox?0:p):m)+t,this.offsetWidth)}, +getAllItems:function(){var a=[];f(this.chart.series,function(c){var b=c&&c.options;c&&w(b.showInLegend,p(b.linkedTo)?!1:void 0,!0)&&(a=a.concat(c.legendItems||("point"===b.legendType?c.data:c)))});return a},getAlignment:function(){var a=this.options;return a.floating?"":a.align.charAt(0)+a.verticalAlign.charAt(0)+a.layout.charAt(0)},adjustMargins:function(a,c){var b=this.chart,d=this.options,e=this.getAlignment();e&&f([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(k,h){k.test(e)&& +!p(a[h])&&(b[r[h]]=Math.max(b[r[h]],b.legend[(h+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][h]*d[h%2?"x":"y"]+w(d.margin,12)+c[h]+(0===h?b.titleOffset+b.options.title.margin:0)))})},render:function(){var a=this,c=a.chart,b=c.renderer,k=a.group,h,m,l,x,p=a.box,t=a.options,C=a.padding;a.itemX=C;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;k||(a.group=k=b.g("legend").attr({zIndex:7}).add(),a.contentGroup=b.g().attr({zIndex:1}).add(k),a.scrollGroup=b.g().add(a.contentGroup));a.renderTitle(); +h=a.getAllItems();e(h,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});t.reversed&&h.reverse();a.allItems=h;a.display=m=!!h.length;a.lastLineHeight=0;f(h,function(b){a.renderItem(b)});l=(t.width||a.offsetWidth)+C;x=a.lastItemY+a.lastLineHeight+a.titleHeight;x=a.handleOverflow(x);x+=C;p||(a.box=p=b.rect().addClass("highcharts-legend-box").attr({r:t.borderRadius}).add(k),p.isNew=!0);p.attr({stroke:t.borderColor,"stroke-width":t.borderWidth||0,fill:t.backgroundColor|| +"none"}).shadow(t.shadow);0b&&!1!==t.enabled?(this.clipHeight=l=Math.max(b-20-this.titleHeight-m,0),this.currentPage=w(this.currentPage,1),this.fullHeight=a,f(G,function(a,b){var c=a._legendItemPos[1],d=Math.round(a.legendItem.getBBox().height),g=A.length;if(!g||c-A[g-1]>l&&(F||c)!==A[g-1])A.push(F||c),g++;a.pageIx=g-1;F&&(G[b-1].pageIx=g-1);b===G.length-1&&c+d-A[g-1]>l&&(A.push(c),a.pageIx=g);c!==F&&(F=c)}),n||(n=c.clipRect=d.clipRect(0,m,9999,0),c.contentGroup.clip(n)),g(l),q||(this.nav=q=d.g().attr({zIndex:1}).add(this.group), +this.up=d.symbol("triangle",0,0,r,r).on("click",function(){c.scroll(-1,p)}).add(q),this.pager=d.text("",15,10).addClass("highcharts-legend-navigation").css(t.style).add(q),this.down=d.symbol("triangle-down",0,0,r,r).on("click",function(){c.scroll(1,p)}).add(q)),c.scroll(0),a=b):q&&(g(),this.nav=q.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,c){var b=this.pages,d=b.length;a=this.currentPage+a;var e=this.clipHeight,h=this.options.navigation,f=this.pager, +m=this.padding;a>d&&(a=d);0b&&(f=typeof a[0],"string"===f?e.name=a[0]:"number"===f&&(e.x=a[0]),k++);l=d.value;)d=h[++f];d&&d.color&&!this.options.color&&(this.color=d.color);return d},destroy:function(){var a=this.series.chart,h=a.hoverPoints,f;a.pointCount--;h&&(this.setState(),p(h,this),h.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)u(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(f in this)this[f]=null},destroyElements:function(){for(var a=["graphic","dataLabel", +"dataLabelUpper","connector","shadowGroup"],h,f=6;f--;)h=a[f],this[h]&&(this[h]=this[h].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var e=this.series,f=e.tooltipOptions,d=w(f.valueDecimals,""),c=f.valuePrefix||"",b=f.valueSuffix||"";D(e.pointArrayMap||["y"],function(e){e="{point."+ +e;if(c||b)a=a.replace(e+"}",c+e+"}"+b);a=a.replace(e+"}",e+":,."+d+"f}")});return l(a,{point:this,series:this.series})},firePointEvent:function(a,h,m){var d=this,c=this.series.options;(c.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();"click"===a&&c.allowPointSelect&&(m=function(a){d.select&&d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});f(this,a,h,m)},visible:!0}})(M);(function(a){var E=a.addEvent,D=a.animObject,H=a.arrayMax,p=a.arrayMin,f=a.correctFloat, +l=a.Date,r=a.defaultOptions,n=a.defaultPlotOptions,w=a.defined,u=a.each,e=a.erase,h=a.extend,m=a.fireEvent,d=a.grep,c=a.isArray,b=a.isNumber,k=a.isString,z=a.merge,B=a.objectEach,I=a.pick,x=a.removeEvent,K=a.splat,t=a.SVGElement,C=a.syncTimeout,N=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc", +lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{animation:{duration:50},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3,findNearestPointBy:"x"}, +{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0,directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var c=this,d,g=a.series,e;c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];c.bindAxes();h(c,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});d=b.events;B(d,function(a,b){E(c,b,a)});if(d&&d.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor(); +c.getSymbol();u(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);c.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(e=g[g.length-1]);c._i=I(e&&e._i,-1)+1;a.orderSeries(this.insert(g))},insert:function(a){var c=this.options.index,d;if(b(c)){for(d=a.length;d--;)if(c>=I(a[d].options.index,a[d]._i)){a.splice(d+1,0,this);break}-1===d&&a.unshift(this);d+=1}else a.push(this);return I(d,a.length-1)},bindAxes:function(){var b=this,c=b.options,d=b.chart,e;u(b.axisTypes||[],function(g){u(d[g], +function(a){e=a.options;if(c[g]===e.index||void 0!==c[g]&&c[g]===e.id||void 0===c[g]&&0===e.index)b.insert(a.series),b[g]=a,a.isDirty=!0});b[g]||b.optionalAxis===g||a.error(18,!0)})},updateParallelArrays:function(a,c){var d=a.series,e=arguments,g=b(c)?function(b){var g="y"===b&&d.toYData?d.toYData(a):a[b];d[b+"Data"][c]=g}:function(a){Array.prototype[c].apply(d[a+"Data"],Array.prototype.slice.call(e,2))};u(d.parallelArrays,g)},autoIncrement:function(){var b=this.options,c=this.xIncrement,d,e=b.pointIntervalUnit, +g=0,c=I(c,b.pointStart,0);this.pointInterval=d=I(this.pointInterval,b.pointInterval,1);e&&(b=new l(c),"day"===e?b=+b[l.hcSetDate](b[l.hcGetDate]()+d):"month"===e?b=+b[l.hcSetMonth](b[l.hcGetMonth]()+d):"year"===e&&(b=+b[l.hcSetFullYear](b[l.hcGetFullYear]()+d)),l.hcHasTimeZone&&(g=a.getTZOffset(b)-a.getTZOffset(c)),d=b-c+g);this.xIncrement=c+d;return c},setOptions:function(a){var b=this.chart,c=b.options,d=c.plotOptions,g=(b.userOptions||{}).plotOptions||{},e=d[this.type];this.userOptions=a;b=z(e, +d.series,a);this.tooltipOptions=z(r.tooltip,r.plotOptions.series&&r.plotOptions.series.tooltip,r.plotOptions[this.type].tooltip,c.tooltip.userOptions,d.series&&d.series.tooltip,d[this.type].tooltip,a.tooltip);this.stickyTracking=I(a.stickyTracking,g[this.type]&&g[this.type].stickyTracking,g.series&&g.series.stickyTracking,this.tooltipOptions.shared&&!this.noSharedTooltip?!0:b.stickyTracking);null===e.marker&&delete b.marker;this.zoneAxis=b.zoneAxis;a=this.zones=(b.zones||[]).slice();!b.negativeColor&& +!b.negativeFillColor||b.zones||a.push({value:b[this.zoneAxis+"Threshold"]||b.threshold||0,className:"highcharts-negative",color:b.negativeColor,fillColor:b.negativeFillColor});a.length&&w(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return b},getCyclic:function(a,b,c){var d,g=this.chart,e=this.userOptions,k=a+"Index",h=a+"Counter",q=c?c.length:I(g.options.chart[a+"Count"],g[a+"Count"]);b||(d=I(e[k],e["_"+k]),w(d)||(g.series.length||(g[h]=0),e["_"+k]=d=g[h]%q,g[h]+=1), +c&&(b=c[d]));void 0!==d&&(this[k]=d);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",this.options.color||n[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker,setData:function(d,e,h,f){var g=this,q=g.points,m=q&&q.length||0,l,A=g.options,t=g.chart,x=null,n=g.xAxis,p=A.turboThreshold,z=this.xData,F= +this.yData,C=(l=g.pointArrayMap)&&l.length;d=d||[];l=d.length;e=I(e,!0);if(!1!==f&&l&&m===l&&!g.cropped&&!g.hasGroupedData&&g.visible)u(d,function(a,b){q[b].update&&a!==A.data[b]&&q[b].update(a,!1,null,!1)});else{g.xIncrement=null;g.colorCounter=0;u(this.parallelArrays,function(a){g[a+"Data"].length=0});if(p&&l>p){for(h=0;null===x&&hf||this.forceCrop))if(c[e-1]z)c=[],d=[];else if(c[0]z)g=this.cropData(this.xData,this.yData,p,z),c=g.xData,d=g.yData,g=g.start,k=!0;for(f=c.length|| +1;--f;)e=x?m(c[f])-m(c[f-1]):c[f]-c[f-1],0e&&n&&(a.error(15),n=!1);this.cropped=k;this.cropStart=g;this.processedXData=c;this.processedYData=d;this.closestPointRange=h},cropData:function(a,b,c,d){var g=a.length,e=0,k=g,h=I(this.cropShoulder,1),f;for(f=0;f=c){e=Math.max(0,f-h);break}for(c=f;cd){k=c+h;break}return{xData:a.slice(e,k),yData:b.slice(e,k),start:e,end:k}},generatePoints:function(){var a=this.options,b=a.data,c=this.data,d,g=this.processedXData, +e=this.processedYData,k=this.pointClass,h=g.length,f=this.cropStart||0,m,l=this.hasGroupedData,a=a.keys,t,x=[],n;c||l||(c=[],c.length=b.length,c=this.data=c);a&&l&&(this.options.keys=!1);for(n=0;n=f&&(e[n-1]||l)<=q,m&&l)if(m=t.length)for(;m--;)"number"===typeof t[m]&&(g[h++]=t[m]);else g[h++]=t;this.dataMin= +p(g);this.dataMax=H(g)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,c=a.stacking,d=this.xAxis,e=d.categories,g=this.yAxis,k=this.points,h=k.length,m=!!this.modifyValue,l=a.pointPlacement,t="between"===l||b(l),n=a.threshold,x=a.startFromThreshold?n:0,p,z,C,r,u=Number.MAX_VALUE;"between"===l&&(l=.5);b(l)&&(l*=I(a.pointRange||d.pointRange));for(a=0;a=K&&(B.isNull=!0);B.plotX=p=f(Math.min(Math.max(-1E5,d.translate(N,0,0,0,1,l,"flags"===this.type)),1E5));c&&this.visible&&!B.isNull&&D&&D[N]&&(r=this.getStackIndicator(r,N,this.index),E=D[N],K=E.points[r.key],z=K[0],K=K[1],z===x&&r.key===D[N].base&&(z=I(n,g.min)),g.positiveValuesOnly&&0>=z&&(z=null),B.total=B.stackTotal=E.total,B.percentage=E.total&&B.y/E.total*100,B.stackY=K,E.setOffset(this.pointXOffset||0,this.barW||0));B.yBottom=w(z)?g.translate(z,0,1,0,1): +null;m&&(K=this.modifyValue(K,B));B.plotY=z="number"===typeof K&&Infinity!==K?Math.min(Math.max(-1E5,g.translate(K,0,1,0,1)),1E5):void 0;B.isInside=void 0!==z&&0<=z&&z<=g.len&&0<=p&&p<=d.len;B.clientX=t?f(d.translate(N,0,0,0,1,l)):p;B.negative=B.y<(n||0);B.category=e&&void 0!==e[B.x]?e[B.x]:B.x;B.isNull||(void 0!==C&&(u=Math.min(u,Math.abs(p-C))),C=p);B.zone=this.zones.length&&B.getZone()}this.closestPointRangePx=u},getValidPoints:function(a,b){var c=this.chart;return d(a||this.points||[],function(a){return b&& +!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,d=b.renderer,g=b.inverted,e=this.clipBox,k=e||b.clipBox,h=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,k.height,c.xAxis,c.yAxis].join(),f=b[h],q=b[h+"m"];f||(a&&(k.width=0,g&&(k.x=b.plotSizeX),b[h+"m"]=q=d.clipRect(g?b.plotSizeX+99:-99,g?-b.plotLeft:-b.plotTop,99,g?b.chartWidth:b.chartHeight)),b[h]=f=d.clipRect(k),f.count={length:0});a&&!f.count[this.index]&&(f.count[this.index]= +!0,f.count.length+=1);!1!==c.clip&&(this.group.clip(a||e?f:b.clipRect),this.markerGroup.clip(q),this.sharedClipKey=h);a||(f.count[this.index]&&(delete f.count[this.index],--f.count.length),0===f.count.length&&h&&b[h]&&(e||(b[h]=b[h].destroy()),b[h+"m"]&&(b[h+"m"]=b[h+"m"].destroy())))},animate:function(a){var b=this.chart,c=D(this.options.animation),d;a?this.setClip(c):(d=this.sharedClipKey,(a=b[d])&&a.animate({width:b.plotSizeX,x:0},c),b[d+"m"]&&b[d+"m"].animate({width:b.plotSizeX+99,x:0},c),this.animate= +null)},afterAnimate:function(){this.setClip();m(this,"afterAnimate");this.finishedAnimating=!0},drawPoints:function(){var a=this.points,b=this.chart,c,d,g,e,k=this.options.marker,h,f,l,m=this[this.specialGroup]||this.markerGroup,t,n=I(k.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>=2*k.radius);if(!1!==k.enabled||this._hasPointMarkers)for(c=0;ce&&b.shadow));k&&(k.startX=c.xMap,k.isArea=c.isArea)})}, +applyZones:function(){var a=this,b=this.chart,c=b.renderer,d=this.zones,e,k,h=this.clips||[],f,m=this.graph,l=this.area,t=Math.max(b.chartWidth,b.chartHeight),n=this[(this.zoneAxis||"y")+"Axis"],x,p,z=b.inverted,C,r,w,B,K=!1;d.length&&(m||l)&&n&&void 0!==n.min&&(p=n.reversed,C=n.horiz,m&&m.hide(),l&&l.hide(),x=n.getExtremes(),u(d,function(d,g){e=p?C?b.plotWidth:0:C?0:n.toPixels(x.min);e=Math.min(Math.max(I(k,e),0),t);k=Math.min(Math.max(Math.round(n.toPixels(I(d.value,x.max),!0)),0),t);K&&(e=k=n.toPixels(x.max)); +r=Math.abs(e-k);w=Math.min(e,k);B=Math.max(e,k);n.isXAxis?(f={x:z?B:w,y:0,width:r,height:t},C||(f.x=b.plotHeight-f.x)):(f={x:0,y:z?B:w,width:t,height:r},C&&(f.y=b.plotWidth-f.y));z&&c.isVML&&(f=n.isXAxis?{x:0,y:p?w:B,height:f.width,width:b.chartWidth}:{x:f.y-b.plotLeft-b.spacingBox.x,y:0,width:f.height,height:b.chartHeight});h[g]?h[g].animate(f):(h[g]=c.clipRect(f),m&&a["zone-graph-"+g].clip(h[g]),l&&a["zone-area-"+g].clip(h[g]));K=d.value>x.max}),this.clips=h)},invertGroups:function(a){function b(){u(["group", +"markerGroup"],function(b){c[b]&&(d.renderer.isVML&&c[b].attr({width:c.yAxis.len,height:c.xAxis.len}),c[b].width=c.yAxis.len,c[b].height=c.xAxis.len,c[b].invert(a))})}var c=this,d=c.chart,e;c.xAxis&&(e=E(d,"resize",b),E(c,"destroy",e),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,d,e){var g=this[a],k=!g;k&&(this[a]=g=this.chart.renderer.g().attr({zIndex:d||.1}).add(e));g.addClass("highcharts-"+b+" highcharts-series-"+this.index+" highcharts-"+this.type+"-series "+(w(this.colorIndex)?"highcharts-color-"+ +this.colorIndex+" ":"")+(this.options.className||"")+(g.hasClass("highcharts-tracker")?" highcharts-tracker":""),!0);g.attr({visibility:c})[k?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,d=a.options,e=!!a.animate&&b.renderer.isSVG&&D(d.animation).duration,k=a.visible?"inherit": +"hidden",h=d.zIndex,f=a.hasRendered,m=b.seriesGroup,l=b.inverted;c=a.plotGroup("group","series",k,h,m);a.markerGroup=a.plotGroup("markerGroup","markers",k,h,m);e&&a.animate(!0);c.inverted=a.isCartesian?l:!1;a.drawGraph&&(a.drawGraph(),a.applyZones());a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(l);!1===d.clip||a.sharedClipKey||f||c.clip(b.clipRect);e&&a.animate();f||(a.animationTimeout=C(function(){a.afterAnimate()}, +e));a.isDirty=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:I(d&&d.left,a.plotLeft),translateY:I(e&&e.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,d=this.yAxis,e=this.chart.inverted;return this.searchKDTree({clientX:e?c.len-a.chartY+ +c.pos:a.chartX-c.pos,plotY:e?d.len-a.chartX+d.pos:a.chartY-d.pos},b)},buildKDTree:function(){function a(c,d,e){var g,k;if(k=c&&c.length)return g=b.kdAxisArray[d%e],c.sort(function(a,b){return a[g]-b[g]}),k=Math.floor(k/2),{point:c[k],left:a(c.slice(0,k),d+1,e),right:a(c.slice(k+1),d+1,e)}}this.buildingKdTree=!0;var b=this,c=-1l?"left":"right";t=0>l?"right":"left";b[q]&&(q=c(a,b[q],g+1,f),n=q[h]x;)q--;this.updateParallelArrays(m,"splice",q,0,0);this.updateParallelArrays(m,q);g&&m.name&&(g[x]=m.name);l.splice(q,0,a);n&&(this.data.splice(q,0,null),this.processData());"point"===e.legendType&&this.generatePoints();c&&(h[0]&&h[0].remove?h[0].remove(!1):(h.shift(),this.updateParallelArrays(m,"shift"),l.shift()));this.isDirtyData=this.isDirty=!0;b&&f.redraw(d)},removePoint:function(a,b,c){var d=this,e=d.data,h=e[a],f=d.points,g=d.chart,l=function(){f&&f.length===e.length&& +f.splice(a,1);e.splice(a,1);d.options.data.splice(a,1);d.updateParallelArrays(h||{series:d},"splice",a,1);h&&h.destroy();d.isDirty=!0;d.isDirtyData=!0;b&&g.redraw()};x(c,g);b=k(b,!0);h?h.firePointEvent("remove",null,l):l()},remove:function(a,b,c){function d(){e.destroy();h.isDirtyLegend=h.isDirtyBox=!0;h.linkSeries();k(a,!0)&&h.redraw(b)}var e=this,h=e.chart;!1!==c?u(e,"remove",null,d):d()},update:function(a,b){var d=this,e=d.chart,h=d.userOptions,f=d.oldType||d.type,l=a.type||h.type||e.options.chart.type, +g=I[f].prototype,m,n=["group","markerGroup","dataLabelsGroup"],t=["navigatorSeries","baseSeries"],x=d.finishedAnimating&&{animation:!1};if(Object.keys&&"data"===Object.keys(a).toString())return this.setData(a.data,b);t=n.concat(t);r(t,function(a){t[a]=d[a];delete d[a]});a=c(h,x,{index:d.index,pointStart:d.xData[0]},{data:d.options.data},a);d.remove(!1,null,!1);for(m in g)d[m]=void 0;w(d,I[l||f].prototype);r(t,function(a){d[a]=t[a]});d.init(e,a);a.zIndex!==h.zIndex&&r(n,function(b){d[b]&&d[b].attr({zIndex:a.zIndex})}); +d.oldType=f;e.linkSeries();k(b,!0)&&e.redraw(!1)}});w(H.prototype,{update:function(a,b){var d=this.chart;a=d.options[this.coll][this.options.index]=c(this.userOptions,a);this.destroy(!0);this.init(d,w(a,{events:void 0}));d.isDirtyBox=!0;k(b,!0)&&d.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,e=this.series,h=e.length;h--;)e[h]&&e[h].remove(!1);n(b.axes,this);n(b[c],this);d(b.options[c])?b.options[c].splice(this.options.index,1):delete b.options[c];r(b[c],function(a,b){a.options.index= +b});this.destroy();b.isDirtyBox=!0;k(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(M);(function(a){var E=a.color,D=a.each,H=a.map,p=a.pick,f=a.Series,l=a.seriesType;l("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(f){var l=[],r=[],u=this.xAxis,e=this.yAxis,h=e.stacks[this.stackKey],m={},d=this.index,c=e.series,b=c.length,k,z=p(e.options.reversedStacks,!0)?1:-1,B;f=f||this.points; +if(this.options.stacking){for(B=0;Ba&&w>l?(w=Math.max(a,l),e=2*l-w):wp&&e>l?(e=Math.max(p,l),w=2*l-e):e=Math.abs(h)&&.5a.closestPointRange*a.xAxis.transA,d=a.borderWidth=r(f.borderWidth,d?0:1),c=a.yAxis,b=f.threshold,k=a.translatedThreshold=c.getThreshold(b),l=r(f.minPointLength,5),p=a.getColumnMetrics(),u=p.width,x=a.barW=Math.max(u,1+2*d),w=a.pointXOffset=p.offset;h.inverted&&(k-=.5);f.pointPadding&&(x=Math.ceil(x));n.prototype.translate.apply(a);H(a.points,function(d){var e=r(d.yBottom,k),f=999+Math.abs(e),f=Math.min(Math.max(-f,d.plotY),c.len+f),m=d.plotX+w,n=x,t=Math.min(f,e),p,g=Math.max(f,e)-t;l&& +Math.abs(g)l?e-l:k-(p?l:0));d.barX=m;d.pointWidth=u;d.tooltipPos=h.inverted?[c.len+c.pos-h.plotLeft-f,a.xAxis.len-m-n/2,g]:[m+n/2,f+c.pos-h.plotTop,g];d.shapeType="rect";d.shapeArgs=a.crispCol.apply(a,d.isNull?[m,k,n,0]:[m,t,n,g])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")}, +pointAttribs:function(a,f){var e=this.options,d,c=this.pointAttrToOptions||{};d=c.stroke||"borderColor";var b=c["stroke-width"]||"borderWidth",k=a&&a.color||this.color,h=a&&a[d]||e[d]||this.color||k,n=a&&a[b]||e[b]||this[b]||0,c=e.dashStyle;a&&this.zones.length&&(k=a.getZone(),k=a.options.color||k&&k.color||this.color);f&&(a=l(e.states[f],a.options.states&&a.options.states[f]||{}),f=a.brightness,k=a.color||void 0!==f&&D(k).brighten(a.brightness).get()||k,h=a[d]||h,n=a[b]||n,c=a.dashStyle||c);d={fill:k, +stroke:h,"stroke-width":n};c&&(d.dashstyle=c);return d},drawPoints:function(){var a=this,h=this.chart,m=a.options,d=h.renderer,c=m.animationLimit||250,b;H(a.points,function(e){var k=e.graphic;if(f(e.plotY)&&null!==e.y){b=e.shapeArgs;if(k)k[h.pointCounte;++e)h=w[e],a=2>e||2===e&&/%$/.test(h),w[e]=p(h,[n,l,u,w[2]][e])+(a?r:0);w[3]>w[2]&&(w[3]=w[2]);return w},getStartAndEndRadians:function(a,l){a=D(a)?a:0;l=D(l)&&l>a&&360>l-a?l:a+360;return{start:E*(a+-90),end:E*(l+-90)}}}})(M);(function(a){var E=a.addEvent,D=a.CenteredSeriesMixin,H=a.defined,p=a.each,f=a.extend,l=D.getStartAndEndRadians,r=a.inArray,n=a.noop,w=a.pick,u=a.Point,e=a.Series,h=a.seriesType,m=a.setAnimation;h("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30, +enabled:!0,formatter:function(){return this.point.isNull?void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c= +this,b=c.points,d=c.startAngleRad;a||(p(b,function(a){var b=a.graphic,e=a.shapeArgs;b&&(b.attr({r:a.startR||c.center[3]/2,start:d,end:d}),b.animate({r:e.r,start:e.start,end:e.end},c.options.animation))}),c.animate=null)},updateTotals:function(){var a,c=0,b=this.points,e=b.length,f,h=this.options.ignoreHiddenPoint;for(a=0;a1.5*Math.PI?m-=2*Math.PI:m<-Math.PI/2&&(m+=2*Math.PI);G.slicedTranslation={translateX:Math.round(Math.cos(m)*d),translateY:Math.round(Math.sin(m)*d)};h=Math.cos(m)*a[2]/ +2;u=Math.sin(m)*a[2]/2;G.tooltipPos=[a[0]+.7*h,a[1]+.7*u];G.half=m<-Math.PI/2||m>Math.PI/2?1:0;G.angle=m;f=Math.min(e,G.labelDistance/5);G.labelPos=[a[0]+h+Math.cos(m)*G.labelDistance,a[1]+u+Math.sin(m)*G.labelDistance,a[0]+h+Math.cos(m)*f,a[1]+u+Math.sin(m)*f,a[0]+h,a[1]+u,0>G.labelDistance?"center":G.half?"right":"left",m]}},drawGraph:null,drawPoints:function(){var a=this,c=a.chart.renderer,b,e,h,l,m=a.options.shadow;m&&!a.shadowGroup&&(a.shadowGroup=c.g("shadow").add(a.group));p(a.points,function(d){e= +d.graphic;if(d.isNull)e&&(d.graphic=e.destroy());else{l=d.shapeArgs;b=d.getTranslate();var k=d.shadowGroup;m&&!k&&(k=d.shadowGroup=c.g("shadow").add(a.shadowGroup));k&&k.attr(b);h=a.pointAttribs(d,d.selected&&"select");e?e.setRadialReference(a.center).attr(h).animate(f(l,b)):(d.graphic=e=c[d.shapeType](l).setRadialReference(a.center).attr(b).add(a.group),d.visible||e.attr({visibility:"hidden"}),e.attr(h).attr({"stroke-linejoin":"round"}).shadow(m,k));e.addClass(d.getClassName())}})},searchPoint:n, +sortByAngle:function(a,c){a.sort(function(a,d){return void 0!==a.angle&&(d.angle-a.angle)*c})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:D.getCenter,getSymbol:n},{init:function(){u.prototype.init.apply(this,arguments);var a=this,c;a.name=w(a.name,"Slice");c=function(b){a.slice("select"===b.type)};E(a,"select",c);E(a,"unselect",c);return a},isValid:function(){return a.isNumber(this.y,!0)&&0<=this.y},setVisible:function(a,c){var b=this,d=b.series,e=d.chart,f=d.options.ignoreHiddenPoint; +c=w(c,f);a!==b.visible&&(b.visible=b.options.visible=a=void 0===a?!b.visible:a,d.options.data[r(b,d.data)]=b.options,p(["graphic","dataLabel","connector","shadowGroup"],function(c){if(b[c])b[c][a?"show":"hide"](!0)}),b.legendItem&&e.legend.colorizeItem(b,a),a||"hover"!==b.state||b.setState(""),f&&(d.isDirty=!0),c&&e.redraw())},slice:function(a,c,b){var d=this.series;m(b,d.chart);w(c,!0);this.sliced=this.options.sliced=H(a)?a:!this.sliced;d.options.data[r(this,d.data)]=this.options;this.graphic.animate(this.getTranslate()); +this.shadowGroup&&this.shadowGroup.animate(this.getTranslate())},getTranslate:function(){return this.sliced?this.slicedTranslation:{translateX:0,translateY:0}},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r-1,start:c.start,end:c.end})}})})(M);(function(a){var E=a.addEvent,D=a.arrayMax,H=a.defined,p=a.each,f=a.extend,l=a.format,r=a.map,n=a.merge,w=a.noop,u=a.pick,e=a.relativeLength,h= +a.Series,m=a.seriesTypes,d=a.stableSort;a.distribute=function(a,b){function c(a,b){return a.target-b.target}var e,f=!0,h=a,l=[],m;m=0;for(e=a.length;e--;)m+=a[e].size;if(m>b){d(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(m=e=0;m<=b;)m+=a[e].size,e++;l=a.splice(e-1,a.length)}d(a,c);for(a=r(a,function(a){return{size:a.size,targets:[a.target],align:u(a.align,.5)}});f;){for(e=a.length;e--;)f=a[e],m=(Math.min.apply(0,f.targets)+Math.max.apply(0,f.targets))/2,f.pos=Math.min(Math.max(0,m-f.size* +f.align),b-f.size);e=a.length;for(f=!1;e--;)0a[e].pos&&(a[e-1].size+=a[e].size,a[e-1].targets=a[e-1].targets.concat(a[e].targets),a[e-1].align=.5,a[e-1].pos+a[e-1].size>b&&(a[e-1].pos=b-a[e-1].size),a.splice(e,1),f=!0)}e=0;p(a,function(a){var b=0;p(a.targets,function(){h[e].pos=a.pos+b;b+=h[e].size;e++})});h.push.apply(h,l);d(h,c)};h.prototype.drawDataLabels=function(){function c(a,b){var c=b.filter;return c?(b=c.operator,a=a[c.property],c=c.value,"\x3e"===b&&a>c||"\x3c"=== +b&&a=c||"\x3c\x3d"===b&&a<=c||"\x3d\x3d"===b&&a==c||"\x3d\x3d\x3d"===b&&a===c?!0:!1):!0}var b=this,d=b.options,e=d.dataLabels,f=b.points,h,m,r=b.hasRendered||0,t,w,D=u(e.defer,!!d.animation),q=b.chart.renderer;if(e.enabled||b._hasPointLabels)b.dlProcessOptions&&b.dlProcessOptions(e),w=b.plotGroup("dataLabelsGroup","data-labels",D&&!r?"hidden":"visible",e.zIndex||6),D&&(w.attr({opacity:+r}),r||E(b,"afterAnimate",function(){b.visible&&w.show(!0);w[d.animation?"animate":"attr"]({opacity:1}, +{duration:200})})),m=e,p(f,function(f){var k,p=f.dataLabel,g,x,r=f.connector,z=!p,C;h=f.dlOptions||f.options&&f.options.dataLabels;(k=u(h&&h.enabled,m.enabled)&&!f.isNull)&&(k=!0===c(f,h||e));k&&(e=n(m,h),g=f.getLabelConfig(),C=e[f.formatPrefix+"Format"]||e.format,t=H(C)?l(C,g):(e[f.formatPrefix+"Formatter"]||e.formatter).call(g,e),C=e.style,g=e.rotation,C.color=u(e.color,C.color,b.color,"#000000"),"contrast"===C.color&&(f.contrastColor=q.getContrast(f.color||b.color),C.color=e.inside||0>u(f.labelDistance, +e.distance)||d.stacking?f.contrastColor:"#000000"),d.cursor&&(C.cursor=d.cursor),x={fill:e.backgroundColor,stroke:e.borderColor,"stroke-width":e.borderWidth,r:e.borderRadius||0,rotation:g,padding:e.padding,zIndex:1},a.objectEach(x,function(a,b){void 0===a&&delete x[b]}));!p||k&&H(t)?k&&H(t)&&(p?x.text=t:(p=f.dataLabel=g?q.text(t,0,-9999).addClass("highcharts-data-label"):q.label(t,0,-9999,e.shape,null,null,e.useHTML,null,"data-label"),p.addClass(" highcharts-data-label-color-"+f.colorIndex+" "+(e.className|| +"")+(e.useHTML?"highcharts-tracker":""))),p.attr(x),p.css(C).shadow(e.shadow),p.added||p.add(w),b.alignDataLabel(f,p,e,null,z)):(f.dataLabel=p=p.destroy(),r&&(f.connector=r.destroy()))})};h.prototype.alignDataLabel=function(a,b,d,e,h){var c=this.chart,k=c.inverted,l=u(a.dlBox&&a.dlBox.centerX,a.plotX,-9999),m=u(a.plotY,-9999),n=b.getBBox(),p,q=d.rotation,r=d.align,w=this.visible&&(a.series.forceDL||c.isInsidePlot(l,Math.round(m),k)||e&&c.isInsidePlot(l,k?e.x+1:e.y+e.height-1,k)),z="justify"===u(d.overflow, +"justify");if(w&&(p=d.style.fontSize,p=c.renderer.fontMetrics(p,b).b,e=f({x:k?this.yAxis.len-m:l,y:Math.round(k?this.xAxis.len-l:m),width:0,height:0},e),f(d,{width:n.width,height:n.height}),q?(z=!1,l=c.renderer.rotCorr(p,q),l={x:e.x+d.x+e.width/2+l.x,y:e.y+d.y+{top:0,middle:.5,bottom:1}[d.verticalAlign]*e.height},b[h?"attr":"animate"](l).attr({align:r}),m=(q+720)%360,m=180m,"left"===r?l.y-=m?n.height:0:"center"===r?(l.x-=n.width/2,l.y-=n.height/2):"right"===r&&(l.x-=n.width,l.y-=m?0:n.height)): +(b.align(d,null,e),l=b.alignAttr),z?a.isLabelJustified=this.justifyDataLabel(b,d,l,n,e,h):u(d.crop,!0)&&(w=c.isInsidePlot(l.x,l.y)&&c.isInsidePlot(l.x+n.width,l.y+n.height)),d.shape&&!q))b[h?"attr":"animate"]({anchorX:k?c.plotWidth-a.plotY:a.plotX,anchorY:k?c.plotHeight-a.plotX:a.plotY});w||(b.attr({y:-9999}),b.placed=!1)};h.prototype.justifyDataLabel=function(a,b,d,e,f,h){var c=this.chart,k=b.align,l=b.verticalAlign,m,n,p=a.box?0:a.padding||0;m=d.x+p;0>m&&("right"===k?b.align="left":b.x=-m,n=!0); +m=d.x+e.width-p;m>c.plotWidth&&("left"===k?b.align="right":b.x=c.plotWidth-m,n=!0);m=d.y+p;0>m&&("bottom"===l?b.verticalAlign="top":b.y=-m,n=!0);m=d.y+e.height-p;m>c.plotHeight&&("top"===l?b.verticalAlign="bottom":b.y=c.plotHeight-m,n=!0);n&&(a.placed=!h,a.align(b,null,f));return n};m.pie&&(m.pie.prototype.drawDataLabels=function(){var c=this,b=c.data,d,e=c.chart,f=c.options.dataLabels,l=u(f.connectorPadding,10),m=u(f.connectorWidth,1),n=e.plotWidth,t=e.plotHeight,r,w=c.center,q=w[2]/2,A=w[1],F,G, +g,v,E=[[],[]],L,P,J,M,y=[0,0,0,0];c.visible&&(f.enabled||c._hasPointLabels)&&(p(b,function(a){a.dataLabel&&a.visible&&a.dataLabel.shortened&&(a.dataLabel.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),a.dataLabel.shortened=!1)}),h.prototype.drawDataLabels.apply(c),p(b,function(a){a.dataLabel&&a.visible&&(E[a.half].push(a),a.dataLabel._pos=null)}),p(E,function(b,h){var k,m,x=b.length,r=[],z;if(x)for(c.sortByAngle(b,h-.5),0d.bottom-2?k:P,h,d),F._attr={visibility:J,align:g[6]},F._pos={x:L+f.x+({left:l,right:-l}[g[6]]||0),y:P+f.y-10},g.x=L,g.y=P,u(f.crop,!0)&&(G=F.getBBox().width,k=null,L-Gn-l&&(k=Math.round(L+G-n+l),y[1]=Math.max(k,y[1])),0>P-v/2?y[0]=Math.max(Math.round(-P+v/2),y[0]):P+v/2>t&&(y[2]=Math.max(Math.round(P+v/2-t),y[2])),F.sideOverflow=k)}),0===D(y)||this.verifyDataLabelOverflow(y))&&(this.placeDataLabels(), +m&&p(this.points,function(a){var b;r=a.connector;if((F=a.dataLabel)&&F._pos&&a.visible&&0u(this.translatedThreshold,k.yAxis.len)),p=u(d.inside,!!this.options.stacking);l&&(e=n(l),0>e.y&&(e.height+=e.y,e.y=0),l=e.y+e.height-k.yAxis.len,0a+c||e+hb+d||f+lthis.pointCount))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&r(d,function(a){a.setState()});r("xy"===b?[1,0]:[1],function(b){b= +c[b?"xAxis":"yAxis"][0];var d=b.horiz,f=a[d?"chartX":"chartY"],d=d?"mouseDownX":"mouseDownY",h=c[d],g=(b.pointRange||0)/2,k=b.getExtremes(),l=b.toValue(h-f,!0)+g,m=b.toValue(h+b.len-f,!0)-g,n=m=l(n.minWidth,0)&&this.chartHeight>=l(n.minHeight,0)}).call(this)&&f.push(a._id)};E.prototype.currentOptions=function(l){function n(e,h,l,d){var c;a.objectEach(e,function(a,e){if(!d&&-1 li.first padding-left: 0px h2 font-size: 150% - -//#subtitle -// color: lighten($brown, 30%) -// font-style: italic -// font-weight: normal -// margin-top: 0px -// padding-left: 1em -// padding-top: 0px - h3 font-size: 120% diff --git a/app/assets/stylesheets/predictions.sass b/app/assets/stylesheets/predictions.sass new file mode 100644 index 000000000..b9496ebc5 --- /dev/null +++ b/app/assets/stylesheets/predictions.sass @@ -0,0 +1,11 @@ +.predictions + .metric + height: 180px + border: #000000 2px + background: $white + margin: 4px + strong + font-size: 250% + font-align: center + h3 + diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 3df1a7ca7..b62177e5d 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -51,11 +51,7 @@ class CropsController < ApplicationController def show @crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:id]) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) - - respond_to do |format| - format.html # show.html.haml - format.json { render json: @crop.to_json(crop_json_fields) } - end + respond_with(@crop) end def new @@ -106,6 +102,14 @@ class CropsController < ApplicationController respond_with @crop end + def sunniness + @crop = Crop.find(params[:crop_id]) + render json: Planting.where(crop: @crop) + .where.not(sunniness: nil) + .where.not(sunniness: '') + .group(:sunniness).count(:id) + end + private def notifier diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index dbde9c783..343f4f6bd 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,29 +1,34 @@ - unless crop.perennial.nil? - %p - #{crop.name} is - - if crop.perennial == true - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - a perennial crop - (living more than two years) - - elsif crop.perennial == false - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - an annual crop - (living and reproducing in a single year or less) + .predictions + .row + %p + #{crop.name} is + - if crop.perennial == true + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + a perennial crop + (living more than two years) + - elsif crop.perennial == false + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + an annual crop + (living and reproducing in a single year or less) -- if crop.annual? && crop.median_lifespan.present? - %p - Median lifespan of #{crop.name} plants is - %strong= crop.median_lifespan - days + .row + - if crop.annual? && crop.median_lifespan.present? + .metric.col-md-3.col-xs-5 + %h3 Median lifespan + %strong= crop.median_lifespan + %span days -- if crop.median_days_to_first_harvest.present? - %p - First harvest expected - %strong= crop.median_days_to_first_harvest - days after planting + - if crop.median_days_to_first_harvest.present? + .metric.col-md-3.col-xs-5 + %h3 First harvest expected + %strong= crop.median_days_to_first_harvest + %span days + after planting -- if crop.annual? && crop.median_days_to_last_harvest.present? - %p - Last harvest expected - %strong= crop.median_days_to_last_harvest - days after planting + - if crop.annual? && crop.median_days_to_last_harvest.present? + .metric.col-md-3.col-xs-5 + %h3 Last harvest expected + %strong= crop.median_days_to_last_harvest + %span days + after planting diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2789d61ef..cf401681e 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -8,6 +8,9 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +- content_for :scripts do + = javascript_include_tag "charts" + = render partial: 'approval_status_message', locals: { crop: @crop } - if @crop.approved? @@ -27,11 +30,6 @@ = display_seed_availability(@current_member, @crop) = link_to "View your seeds", seeds_by_owner_path(owner: current_member.slug) - %h2 Predictions - = render 'predictions', crop: @crop - - %p= render 'crops/photos', crop: @crop - %h2 - if !@crop.plantings.empty? = @crop.name.titleize @@ -41,19 +39,26 @@ - else Nobody is growing this yet. You could be the first! - %h2 - Sunniness Chart + .row + .col-md-3 + %h2 Sunniness Chart + = pie_chart crop_sunniness_path(@crop), legend: "bottom" - #sunchart + .col-md-9 + %h2 Predictions + = render 'predictions', crop: @crop - %h2 - Crop Map - %p - Only plantings by members who have set their locations are shown on this map. - - if current_member && current_member.location.blank? - = link_to "Set your location.", edit_member_registration_path + .row + .col-md-12 + %h2 Photos + %p= render 'crops/photos', crop: @crop - #cropmap + %h2 Crop Map + %p + Only plantings by members who have set their locations are shown on this map. + - if current_member && current_member.location.blank? + = link_to "Set your location.", edit_member_registration_path + #cropmap %a{ name: 'posts' } %h2 What people are saying about #{@crop.name.pluralize} diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7fe945d8a..40f83db5b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,5 +1,6 @@ !!! 5 %html{ lang: "en", prefix: "og: http://ogp.me/ns#" } + = yield :scripts = render partial: "layouts/meta" %body = render partial: "layouts/header" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 000000000..60484d4a4 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,15 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) +Rails.application.config.assets.precompile += %w(charts.js) diff --git a/config/routes.rb b/config/routes.rb index eb963311a..14c4bd401 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,6 +50,7 @@ Growstuff::Application.routes.draw do get 'crops/search' => 'crops#search', as: 'crops_search' resources :crops do get 'photos' => 'photos#index' + get 'sunniness' => 'crops#sunniness' end resources :comments From 59c3edcf82411f255b5e82126a07bc738fcda99a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 7 Jan 2018 19:25:05 +1300 Subject: [PATCH 022/101] Add timeline to gardens --- app/controllers/gardens_controller.rb | 11 +++++++++++ app/views/gardens/show.html.haml | 9 +++++++++ config/routes.rb | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index ede5c2602..d2aa8bfe0 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -58,6 +58,17 @@ class GardensController < ApplicationController redirect_to(gardens_by_owner_path(owner: @garden.owner)) end + def timeline + @data = [] + @garden = Garden.find(params[:garden_id]) + @garden.plantings.where.not(finished_at: nil) + .where.not(planted_at: nil) + .order(finished_at: :desc).each do |p| + @data << [p.crop.name, p.planted_at, p.finished_at] + end + render json: @data + end + private def garden_params diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index ef5b41cfb..5ffed7152 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -9,6 +9,11 @@ = tag("meta", property: "og:type", content: "website") = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) + +- content_for :scripts do + = javascript_include_tag "charts" + = javascript_include_tag "https://www.gstatic.com/charts/loader.js" + .row .col-md-9 %p.btn-group= render 'gardens/actions', garden: @garden @@ -32,6 +37,10 @@ Why not = link_to 'tell us more.', edit_garden_path(@garden) + %h3 Garden timeline + .row + = timeline garden_timeline_path(@garden), adapter: "google" + %h3 What's planted here? .row - if @current_plantings.size.positive? diff --git a/config/routes.rb b/config/routes.rb index 14c4bd401..cc90a4063 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,7 +27,9 @@ Growstuff::Application.routes.draw do get '/plantings/owner/:owner' => 'plantings#index', as: 'plantings_by_owner' get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop' - resources :gardens + resources :gardens do + get 'timeline' => 'gardens#timeline' + end get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner' resources :seeds From 1f8413bf3ed308342272d3ad4a85b5ee24c346c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jan 2018 18:03:20 +1300 Subject: [PATCH 023/101] Remove highcharts.js, we're not using it --- app/assets/javascripts/highcharts.js | 389 --------------------------- 1 file changed, 389 deletions(-) delete mode 100644 app/assets/javascripts/highcharts.js diff --git a/app/assets/javascripts/highcharts.js b/app/assets/javascripts/highcharts.js deleted file mode 100644 index 9554ef58b..000000000 --- a/app/assets/javascripts/highcharts.js +++ /dev/null @@ -1,389 +0,0 @@ -/* - Highcharts JS v6.0.4 (2017-12-15) - - (c) 2009-2016 Torstein Honsi - - License: www.highcharts.com/license -*/ -(function(S,M){"object"===typeof module&&module.exports?module.exports=S.document?M(S):M:S.Highcharts=M(S)})("undefined"!==typeof window?window:this,function(S){var M=function(){var a="undefined"===typeof S?window:S,E=a.document,D=a.navigator&&a.navigator.userAgent||"",H=E&&E.createElementNS&&!!E.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,p=/(edge|msie|trident)/i.test(D)&&!a.opera,f=/Firefox/.test(D),l=f&&4>parseInt(D.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16, -!0):{product:"Highcharts",version:"6.0.4",deg2rad:2*Math.PI/360,doc:E,hasBidiBug:l,hasTouch:E&&void 0!==E.documentElement.ontouchstart,isMS:p,isWebKit:/AppleWebKit/.test(D),isFirefox:f,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(D),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:H,win:a,marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){},charts:[]}}();(function(a){a.timers=[];var E=a.charts,D=a.doc,H=a.win;a.error=function(p, -f){p=a.isNumber(p)?"Highcharts error #"+p+": www.highcharts.com/errors/"+p:p;if(f)throw Error(p);H.console&&console.log(p)};a.Fx=function(a,f,l){this.options=f;this.elem=a;this.prop=l};a.Fx.prototype={dSetter:function(){var a=this.paths[0],f=this.paths[1],l=[],r=this.now,n=a.length,w;if(1===r)l=this.toD;else if(n===f.length&&1>r)for(;n--;)w=parseFloat(a[n]),l[n]=isNaN(w)?f[n]:r*parseFloat(f[n]-w)+w;else l=f;this.elem.attr("d",l,null,!0)},update:function(){var a=this.elem,f=this.prop,l=this.now,r= -this.options.step;if(this[f+"Setter"])this[f+"Setter"]();else a.attr?a.element&&a.attr(f,l,null,!0):a.style[f]=l+this.unit;r&&r.call(a,l,this)},run:function(p,f,l){var r=this,n=r.options,w=function(a){return w.stopped?!1:r.step(a)},u=H.requestAnimationFrame||function(a){setTimeout(a,13)},e=function(){for(var h=0;h=u+this.startTime?(this.now=this.end,this.pos=1,this.update(),l=e[this.prop]=!0,a.objectEach(e,function(a){!0!==a&&(l=!1)}),l&&w&&w.call(n),p=!1):(this.pos=r.easing((f-this.startTime)/u),this.now=this.start+(this.end- -this.start)*this.pos,this.update(),p=!0);return p},initPath:function(p,f,l){function r(a){var b,c;for(k=a.length;k--;)b="M"===a[k]||"L"===a[k],c=/[a-zA-Z]/.test(a[k+3]),b&&c&&a.splice(k+1,0,a[k+1],a[k+2],a[k+1],a[k+2])}function n(a,b){for(;a.lengtha&&-Infinityw?"AM":"PM",P:12>w?"am":"pm",S:k(n.getSeconds()),L:k(Math.round(f%1E3),3)},a.dateFormats);a.objectEach(r,function(a,b){for(;-1!==p.indexOf("%"+b);)p=p.replace("%"+b,"function"===typeof a?a(f):a)});return l?p.substr(0,1).toUpperCase()+p.substr(1):p};a.formatSingle=function(p,f){var l=/\.([0-9])/,r=a.defaultOptions.lang;/f$/.test(p)?(l=(l=p.match(l))?l[1]:-1,null!==f&&(f=a.numberFormat(f,l,r.decimalPoint,-1=l&&(f=[1/l])));for(r=0;r=p||!n&&w<=(f[r]+(f[r+1]||f[r]))/2);r++);return u=a.correctFloat(u*l,-Math.round(Math.log(.001)/Math.LN10))};a.stableSort=function(a,f){var l=a.length,p,n;for(n=0;nl&&(l=a[f]);return l};a.destroyObjectProperties=function(p,f){a.objectEach(p,function(a,r){a&&a!==f&&a.destroy&&a.destroy();delete p[r]})};a.discardElement=function(p){var f=a.garbageBin;f||(f=a.createElement("div"));p&&f.appendChild(p);f.innerHTML=""};a.correctFloat=function(a,f){return parseFloat(a.toPrecision(f||14))};a.setAnimation=function(p,f){f.renderer.globalAnimation=a.pick(p,f.options.chart.animation, -!0)};a.animObject=function(p){return a.isObject(p)?a.merge(p):{duration:p?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat=function(p,f,l,r){p=+p||0;f=+f;var n=a.defaultOptions.lang,w=(p.toString().split(".")[1]||"").split("e")[0].length,u,e,h=p.toString().split("e");-1===f?f=Math.min(w,20):a.isNumber(f)?f&&h[1]&&0>h[1]&&(u=f+ +h[1],0<=u?(h[0]=(+h[0]).toExponential(u).split("e")[0],f=u):(h[0]=h[0].split(".")[0]||0, -p=20>f?(h[0]*Math.pow(10,h[1])).toFixed(f):0,h[1]=0)):f=2;e=(Math.abs(h[1]?h[0]:p)+Math.pow(10,-Math.max(f,w)-1)).toFixed(f);w=String(a.pInt(e));u=3p?"-":"")+(u?w.substr(0,u)+r:"");p+=w.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+r);f&&(p+=l+e.slice(-f));h[1]&&0!==+p&&(p+="e"+h[1]);return p};Math.easeInOutSine=function(a){return-.5*(Math.cos(Math.PI*a)-1)};a.getStyle=function(p,f,l){if("width"===f)return Math.min(p.offsetWidth, -p.scrollWidth)-a.getStyle(p,"padding-left")-a.getStyle(p,"padding-right");if("height"===f)return Math.min(p.offsetHeight,p.scrollHeight)-a.getStyle(p,"padding-top")-a.getStyle(p,"padding-bottom");H.getComputedStyle||a.error(27,!0);if(p=H.getComputedStyle(p,void 0))p=p.getPropertyValue(f),a.pick(l,"opacity"!==f)&&(p=a.pInt(p));return p};a.inArray=function(p,f){return(a.indexOfPolyfill||Array.prototype.indexOf).call(f,p)};a.grep=function(p,f){return(a.filterPolyfill||Array.prototype.filter).call(p, -f)};a.find=Array.prototype.find?function(a,f){return a.find(f)}:function(a,f){var l,r=a.length;for(l=0;l>16,(l&65280)>> -8,l&255,1]:4===f&&(n=[(l&3840)>>4|(l&3840)>>8,(l&240)>>4|l&240,(l&15)<<4|l&15,1])),!n)for(w=this.parsers.length;w--&&!n;)u=this.parsers[w],(f=u.regex.exec(l))&&(n=u.parse(f));this.rgba=n||[]},get:function(a){var f=this.input,n=this.rgba,l;this.stops?(l=p(f),l.stops=[].concat(l.stops),E(this.stops,function(n,e){l.stops[e]=[l.stops[e][0],n.get(a)]})):l=n&&D(n[0])?"rgb"===a||!a&&1===n[3]?"rgb("+n[0]+","+n[1]+","+n[2]+")":"a"===a?n[3]:"rgba("+n.join(",")+")":f;return l},brighten:function(a){var l,n=this.rgba; -if(this.stops)E(this.stops,function(n){n.brighten(a)});else if(D(a)&&0!==a)for(l=0;3>l;l++)n[l]+=f(255*a),0>n[l]&&(n[l]=0),255y.width)y={width:0,height:0}}else y=this.htmlGetBBox();b.isSVG&& -(a=y.width,b=y.height,q&&"11px"===q.fontSize&&17===Math.round(b)&&(y.height=b=14),g&&(y.width=Math.abs(b*Math.sin(v))+Math.abs(a*Math.cos(v)),y.height=Math.abs(b*Math.cos(v))+Math.abs(a*Math.sin(v))));if(A&&0]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a,g,b){"string"===typeof a?b.setAttribute(g,a):a&&this.colorGradient(a,g,b)},visibilitySetter:function(a,g,b){"inherit"===a?b.removeAttribute(g):this[g]!==a&&b.setAttribute(g,a);this[g]=a},zIndexSetter:function(a,b){var v=this.renderer,y=this.parentGroup,c=(y||v).element||v.box,k,d=this.element,q,e,v=c===v.box;k=this.added;var z;u(a)&& -(d.zIndex=a,a=+a,this[b]===a&&(k=!1),this[b]=a);if(k){(a=this.zIndex)&&y&&(y.handleZ=!0);b=c.childNodes;for(z=b.length-1;0<=z&&!q;z--)if(y=b[z],k=y.zIndex,e=!u(k),y!==d)if(0>a&&e&&!v&&!z)c.insertBefore(d,b[z]),q=!0;else if(g(k)<=a||e&&(!u(a)||0<=a))c.insertBefore(d,b[z+1]||null),q=!0;q||(c.insertBefore(d,b[v?3:0]||null),q=!0)}return q},_defaultSetter:function(a,g,b){b.setAttribute(g,a)}});E.prototype.yGetter=E.prototype.xGetter;E.prototype.translateXSetter=E.prototype.translateYSetter=E.prototype.rotationSetter= -E.prototype.verticalAlignSetter=E.prototype.rotationOriginXSetter=E.prototype.rotationOriginYSetter=E.prototype.scaleXSetter=E.prototype.scaleYSetter=E.prototype.matrixSetter=function(a,g){this[g]=a;this.doTransform=!0};E.prototype["stroke-widthSetter"]=E.prototype.strokeSetter=function(a,g,b){this[g]=a;this.stroke&&this["stroke-width"]?(E.prototype.fillSetter.call(this,this.stroke,"stroke",b),b.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&& -(b.removeAttribute("stroke"),this.hasStroke=!1)};D=a.SVGRenderer=function(){this.init.apply(this,arguments)};c(D.prototype,{Element:E,SVG_NS:P,init:function(a,g,b,v,c,k){var y;v=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(v));y=v.element;a.appendChild(y);f(a,"dir","ltr");-1===a.innerHTML.indexOf("xmlns")&&f(y,"xmlns",this.SVG_NS);this.isSVG=!0;this.box=y;this.boxWrapper=v;this.alignedObjects=[];this.url=(x||N)&&m.getElementsByTagName("base").length? -R.location.href.replace(/#.*?$/,"").replace(/<[^>]*>/g,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(m.createTextNode("Created with Highcharts 6.0.4"));this.defs=this.createElement("defs").add();this.allowHTML=k;this.forExport=c;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,b,!1);var d;x&&a.getBoundingClientRect&&(g=function(){n(a,{left:0,top:0});d=a.getBoundingClientRect();n(a,{left:Math.ceil(d.left)- -d.left+"px",top:Math.ceil(d.top)-d.top+"px"})},g(),this.unSubPixelFix=H(R,"resize",g))},getStyle:function(a){return this.style=c({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();h(this.gradients||{});this.gradients=null;a&&(this.defs=a.destroy()); -this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:A,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},getSpanWidth:function(a,g){var b=a.getBBox(!0).width;!L&&this.forExport&&(b=this.measureSpanWidth(g.firstChild.data,a.styles));return b},applyEllipsis:function(a,g,b,v){var c=a.rotation,y=b,k,d=0,q=b.length,e=function(a){g.removeChild(g.firstChild); -a&&g.appendChild(m.createTextNode(a))},z;a.rotation=0;y=this.getSpanWidth(a,g);if(z=y>v){for(;d<=q;)k=Math.ceil((d+q)/2),y=b.substring(0,k)+"\u2026",e(y),y=this.getSpanWidth(a,g),d===q?d=q+1:y>v?q=k-1:d=k;0===q&&e("")}a.rotation=c;return z},escapes:{"\x26":"\x26amp;","\x3c":"\x26lt;","\x3e":"\x26gt;","'":"\x26#39;",'"':"\x26quot;"},buildText:function(a){var b=a.element,v=this,c=v.forExport,y=G(a.textStr,"").toString(),q=-1!==y.indexOf("\x3c"),e=b.childNodes,z,h,A,J,t=f(b,"x"),x=a.styles,B=a.textWidth, -l=x&&x.lineHeight,C=x&&x.textOutline,u=x&&"ellipsis"===x.textOverflow,Q=x&&"nowrap"===x.whiteSpace,w=x&&x.fontSize,R,I,r=e.length,x=B&&!a.added&&this.box,p=function(a){var c;c=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:w||v.style.fontSize||12;return l?g(l):v.fontMetrics(c,a.getAttribute("style")?a:b).h},K=function(a){F(v.escapes,function(g,b){a=a.replace(new RegExp(g,"g"),b)});return a};R=[y,u,Q,l,C,w,B].join();if(R!==a.textCache){for(a.textCache=R;r--;)b.removeChild(e[r]);q||C||u||B|| --1!==y.indexOf(" ")?(z=/<.*class="([^"]+)".*>/,h=/<.*style="([^"]+)".*>/,A=/<.*href="([^"]+)".*>/,x&&x.appendChild(b),y=q?y.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g,'\x3cspan style\x3d"font-style:italic"\x3e').replace(//g,"\x3c/span\x3e").split(//g):[y],y=k(y,function(a){return""!==a}),d(y,function(g,y){var k,q=0;g=g.replace(/^\s+|\s+$/g,"").replace(//g,"\x3c/span\x3e|||"); -k=g.split("|||");d(k,function(g){if(""!==g||1===k.length){var d={},e=m.createElementNS(v.SVG_NS,"tspan"),x,F;z.test(g)&&(x=g.match(z)[1],f(e,"class",x));h.test(g)&&(F=g.match(h)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),f(e,"style",F));A.test(g)&&!c&&(f(e,"onclick",'location.href\x3d"'+g.match(A)[1]+'"'),f(e,"class","highcharts-anchor"),n(e,{cursor:"pointer"}));g=K(g.replace(/<[a-zA-Z\/](.|\n)*?>/g,"")||" ");if(" "!==g){e.appendChild(m.createTextNode(g));q?d.dx=0:y&&null!==t&&(d.x=t);f(e,d);b.appendChild(e); -!q&&I&&(!L&&c&&n(e,{display:"block"}),f(e,"dy",p(e)));if(B){d=g.replace(/([^\^])-/g,"$1- ").split(" ");x=1B,void 0===J&&(J=g),g&&1!==d.length?(e.removeChild(e.firstChild),O.unshift(d.pop())):(d=O,O=[],d.length&&!Q&&(e=m.createElementNS(P,"tspan"),f(e,{dy:C,x:t}),F&&f(e,"style",F),b.appendChild(e)),l>B&&(B=l)),d.length&&e.appendChild(m.createTextNode(d.join(" ").replace(/- /g, -"-")));a.rotation=G}q++}}});I=I||b.childNodes.length}),J&&a.attr("title",a.textStr),x&&x.removeChild(b),C&&a.applyTextOutline&&a.applyTextOutline(C)):b.appendChild(m.createTextNode(K(y)))}},getContrast:function(a){a=r(a).rgba;return 510Math.abs(c.end-c.start-2*Math.PI));var y=Math.cos(k),z=Math.sin(k),h=Math.cos(e),e=Math.sin(e);c=.001>c.end-k-Math.PI?0:1;d=["M",a+d*y,g+q*z,"A",d,q,0,c,1,a+d*h,g+q*e];u(b)&&d.push(v?"M":"L",a+b* -h,g+b*e,"A",b,b,0,c,0,a+b*y,g+b*z);d.push(v?"":"Z");return d},callout:function(a,g,b,v,c){var d=Math.min(c&&c.r||0,b,v),k=d+6,q=c&&c.anchorX;c=c&&c.anchorY;var e;e=["M",a+d,g,"L",a+b-d,g,"C",a+b,g,a+b,g,a+b,g+d,"L",a+b,g+v-d,"C",a+b,g+v,a+b,g+v,a+b-d,g+v,"L",a+d,g+v,"C",a,g+v,a,g+v,a,g+v-d,"L",a,g+d,"C",a,g,a,g,a+d,g];q&&q>b?c>g+k&&cq?c>g+k&&cv&&q>a+k&&qc&&q>a+k&&qa?a+3:Math.round(1.2*a);return{h:b,b:Math.round(.8* -b),f:a}},rotCorr:function(a,g,b){var v=a;g&&b&&(v=Math.max(v*Math.cos(g*e),4));return{x:-a/3*Math.sin(g*e),y:v}},label:function(g,b,k,e,z,h,m,A,L){var y=this,J=y.g("button"!==L&&"label"),t=J.text=y.text("",0,0,m).attr({zIndex:1}),x,F,n=0,B=3,l=0,C,f,Q,G,w,R={},I,P,r=/^url\((.*?)\)$/.test(e),p=r,K,O,N,T;L&&J.addClass("highcharts-"+L);p=r;K=function(){return(I||0)%2/2};O=function(){var a=t.element.style,g={};F=(void 0===C||void 0===f||w)&&u(t.textStr)&&t.getBBox();J.width=(C||F.width||0)+2*B+l;J.height= -(f||F.height||0)+2*B;P=B+y.fontMetrics(a&&a.fontSize,t).b;p&&(x||(J.box=x=y.symbols[e]||r?y.symbol(e):y.rect(),x.addClass(("button"===L?"":"highcharts-label-box")+(L?" highcharts-"+L+"-box":"")),x.add(J),a=K(),g.x=a,g.y=(A?-P:0)+a),g.width=Math.round(J.width),g.height=Math.round(J.height),x.attr(c(g,R)),R={})};N=function(){var a=l+B,g;g=A?0:P;u(C)&&F&&("center"===w||"right"===w)&&(a+={center:.5,right:1}[w]*(C-F.width));if(a!==t.x||g!==t.y)t.attr("x",a),void 0!==g&&t.attr("y",g);t.x=a;t.y=g};T=function(a, -g){x?x.attr(a,g):R[a]=g};J.onAdd=function(){t.add(J);J.attr({text:g||0===g?g:"",x:b,y:k});x&&u(z)&&J.attr({anchorX:z,anchorY:h})};J.widthSetter=function(g){C=a.isNumber(g)?g:null};J.heightSetter=function(a){f=a};J["text-alignSetter"]=function(a){w=a};J.paddingSetter=function(a){u(a)&&a!==B&&(B=J.padding=a,N())};J.paddingLeftSetter=function(a){u(a)&&a!==l&&(l=a,N())};J.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==n&&(n=a,F&&J.attr({x:Q}))};J.textSetter=function(a){void 0!==a&&t.textSetter(a); -O();N()};J["stroke-widthSetter"]=function(a,g){a&&(p=!0);I=this["stroke-width"]=a;T(g,a)};J.strokeSetter=J.fillSetter=J.rSetter=function(a,g){"r"!==g&&("fill"===g&&a&&(p=!0),J[g]=a);T(g,a)};J.anchorXSetter=function(a,g){z=J.anchorX=a;T(g,Math.round(a)-K()-Q)};J.anchorYSetter=function(a,g){h=J.anchorY=a;T(g,a-G)};J.xSetter=function(a){J.x=a;n&&(a-=n*((C||F.width)+2*B));Q=Math.round(a);J.attr("translateX",Q)};J.ySetter=function(a){G=J.y=Math.round(a);J.attr("translateY",G)};var U=J.css;return c(J,{css:function(a){if(a){var g= -{};a=q(a);d(J.textProps,function(b){void 0!==a[b]&&(g[b]=a[b],delete a[b])});t.css(g)}return U.call(J,a)},getBBox:function(){return{width:F.width+2*B,height:F.height+2*B,x:F.x-B,y:F.y-B}},shadow:function(a){a&&(O(),x&&x.shadow(a));return J},destroy:function(){v(J.element,"mouseenter");v(J.element,"mouseleave");t&&(t=t.destroy());x&&(x=x.destroy());E.prototype.destroy.call(J);J=y=O=N=T=null}})}});a.Renderer=D})(M);(function(a){var E=a.attr,D=a.createElement,H=a.css,p=a.defined,f=a.each,l=a.extend, -r=a.isFirefox,n=a.isMS,w=a.isWebKit,u=a.pick,e=a.pInt,h=a.SVGRenderer,m=a.win,d=a.wrap;l(a.SVGElement.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&"SPAN"===b.tagName&&a.width)delete a.width,this.textWidth=b,this.updateTransform();a&&"ellipsis"===a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=l(this.styles,a);H(this.element,a);return this},htmlGetBBox:function(){var a=this.element;return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}, -htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,d=this.translateX||0,z=this.translateY||0,h=this.x||0,m=this.y||0,x=this.textAlign||"left",n={left:0,center:.5,right:1}[x],t=this.styles;H(b,{marginLeft:d,marginTop:z});this.shadows&&f(this.shadows,function(a){H(a,{marginLeft:d+1,marginTop:z+1})});this.inverted&&f(b.childNodes,function(c){a.invertChild(c,b)});if("SPAN"===b.tagName){var l=this.rotation,u=e(this.textWidth),q=t&&t.whiteSpace,A=[l,x,b.innerHTML,this.textWidth, -this.textAlign].join();A!==this.cTT&&(t=a.fontMetrics(b.style.fontSize).b,p(l)&&this.setSpanRotation(l,n,t),H(b,{width:"",whiteSpace:q||"nowrap"}),b.offsetWidth>u&&/[ \-]/.test(b.textContent||b.innerText)&&H(b,{width:u+"px",display:"block",whiteSpace:q||"normal"}),this.getSpanCorrection(b.offsetWidth,t,n,l,x));H(b,{left:h+(this.xCorr||0)+"px",top:m+(this.yCorr||0)+"px"});w&&(t=b.offsetHeight);this.cTT=A}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,d){var c={},k=this.renderer.getTransformKey(); -c[k]=c.transform="rotate("+a+"deg)";c[k+(r?"Origin":"-origin")]=c.transformOrigin=100*b+"% "+d+"px";H(this.element,c)},getSpanCorrection:function(a,b,d){this.xCorr=-a*d;this.yCorr=-b}});l(h.prototype,{getTransformKey:function(){return n&&!/Edge/.test(m.navigator.userAgent)?"-ms-transform":w?"-webkit-transform":r?"MozTransform":m.opera?"-o-transform":""},html:function(a,b,k){var c=this.createElement("span"),e=c.element,h=c.renderer,m=h.isSVG,w=function(a,b){f(["opacity","visibility"],function(c){d(a, -c+"Setter",function(a,c,d,k){a.call(this,c,d,k);b[d]=c})})};c.textSetter=function(a){a!==e.innerHTML&&delete this.bBox;this.textStr=a;e.innerHTML=u(a,"");c.htmlUpdateTransform()};m&&w(c,c.element.style);c.xSetter=c.ySetter=c.alignSetter=c.rotationSetter=function(a,b){"align"===b&&(b="textAlign");c[b]=a;c.htmlUpdateTransform()};c.attr({text:a,x:Math.round(b),y:Math.round(k)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});e.style.whiteSpace="nowrap";c.css= -c.htmlCss;m&&(c.add=function(a){var b,d=h.box.parentNode,k=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)k.push(a),a=a.parentGroup;f(k.reverse(),function(a){function e(g,b){a[b]=g;n?q[h.getTransformKey()]="translate("+(a.x||a.translateX)+"px,"+(a.y||a.translateY)+"px)":"translateX"===b?q.left=g+"px":q.top=g+"px";a.doTransform=!0}var q,g=E(a.element,"class");g&&(g={className:g});b=a.div=a.div||D("div",g,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display, -opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||d);q=b.style;l(a,{classSetter:function(a){return function(g){this.element.setAttribute("class",g);a.className=g}}(b),on:function(){k[0].div&&c.on.apply({element:k[0].div},arguments);return a},translateXSetter:e,translateYSetter:e});w(a,q)})}}else b=d;b.appendChild(e);c.added=!0;c.alignOnAdd&&c.htmlUpdateTransform();return c});return c}})})(M);(function(a){function E(){var n=a.defaultOptions.global,l=r.moment;if(n.timezone){if(l)return function(a){return-l.tz(a, -n.timezone).utcOffset()};a.error(25)}return n.useUTC&&n.getTimezoneOffset}function D(){var n=a.defaultOptions.global,f,u=n.useUTC,e=u?"getUTC":"get",h=u?"setUTC":"set",m="Minutes Hours Day Date Month FullYear".split(" "),d=m.concat(["Milliseconds","Seconds"]);a.Date=f=n.Date||r.Date;f.hcTimezoneOffset=u&&n.timezoneOffset;f.hcGetTimezoneOffset=E();f.hcHasTimeZone=!(!f.hcTimezoneOffset&&!f.hcGetTimezoneOffset);f.hcMakeTime=function(a,b,d,e,h,m){var c;u?(c=f.UTC.apply(0,arguments),c+=p(c)):c=(new f(a, -b,l(d,1),l(e,0),l(h,0),l(m,0))).getTime();return c};for(n=0;nb&&e-k*zm&&(p=Math.round((h-e)/Math.cos(b*r)));else if(h=e+(1-k)*z,e-k*zm&&(I=m-a.x+I*k,x=-1),I=Math.min(B,I),II||f.autoRotation&&(c.styles||{}).width)p=I;p&&(t.width=p,(n.style||{}).textOverflow||(t.textOverflow="ellipsis"),c.css(t))},getPosition:function(a,f,l,e){var h=this.axis,m=h.chart,d=e&&m.oldChartHeight||m.chartHeight;return{x:a?h.translate(f+l,null,null,e)+h.transB:h.left+h.offset+(h.opposite?(e&&m.oldChartWidth||m.chartWidth)-h.right-h.left:0),y:a?d-h.bottom+h.offset-(h.opposite?h.height:0):d-h.translate(f+l,null,null,e)-h.transB}},getLabelPosition:function(a, -f,l,e,h,m,d,c){var b=this.axis,k=b.transA,z=b.reversed,B=b.staggerLines,n=b.tickRotCorr||{x:0,y:0},x=h.y,u=e||b.reserveSpaceDefault?0:-b.labelOffset*("center"===b.labelAlign?.5:1);D(x)||(x=0===b.side?l.rotation?-8:-l.getBBox().height:2===b.side?n.y+8:Math.cos(l.rotation*r)*(n.y-l.getBBox(!1,0).height/2));a=a+h.x+u+n.x-(m&&e?m*k*(z?-1:1):0);f=f+x-(m&&!e?m*k*(z?1:-1):0);B&&(l=d/(c||1)%B,b.opposite&&(l=B-l-1),f+=b.labelOffset/B*l);return{x:a,y:Math.round(f)}},getMarkPath:function(a,f,l,e,h,m){return m.crispLine(["M", -a,f,"L",a+(h?0:-l),f+(h?l:0)],e)},renderGridLine:function(a,f,l){var e=this.axis,h=e.options,m=this.gridLine,d={},c=this.pos,b=this.type,k=e.tickmarkOffset,z=e.chart.renderer,B=b?b+"Grid":"grid",n=h[B+"LineWidth"],x=h[B+"LineColor"],h=h[B+"LineDashStyle"];m||(d.stroke=x,d["stroke-width"]=n,h&&(d.dashstyle=h),b||(d.zIndex=1),a&&(d.opacity=0),this.gridLine=m=z.path().attr(d).addClass("highcharts-"+(b?b+"-":"")+"grid-line").add(e.gridGroup));if(!a&&m&&(a=e.getPlotLinePath(c+k,m.strokeWidth()*l,a,!0)))m[this.isNew? -"attr":"animate"]({d:a,opacity:f})},renderMark:function(a,f,u){var e=this.axis,h=e.options,m=e.chart.renderer,d=this.type,c=d?d+"Tick":"tick",b=e.tickSize(c),k=this.mark,z=!k,B=a.x;a=a.y;var n=l(h[c+"Width"],!d&&e.isXAxis?1:0),h=h[c+"Color"];b&&(e.opposite&&(b[0]=-b[0]),z&&(this.mark=k=m.path().addClass("highcharts-"+(d?d+"-":"")+"tick").add(e.axisGroup),k.attr({stroke:h,"stroke-width":n})),k[z?"attr":"animate"]({d:this.getMarkPath(B,a,b[0],k.strokeWidth()*u,e.horiz,m),opacity:f}))},renderLabel:function(a, -f,u,e){var h=this.axis,m=h.horiz,d=h.options,c=this.label,b=d.labels,k=b.step,h=h.tickmarkOffset,z=!0,B=a.x;a=a.y;c&&p(B)&&(c.xy=a=this.getLabelPosition(B,a,c,m,b,h,e,k),this.isFirst&&!this.isLast&&!l(d.showFirstLabel,1)||this.isLast&&!this.isFirst&&!l(d.showLastLabel,1)?z=!1:!m||b.step||b.rotation||f||0===u||this.handleOverflow(a),k&&e%k&&(z=!1),z&&p(a.y)?(a.opacity=u,c[this.isNewLabel?"attr":"animate"](a),this.isNewLabel=!1):(c.attr("y",-9999),this.isNewLabel=!0))},render:function(a,f,u){var e= -this.axis,h=e.horiz,m=this.getPosition(h,this.pos,e.tickmarkOffset,f),d=m.x,c=m.y,e=h&&d===e.pos+e.len||!h&&c===e.pos?-1:1;u=l(u,1);this.isActive=!0;this.renderGridLine(f,u,e);this.renderMark(m,u,e);this.renderLabel(m,f,u,a);this.isNew=!1},destroy:function(){H(this,this.axis)}}})(M);var V=function(a){var E=a.addEvent,D=a.animObject,H=a.arrayMax,p=a.arrayMin,f=a.color,l=a.correctFloat,r=a.defaultOptions,n=a.defined,w=a.deg2rad,u=a.destroyObjectProperties,e=a.each,h=a.extend,m=a.fireEvent,d=a.format, -c=a.getMagnitude,b=a.grep,k=a.inArray,z=a.isArray,B=a.isNumber,I=a.isString,x=a.merge,K=a.normalizeTickInterval,t=a.objectEach,C=a.pick,N=a.removeEvent,q=a.splat,A=a.syncTimeout,F=a.Tick,G=function(){this.init.apply(this,arguments)};a.extend(G.prototype,{defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"}, -x:0},maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",minPadding:.01,startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",lineColor:"#ccd6eb",lineWidth:1,gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05, -minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{allowOverlap:!1,enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45], -x:0},title:{rotation:0}},init:function(a,b){var g=b.isX,v=this;v.chart=a;v.horiz=a.inverted&&!v.isZAxis?!g:g;v.isXAxis=g;v.coll=v.coll||(g?"xAxis":"yAxis");v.opposite=b.opposite;v.side=b.side||(v.horiz?v.opposite?0:2:v.opposite?1:3);v.setOptions(b);var c=this.options,d=c.type;v.labelFormatter=c.labels.formatter||v.defaultLabelFormatter;v.userOptions=b;v.minPixelPadding=0;v.reversed=c.reversed;v.visible=!1!==c.visible;v.zoomEnabled=!1!==c.zoomEnabled;v.hasNames="category"===d||!0===c.categories;v.categories= -c.categories||v.hasNames;v.names=v.names||[];v.plotLinesAndBandsGroups={};v.isLog="logarithmic"===d;v.isDatetimeAxis="datetime"===d;v.positiveValuesOnly=v.isLog&&!v.allowNegativeLog;v.isLinked=n(c.linkedTo);v.ticks={};v.labelEdge=[];v.minorTicks={};v.plotLinesAndBands=[];v.alternateBands={};v.len=0;v.minRange=v.userMinRange=c.minRange||c.maxZoom;v.range=c.range;v.offset=c.offset||0;v.stacks={};v.oldStacks={};v.stacksTouched=0;v.max=null;v.min=null;v.crosshair=C(c.crosshair,q(a.options.tooltip.crosshairs)[g? -0:1],!1);b=v.options.events;-1===k(v,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,v):a.axes.push(v),a[v.coll].push(v));v.series=v.series||[];a.inverted&&!v.isZAxis&&g&&void 0===v.reversed&&(v.reversed=!0);t(b,function(a,g){E(v,g,a)});v.lin2log=c.linearToLogConverter||v.lin2log;v.isLog&&(v.val2lin=v.log2lin,v.lin2val=v.lin2log)},setOptions:function(a){this.options=x(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions, -this.defaultLeftAxisOptions][this.side],x(r[this.coll],a))},defaultLabelFormatter:function(){var g=this.axis,b=this.value,c=g.categories,k=this.dateTimeLabelFormat,e=r.lang,q=e.numericSymbols,e=e.numericSymbolMagnitude||1E3,h=q&&q.length,m,z=g.options.labels.format,g=g.isLog?Math.abs(b):g.tickInterval;if(z)m=d(z,this);else if(c)m=b;else if(k)m=a.dateFormat(k,b);else if(h&&1E3<=g)for(;h--&&void 0===m;)c=Math.pow(e,h+1),g>=c&&0===10*b%c&&null!==q[h]&&0!==b&&(m=a.numberFormat(b/c,-1)+q[h]);void 0=== -m&&(m=1E4<=Math.abs(b)?a.numberFormat(b,-1):a.numberFormat(b,-1,void 0,""));return m},getSeriesExtremes:function(){var a=this,v=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();e(a.series,function(g){if(g.visible||!v.options.chart.ignoreHiddenSeries){var c=g.options,d=c.threshold,k;a.hasVisibleSeries=!0;a.positiveValuesOnly&&0>=d&&(d=null);if(a.isXAxis)c=g.xData,c.length&&(g=p(c),k=H(c),B(g)||g instanceof Date||(c=b(c,B), -g=p(c)),a.dataMin=Math.min(C(a.dataMin,c[0],g),g),a.dataMax=Math.max(C(a.dataMax,c[0],k),k));else if(g.getExtremes(),k=g.dataMax,g=g.dataMin,n(g)&&n(k)&&(a.dataMin=Math.min(C(a.dataMin,g),g),a.dataMax=Math.max(C(a.dataMax,k),k)),n(d)&&(a.threshold=d),!c.softThreshold||a.positiveValuesOnly)a.softThreshold=!1}})},translate:function(a,b,c,d,k,e){var g=this.linkedParent||this,v=1,q=0,h=d?g.oldTransA:g.transA;d=d?g.oldMin:g.min;var m=g.minPixelPadding;k=(g.isOrdinal||g.isBroken||g.isLog&&k)&&g.lin2val; -h||(h=g.transA);c&&(v*=-1,q=g.len);g.reversed&&(v*=-1,q-=v*(g.sector||g.len));b?(a=(a*v+q-m)/h+d,k&&(a=g.lin2val(a))):(k&&(a=g.val2lin(a)),a=B(d)?v*(a-d)*h+q+v*m+(B(e)?h*e:0):void 0);return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,k){var g=this.chart,v=this.left,q=this.top,e,h,m=c&&g.oldChartHeight||g.chartHeight,z=c&&g.oldChartWidth|| -g.chartWidth,A;e=this.transB;var t=function(a,g,b){if(ab)d?a=Math.min(Math.max(g,a),b):A=!0;return a};k=C(k,this.translate(a,null,null,c));a=c=Math.round(k+e);e=h=Math.round(m-k-e);B(k)?this.horiz?(e=q,h=m-this.bottom,a=c=t(a,v,v+this.width)):(a=v,c=z-this.right,e=h=t(e,q,q+this.height)):(A=!0,d=!1);return A&&!d?null:g.renderer.crispLine(["M",a,e,"L",c,h],b||1)},getLinearTickPositions:function(a,b,c){var g,v=l(Math.floor(b/a)*a);c=l(Math.ceil(c/a)*a);var d=[],k;l(v+a)===v&&(k=20);if(this.single)return[b]; -for(b=v;b<=c;){d.push(b);b=l(b+a,k);if(b===g)break;g=b}return d},getMinorTickInterval:function(){var a=this.options;return!0===a.minorTicks?C(a.minorTickInterval,"auto"):!1===a.minorTicks?null:a.minorTickInterval},getMinorTickPositions:function(){var a=this,b=a.options,c=a.tickPositions,d=a.minorTickInterval,k=[],q=a.pointRangePadding||0,h=a.min-q,q=a.max+q,m=q-h;if(m&&m/d=this.minRange,t=this.minRange,d=(t-c+b)/2,d=[b-d,C(a.min,b-d)],k&&(d[2]=this.isLog?this.log2lin(this.dataMin):this.dataMin),b=H(d),c=[b+t,C(a.max,b+t)],k&&(c[2]=this.isLog?this.log2lin(this.dataMax):this.dataMax),c=p(c),c-b=p?(r=p,f=0):b.dataMax<=p&&(w=p,x=0)),b.min= -C(N,r,b.dataMin),b.max=C(D,w,b.dataMax));q&&(b.positiveValuesOnly&&!g&&0>=Math.min(b.min,C(b.dataMin,b.min))&&a.error(10,1),b.min=l(h(b.min),15),b.max=l(h(b.max),15));b.range&&n(b.max)&&(b.userMin=b.min=N=Math.max(b.dataMin,b.minFromRange()),b.userMax=D=b.max,b.range=null);m(b,"foundExtremes");b.beforePadding&&b.beforePadding();b.adjustForMinRange();!(G||b.axisPointRange||b.usePercentage||t)&&n(b.min)&&n(b.max)&&(h=b.max-b.min)&&(!n(N)&&f&&(b.min-=h*f),!n(D)&&x&&(b.max+=h*x));B(k.softMin)&&!B(b.userMin)&& -(b.min=Math.min(b.min,k.softMin));B(k.softMax)&&!B(b.userMax)&&(b.max=Math.max(b.max,k.softMax));B(k.floor)&&(b.min=Math.max(b.min,k.floor));B(k.ceiling)&&(b.max=Math.min(b.max,k.ceiling));I&&n(b.dataMin)&&(p=p||0,!n(N)&&b.min=p?b.min=p:!n(D)&&b.max>p&&b.dataMax<=p&&(b.max=p));b.tickInterval=b.min===b.max||void 0===b.min||void 0===b.max?1:t&&!F&&u===b.linkedParent.options.tickPixelInterval?F=b.linkedParent.tickInterval:C(F,this.tickAmount?(b.max-b.min)/Math.max(this.tickAmount-1,1): -void 0,G?1:(b.max-b.min)*u/Math.max(b.len,u));A&&!g&&e(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();b.postProcessTickInterval&&(b.tickInterval=b.postProcessTickInterval(b.tickInterval));b.pointRange&&!F&&(b.tickInterval=Math.max(b.pointRange,b.tickInterval));g=C(k.minTickInterval,b.isDatetimeAxis&&b.closestPointRange);!F&&b.tickIntervalb.tickInterval&&1E3b.max)),!!this.tickAmount));this.tickAmount||(b.tickInterval=b.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions;b=this.getMinorTickInterval();var d=a.tickPositioner,k=a.startOnTick,q=a.endOnTick;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval="auto"===b&&this.tickInterval?this.tickInterval/ -5:b;this.single=this.min===this.max&&n(this.min)&&!this.tickAmount&&(parseInt(this.min,10)===this.min||!1!==a.allowDecimals);this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,this.min,this.max),b.length>this.len&&(b= -[b[0],b.pop()],b[0]===b[1]&&(b.length=1)),this.tickPositions=b,d&&(d=d.apply(this,[this.min,this.max])))&&(this.tickPositions=b=d);this.paddedTicks=b.slice(0);this.trimTicks(b,k,q);this.isLinked||(this.single&&2>b.length&&(this.min-=.5,this.max+=.5),c||d||this.adjustTickAmount())},trimTicks:function(a,b,c){var g=a[0],d=a[a.length-1],k=this.minPointOffset||0;if(!this.isLinked){if(b&&-Infinity!==g)this.min=g;else for(;this.min-k>a[0];)a.shift();if(c)this.max=d;else for(;this.max+kb&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,d=this.finalTickAmt,k=b&&b.length,q=C(this.threshold,this.softThreshold?0:null);if(this.hasData()){if(kc&&(this.tickInterval*= -2,this.setTickPositions());if(n(d)){for(a=c=b.length;a--;)(3===d&&1===a%2||2>=d&&0d&&(a=d)),n(c)&&(bd&&(b=d))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var b=this.chart,c=this.options,d=c.offsets||[0,0,0,0],k=this.horiz,q=this.width=Math.round(a.relativeLength(C(c.width,b.plotWidth-d[3]+d[1]),b.plotWidth)),e=this.height=Math.round(a.relativeLength(C(c.height, -b.plotHeight-d[0]+d[2]),b.plotHeight)),h=this.top=Math.round(a.relativeLength(C(c.top,b.plotTop+d[0]),b.plotHeight,b.plotTop)),c=this.left=Math.round(a.relativeLength(C(c.left,b.plotLeft+d[3]),b.plotWidth,b.plotLeft));this.bottom=b.chartHeight-e-h;this.right=b.chartWidth-q-c;this.len=Math.max(k?q:e,0);this.pos=k?c:h},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?l(b(this.min)):this.min,max:a?l(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin, -userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,g=this.lin2log,c=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=c:c>a?a=c:ba?"right":195a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],c=C(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(c&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,c]},labelMetrics:function(){var a= -this.tickPositions&&this.tickPositions[0]||0;return this.chart.renderer.fontMetrics(this.options.labels.style&&this.options.labels.style.fontSize,this.ticks[a]&&this.ticks[a].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,c=this.tickInterval,d=c,k=this.len/(((this.categories?1:0)+this.max-this.min)/c),q,h=a.rotation,m=this.labelMetrics(),z,A=Number.MAX_VALUE,t,x=function(a){a/=k||1;a=1=a)z=x(Math.abs(m.h/Math.sin(w*a))),b=z+Math.abs(a/360),b(c.step||0)&&!c.rotation&&(this.staggerLines||1)*this.len/d||!b&&(c.style&&parseInt(c.style.width,10)||k&&k-a.spacing[3]|| -.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,c=this.tickPositions,d=this.ticks,k=this.options.labels,q=this.horiz,h=this.getSlotWidth(),m=Math.max(1,Math.round(h-2*(k.padding||5))),z={},A=this.labelMetrics(),t=k.style&&k.style.textOverflow,f,F=0,l,B;I(k.rotation)||(z.rotation=k.rotation||0);e(c,function(a){(a=d[a])&&a.labelLength>F&&(F=a.labelLength)});this.maxLabelLength=F;if(this.autoRotation)F>m&&F>A.h?z.rotation=this.labelRotation:this.labelRotation=0;else if(h&& -(f={width:m+"px"},!t))for(f.textOverflow="clip",l=c.length;!q&&l--;)if(B=c[l],m=d[B].label)m.styles&&"ellipsis"===m.styles.textOverflow?m.css({textOverflow:"clip"}):d[B].labelLength>h&&m.css({width:h+"px"}),m.getBBox().height>this.len/c.length-(A.h-A.f)&&(m.specCss={textOverflow:"ellipsis"});z.rotation&&(f={width:(F>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},t||(f.textOverflow="ellipsis"));if(this.labelAlign=k.align||this.autoLabelAlign(this.labelRotation))z.align=this.labelAlign;e(c, -function(a){var b=(a=d[a])&&a.label;b&&(b.attr(z),f&&b.css(x(f,b.specCss)),delete b.specCss,a.rotation=z.rotation)});this.tickRotCorr=b.rotCorr(A.b,this.labelRotation||0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||n(this.min)&&n(this.max)&&this.tickPositions&&0=this.min&&a<=this.max)g[a]||(g[a]=new F(this,a)),d&&g[a].isNew&&g[a].render(b,!0,.1),g[a].render(b)},render:function(){var b= -this,c=b.chart,d=b.options,k=b.isLog,q=b.lin2log,h=b.isLinked,m=b.tickPositions,z=b.axisTitle,x=b.ticks,f=b.minorTicks,l=b.alternateBands,C=d.stackLabels,n=d.alternateGridColor,u=b.tickmarkOffset,G=b.axisLine,p=b.showAxis,I=D(c.renderer.globalAnimation),r,w;b.labelEdge.length=0;b.overlap=!1;e([x,f,l],function(a){t(a,function(a){a.isActive=!1})});if(b.hasData()||h)b.minorTickInterval&&!b.categories&&e(b.getMinorTickPositions(),function(a){b.renderMinorTick(a)}),m.length&&(e(m,function(a,c){b.renderTick(a, -c)}),u&&(0===b.min||b.single)&&(x[-1]||(x[-1]=new F(b,-1,null,!0)),x[-1].render(-1))),n&&e(m,function(d,g){w=void 0!==m[g+1]?m[g+1]+u:b.max-u;0===g%2&&d=h.second?0:C*Math.floor(x.getMilliseconds()/C));if(t>=h.second)x[D.hcSetSeconds](t>=h.minute? -0:C*Math.floor(x.getSeconds()/C));if(t>=h.minute)x[D.hcSetMinutes](t>=h.hour?0:C*Math.floor(x[D.hcGetMinutes]()/C));if(t>=h.hour)x[D.hcSetHours](t>=h.day?0:C*Math.floor(x[D.hcGetHours]()/C));if(t>=h.day)x[D.hcSetDate](t>=h.month?1:C*Math.floor(x[D.hcGetDate]()/C));t>=h.month&&(x[D.hcSetMonth](t>=h.year?0:C*Math.floor(x[D.hcGetMonth]()/C)),n=x[D.hcGetFullYear]());if(t>=h.year)x[D.hcSetFullYear](n-n%C);if(t===h.week)x[D.hcSetDate](x[D.hcGetDate]()-x[D.hcGetDay]()+e(b,1));n=x[D.hcGetFullYear]();b=x[D.hcGetMonth](); -var A=x[D.hcGetDate](),F=x[D.hcGetHours]();d=x.getTime();D.hcHasTimeZone&&(q=(!B||!!D.hcGetTimezoneOffset)&&(c-d>4*h.month||w(d)!==w(c)),N=w(x),x=new D(d+N));B=x.getTime();for(d=1;Bk.length&&l(k,function(a){0===a%18E5&&"000000000"===H("%H%M%S%L",a)&&(m[a]="day")})}k.info=r(a,{higherRanks:m,totalRange:t*C});return k}; -E.prototype.normalizeTimeTickInterval=function(a,d){var c=d||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]];d=c[c.length-1];var b=h[d[0]],k=d[1],e;for(e=0;er&&(!w||z<=n)&&void 0!==z&&d.push(z),z>n&& -(B=!0),z=k;else r=h(r),n=h(n),a=w?this.getMinorTickInterval():l.tickInterval,a=f("auto"===a?null:a,this._minorAutoInterval,l.tickPixelInterval/(w?5:1)*(n-r)/((w?e/this.tickPositions.length:e)||1)),a=p(a,null,D(a)),d=H(this.getLinearTickPositions(a,r,n),m),w||(this._minorAutoInterval=a/5);w||(this.tickInterval=a);return d};E.prototype.log2lin=function(a){return Math.log(a)/Math.LN10};E.prototype.lin2log=function(a){return Math.pow(10,a)}})(M);(function(a,E){var D=a.arrayMax,H=a.arrayMin,p=a.defined, -f=a.destroyObjectProperties,l=a.each,r=a.erase,n=a.merge,w=a.pick;a.PlotLineOrBand=function(a,e){this.axis=a;e&&(this.options=e,this.id=e.id)};a.PlotLineOrBand.prototype={render:function(){var f=this,e=f.axis,h=e.horiz,m=f.options,d=m.label,c=f.label,b=m.to,k=m.from,z=m.value,l=p(k)&&p(b),r=p(z),x=f.svgElem,K=!x,t=[],C=m.color,N=w(m.zIndex,0),q=m.events,t={"class":"highcharts-plot-"+(l?"band ":"line ")+(m.className||"")},A={},F=e.chart.renderer,G=l?"bands":"lines",g=e.log2lin;e.isLog&&(k=g(k),b=g(b), -z=g(z));r?(t={stroke:C,"stroke-width":m.width},m.dashStyle&&(t.dashstyle=m.dashStyle)):l&&(C&&(t.fill=C),m.borderWidth&&(t.stroke=m.borderColor,t["stroke-width"]=m.borderWidth));A.zIndex=N;G+="-"+N;(C=e.plotLinesAndBandsGroups[G])||(e.plotLinesAndBandsGroups[G]=C=F.g("plot-"+G).attr(A).add());K&&(f.svgElem=x=F.path().attr(t).add(C));if(r)t=e.getPlotLinePath(z,x.strokeWidth());else if(l)t=e.getPlotBandPath(k,b,m);else return;K&&t&&t.length?(x.attr({d:t}),q&&a.objectEach(q,function(a,b){x.on(b,function(a){q[b].apply(f, -[a])})})):x&&(t?(x.show(),x.animate({d:t})):(x.hide(),c&&(f.label=c=c.destroy())));d&&p(d.text)&&t&&t.length&&0this.max&& -e>this.max;if(m&&h)for(a&&(k=m.toString()===h.toString(),b=0),a=0;aA-h?A:A-h);else if(z)k[a]=Math.max(e,g+h+d>c?g:g+h);else return!1},C=function(a,c,d,g){var e;gc-b?e=!1:k[a]=gc-d/2?c-d-2:g-d/2;return e},p=function(a){var b=f;f=x;x=b;m=a},q=function(){!1!==t.apply(0,f)?!1!==C.apply(0,x)||m||(p(!0),q()):m?k.x=k.y=0:(p(!0),q())};(c.inverted||1q&&(h=!1);a=(e.series&& -e.series.yAxis&&e.series.yAxis.pos)+(e.plotY||0);a-=b.plotTop;c.push({target:e.isHeader?b.plotHeight+l:a,rank:e.isHeader?1:0,size:z.tt.getBBox().height+1,point:e,x:q,tt:t})}});this.cleanSplit();a.distribute(c,b.plotHeight+l);D(c,function(a){var c=a.point,d=c.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:h||c.isHeader?a.x:c.plotX+b.plotLeft+n(f.distance,16),y:a.pos+b.plotTop,anchorX:c.isHeader?c.plotX+b.plotLeft:c.plotX+d.xAxis.pos,anchorY:c.isHeader?a.pos+b.plotTop-15:c.plotY+d.yAxis.pos})})}, -updatePosition:function(a){var e=this.chart,d=this.getLabel(),d=(this.options.positioner||this.getPosition).call(this,d.width,d.height,a);this.move(Math.round(d.x),Math.round(d.y||0),a.plotX+e.plotLeft,a.plotY+e.plotTop)},getDateFormat:function(a,m,d,c){var b=E("%m-%d %H:%M:%S.%L",m),k,h,f={millisecond:15,second:12,minute:9,hour:6,day:3},l="millisecond";for(h in e){if(a===e.week&&+E("%w",m)===d&&"00:00:00.000"===b.substr(6)){h="week";break}if(e[h]>a){h=l;break}if(f[h]&&b.substr(f[h])!=="01-01 00:00:00.000".substr(f[h]))break; -"week"!==h&&(l=h)}h&&(k=c[h]);return k},getXDateFormat:function(a,e,d){e=e.dateTimeLabelFormats;var c=d&&d.closestPointRange;return(c?this.getDateFormat(c,a.x,d.options.startOfWeek,e):e.day)||e.year},tooltipFooterHeaderFormatter:function(a,e){e=e?"footer":"header";var d=a.series,c=d.tooltipOptions,b=c.xDateFormat,k=d.xAxis,h=k&&"datetime"===k.options.type&&f(a.key),m=c[e+"Format"];h&&!b&&(b=this.getXDateFormat(a,c,k));h&&b&&D(a.point&&a.point.tooltipDateKeys||["key"],function(a){m=m.replace("{point."+ -a+"}","{point."+a+":"+b+"}")});return p(m,{point:a,series:d})},bodyFormatter:function(a){return l(a,function(a){var d=a.series.tooltipOptions;return(d[(a.point.formatPrefix||"point")+"Formatter"]||a.point.tooltipFormatter).call(a.point,d[(a.point.formatPrefix||"point")+"Format"])})}}})(M);(function(a){var E=a.addEvent,D=a.attr,H=a.charts,p=a.color,f=a.css,l=a.defined,r=a.each,n=a.extend,w=a.find,u=a.fireEvent,e=a.isObject,h=a.offset,m=a.pick,d=a.splat,c=a.Tooltip;a.Pointer=function(a,c){this.init(a, -c)};a.Pointer.prototype={init:function(a,d){this.options=d;this.chart=a;this.runChartClick=d.chart.events&&!!d.chart.events.click;this.pinchDown=[];this.lastValidTouch={};c&&(a.tooltip=new c(a,d.tooltip),this.followTouchMove=m(d.tooltip.followTouchMove,!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,c=b.options.chart,d=c.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=m(c.pinchType,d));this.zoomX=a=/x/.test(d);this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&& -!b||a&&b;this.hasZoom=a||d},normalize:function(a,c){var b;b=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;c||(this.chartPosition=c=h(this.chart.container));return n(a,{chartX:Math.round(b.pageX-c.left),chartY:Math.round(b.pageY-c.top)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};r(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},findNearestKDPoint:function(a,c,d){var b;r(a,function(a){var k= -!(a.noSharedTooltip&&c)&&0>a.options.findNearestPointBy.indexOf("y");a=a.searchPoint(d,k);if((k=e(a,!0))&&!(k=!e(b,!0)))var k=b.distX-a.distX,h=b.dist-a.dist,m=(a.series.group&&a.series.group.zIndex)-(b.series.group&&b.series.group.zIndex),k=0<(0!==k&&c?k:0!==h?h:0!==m?m:b.series.index>a.series.index?-1:1);k&&(b=a)});return b},getPointFromEvent:function(a){a=a.target;for(var b;a&&!b;)b=a.point,a=a.parentNode;return b},getChartCoordinatesFromPoint:function(a,c){var b=a.series,d=b.xAxis,b=b.yAxis,k= -m(a.clientX,a.plotX);if(d&&b)return c?{chartX:d.len+d.pos-k,chartY:b.len+b.pos-a.plotY}:{chartX:k+d.pos,chartY:a.plotY+b.pos}},getHoverData:function(b,c,d,h,f,l,n){var k,z=[],x=n&&n.isBoosting;h=!(!h||!b);n=c&&!c.stickyTracking?[c]:a.grep(d,function(a){return a.visible&&!(!f&&a.directTouch)&&m(a.options.enableMouseTracking,!0)&&a.stickyTracking});c=(k=h?b:this.findNearestKDPoint(n,f,l))&&k.series;k&&(f&&!c.noSharedTooltip?(n=a.grep(d,function(a){return a.visible&&!(!f&&a.directTouch)&&m(a.options.enableMouseTracking, -!0)&&!a.noSharedTooltip}),r(n,function(a){var b=w(a.points,function(a){return a.x===k.x&&!a.isNull});e(b)&&(x&&(b=a.getPoint(b)),z.push(b))})):z.push(k));return{hoverPoint:k,hoverSeries:c,hoverPoints:z}},runPointActions:function(b,c){var d=this.chart,k=d.tooltip&&d.tooltip.options.enabled?d.tooltip:void 0,e=k?k.shared:!1,h=c||d.hoverPoint,f=h&&h.series||d.hoverSeries,f=this.getHoverData(h,f,d.series,!!c||f&&f.directTouch&&this.isDirectTouch,e,b,{isBoosting:d.isBoosting}),l,h=f.hoverPoint;l=f.hoverPoints; -c=(f=f.hoverSeries)&&f.tooltipOptions.followPointer;e=e&&f&&!f.noSharedTooltip;if(h&&(h!==d.hoverPoint||k&&k.isHidden)){r(d.hoverPoints||[],function(b){-1===a.inArray(b,l)&&b.setState()});r(l||[],function(a){a.setState("hover")});if(d.hoverSeries!==f)f.onMouseOver();d.hoverPoint&&d.hoverPoint.firePointEvent("mouseOut");if(!h.series)return;h.firePointEvent("mouseOver");d.hoverPoints=l;d.hoverPoint=h;k&&k.refresh(e?l:h,b)}else c&&k&&!k.isHidden&&(h=k.getAnchor([{}],b),k.updatePosition({plotX:h[0],plotY:h[1]})); -this.unDocMouseMove||(this.unDocMouseMove=E(d.container.ownerDocument,"mousemove",function(b){var c=H[a.hoverChartIndex];if(c)c.pointer.onDocumentMouseMove(b)}));r(d.axes,function(c){var d=m(c.crosshair.snap,!0),k=d?a.find(l,function(a){return a.series[c.coll]===c}):void 0;k||!d?c.drawCrosshair(b,k):c.hideCrosshair()})},reset:function(a,c){var b=this.chart,k=b.hoverSeries,e=b.hoverPoint,h=b.hoverPoints,m=b.tooltip,f=m&&m.shared?h:e;a&&f&&r(d(f),function(b){b.series.isCartesian&&void 0===b.plotX&& -(a=!1)});if(a)m&&f&&(m.refresh(f),e&&(e.setState(e.state,!0),r(b.axes,function(a){a.crosshair&&a.drawCrosshair(null,e)})));else{if(e)e.onMouseOut();h&&r(h,function(a){a.setState()});if(k)k.onMouseOut();m&&m.hide(c);this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove());r(b.axes,function(a){a.hideCrosshair()});this.hoverX=b.hoverPoints=b.hoverPoint=null}},scaleGroups:function(a,c){var b=this.chart,d;r(b.series,function(k){d=a||k.getPlotBox();k.xAxis&&k.xAxis.zoomEnabled&&k.group&&(k.group.attr(d), -k.markerGroup&&(k.markerGroup.attr(d),k.markerGroup.clip(c?b.clipRect:null)),k.dataLabelsGroup&&k.dataLabelsGroup.attr(d))});b.clipRect.attr(c||b.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,h=this.zoomHor,m=this.zoomVert,f=b.plotLeft,l=b.plotTop,n=b.plotWidth,q=b.plotHeight,A,F=this.selectionMarker,G=this.mouseDownX, -g=this.mouseDownY,v=c.panKey&&a[c.panKey+"Key"];F&&F.touch||(df+n&&(d=f+n),el+q&&(e=l+q),this.hasDragged=Math.sqrt(Math.pow(G-d,2)+Math.pow(g-e,2)),10u.max&&(f=u.max-x,v=!0);v?(F-=.8*(F-m[b][0]),q||(g-=.8*(g-m[b][1])),l()):m[b]=[F,g];C||(h[b]=w-r,h[n]=x);h=C?1/t:t;e[n]=x;e[b]=f;p[C?a?"scaleY":"scaleX":"scale"+k]=t;p["translate"+k]=h*r+(F-h*A)},pinch:function(a){var n=this,r=n.chart,u=n.pinchDown,e=a.touches,h=e.length,m=n.lastValidTouch, -d=n.hasZoom,c=n.selectionMarker,b={},k=1===h&&(n.inClass(a.target,"highcharts-tracker")&&r.runTrackerClick||n.runChartClick),z={};1c-6&&h(q||c.spacingBox.width-2*t-d.x)&&(this.itemX=t,this.itemY+=F+this.lastLineHeight+A,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,m);this.lastItemY=F+this.itemY+A;this.lastLineHeight=Math.max(b,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];e?this.itemX+=m:(this.itemY+=F+b+A,this.lastLineHeight=b);this.offsetWidth=q||Math.max((e?this.itemX-t-(a.checkbox?0:p):m)+t,this.offsetWidth)}, -getAllItems:function(){var a=[];f(this.chart.series,function(c){var b=c&&c.options;c&&w(b.showInLegend,p(b.linkedTo)?!1:void 0,!0)&&(a=a.concat(c.legendItems||("point"===b.legendType?c.data:c)))});return a},getAlignment:function(){var a=this.options;return a.floating?"":a.align.charAt(0)+a.verticalAlign.charAt(0)+a.layout.charAt(0)},adjustMargins:function(a,c){var b=this.chart,d=this.options,e=this.getAlignment();e&&f([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(k,h){k.test(e)&& -!p(a[h])&&(b[r[h]]=Math.max(b[r[h]],b.legend[(h+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][h]*d[h%2?"x":"y"]+w(d.margin,12)+c[h]+(0===h?b.titleOffset+b.options.title.margin:0)))})},render:function(){var a=this,c=a.chart,b=c.renderer,k=a.group,h,m,l,x,p=a.box,t=a.options,C=a.padding;a.itemX=C;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;k||(a.group=k=b.g("legend").attr({zIndex:7}).add(),a.contentGroup=b.g().attr({zIndex:1}).add(k),a.scrollGroup=b.g().add(a.contentGroup));a.renderTitle(); -h=a.getAllItems();e(h,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});t.reversed&&h.reverse();a.allItems=h;a.display=m=!!h.length;a.lastLineHeight=0;f(h,function(b){a.renderItem(b)});l=(t.width||a.offsetWidth)+C;x=a.lastItemY+a.lastLineHeight+a.titleHeight;x=a.handleOverflow(x);x+=C;p||(a.box=p=b.rect().addClass("highcharts-legend-box").attr({r:t.borderRadius}).add(k),p.isNew=!0);p.attr({stroke:t.borderColor,"stroke-width":t.borderWidth||0,fill:t.backgroundColor|| -"none"}).shadow(t.shadow);0b&&!1!==t.enabled?(this.clipHeight=l=Math.max(b-20-this.titleHeight-m,0),this.currentPage=w(this.currentPage,1),this.fullHeight=a,f(G,function(a,b){var c=a._legendItemPos[1],d=Math.round(a.legendItem.getBBox().height),g=A.length;if(!g||c-A[g-1]>l&&(F||c)!==A[g-1])A.push(F||c),g++;a.pageIx=g-1;F&&(G[b-1].pageIx=g-1);b===G.length-1&&c+d-A[g-1]>l&&(A.push(c),a.pageIx=g);c!==F&&(F=c)}),n||(n=c.clipRect=d.clipRect(0,m,9999,0),c.contentGroup.clip(n)),g(l),q||(this.nav=q=d.g().attr({zIndex:1}).add(this.group), -this.up=d.symbol("triangle",0,0,r,r).on("click",function(){c.scroll(-1,p)}).add(q),this.pager=d.text("",15,10).addClass("highcharts-legend-navigation").css(t.style).add(q),this.down=d.symbol("triangle-down",0,0,r,r).on("click",function(){c.scroll(1,p)}).add(q)),c.scroll(0),a=b):q&&(g(),this.nav=q.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,c){var b=this.pages,d=b.length;a=this.currentPage+a;var e=this.clipHeight,h=this.options.navigation,f=this.pager, -m=this.padding;a>d&&(a=d);0b&&(f=typeof a[0],"string"===f?e.name=a[0]:"number"===f&&(e.x=a[0]),k++);l=d.value;)d=h[++f];d&&d.color&&!this.options.color&&(this.color=d.color);return d},destroy:function(){var a=this.series.chart,h=a.hoverPoints,f;a.pointCount--;h&&(this.setState(),p(h,this),h.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)u(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(f in this)this[f]=null},destroyElements:function(){for(var a=["graphic","dataLabel", -"dataLabelUpper","connector","shadowGroup"],h,f=6;f--;)h=a[f],this[h]&&(this[h]=this[h].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var e=this.series,f=e.tooltipOptions,d=w(f.valueDecimals,""),c=f.valuePrefix||"",b=f.valueSuffix||"";D(e.pointArrayMap||["y"],function(e){e="{point."+ -e;if(c||b)a=a.replace(e+"}",c+e+"}"+b);a=a.replace(e+"}",e+":,."+d+"f}")});return l(a,{point:this,series:this.series})},firePointEvent:function(a,h,m){var d=this,c=this.series.options;(c.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();"click"===a&&c.allowPointSelect&&(m=function(a){d.select&&d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});f(this,a,h,m)},visible:!0}})(M);(function(a){var E=a.addEvent,D=a.animObject,H=a.arrayMax,p=a.arrayMin,f=a.correctFloat, -l=a.Date,r=a.defaultOptions,n=a.defaultPlotOptions,w=a.defined,u=a.each,e=a.erase,h=a.extend,m=a.fireEvent,d=a.grep,c=a.isArray,b=a.isNumber,k=a.isString,z=a.merge,B=a.objectEach,I=a.pick,x=a.removeEvent,K=a.splat,t=a.SVGElement,C=a.syncTimeout,N=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc", -lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{animation:{duration:50},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3,findNearestPointBy:"x"}, -{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0,directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var c=this,d,g=a.series,e;c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];c.bindAxes();h(c,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});d=b.events;B(d,function(a,b){E(c,b,a)});if(d&&d.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor(); -c.getSymbol();u(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);c.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(e=g[g.length-1]);c._i=I(e&&e._i,-1)+1;a.orderSeries(this.insert(g))},insert:function(a){var c=this.options.index,d;if(b(c)){for(d=a.length;d--;)if(c>=I(a[d].options.index,a[d]._i)){a.splice(d+1,0,this);break}-1===d&&a.unshift(this);d+=1}else a.push(this);return I(d,a.length-1)},bindAxes:function(){var b=this,c=b.options,d=b.chart,e;u(b.axisTypes||[],function(g){u(d[g], -function(a){e=a.options;if(c[g]===e.index||void 0!==c[g]&&c[g]===e.id||void 0===c[g]&&0===e.index)b.insert(a.series),b[g]=a,a.isDirty=!0});b[g]||b.optionalAxis===g||a.error(18,!0)})},updateParallelArrays:function(a,c){var d=a.series,e=arguments,g=b(c)?function(b){var g="y"===b&&d.toYData?d.toYData(a):a[b];d[b+"Data"][c]=g}:function(a){Array.prototype[c].apply(d[a+"Data"],Array.prototype.slice.call(e,2))};u(d.parallelArrays,g)},autoIncrement:function(){var b=this.options,c=this.xIncrement,d,e=b.pointIntervalUnit, -g=0,c=I(c,b.pointStart,0);this.pointInterval=d=I(this.pointInterval,b.pointInterval,1);e&&(b=new l(c),"day"===e?b=+b[l.hcSetDate](b[l.hcGetDate]()+d):"month"===e?b=+b[l.hcSetMonth](b[l.hcGetMonth]()+d):"year"===e&&(b=+b[l.hcSetFullYear](b[l.hcGetFullYear]()+d)),l.hcHasTimeZone&&(g=a.getTZOffset(b)-a.getTZOffset(c)),d=b-c+g);this.xIncrement=c+d;return c},setOptions:function(a){var b=this.chart,c=b.options,d=c.plotOptions,g=(b.userOptions||{}).plotOptions||{},e=d[this.type];this.userOptions=a;b=z(e, -d.series,a);this.tooltipOptions=z(r.tooltip,r.plotOptions.series&&r.plotOptions.series.tooltip,r.plotOptions[this.type].tooltip,c.tooltip.userOptions,d.series&&d.series.tooltip,d[this.type].tooltip,a.tooltip);this.stickyTracking=I(a.stickyTracking,g[this.type]&&g[this.type].stickyTracking,g.series&&g.series.stickyTracking,this.tooltipOptions.shared&&!this.noSharedTooltip?!0:b.stickyTracking);null===e.marker&&delete b.marker;this.zoneAxis=b.zoneAxis;a=this.zones=(b.zones||[]).slice();!b.negativeColor&& -!b.negativeFillColor||b.zones||a.push({value:b[this.zoneAxis+"Threshold"]||b.threshold||0,className:"highcharts-negative",color:b.negativeColor,fillColor:b.negativeFillColor});a.length&&w(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return b},getCyclic:function(a,b,c){var d,g=this.chart,e=this.userOptions,k=a+"Index",h=a+"Counter",q=c?c.length:I(g.options.chart[a+"Count"],g[a+"Count"]);b||(d=I(e[k],e["_"+k]),w(d)||(g.series.length||(g[h]=0),e["_"+k]=d=g[h]%q,g[h]+=1), -c&&(b=c[d]));void 0!==d&&(this[k]=d);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",this.options.color||n[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker,setData:function(d,e,h,f){var g=this,q=g.points,m=q&&q.length||0,l,A=g.options,t=g.chart,x=null,n=g.xAxis,p=A.turboThreshold,z=this.xData,F= -this.yData,C=(l=g.pointArrayMap)&&l.length;d=d||[];l=d.length;e=I(e,!0);if(!1!==f&&l&&m===l&&!g.cropped&&!g.hasGroupedData&&g.visible)u(d,function(a,b){q[b].update&&a!==A.data[b]&&q[b].update(a,!1,null,!1)});else{g.xIncrement=null;g.colorCounter=0;u(this.parallelArrays,function(a){g[a+"Data"].length=0});if(p&&l>p){for(h=0;null===x&&hf||this.forceCrop))if(c[e-1]z)c=[],d=[];else if(c[0]z)g=this.cropData(this.xData,this.yData,p,z),c=g.xData,d=g.yData,g=g.start,k=!0;for(f=c.length|| -1;--f;)e=x?m(c[f])-m(c[f-1]):c[f]-c[f-1],0e&&n&&(a.error(15),n=!1);this.cropped=k;this.cropStart=g;this.processedXData=c;this.processedYData=d;this.closestPointRange=h},cropData:function(a,b,c,d){var g=a.length,e=0,k=g,h=I(this.cropShoulder,1),f;for(f=0;f=c){e=Math.max(0,f-h);break}for(c=f;cd){k=c+h;break}return{xData:a.slice(e,k),yData:b.slice(e,k),start:e,end:k}},generatePoints:function(){var a=this.options,b=a.data,c=this.data,d,g=this.processedXData, -e=this.processedYData,k=this.pointClass,h=g.length,f=this.cropStart||0,m,l=this.hasGroupedData,a=a.keys,t,x=[],n;c||l||(c=[],c.length=b.length,c=this.data=c);a&&l&&(this.options.keys=!1);for(n=0;n=f&&(e[n-1]||l)<=q,m&&l)if(m=t.length)for(;m--;)"number"===typeof t[m]&&(g[h++]=t[m]);else g[h++]=t;this.dataMin= -p(g);this.dataMax=H(g)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,c=a.stacking,d=this.xAxis,e=d.categories,g=this.yAxis,k=this.points,h=k.length,m=!!this.modifyValue,l=a.pointPlacement,t="between"===l||b(l),n=a.threshold,x=a.startFromThreshold?n:0,p,z,C,r,u=Number.MAX_VALUE;"between"===l&&(l=.5);b(l)&&(l*=I(a.pointRange||d.pointRange));for(a=0;a=K&&(B.isNull=!0);B.plotX=p=f(Math.min(Math.max(-1E5,d.translate(N,0,0,0,1,l,"flags"===this.type)),1E5));c&&this.visible&&!B.isNull&&D&&D[N]&&(r=this.getStackIndicator(r,N,this.index),E=D[N],K=E.points[r.key],z=K[0],K=K[1],z===x&&r.key===D[N].base&&(z=I(n,g.min)),g.positiveValuesOnly&&0>=z&&(z=null),B.total=B.stackTotal=E.total,B.percentage=E.total&&B.y/E.total*100,B.stackY=K,E.setOffset(this.pointXOffset||0,this.barW||0));B.yBottom=w(z)?g.translate(z,0,1,0,1): -null;m&&(K=this.modifyValue(K,B));B.plotY=z="number"===typeof K&&Infinity!==K?Math.min(Math.max(-1E5,g.translate(K,0,1,0,1)),1E5):void 0;B.isInside=void 0!==z&&0<=z&&z<=g.len&&0<=p&&p<=d.len;B.clientX=t?f(d.translate(N,0,0,0,1,l)):p;B.negative=B.y<(n||0);B.category=e&&void 0!==e[B.x]?e[B.x]:B.x;B.isNull||(void 0!==C&&(u=Math.min(u,Math.abs(p-C))),C=p);B.zone=this.zones.length&&B.getZone()}this.closestPointRangePx=u},getValidPoints:function(a,b){var c=this.chart;return d(a||this.points||[],function(a){return b&& -!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,d=b.renderer,g=b.inverted,e=this.clipBox,k=e||b.clipBox,h=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,k.height,c.xAxis,c.yAxis].join(),f=b[h],q=b[h+"m"];f||(a&&(k.width=0,g&&(k.x=b.plotSizeX),b[h+"m"]=q=d.clipRect(g?b.plotSizeX+99:-99,g?-b.plotLeft:-b.plotTop,99,g?b.chartWidth:b.chartHeight)),b[h]=f=d.clipRect(k),f.count={length:0});a&&!f.count[this.index]&&(f.count[this.index]= -!0,f.count.length+=1);!1!==c.clip&&(this.group.clip(a||e?f:b.clipRect),this.markerGroup.clip(q),this.sharedClipKey=h);a||(f.count[this.index]&&(delete f.count[this.index],--f.count.length),0===f.count.length&&h&&b[h]&&(e||(b[h]=b[h].destroy()),b[h+"m"]&&(b[h+"m"]=b[h+"m"].destroy())))},animate:function(a){var b=this.chart,c=D(this.options.animation),d;a?this.setClip(c):(d=this.sharedClipKey,(a=b[d])&&a.animate({width:b.plotSizeX,x:0},c),b[d+"m"]&&b[d+"m"].animate({width:b.plotSizeX+99,x:0},c),this.animate= -null)},afterAnimate:function(){this.setClip();m(this,"afterAnimate");this.finishedAnimating=!0},drawPoints:function(){var a=this.points,b=this.chart,c,d,g,e,k=this.options.marker,h,f,l,m=this[this.specialGroup]||this.markerGroup,t,n=I(k.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>=2*k.radius);if(!1!==k.enabled||this._hasPointMarkers)for(c=0;ce&&b.shadow));k&&(k.startX=c.xMap,k.isArea=c.isArea)})}, -applyZones:function(){var a=this,b=this.chart,c=b.renderer,d=this.zones,e,k,h=this.clips||[],f,m=this.graph,l=this.area,t=Math.max(b.chartWidth,b.chartHeight),n=this[(this.zoneAxis||"y")+"Axis"],x,p,z=b.inverted,C,r,w,B,K=!1;d.length&&(m||l)&&n&&void 0!==n.min&&(p=n.reversed,C=n.horiz,m&&m.hide(),l&&l.hide(),x=n.getExtremes(),u(d,function(d,g){e=p?C?b.plotWidth:0:C?0:n.toPixels(x.min);e=Math.min(Math.max(I(k,e),0),t);k=Math.min(Math.max(Math.round(n.toPixels(I(d.value,x.max),!0)),0),t);K&&(e=k=n.toPixels(x.max)); -r=Math.abs(e-k);w=Math.min(e,k);B=Math.max(e,k);n.isXAxis?(f={x:z?B:w,y:0,width:r,height:t},C||(f.x=b.plotHeight-f.x)):(f={x:0,y:z?B:w,width:t,height:r},C&&(f.y=b.plotWidth-f.y));z&&c.isVML&&(f=n.isXAxis?{x:0,y:p?w:B,height:f.width,width:b.chartWidth}:{x:f.y-b.plotLeft-b.spacingBox.x,y:0,width:f.height,height:b.chartHeight});h[g]?h[g].animate(f):(h[g]=c.clipRect(f),m&&a["zone-graph-"+g].clip(h[g]),l&&a["zone-area-"+g].clip(h[g]));K=d.value>x.max}),this.clips=h)},invertGroups:function(a){function b(){u(["group", -"markerGroup"],function(b){c[b]&&(d.renderer.isVML&&c[b].attr({width:c.yAxis.len,height:c.xAxis.len}),c[b].width=c.yAxis.len,c[b].height=c.xAxis.len,c[b].invert(a))})}var c=this,d=c.chart,e;c.xAxis&&(e=E(d,"resize",b),E(c,"destroy",e),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,d,e){var g=this[a],k=!g;k&&(this[a]=g=this.chart.renderer.g().attr({zIndex:d||.1}).add(e));g.addClass("highcharts-"+b+" highcharts-series-"+this.index+" highcharts-"+this.type+"-series "+(w(this.colorIndex)?"highcharts-color-"+ -this.colorIndex+" ":"")+(this.options.className||"")+(g.hasClass("highcharts-tracker")?" highcharts-tracker":""),!0);g.attr({visibility:c})[k?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,d=a.options,e=!!a.animate&&b.renderer.isSVG&&D(d.animation).duration,k=a.visible?"inherit": -"hidden",h=d.zIndex,f=a.hasRendered,m=b.seriesGroup,l=b.inverted;c=a.plotGroup("group","series",k,h,m);a.markerGroup=a.plotGroup("markerGroup","markers",k,h,m);e&&a.animate(!0);c.inverted=a.isCartesian?l:!1;a.drawGraph&&(a.drawGraph(),a.applyZones());a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(l);!1===d.clip||a.sharedClipKey||f||c.clip(b.clipRect);e&&a.animate();f||(a.animationTimeout=C(function(){a.afterAnimate()}, -e));a.isDirty=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:I(d&&d.left,a.plotLeft),translateY:I(e&&e.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,d=this.yAxis,e=this.chart.inverted;return this.searchKDTree({clientX:e?c.len-a.chartY+ -c.pos:a.chartX-c.pos,plotY:e?d.len-a.chartX+d.pos:a.chartY-d.pos},b)},buildKDTree:function(){function a(c,d,e){var g,k;if(k=c&&c.length)return g=b.kdAxisArray[d%e],c.sort(function(a,b){return a[g]-b[g]}),k=Math.floor(k/2),{point:c[k],left:a(c.slice(0,k),d+1,e),right:a(c.slice(k+1),d+1,e)}}this.buildingKdTree=!0;var b=this,c=-1l?"left":"right";t=0>l?"right":"left";b[q]&&(q=c(a,b[q],g+1,f),n=q[h]x;)q--;this.updateParallelArrays(m,"splice",q,0,0);this.updateParallelArrays(m,q);g&&m.name&&(g[x]=m.name);l.splice(q,0,a);n&&(this.data.splice(q,0,null),this.processData());"point"===e.legendType&&this.generatePoints();c&&(h[0]&&h[0].remove?h[0].remove(!1):(h.shift(),this.updateParallelArrays(m,"shift"),l.shift()));this.isDirtyData=this.isDirty=!0;b&&f.redraw(d)},removePoint:function(a,b,c){var d=this,e=d.data,h=e[a],f=d.points,g=d.chart,l=function(){f&&f.length===e.length&& -f.splice(a,1);e.splice(a,1);d.options.data.splice(a,1);d.updateParallelArrays(h||{series:d},"splice",a,1);h&&h.destroy();d.isDirty=!0;d.isDirtyData=!0;b&&g.redraw()};x(c,g);b=k(b,!0);h?h.firePointEvent("remove",null,l):l()},remove:function(a,b,c){function d(){e.destroy();h.isDirtyLegend=h.isDirtyBox=!0;h.linkSeries();k(a,!0)&&h.redraw(b)}var e=this,h=e.chart;!1!==c?u(e,"remove",null,d):d()},update:function(a,b){var d=this,e=d.chart,h=d.userOptions,f=d.oldType||d.type,l=a.type||h.type||e.options.chart.type, -g=I[f].prototype,m,n=["group","markerGroup","dataLabelsGroup"],t=["navigatorSeries","baseSeries"],x=d.finishedAnimating&&{animation:!1};if(Object.keys&&"data"===Object.keys(a).toString())return this.setData(a.data,b);t=n.concat(t);r(t,function(a){t[a]=d[a];delete d[a]});a=c(h,x,{index:d.index,pointStart:d.xData[0]},{data:d.options.data},a);d.remove(!1,null,!1);for(m in g)d[m]=void 0;w(d,I[l||f].prototype);r(t,function(a){d[a]=t[a]});d.init(e,a);a.zIndex!==h.zIndex&&r(n,function(b){d[b]&&d[b].attr({zIndex:a.zIndex})}); -d.oldType=f;e.linkSeries();k(b,!0)&&e.redraw(!1)}});w(H.prototype,{update:function(a,b){var d=this.chart;a=d.options[this.coll][this.options.index]=c(this.userOptions,a);this.destroy(!0);this.init(d,w(a,{events:void 0}));d.isDirtyBox=!0;k(b,!0)&&d.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,e=this.series,h=e.length;h--;)e[h]&&e[h].remove(!1);n(b.axes,this);n(b[c],this);d(b.options[c])?b.options[c].splice(this.options.index,1):delete b.options[c];r(b[c],function(a,b){a.options.index= -b});this.destroy();b.isDirtyBox=!0;k(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(M);(function(a){var E=a.color,D=a.each,H=a.map,p=a.pick,f=a.Series,l=a.seriesType;l("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(f){var l=[],r=[],u=this.xAxis,e=this.yAxis,h=e.stacks[this.stackKey],m={},d=this.index,c=e.series,b=c.length,k,z=p(e.options.reversedStacks,!0)?1:-1,B;f=f||this.points; -if(this.options.stacking){for(B=0;Ba&&w>l?(w=Math.max(a,l),e=2*l-w):wp&&e>l?(e=Math.max(p,l),w=2*l-e):e=Math.abs(h)&&.5a.closestPointRange*a.xAxis.transA,d=a.borderWidth=r(f.borderWidth,d?0:1),c=a.yAxis,b=f.threshold,k=a.translatedThreshold=c.getThreshold(b),l=r(f.minPointLength,5),p=a.getColumnMetrics(),u=p.width,x=a.barW=Math.max(u,1+2*d),w=a.pointXOffset=p.offset;h.inverted&&(k-=.5);f.pointPadding&&(x=Math.ceil(x));n.prototype.translate.apply(a);H(a.points,function(d){var e=r(d.yBottom,k),f=999+Math.abs(e),f=Math.min(Math.max(-f,d.plotY),c.len+f),m=d.plotX+w,n=x,t=Math.min(f,e),p,g=Math.max(f,e)-t;l&& -Math.abs(g)l?e-l:k-(p?l:0));d.barX=m;d.pointWidth=u;d.tooltipPos=h.inverted?[c.len+c.pos-h.plotLeft-f,a.xAxis.len-m-n/2,g]:[m+n/2,f+c.pos-h.plotTop,g];d.shapeType="rect";d.shapeArgs=a.crispCol.apply(a,d.isNull?[m,k,n,0]:[m,t,n,g])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")}, -pointAttribs:function(a,f){var e=this.options,d,c=this.pointAttrToOptions||{};d=c.stroke||"borderColor";var b=c["stroke-width"]||"borderWidth",k=a&&a.color||this.color,h=a&&a[d]||e[d]||this.color||k,n=a&&a[b]||e[b]||this[b]||0,c=e.dashStyle;a&&this.zones.length&&(k=a.getZone(),k=a.options.color||k&&k.color||this.color);f&&(a=l(e.states[f],a.options.states&&a.options.states[f]||{}),f=a.brightness,k=a.color||void 0!==f&&D(k).brighten(a.brightness).get()||k,h=a[d]||h,n=a[b]||n,c=a.dashStyle||c);d={fill:k, -stroke:h,"stroke-width":n};c&&(d.dashstyle=c);return d},drawPoints:function(){var a=this,h=this.chart,m=a.options,d=h.renderer,c=m.animationLimit||250,b;H(a.points,function(e){var k=e.graphic;if(f(e.plotY)&&null!==e.y){b=e.shapeArgs;if(k)k[h.pointCounte;++e)h=w[e],a=2>e||2===e&&/%$/.test(h),w[e]=p(h,[n,l,u,w[2]][e])+(a?r:0);w[3]>w[2]&&(w[3]=w[2]);return w},getStartAndEndRadians:function(a,l){a=D(a)?a:0;l=D(l)&&l>a&&360>l-a?l:a+360;return{start:E*(a+-90),end:E*(l+-90)}}}})(M);(function(a){var E=a.addEvent,D=a.CenteredSeriesMixin,H=a.defined,p=a.each,f=a.extend,l=D.getStartAndEndRadians,r=a.inArray,n=a.noop,w=a.pick,u=a.Point,e=a.Series,h=a.seriesType,m=a.setAnimation;h("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30, -enabled:!0,formatter:function(){return this.point.isNull?void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c= -this,b=c.points,d=c.startAngleRad;a||(p(b,function(a){var b=a.graphic,e=a.shapeArgs;b&&(b.attr({r:a.startR||c.center[3]/2,start:d,end:d}),b.animate({r:e.r,start:e.start,end:e.end},c.options.animation))}),c.animate=null)},updateTotals:function(){var a,c=0,b=this.points,e=b.length,f,h=this.options.ignoreHiddenPoint;for(a=0;a1.5*Math.PI?m-=2*Math.PI:m<-Math.PI/2&&(m+=2*Math.PI);G.slicedTranslation={translateX:Math.round(Math.cos(m)*d),translateY:Math.round(Math.sin(m)*d)};h=Math.cos(m)*a[2]/ -2;u=Math.sin(m)*a[2]/2;G.tooltipPos=[a[0]+.7*h,a[1]+.7*u];G.half=m<-Math.PI/2||m>Math.PI/2?1:0;G.angle=m;f=Math.min(e,G.labelDistance/5);G.labelPos=[a[0]+h+Math.cos(m)*G.labelDistance,a[1]+u+Math.sin(m)*G.labelDistance,a[0]+h+Math.cos(m)*f,a[1]+u+Math.sin(m)*f,a[0]+h,a[1]+u,0>G.labelDistance?"center":G.half?"right":"left",m]}},drawGraph:null,drawPoints:function(){var a=this,c=a.chart.renderer,b,e,h,l,m=a.options.shadow;m&&!a.shadowGroup&&(a.shadowGroup=c.g("shadow").add(a.group));p(a.points,function(d){e= -d.graphic;if(d.isNull)e&&(d.graphic=e.destroy());else{l=d.shapeArgs;b=d.getTranslate();var k=d.shadowGroup;m&&!k&&(k=d.shadowGroup=c.g("shadow").add(a.shadowGroup));k&&k.attr(b);h=a.pointAttribs(d,d.selected&&"select");e?e.setRadialReference(a.center).attr(h).animate(f(l,b)):(d.graphic=e=c[d.shapeType](l).setRadialReference(a.center).attr(b).add(a.group),d.visible||e.attr({visibility:"hidden"}),e.attr(h).attr({"stroke-linejoin":"round"}).shadow(m,k));e.addClass(d.getClassName())}})},searchPoint:n, -sortByAngle:function(a,c){a.sort(function(a,d){return void 0!==a.angle&&(d.angle-a.angle)*c})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:D.getCenter,getSymbol:n},{init:function(){u.prototype.init.apply(this,arguments);var a=this,c;a.name=w(a.name,"Slice");c=function(b){a.slice("select"===b.type)};E(a,"select",c);E(a,"unselect",c);return a},isValid:function(){return a.isNumber(this.y,!0)&&0<=this.y},setVisible:function(a,c){var b=this,d=b.series,e=d.chart,f=d.options.ignoreHiddenPoint; -c=w(c,f);a!==b.visible&&(b.visible=b.options.visible=a=void 0===a?!b.visible:a,d.options.data[r(b,d.data)]=b.options,p(["graphic","dataLabel","connector","shadowGroup"],function(c){if(b[c])b[c][a?"show":"hide"](!0)}),b.legendItem&&e.legend.colorizeItem(b,a),a||"hover"!==b.state||b.setState(""),f&&(d.isDirty=!0),c&&e.redraw())},slice:function(a,c,b){var d=this.series;m(b,d.chart);w(c,!0);this.sliced=this.options.sliced=H(a)?a:!this.sliced;d.options.data[r(this,d.data)]=this.options;this.graphic.animate(this.getTranslate()); -this.shadowGroup&&this.shadowGroup.animate(this.getTranslate())},getTranslate:function(){return this.sliced?this.slicedTranslation:{translateX:0,translateY:0}},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r-1,start:c.start,end:c.end})}})})(M);(function(a){var E=a.addEvent,D=a.arrayMax,H=a.defined,p=a.each,f=a.extend,l=a.format,r=a.map,n=a.merge,w=a.noop,u=a.pick,e=a.relativeLength,h= -a.Series,m=a.seriesTypes,d=a.stableSort;a.distribute=function(a,b){function c(a,b){return a.target-b.target}var e,f=!0,h=a,l=[],m;m=0;for(e=a.length;e--;)m+=a[e].size;if(m>b){d(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(m=e=0;m<=b;)m+=a[e].size,e++;l=a.splice(e-1,a.length)}d(a,c);for(a=r(a,function(a){return{size:a.size,targets:[a.target],align:u(a.align,.5)}});f;){for(e=a.length;e--;)f=a[e],m=(Math.min.apply(0,f.targets)+Math.max.apply(0,f.targets))/2,f.pos=Math.min(Math.max(0,m-f.size* -f.align),b-f.size);e=a.length;for(f=!1;e--;)0a[e].pos&&(a[e-1].size+=a[e].size,a[e-1].targets=a[e-1].targets.concat(a[e].targets),a[e-1].align=.5,a[e-1].pos+a[e-1].size>b&&(a[e-1].pos=b-a[e-1].size),a.splice(e,1),f=!0)}e=0;p(a,function(a){var b=0;p(a.targets,function(){h[e].pos=a.pos+b;b+=h[e].size;e++})});h.push.apply(h,l);d(h,c)};h.prototype.drawDataLabels=function(){function c(a,b){var c=b.filter;return c?(b=c.operator,a=a[c.property],c=c.value,"\x3e"===b&&a>c||"\x3c"=== -b&&a=c||"\x3c\x3d"===b&&a<=c||"\x3d\x3d"===b&&a==c||"\x3d\x3d\x3d"===b&&a===c?!0:!1):!0}var b=this,d=b.options,e=d.dataLabels,f=b.points,h,m,r=b.hasRendered||0,t,w,D=u(e.defer,!!d.animation),q=b.chart.renderer;if(e.enabled||b._hasPointLabels)b.dlProcessOptions&&b.dlProcessOptions(e),w=b.plotGroup("dataLabelsGroup","data-labels",D&&!r?"hidden":"visible",e.zIndex||6),D&&(w.attr({opacity:+r}),r||E(b,"afterAnimate",function(){b.visible&&w.show(!0);w[d.animation?"animate":"attr"]({opacity:1}, -{duration:200})})),m=e,p(f,function(f){var k,p=f.dataLabel,g,x,r=f.connector,z=!p,C;h=f.dlOptions||f.options&&f.options.dataLabels;(k=u(h&&h.enabled,m.enabled)&&!f.isNull)&&(k=!0===c(f,h||e));k&&(e=n(m,h),g=f.getLabelConfig(),C=e[f.formatPrefix+"Format"]||e.format,t=H(C)?l(C,g):(e[f.formatPrefix+"Formatter"]||e.formatter).call(g,e),C=e.style,g=e.rotation,C.color=u(e.color,C.color,b.color,"#000000"),"contrast"===C.color&&(f.contrastColor=q.getContrast(f.color||b.color),C.color=e.inside||0>u(f.labelDistance, -e.distance)||d.stacking?f.contrastColor:"#000000"),d.cursor&&(C.cursor=d.cursor),x={fill:e.backgroundColor,stroke:e.borderColor,"stroke-width":e.borderWidth,r:e.borderRadius||0,rotation:g,padding:e.padding,zIndex:1},a.objectEach(x,function(a,b){void 0===a&&delete x[b]}));!p||k&&H(t)?k&&H(t)&&(p?x.text=t:(p=f.dataLabel=g?q.text(t,0,-9999).addClass("highcharts-data-label"):q.label(t,0,-9999,e.shape,null,null,e.useHTML,null,"data-label"),p.addClass(" highcharts-data-label-color-"+f.colorIndex+" "+(e.className|| -"")+(e.useHTML?"highcharts-tracker":""))),p.attr(x),p.css(C).shadow(e.shadow),p.added||p.add(w),b.alignDataLabel(f,p,e,null,z)):(f.dataLabel=p=p.destroy(),r&&(f.connector=r.destroy()))})};h.prototype.alignDataLabel=function(a,b,d,e,h){var c=this.chart,k=c.inverted,l=u(a.dlBox&&a.dlBox.centerX,a.plotX,-9999),m=u(a.plotY,-9999),n=b.getBBox(),p,q=d.rotation,r=d.align,w=this.visible&&(a.series.forceDL||c.isInsidePlot(l,Math.round(m),k)||e&&c.isInsidePlot(l,k?e.x+1:e.y+e.height-1,k)),z="justify"===u(d.overflow, -"justify");if(w&&(p=d.style.fontSize,p=c.renderer.fontMetrics(p,b).b,e=f({x:k?this.yAxis.len-m:l,y:Math.round(k?this.xAxis.len-l:m),width:0,height:0},e),f(d,{width:n.width,height:n.height}),q?(z=!1,l=c.renderer.rotCorr(p,q),l={x:e.x+d.x+e.width/2+l.x,y:e.y+d.y+{top:0,middle:.5,bottom:1}[d.verticalAlign]*e.height},b[h?"attr":"animate"](l).attr({align:r}),m=(q+720)%360,m=180m,"left"===r?l.y-=m?n.height:0:"center"===r?(l.x-=n.width/2,l.y-=n.height/2):"right"===r&&(l.x-=n.width,l.y-=m?0:n.height)): -(b.align(d,null,e),l=b.alignAttr),z?a.isLabelJustified=this.justifyDataLabel(b,d,l,n,e,h):u(d.crop,!0)&&(w=c.isInsidePlot(l.x,l.y)&&c.isInsidePlot(l.x+n.width,l.y+n.height)),d.shape&&!q))b[h?"attr":"animate"]({anchorX:k?c.plotWidth-a.plotY:a.plotX,anchorY:k?c.plotHeight-a.plotX:a.plotY});w||(b.attr({y:-9999}),b.placed=!1)};h.prototype.justifyDataLabel=function(a,b,d,e,f,h){var c=this.chart,k=b.align,l=b.verticalAlign,m,n,p=a.box?0:a.padding||0;m=d.x+p;0>m&&("right"===k?b.align="left":b.x=-m,n=!0); -m=d.x+e.width-p;m>c.plotWidth&&("left"===k?b.align="right":b.x=c.plotWidth-m,n=!0);m=d.y+p;0>m&&("bottom"===l?b.verticalAlign="top":b.y=-m,n=!0);m=d.y+e.height-p;m>c.plotHeight&&("top"===l?b.verticalAlign="bottom":b.y=c.plotHeight-m,n=!0);n&&(a.placed=!h,a.align(b,null,f));return n};m.pie&&(m.pie.prototype.drawDataLabels=function(){var c=this,b=c.data,d,e=c.chart,f=c.options.dataLabels,l=u(f.connectorPadding,10),m=u(f.connectorWidth,1),n=e.plotWidth,t=e.plotHeight,r,w=c.center,q=w[2]/2,A=w[1],F,G, -g,v,E=[[],[]],L,P,J,M,y=[0,0,0,0];c.visible&&(f.enabled||c._hasPointLabels)&&(p(b,function(a){a.dataLabel&&a.visible&&a.dataLabel.shortened&&(a.dataLabel.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),a.dataLabel.shortened=!1)}),h.prototype.drawDataLabels.apply(c),p(b,function(a){a.dataLabel&&a.visible&&(E[a.half].push(a),a.dataLabel._pos=null)}),p(E,function(b,h){var k,m,x=b.length,r=[],z;if(x)for(c.sortByAngle(b,h-.5),0d.bottom-2?k:P,h,d),F._attr={visibility:J,align:g[6]},F._pos={x:L+f.x+({left:l,right:-l}[g[6]]||0),y:P+f.y-10},g.x=L,g.y=P,u(f.crop,!0)&&(G=F.getBBox().width,k=null,L-Gn-l&&(k=Math.round(L+G-n+l),y[1]=Math.max(k,y[1])),0>P-v/2?y[0]=Math.max(Math.round(-P+v/2),y[0]):P+v/2>t&&(y[2]=Math.max(Math.round(P+v/2-t),y[2])),F.sideOverflow=k)}),0===D(y)||this.verifyDataLabelOverflow(y))&&(this.placeDataLabels(), -m&&p(this.points,function(a){var b;r=a.connector;if((F=a.dataLabel)&&F._pos&&a.visible&&0u(this.translatedThreshold,k.yAxis.len)),p=u(d.inside,!!this.options.stacking);l&&(e=n(l),0>e.y&&(e.height+=e.y,e.y=0),l=e.y+e.height-k.yAxis.len,0a+c||e+hb+d||f+lthis.pointCount))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&r(d,function(a){a.setState()});r("xy"===b?[1,0]:[1],function(b){b= -c[b?"xAxis":"yAxis"][0];var d=b.horiz,f=a[d?"chartX":"chartY"],d=d?"mouseDownX":"mouseDownY",h=c[d],g=(b.pointRange||0)/2,k=b.getExtremes(),l=b.toValue(h-f,!0)+g,m=b.toValue(h+b.len-f,!0)-g,n=m=l(n.minWidth,0)&&this.chartHeight>=l(n.minHeight,0)}).call(this)&&f.push(a._id)};E.prototype.currentOptions=function(l){function n(e,h,l,d){var c;a.objectEach(e,function(a,e){if(!d&&-1 Date: Mon, 8 Jan 2018 18:12:57 +1300 Subject: [PATCH 024/101] Add a green border around predictions boxes --- app/assets/stylesheets/predictions.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/predictions.sass b/app/assets/stylesheets/predictions.sass index b9496ebc5..00be9af21 100644 --- a/app/assets/stylesheets/predictions.sass +++ b/app/assets/stylesheets/predictions.sass @@ -1,7 +1,7 @@ .predictions .metric height: 180px - border: #000000 2px + border: 1px solid lighten($green, 20%) background: $white margin: 4px strong From 020d024e4b7bb94fc13ba19dff6a78e7ea361c28 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Mon, 8 Jan 2018 23:46:57 +0000 Subject: [PATCH 025/101] Auto corrected by following EmptyLine --- script/check_contributors_md.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/script/check_contributors_md.rb b/script/check_contributors_md.rb index 3fca50489..4792abbb5 100755 --- a/script/check_contributors_md.rb +++ b/script/check_contributors_md.rb @@ -22,7 +22,6 @@ else abort %( Couldn't determine your GitHub username, and not in a Travis PR build Please set it using - git config --add github.user [username] ) end From b1096cd021778ebb0fb356bed41ee81f42bd1e3d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 9 Jan 2018 12:51:21 +1300 Subject: [PATCH 026/101] Moved chart includes to application.js, attempting to fix json parse error --- app/assets/javascripts/application.js | 2 ++ app/assets/javascripts/charts.js | 2 -- app/views/crops/show.html.haml | 3 --- app/views/layouts/application.html.haml | 4 +--- config/initializers/assets.rb | 1 - 5 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 app/assets/javascripts/charts.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index fc3369264..e0d7b8463 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,6 +10,8 @@ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // +// = require Chart.bundle +// = require chartkick // = require leaflet // = require leaflet.markercluster // = require js-routes diff --git a/app/assets/javascripts/charts.js b/app/assets/javascripts/charts.js deleted file mode 100644 index 1c42da456..000000000 --- a/app/assets/javascripts/charts.js +++ /dev/null @@ -1,2 +0,0 @@ -// = require Chart.bundle -// = require chartkick diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index cf401681e..e5e7e7a1a 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -8,9 +8,6 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -- content_for :scripts do - = javascript_include_tag "charts" - = render partial: 'approval_status_message', locals: { crop: @crop } - if @crop.approved? diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 40f83db5b..b90c025e7 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,6 +1,6 @@ !!! 5 %html{ lang: "en", prefix: "og: http://ogp.me/ns#" } - = yield :scripts + = javascript_include_tag "application" = render partial: "layouts/meta" %body = render partial: "layouts/header" @@ -27,6 +27,4 @@ Javascripts \================================================== / Placed at the end of the document so the pages load faster - = javascript_include_tag "application" - != Growstuff::Application.config.analytics_code diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 60484d4a4..4b828e80c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -12,4 +12,3 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules') # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) -Rails.application.config.assets.precompile += %w(charts.js) From 427a0187e1e761d1820349bee6c9f2464aa5144d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 9 Jan 2018 13:18:58 +1300 Subject: [PATCH 027/101] updated prediction spec --- spec/features/crops/crop_detail_page_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 05ebdb6e7..29d73a47a 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -215,7 +215,7 @@ feature "crop detail page", js: true do end it "predicts lifespan" do - is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" + is_expected.to have_text "Median lifespan 99 days" end it "describes annual crops" do From ca16b2c40709c4b38d6aae2034dd34612c176921 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 9 Jan 2018 14:31:03 +1300 Subject: [PATCH 028/101] Removed ignore of highcharts --- .overcommit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.overcommit.yml b/.overcommit.yml index 200a90e42..d7899885f 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -61,7 +61,6 @@ PreCommit: enabled: true exclude: - 'app/assets/**' - - 'app/assets/javascripts/highcharts.js' - 'spec/javascripts/support/vendor/**' - '**/bootstrap*' command: ['./node_modules/.bin/eslint'] From 49253b59ee4b741bc2c8b6ffb95124fc0f36ef79 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 9 Jan 2018 14:37:21 +1300 Subject: [PATCH 029/101] Fixing up prediction specs --- spec/features/crops/crop_detail_page_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 29d73a47a..e21c5eb47 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -181,6 +181,7 @@ feature "crop detail page", js: true do # 10 days to harvest FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: planting.crop, planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + planting.crop.update_medians end it "predicts harvest" do is_expected.to have_text("First harvest expected 20 days after planting") @@ -215,7 +216,8 @@ feature "crop detail page", js: true do end it "predicts lifespan" do - is_expected.to have_text "Median lifespan 99 days" + is_expected.to have_text "Median lifespan" + is_expected.to have_text "99 days" end it "describes annual crops" do From 8d166f1fe631ac5e6b142efbc765bab5161cf792 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Tue, 9 Jan 2018 01:59:43 +0000 Subject: [PATCH 030/101] Auto corrected by following FactoryBot/DynamicAttributeDefinedStatically --- spec/factories/harvests.rb | 2 +- spec/factories/member.rb | 2 +- spec/factories/planting.rb | 6 +++--- spec/factories/post.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index c707a2e2c..ae3144a1e 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -6,7 +6,7 @@ FactoryBot.define do plant_part planting nil owner { planting.present? ? planting.owner : FactoryBot.create(:member) } - harvested_at Time.zone.local(2015, 9, 17) + harvested_at { Time.zone.local(2015, 9, 17) } quantity "3" unit "individual" weight_quantity 6 diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 619e7d4f2..016b12263 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -7,7 +7,7 @@ FactoryBot.define do password 'password1' email { generate(:email) } tos_agreement true - confirmed_at Time.now + confirmed_at { Time.now } show_email false bio 'I love seeds' diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 2bcfac397..5b7311025 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -3,7 +3,7 @@ FactoryBot.define do owner garden { FactoryBot.create :garden, owner: owner } crop - planted_at Time.zone.local(2014, 7, 30) + planted_at { Time.zone.local(2014, 7, 30) } quantity 33 description "This is a *really* good plant." @@ -33,8 +33,8 @@ FactoryBot.define do factory :finished_planting do finished true - planted_at Time.zone.local(2014, 7, 30) - finished_at Time.zone.local(2014, 8, 30) + planted_at { Time.zone.local(2014, 7, 30) } + finished_at { Time.zone.local(2014, 8, 30) } end end end diff --git a/spec/factories/post.rb b/spec/factories/post.rb index d53f33100..da6390ef8 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -3,7 +3,7 @@ FactoryBot.define do subject "A Post" body "This is some text." author - created_at Time.now + created_at { Time.now } # Markdown is allowed in posts factory :markdown_post do From dea7ce241b0d7242c34d0609c8190e6193279105 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Tue, 9 Jan 2018 02:00:40 +0000 Subject: [PATCH 031/101] Auto corrected by following RSpec/EmptyLineAfterFinalLet --- spec/controllers/account_types_controller_spec.rb | 1 + spec/controllers/comments_controller_spec.rb | 11 +++++++++++ spec/controllers/gardens_controller_spec.rb | 2 ++ spec/controllers/harvests_controller_spec.rb | 4 ++++ spec/controllers/likes_controller_spec.rb | 1 + .../controllers/photo_associations_controller_spec.rb | 1 + spec/controllers/photos_controller_spec.rb | 3 +++ spec/controllers/plantings_controller_spec.rb | 5 +++++ spec/controllers/shop_controller_spec.rb | 1 + spec/features/crops/crop_detail_page_spec.rb | 4 ++++ spec/features/crops/requested_crops_spec.rb | 1 + spec/features/gardens_spec.rb | 1 + spec/features/members/deletion_spec.rb | 1 + spec/features/plantings/planting_a_crop_spec.rb | 1 + spec/features/seeds/seed_photos.rb | 2 ++ spec/features/signout_spec.rb | 1 + spec/models/crop_spec.rb | 8 ++++++++ spec/models/member_spec.rb | 4 ++++ spec/models/photo_spec.rb | 1 + spec/models/planting_spec.rb | 11 +++++++++++ spec/models/post_spec.rb | 1 + spec/models/role_spec.rb | 2 ++ spec/models/seed_spec.rb | 1 + spec/views/crops/_planting_advice.html.haml_spec.rb | 1 + spec/views/home/_crops.html.haml_spec.rb | 1 + spec/views/members/index.html.haml_spec.rb | 1 + spec/views/plantings/index.html.haml_spec.rb | 1 + spec/views/plantings/show.html.haml_spec.rb | 1 + spec/views/posts/show.html.haml_spec.rb | 9 +++++++++ 29 files changed, 82 insertions(+) diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb index 37dbfa706..010c8bf1f 100644 --- a/spec/controllers/account_types_controller_spec.rb +++ b/spec/controllers/account_types_controller_spec.rb @@ -21,6 +21,7 @@ describe AccountTypesController do describe '#index' do let!(:aaa) { FactoryBot.create :account_type, name: 'aaa' } let!(:zzz) { FactoryBot.create :account_type, name: 'zzz' } + before { get :index } it { is_expected.to be_success } it { expect(assigns[:account_types].first).to eql(aaa) } diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 0e986cc93..2d265de5f 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe CommentsController do subject { response } let(:member) { FactoryBot.create(:member) } + before(:each) do sign_in member controller.stub(:current_member) { member } @@ -16,6 +17,7 @@ describe CommentsController do describe "GET RSS feed" do let!(:first_comment) { FactoryBot.create :comment, created_at: 10.days.ago } let!(:last_comment) { FactoryBot.create :comment, created_at: 4.minutes.ago } + describe "returns an RSS feed" do before { get :index, format: "rss" } it { is_expected.to be_success } @@ -36,6 +38,7 @@ describe CommentsController do end let(:old_comment) { FactoryBot.create(:comment, post: post) } + it "assigns the old comments as @comments" do assigns(:comments).should eq [old_comment] end @@ -49,11 +52,13 @@ describe CommentsController do describe "GET edit" do let(:post) { FactoryBot.create(:post) } + before { get :edit, id: comment.to_param } describe "my comment" do let!(:comment) { FactoryBot.create :comment, author: member, post: post } let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) } + it "assigns previous comments as @comments" do expect(assigns(:comments)).to eq([comment, old_comment]) end @@ -61,6 +66,7 @@ describe CommentsController do describe "not my comment" do let(:comment) { FactoryBot.create :comment, post: post } + it { expect(response).not_to be_success } end end @@ -70,12 +76,14 @@ describe CommentsController do describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } + it "redirects to the comment's post" do expect(response).to redirect_to(comment.post) end end describe "not my comment" do let(:comment) { FactoryBot.create :comment } + it { expect(response).not_to be_success } end describe "attempting to change post_id" do @@ -83,6 +91,7 @@ describe CommentsController do let(:other_post) { FactoryBot.create :post, subject: 'the other post' } let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } } let(:comment) { FactoryBot.create :comment, author: member, post: post } + it "does not change post_id" do comment.reload expect(comment.post_id).to eq(post.id) @@ -95,6 +104,7 @@ describe CommentsController do describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } + it "redirects to the post the comment was on" do expect(response).to redirect_to(comment.post) end @@ -102,6 +112,7 @@ describe CommentsController do describe "not my comment" do let(:comment) { FactoryBot.create :comment } + it { expect(response).not_to be_success } end end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index b0ccae0b8..9253b5ddb 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -6,6 +6,7 @@ RSpec.describe GardensController, type: :controller do context "when not signed in" do let(:garden) { double('garden') } + describe 'GET new' do before { get :new, id: garden.to_param } it { expect(response).to redirect_to(new_member_session_path) } @@ -45,6 +46,7 @@ RSpec.describe GardensController, type: :controller do describe "for another member's garden" do let(:not_my_garden) { double('garden') } + before do expect(Garden).to receive(:find).and_return(:not_my_garden) expect(not_my_garden).not_to receive(:save) diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 8a2edb56b..705f954b5 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -45,6 +45,7 @@ describe HarvestsController do describe "GET show" do let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do before { get :show, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } @@ -65,6 +66,7 @@ describe HarvestsController do describe "GET edit" do let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do before { get :edit, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } @@ -92,6 +94,7 @@ describe HarvestsController do describe "links to planting" do let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } + before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } it { expect(Harvest.last.planting.id).to eq(planting.id) } end @@ -170,6 +173,7 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } + describe "does not save planting_id" do before do put :update, id: harvest.to_param, diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 6f43760c1..a80fc0d56 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -35,6 +35,7 @@ describe LikesController do describe "Deleting someone else's like" do let(:like) { FactoryBot.create :like } + it { expect(response.code).to eq('403') } it { JSON.parse(response.body)["error"] == "Unable to like" } end diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index 42e0ccc37..75a04eedd 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -26,6 +26,7 @@ describe PhotoAssociationsController do describe "another member's harvest from another member's photo" do let(:harvest) { FactoryBot.create :harvest } let(:photo) { FactoryBot.create :photo } + it do expect do begin diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 3c4f9dacb..76869ebf3 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -73,6 +73,7 @@ describe PhotosController do let(:planting) { FactoryBot.create(:planting, garden: garden, owner: member) } let(:harvest) { FactoryBot.create(:harvest, owner: member) } let(:photo) { FactoryBot.create(:photo, owner: member) } + describe "with valid params" do before { controller.stub(:current_member) { member } } it "attaches the photo to a planting" do @@ -113,6 +114,7 @@ describe PhotosController do describe "for the second time" do let(:planting) { FactoryBot.create :planting, owner: member } + it "does not add a photo twice" do expect do post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' @@ -142,6 +144,7 @@ describe PhotosController do describe "with mismatched owners" do let(:photo) { FactoryBot.create(:photo) } + it "does not create the planting/photo link" do # members will be auto-created, and different another_planting = FactoryBot.create(:planting) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index dd1340d44..abe5ea626 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -39,6 +39,7 @@ describe PlantingsController do describe "GET new" do describe "picks up crop from params" do let(:crop) { FactoryBot.create(:crop) } + before { get :new, crop_id: crop.id } it { expect(assigns(:crop)).to eq(crop) } end @@ -50,6 +51,7 @@ describe PlantingsController do describe "picks up member's garden from params" do let(:garden) { FactoryBot.create(:garden, owner: member) } + before { get :new, garden_id: garden.id } it { expect(assigns(:garden)).to eq(garden) } end @@ -57,6 +59,7 @@ describe PlantingsController do describe "Doesn't display another member's garden on planting form" do let(:another_member) { FactoryBot.create(:member) } # over-riding member from login_member() let(:garden) { FactoryBot.create(:garden, owner: another_member) } + before { get :new, garden_id: garden.id } it { expect(assigns(:garden)).not_to eq(garden) } end @@ -64,6 +67,7 @@ describe PlantingsController do describe "Doesn't display un-approved crops on planting form" do let(:crop) { FactoryBot.create(:crop, approval_status: 'pending') } let!(:garden) { FactoryBot.create(:garden, owner: member) } + before { get :new, crop_id: crop.id } it { expect(assigns(:crop)).not_to eq(crop) } end @@ -71,6 +75,7 @@ describe PlantingsController do describe "Doesn't display rejected crops on planting form" do let(:crop) { FactoryBot.create(:crop, approval_status: 'rejected', reason_for_rejection: 'nope') } let!(:garden) { FactoryBot.create(:garden, owner: member) } + before { get :new, crop_id: crop.id } it { expect(assigns(:crop)).not_to eq(crop) } end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index c25039d2d..2fc6b77f7 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -24,6 +24,7 @@ describe ShopController do describe "assigns @order as current_order if there is one" do let(:member) { FactoryBot.create(:member) } let!(:order) { FactoryBot.create(:order, member: member) } + before do sign_in member get :index, {} diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index e21c5eb47..1ee9bae80 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -205,6 +205,7 @@ feature "crop detail page", js: true do planted_at: 100.days.ago, finished_at: 1.day.ago) end + context 'crop is an annual' do let(:crop) { FactoryBot.create(:annual_crop) } @@ -258,16 +259,19 @@ feature "crop detail page", js: true do before { visit crop_path(crop) } context 'crop is an annual' do let(:crop) { FactoryBot.create :annual_crop } + it { expect(page).to have_text 'annual crop (living and reproducing in a single year or less)' } it { expect(page).not_to have_text 'perennial crop (living more than two years)' } end context 'crop is perennial' do let(:crop) { FactoryBot.create :perennial_crop } + it { expect(page).to have_text 'perennial crop (living more than two years)' } it { expect(page).not_to have_text 'annual crop (living and reproducing in a single year or less)' } end context 'crop perennial value is null' do let(:crop) { FactoryBot.create :crop, perennial: nil } + it { expect(page).not_to have_text 'perennial crop (living more than two years)' } it { expect(page).not_to have_text 'annual crop (living and reproducing in a single year or less)' } end diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index 6bfb8220c..15226efe4 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' feature "Crop - " do let(:member) { create :member } let!(:requested_crop) { create :crop, requester: member, approval_status: 'pending', name: 'puha for dinner' } + background do login_as member visit requested_crops_path diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index a299a0197..0954d35eb 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -88,6 +88,7 @@ feature "Planting a crop", js: true do describe "Making a planting inactive from garden show" do let(:path) { garden_path garden } let(:link_text) { "Mark as finished" } + it_behaves_like "append date" end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 3009f51be..793a6ada5 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -12,6 +12,7 @@ feature "member deletion" do let!(:secondgarden) { FactoryBot.create(:garden, owner: member) } let!(:order) { FactoryBot.create(:order, member: member, completed_at: Time.zone.now) } let(:admin) { FactoryBot.create(:admin_member) } + background do login_as(member) visit member_path(other_member) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 0c984837b..51ff69be2 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -270,6 +270,7 @@ feature "Planting a crop", :js, :elasticsearch do describe "Marking a planting as finished from the show page" do let(:path) { planting_path(planting) } let(:link_text) { "Mark as finished" } + it_behaves_like "append date" end diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 635b4dc4d..3d57f2cfe 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -19,12 +19,14 @@ feature "Seeds", :js do context 'has one photo' do before { seed.photos = [photo] } let!(:photo) { FactoryBot.create :photo, title: 'hello photo' } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo.thumbnail_url}')]") } it { is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photo)}')]") } end context 'has 50 photos' do before { seed.photos = photos } let!(:photos) { FactoryBot.create_list :photo, 50 } + it "shows newest photo" do is_expected.to have_xpath("//img[contains(@src,'#{photos.last.thumbnail_url}')]") end diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index a6402df2c..35cd8af9b 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -30,6 +30,7 @@ feature "signout" do end let(:path) {} + describe 'after signout, redirect to signin page if page needs authentication' do include_examples "sign-in redirects", "/plantings/new" include_examples "sign-in redirects", "/harvests/new" diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index f89cc3377..515d0160c 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -82,36 +82,43 @@ describe Crop do context 'not a url' do let(:wikipedia_url) { 'this is not valid' } + it { expect(subject).not_to be_valid } end context 'http url' do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } + it { expect(subject).to be_valid } end context 'with ssl' do let(:wikipedia_url) { 'https://en.wikipedia.org/wiki/SomePage' } + it { expect(subject).to be_valid } end context 'with utf8 macrons' do let(:wikipedia_url) { 'https://en.wikipedia.org/wiki/Māori' } + it { expect(subject).to be_valid } end context 'urlencoded' do let(:wikipedia_url) { 'https://en.wikipedia.org/wiki/M%C4%81ori' } + it { expect(subject).to be_valid } end context 'with new lines in url' do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage\n\nBrendaRocks' } + it { expect(subject).not_to be_valid } end context "with script tags in url" do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } + it { expect(subject).not_to be_valid } end end @@ -330,6 +337,7 @@ describe Crop do let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } + it "has harvests" do expect(crop.harvests).to eq [harvest] end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 1911ae8da..cf7b81486 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -432,6 +432,7 @@ describe 'member' do context 'member deleted' do let(:member) { FactoryBot.create(:member) } + context 'queries a scope' do before { member.destroy } it { expect(Member.all).not_to include(member) } @@ -450,10 +451,12 @@ describe 'member' do context "deleted admin member" do let(:member) { FactoryBot.create(:admin_member) } + before { member.destroy } context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } + it "leaves crops behind, reassigned to cropbot" do expect(Crop.all).to include(crop) end @@ -461,6 +464,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } + it "leaves forums behind, reassigned to ex_admin" do expect(forum.owner).to eq(member) end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index e220bfe59..c971ce2fd 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe Photo do let(:photo) { FactoryBot.create(:photo, owner: member) } let(:member) { FactoryBot.create(:member) } + describe 'add/delete functionality' do let(:planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 48a035bb4..60a95c245 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -13,6 +13,7 @@ describe Planting do context 'no predications data yet' do describe 'planting planted, not finished' do let(:planting) { FactoryBot.create :planting, planted_at: 30.days.ago, finished_at: nil, finished: false } + it { expect(planting.crop.median_lifespan).to eq(nil) } it { expect(planting.expected_lifespan).to eq(nil) } it { expect(planting.days_since_planted).to eq(30) } @@ -20,6 +21,7 @@ describe Planting do end describe 'planting not planted yet' do let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: nil, finished: false } + it { expect(planting.crop.median_lifespan).to eq(nil) } it { expect(planting.expected_lifespan).to eq(nil) } it { expect(planting.days_since_planted).to eq(nil) } @@ -27,6 +29,7 @@ describe Planting do end describe 'planting finished, no planted_at' do let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: 1.day.ago, finished: true } + it { expect(planting.crop.median_lifespan).to eq(nil) } it { expect(planting.expected_lifespan).to eq(nil) } it { expect(planting.days_since_planted).to eq(nil) } @@ -34,6 +37,7 @@ describe Planting do end describe 'planting all finished' do let(:planting) { FactoryBot.create :planting, planted_at: 30.days.ago, finished_at: 1.day.ago, finished: true } + it { expect(planting.crop.median_lifespan).to eq(nil) } it { expect(planting.expected_lifespan).to eq(29) } it { expect(planting.days_since_planted).to eq(30) } @@ -63,16 +67,19 @@ describe Planting do describe 'planting not planted yet' do let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: nil } + it { expect(planting.percentage_grown).to eq nil } end describe 'planting finished 10 days, but was never planted' do let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: 10.days.ago } + it { expect(planting.percentage_grown).to eq nil } end describe 'planted 30 days ago, finished 10 days ago' do let(:planting) { FactoryBot.create :planting, planted_at: 30.days.ago, finished_at: 10.days.ago } + it { expect(planting.days_since_planted).to eq 30 } it { expect(planting.percentage_grown).to eq 100 } end @@ -82,6 +89,7 @@ describe Planting do describe 'planting first harvest preductions' do context 'no data' do let(:planting) { FactoryBot.create :planting } + it { expect(planting.crop.median_days_to_first_harvest).to eq(nil) } it { expect(planting.crop.median_days_to_last_harvest).to eq(nil) } it { expect(planting.days_to_first_harvest).to eq(nil) } @@ -114,11 +122,13 @@ describe Planting do planting.crop.update_harvest_medians end let(:planting) { FactoryBot.create :planting } + it { expect(planting.days_to_first_harvest).to eq(nil) } it { expect(planting.days_to_last_harvest).to eq(nil) } end describe 'planting has first harvest' do let(:planting) { FactoryBot.create :planting, planted_at: 100.days.ago } + before do FactoryBot.create(:harvest, planting: planting, @@ -134,6 +144,7 @@ describe Planting do end describe 'planting has last harvest' do let(:planting) { FactoryBot.create :planting, planted_at: 100.days.ago, finished_at: 1.day.ago, finished: true } + before do FactoryBot.create :harvest, planting: planting, crop: planting.crop, harvested_at: 90.days.ago FactoryBot.create :harvest, planting: planting, crop: planting.crop, harvested_at: 10.days.ago diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index cb8cbcc91..062aba487 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } + it_behaves_like "it is likeable" it "should have a slug" do diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 3016591b7..a7cfbecd3 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -19,6 +19,7 @@ describe Role do describe '.crop_wranglers' do let!(:crop_wranglers) { FactoryBot.create_list(:crop_wrangling_member, 3) } + it 'return the crop wranglers that are members of that role' do expect(Role.crop_wranglers).to match_array(crop_wranglers) end @@ -26,6 +27,7 @@ describe Role do describe '.admins' do let!(:admins) { FactoryBot.create_list(:admin_member, 3) } + it 'return the members that have the role of admin' do expect(Role.admins).to match_array(admins) end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index c1cd95cbd..e45d0e240 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -151,6 +151,7 @@ describe Seed do context 'photos' do let(:seed) { FactoryBot.create :seed } + before { seed.photos << FactoryBot.create(:photo) } it 'is found in has_photos scope' do Seed.has_photos.should include(seed) diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index c7a4719b5..38499e2d9 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' describe "crops/_planting_advice" do let(:planting) { FactoryBot.create(:planting) } + subject { rendered } shared_examples "render planting_advice" do diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index 254fcb2f6..3ed655438 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -4,6 +4,7 @@ describe 'home/_crops.html.haml', type: "view" do let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } let(:planting) { crop.plantings.first } + before(:each) { render } it 'shows crops section' do assert_select 'h2', text: 'Some of our crops' diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 81e8a6670..87dd3a285 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' describe "members/index" do let(:member) { FactoryBot.create(:london_member) } + before(:each) do controller.stub(:current_user) { nil } page = 1 diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index f682d62e9..a3a713100 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -5,6 +5,7 @@ describe "plantings/index" do let(:garden) { FactoryBot.create(:garden, owner: member) } let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } + before(:each) do controller.stub(:current_user) { nil } page = 1 diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 040a0f6b0..899724ac7 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -28,6 +28,7 @@ describe "plantings/show" do context 'planted from' do let(:planting) { FactoryBot.create(:cutting_planting) } + it "shows planted_from" do render rendered.should have_content 'Planted from:' diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index 169e90da0..273f400cc 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -25,25 +25,30 @@ describe "posts/show" do describe "should parse markdown into html" do let(:post) { FactoryBot.create(:markdown_post, author: author) } + it { assert_select "strong", "strong" } end describe "shouldn't let html through in body" do let(:post) { FactoryBot.create(:post, author: author, body: 'EVIL') } + it { is_expected.to have_content('EVIL') } it { is_expected.not_to have_link("http://evil.com") } end describe 'script tag in post body' do let(:post) { FactoryBot.create(:post, author: author, body: "") } + it { is_expected.not_to have_selector('script') } end describe 'script tag in post title' do let(:post) { FactoryBot.create(:post, author: author, subject: "") } + it { is_expected.not_to have_selector('script') } end describe 'has an anchor to the comments' do let(:post) { FactoryBot.create(:post, author: author) } + it { is_expected.to have_selector('a[name=comments]') } end end @@ -51,6 +56,7 @@ describe "posts/show" do context "when there is one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } let!(:comment) { FactoryBot.create(:comment, post: post) } + before(:each) do @comments = post.comments render @@ -71,6 +77,7 @@ describe "posts/show" do context "when there is more than one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } + before(:each) do @comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!", created_at: Date.new(2010, 5, 17)) @@ -90,6 +97,7 @@ describe "posts/show" do context "forum post" do let(:post) { FactoryBot.create(:forum_post, author: author) } + before { render } it "shows forum name" do is_expected.to have_content "in #{post.forum.name}" @@ -98,6 +106,7 @@ describe "posts/show" do context "signed in" do let(:post) { FactoryBot.create(:post, author: author) } + before(:each) do sign_in author controller.stub(:current_user) { author } From b83db1d4e77f8c4c4f18711b4134af08a641a9c5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 9 Jan 2018 15:53:40 +1300 Subject: [PATCH 032/101] Fix predictions, it wasn't showing nil --- app/views/crops/_predictions.html.haml | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 343f4f6bd..2a647d350 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,5 +1,5 @@ -- unless crop.perennial.nil? - .predictions +.predictions + - unless crop.perennial.nil? .row %p #{crop.name} is @@ -12,23 +12,23 @@ an annual crop (living and reproducing in a single year or less) - .row - - if crop.annual? && crop.median_lifespan.present? - .metric.col-md-3.col-xs-5 - %h3 Median lifespan - %strong= crop.median_lifespan - %span days + .row + - if crop.annual? && crop.median_lifespan.present? + .metric.col-md-3.col-xs-5 + %h3 Median lifespan + %strong= crop.median_lifespan + %span days - - if crop.median_days_to_first_harvest.present? - .metric.col-md-3.col-xs-5 - %h3 First harvest expected - %strong= crop.median_days_to_first_harvest - %span days - after planting + - if crop.median_days_to_first_harvest.present? + .metric.col-md-3.col-xs-5 + %h3 First harvest expected + %strong= crop.median_days_to_first_harvest + %span days + after planting - - if crop.annual? && crop.median_days_to_last_harvest.present? - .metric.col-md-3.col-xs-5 - %h3 Last harvest expected - %strong= crop.median_days_to_last_harvest - %span days - after planting + - if crop.annual? && crop.median_days_to_last_harvest.present? + .metric.col-md-3.col-xs-5 + %h3 Last harvest expected + %strong= crop.median_days_to_last_harvest + %span days + after planting From 4821bf3b07b2e9f3e05c4b63ac195031947c6d90 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jan 2018 08:26:59 +1300 Subject: [PATCH 033/101] Wrapped thre crops show js in a document.ready --- app/assets/javascripts/crops.js.erb | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index 9a60dd60c..4e2a67e82 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -1,14 +1,3 @@ -if (document.getElementById("cropmap") !== null) { - mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; - mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; - mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; - - L.Icon.Default.imagePath = '/assets' - - cropmap = L.map('cropmap').setView([0.0, -0.0], 2); - showCropMap(cropmap); -} - function showCropMap(cropmap) { L.tileLayer(mapbox_base_url, { @@ -49,6 +38,20 @@ function showCropMap(cropmap) { cropmap.addLayer(markers); } -$('.btn.toggle.crop-hierarchy').click(function () { - $('.toggle.crop-hierarchy').toggleClass('hide'); -}); +$(document).ready(function() { + + if (document.getElementById("cropmap") !== null) { + mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; + mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; + mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; + + L.Icon.Default.imagePath = '/assets' + + cropmap = L.map('cropmap').setView([0.0, -0.0], 2); + showCropMap(cropmap); + } + + $('.btn.toggle.crop-hierarchy').click(function () { + $('.toggle.crop-hierarchy').toggleClass('hide'); + }); +}); \ No newline at end of file From eb1b890eec8f5c2631cb81974dce4f69369d2661 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jan 2018 08:29:20 +1300 Subject: [PATCH 034/101] Add planted_from chart --- app/controllers/crops_controller.rb | 8 +++++ app/views/crops/_predictions.html.haml | 21 ++++++------- app/views/crops/show.html.haml | 41 ++++++++++++++++---------- config/routes.rb | 1 + 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index b62177e5d..371e70726 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -110,6 +110,14 @@ class CropsController < ApplicationController .group(:sunniness).count(:id) end + def planted_from + @crop = Crop.find(params[:crop_id]) + render json: Planting.where(crop: @crop) + .where.not(planted_from: nil) + .where.not(planted_from: '') + .group(:planted_from).count(:id) + end + private def notifier diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 2a647d350..74e8bafb1 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,16 +1,17 @@ .predictions - unless crop.perennial.nil? .row - %p - #{crop.name} is - - if crop.perennial == true - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - a perennial crop - (living more than two years) - - elsif crop.perennial == false - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - an annual crop - (living and reproducing in a single year or less) + .col-md-12 + %p + #{crop.name} is + - if crop.perennial == true + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + a perennial crop + (living more than two years) + - elsif crop.perennial == false + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + an annual crop + (living and reproducing in a single year or less) .row - if crop.annual? && crop.median_lifespan.present? diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index e5e7e7a1a..8f4486fe9 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -23,25 +23,24 @@ .row .col-md-9 - - if member_signed_in? - = display_seed_availability(@current_member, @crop) - = link_to "View your seeds", seeds_by_owner_path(owner: current_member.slug) + .row + .col-md-12 + - if member_signed_in? + = display_seed_availability(@current_member, @crop) + = link_to "View your seeds", seeds_by_owner_path(owner: current_member.slug) + + %h2 + - if !@crop.plantings.empty? + = @crop.name.titleize + has been planted + = pluralize(@crop.plantings.size, "time") + by #{ENV['GROWSTUFF_SITE_NAME']} members. + - else + Nobody is growing this yet. You could be the first! - %h2 - - if !@crop.plantings.empty? - = @crop.name.titleize - has been planted - = pluralize(@crop.plantings.size, "time") - by #{ENV['GROWSTUFF_SITE_NAME']} members. - - else - Nobody is growing this yet. You could be the first! .row - .col-md-3 - %h2 Sunniness Chart - = pie_chart crop_sunniness_path(@crop), legend: "bottom" - - .col-md-9 + .col-md-12 %h2 Predictions = render 'predictions', crop: @crop @@ -49,7 +48,17 @@ .col-md-12 %h2 Photos %p= render 'crops/photos', crop: @crop + .row + .col-md-3 + %h2 Sunniness + = pie_chart crop_sunniness_path(@crop), legend: "bottom" + .col-md-3 + %h2 Planted from + = pie_chart crop_planted_from_path(@crop), legend: "bottom" + + .row + .col-md-12 %h2 Crop Map %p Only plantings by members who have set their locations are shown on this map. diff --git a/config/routes.rb b/config/routes.rb index cc90a4063..2c33bbd41 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,6 +53,7 @@ Growstuff::Application.routes.draw do resources :crops do get 'photos' => 'photos#index' get 'sunniness' => 'crops#sunniness' + get 'planted_from' => 'crops#planted_from' end resources :comments From 5ea7ae8af08976b13ca785545cb890993661127b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jan 2018 09:03:13 +1300 Subject: [PATCH 035/101] Added Harvested for chart --- app/controllers/crops_controller.rb | 24 +++++++++++++++--------- app/views/crops/show.html.haml | 3 +++ config/routes.rb | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 371e70726..d3bd5dcf9 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -103,23 +103,29 @@ class CropsController < ApplicationController end def sunniness - @crop = Crop.find(params[:crop_id]) - render json: Planting.where(crop: @crop) - .where.not(sunniness: nil) - .where.not(sunniness: '') - .group(:sunniness).count(:id) + pie_chart_query 'sunniness' end def planted_from + pie_chart_query 'planted_from' + end + + def harvested_for @crop = Crop.find(params[:crop_id]) - render json: Planting.where(crop: @crop) - .where.not(planted_from: nil) - .where.not(planted_from: '') - .group(:planted_from).count(:id) + render json: Harvest.joins(:plant_part).where(crop: @crop) + .group("plant_parts.name").count(:id) end private + def pie_chart_query(field) + @crop = Crop.find(params[:crop_id]) + render json: Planting.where(crop: @crop) + .where.not(field.to_sym => nil) + .where.not(field.to_sym => '') + .group(field.to_sym).count(:id) + end + def notifier case @crop.approval_status when "approved" diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 8f4486fe9..270c0db2b 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -56,6 +56,9 @@ .col-md-3 %h2 Planted from = pie_chart crop_planted_from_path(@crop), legend: "bottom" + .col-md-3 + %h2 Harvested for + = pie_chart crop_harvested_for_path(@crop), legend: "bottom" .row .col-md-12 diff --git a/config/routes.rb b/config/routes.rb index 2c33bbd41..cba5c2853 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,7 @@ Growstuff::Application.routes.draw do get 'photos' => 'photos#index' get 'sunniness' => 'crops#sunniness' get 'planted_from' => 'crops#planted_from' + get 'harvested_for' => 'crops#harvested_for' end resources :comments From 0c8240d4e8d7e8570c35932ae38377847585e316 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Wed, 10 Jan 2018 20:17:58 +0000 Subject: [PATCH 036/101] Auto corrected by following Style/OrAssignment --- app/models/csv_importer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index 66297b13c..e24991e80 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -46,7 +46,7 @@ class CsvImporter names_to_add.each do |name| sciname = ScientificName.find_by(name: name, crop: @crop) - sciname = ScientificName.create!(name: name, crop: @crop, creator: cropbot) unless sciname + sciname ||= ScientificName.create!(name: name, crop: @crop, creator: cropbot) @crop.scientific_names << sciname end end @@ -56,13 +56,13 @@ class CsvImporter return if alternate_names.blank? alternate_names.split(/,\s*/).each do |name| altname = AlternateName.find_by(name: name, crop: @crop) - altname = AlternateName.create! name: name, crop: @crop, creator: cropbot unless altname + altname ||= AlternateName.create! name: name, crop: @crop, creator: cropbot @crop.alternate_names << altname end end def cropbot - @cropbot = Member.find_by!(login_name: 'cropbot') unless @cropbot + @cropbot ||= Member.find_by!(login_name: 'cropbot') @cropbot rescue raise "cropbot account not found: run rake db:seed" From a13acbe08785c82faffce799cbe9a0ca9f26cc62 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Wed, 10 Jan 2018 20:18:10 +0000 Subject: [PATCH 037/101] Auto corrected by following Style/ParallelAssignment --- app/mailers/notifier.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 569400ce6..6c479f51f 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -37,17 +37,20 @@ class Notifier < ActionMailer::Base end def new_crop_request(member, request) - @member, @request = member, request + @member = member + @request = request mail(to: @member.email, subject: "#{@request.requester.login_name} has requested #{@request.name} as a new crop") end def crop_request_approved(member, crop) - @member, @crop = member, crop + @member = member + @crop = crop mail(to: @member.email, subject: "#{crop.name.capitalize} has been approved") end def crop_request_rejected(member, crop) - @member, @crop = member, crop + @member = member + @crop = crop mail(to: @member.email, subject: "#{crop.name.capitalize} has been rejected") end end From 3391f6c3921333f046ab848c866b491dd467ae79 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Wed, 10 Jan 2018 20:18:17 +0000 Subject: [PATCH 038/101] Auto corrected by following Style/RescueStandardError --- app/models/csv_importer.rb | 2 +- db/seeds.rb | 2 +- spec/controllers/photo_associations_controller_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index e24991e80..2f646b6ab 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -64,7 +64,7 @@ class CsvImporter def cropbot @cropbot ||= Member.find_by!(login_name: 'cropbot') @cropbot - rescue + rescue StandardError raise "cropbot account not found: run rake db:seed" end end diff --git a/db/seeds.rb b/db/seeds.rb index 7df7e0e4c..be885a352 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -65,7 +65,7 @@ def load_test_users # rubocop:disable Metrics/AbcSize source_path = Rails.root.join('db', 'seeds') begin suburb_file = File.open("#{source_path}/suburbs.csv") - rescue + rescue StandardError puts "Warning: unable to open suburbs.csv" end diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index 75a04eedd..f021d5aa8 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -31,7 +31,7 @@ describe PhotoAssociationsController do expect do begin delete :destroy, valid_params - rescue + rescue StandardError nil end end.not_to change(photo.harvests, :count) From 9adb3d1e4ed70ad89037fb7b94424eba2c981908 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jan 2018 09:31:59 +1300 Subject: [PATCH 039/101] Removed d3 graph tests --- spec/javascripts/graphs/bar_group_spec.js | 54 -------------- .../graphs/bar_label_group_spec.js | 38 ---------- spec/javascripts/graphs/height_scale_spec.js | 35 --------- .../graphs/horizontal_bar_graph_spec.js | 74 ------------------- spec/javascripts/graphs/width_scale_spec.js | 40 ---------- 5 files changed, 241 deletions(-) delete mode 100644 spec/javascripts/graphs/bar_group_spec.js delete mode 100644 spec/javascripts/graphs/bar_label_group_spec.js delete mode 100644 spec/javascripts/graphs/height_scale_spec.js delete mode 100644 spec/javascripts/graphs/horizontal_bar_graph_spec.js delete mode 100644 spec/javascripts/graphs/width_scale_spec.js diff --git a/spec/javascripts/graphs/bar_group_spec.js b/spec/javascripts/graphs/bar_group_spec.js deleted file mode 100644 index a76992a6c..000000000 --- a/spec/javascripts/graphs/bar_group_spec.js +++ /dev/null @@ -1,54 +0,0 @@ -(function() { - 'use strict'; - - /* - These tests are for the BarGroup object. - */ - - describe('when drawing the group of bars', function() { - var BarGroup; var subject; var bars; var data; - - beforeEach(function() { - BarGroup = growstuff.BarGroup; - - bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5}, - ]; - - data = { - bars: bars, - bar_color: 'steelblue', - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'}, - }; - - subject = new BarGroup(data); - subject.render(d3.select('#jasmine_content').append('svg')); - }); - - it('draws a group', function() { - expect($('g.bar')).toExist(); - }); - - it('draws 2 bars', function() { - expect($('g.bar rect')).toHaveLength(2); - }); - - it('fills the bars with color', function() { - expect($('g.bar rect')).toHaveAttr('fill', 'steelblue'); - }); - - it('shows a tooltip on hover', function() { - var i; - - // get all of the title nodes for the bars - var barNodes = $('g.bar rect title'); - - for (i = 0; i < bars.length; i++) { - expect(barNodes[i].textContent) - .toBe('This value is ' + bars[i].value + '' + '.'); - } - }); - }); -}()); diff --git a/spec/javascripts/graphs/bar_label_group_spec.js b/spec/javascripts/graphs/bar_label_group_spec.js deleted file mode 100644 index 7cb6e5537..000000000 --- a/spec/javascripts/graphs/bar_label_group_spec.js +++ /dev/null @@ -1,38 +0,0 @@ -(function() { - 'use strict'; - - /* - This file contains tests for the labels that get rendered next to each bar - */ - - describe('BarLabelGroup', function() { - var BarLabelGroup; var subject; var data; - - beforeEach(function() { - BarLabelGroup = growstuff.BarLabelGroup; - var bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5}, - ]; - data = { - bars: bars, - }; - subject = new BarLabelGroup(data); - subject.render(d3.select('#jasmine_content').append('svg')); - }); - - it('draws a group for labels', function() { - expect($('g.bar-label')).toExist(); - }); - - it('draws 2 bar labels', function() { - expect($('g.bar-label text')).toHaveLength(2); - }); - - it('has text for 2 bar labels', function() { - // jquery jasmine appends text from all text elements - // into one string - expect($('g.bar-label text')).toHaveText('ShadeHalf Shade'); - }); - }); -}()); diff --git a/spec/javascripts/graphs/height_scale_spec.js b/spec/javascripts/graphs/height_scale_spec.js deleted file mode 100644 index 3a257400c..000000000 --- a/spec/javascripts/graphs/height_scale_spec.js +++ /dev/null @@ -1,35 +0,0 @@ -(function() { - 'use strict'; - - /* - Tests for mapping the number of bars to the size of the svg - */ - - describe('HeightScale when specifying height', function() { - var data; var bars; var HeightScale; var subject; var mockD3; - - beforeEach(function() { - HeightScale = growstuff.HeightScale; - bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5}, - ]; - data = { - bars: bars, - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'}, - }; - - subject = new HeightScale(data); - mockD3 = jasmine.createSpyObj('d3', ['domain', 'rangeRoundBands']); - mockD3.domain.and.returnValue(mockD3); - mockD3.rangeRoundBands.and.returnValue(mockD3); - spyOn(d3.scale, 'ordinal').and.returnValue(mockD3); - subject.render(); - }); - - it('calls the d3 range round bands function to draw the height', function() { - expect(mockD3.rangeRoundBands).toHaveBeenCalledWith([0, 400], 0.05, 0); - }); - }); -}()); diff --git a/spec/javascripts/graphs/horizontal_bar_graph_spec.js b/spec/javascripts/graphs/horizontal_bar_graph_spec.js deleted file mode 100644 index 16f35f018..000000000 --- a/spec/javascripts/graphs/horizontal_bar_graph_spec.js +++ /dev/null @@ -1,74 +0,0 @@ -(function() { - 'use strict'; - - /* - Tests in this file are for the pieces of HorizontalBarGraph or - are more integration-y type tests that require the full graph. - */ - - describe('HorizontalBarGraph', function() { - var BarLabelGroup; var BarGroup; var subject; var data; - - beforeEach(function() { - var HorizontalBarGraph = growstuff.HorizontalBarGraph; - var bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5}, - ]; - data = { - bars: bars, - bar_color: 'steelblue', - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'}, - // left is used to shift the bars over so that there is - // room for the labels - margin: {top: 0, right: 0, bottom: 0, left: 100}, - }; - - subject = new HorizontalBarGraph(data); - BarGroup = growstuff.BarGroup; - BarLabelGroup = growstuff.BarLabelGroup; - expect(BarLabelGroup).toExist(); - spyOn(BarGroup.prototype, 'render').and.callThrough(); - spyOn(BarLabelGroup.prototype, 'render').and.callThrough(); - subject.render(d3.select($('#jasmine_content')[0])); - }); - - it('draws a graph', function() { - expect($('#jasmine_content svg')).toExist(); - }); - - it('draws a group for the whole graph', function() { - expect($('g.bar-graph')).toExist(); - }); - - it('draws a bar group', function() { - expect(BarGroup.prototype.render).toHaveBeenCalled(); - }); - - it('draws a group of bar labels', function() { - expect(BarLabelGroup.prototype.render).toHaveBeenCalled(); - }); - - it('has the expected width and height', function() { - var $svg = $('svg'); - var margin = data.margin; - expect($svg).toHaveAttr('width', (data.width.size + margin.left + margin.right) + ''); - expect($svg).toHaveAttr('height', (data.height.size + margin.top + margin.bottom) + ''); - }); - - it('draws the graph shifted to the right to accommodate for labels', function() { - expect('g.bar-graph').toHaveAttr('transform', 'translate(100,0)'); - }); - - it('on the x axis, draws at least one bar at max width less margin width', function() { - // because of domain and range mapping - expect('g.bar rect:eq(1)').toHaveAttr('width', '300' ); - }); - - it('on the y axis, all bars are the same height', function() { - expect('g.bar rect:eq(0)').toHaveAttr('height', '195'); - expect('g.bar rect:eq(1)').toHaveAttr('height', '195'); - }); - }); -}()); diff --git a/spec/javascripts/graphs/width_scale_spec.js b/spec/javascripts/graphs/width_scale_spec.js deleted file mode 100644 index d8e34234a..000000000 --- a/spec/javascripts/graphs/width_scale_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -(function() { - 'use strict'; - - /* - This file contains tests for the mapping the data values to - the length of a bar so that it is the correct size for the screen - */ - - describe('GraphScale, when specifying width', function() { - var data; var WidthScale; var subject; var mockD3; - - beforeEach(function() { - WidthScale = growstuff.WidthScale; - var bars = [ - {name: 'Shade', value: 0.2}, - {name: 'Half Shade', value: 0.5}, - ]; - data = { - bars: bars, - width: {size: 300, scale: 'linear'}, - height: {size: 400, scale: 'ordinal'}, - }; - - subject = new WidthScale(data, 'width'); - mockD3 = jasmine.createSpyObj('d3', ['domain', 'range', 'max']); - mockD3.domain.and.returnValue(mockD3); - mockD3.range.and.returnValue(mockD3); - spyOn(d3.scale, 'linear').and.returnValue(mockD3); - subject.render(); - }); - - it('gets the value of the longest bar', function() { - expect(subject.getMaxValue()).toEqual(0.5); - }); - - it('calls the d3 range function to draw the width', function() { - expect(mockD3.range).toHaveBeenCalledWith([0, 300]); - }); - }); -}()); From 33276874a860b1d9c1321130c840db8859ae694d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jan 2018 15:36:27 +1300 Subject: [PATCH 040/101] add google js to gardens#show --- app/views/gardens/show.html.haml | 1 - app/views/layouts/application.html.haml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 5ffed7152..c6c08b792 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -11,7 +11,6 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) - content_for :scripts do - = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" .row diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b90c025e7..7fa9b185f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,5 +1,6 @@ !!! 5 %html{ lang: "en", prefix: "og: http://ogp.me/ns#" } + = yield :scripts = javascript_include_tag "application" = render partial: "layouts/meta" %body From b6e95391279cc707fd8819a8452aa48d4054311c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jan 2018 08:07:38 +1300 Subject: [PATCH 041/101] Use predicted finish times to put current plantings on the timeline --- app/controllers/gardens_controller.rb | 11 ++++++++--- app/views/gardens/show.html.haml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index d2aa8bfe0..a8f664b6d 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -61,10 +61,15 @@ class GardensController < ApplicationController def timeline @data = [] @garden = Garden.find(params[:garden_id]) - @garden.plantings.where.not(finished_at: nil) - .where.not(planted_at: nil) + @garden.plantings.where.not(planted_at: nil) .order(finished_at: :desc).each do |p| - @data << [p.crop.name, p.planted_at, p.finished_at] + + finish = if p.finished_at.present? + p.finished_at + else + p.finish_predicted_at + end + @data << [p.crop.name, p.planted_at, finish] if finish.present? end render json: @data end diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index c6c08b792..3928cfa58 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -40,7 +40,7 @@ .row = timeline garden_timeline_path(@garden), adapter: "google" - %h3 What's planted here? + %h3 Current plantings in garden .row - if @current_plantings.size.positive? - @current_plantings.each do |planting| From 78b8be1fc2d23caddfe9e946284fbf893683f20b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jan 2018 08:07:38 +1300 Subject: [PATCH 042/101] Use .presence to find finished ts in timeline --- app/controllers/gardens_controller.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index a8f664b6d..585966e54 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -63,12 +63,8 @@ class GardensController < ApplicationController @garden = Garden.find(params[:garden_id]) @garden.plantings.where.not(planted_at: nil) .order(finished_at: :desc).each do |p| - - finish = if p.finished_at.present? - p.finished_at - else - p.finish_predicted_at - end + # use finished_at if we have it, otherwise use predictions + finish = p.finished_at.presence || p.finish_predicted_at @data << [p.crop.name, p.planted_at, finish] if finish.present? end render json: @data From 04a7c41f634279e7b2c9f24f6bc868593f55a086 Mon Sep 17 00:00:00 2001 From: pozorvlak Date: Fri, 12 Jan 2018 11:31:28 +0000 Subject: [PATCH 043/101] Only deploy from the Elasticsearch build job Fixes #1099, or at least works around it, though a better solution would be to rewrite our deployment system using Travis build stages or Heroku build pipelines. The Elasticsearch job was picked because it's the one most likely to fail, and I can't work out how to deploy only if all three jobs pass. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ef68fec4f..5d94d6a86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,6 +56,7 @@ deploy: secure: "WrQxf0fEKkCdXrjcejurobOnNNz3he4dDwjBbToXbQTQNDObPp7NetJrLsfM8FiUFEeOuvhIHHiDQtMvY720zGGAGxDptvgFS+0QHCUqoTRZA/yFfUmHlG2jROXTzk5uVK0AE4k6Ion5kX8+mM0EnMT/7u+MTFiukrJctSiEXfg=" on: repo: Growstuff/growstuff + condition: "$RSPEC_TAG = elasticsearch" app: dev: growstuff-staging master: growstuff-prod From 9db4736229f32da1b4a5a359bb83a6cef9587664 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 13 Jan 2018 22:11:02 +1300 Subject: [PATCH 044/101] Permissions (and specs) for charts json --- app/controllers/gardens_controller.rb | 2 +- app/models/ability.rb | 6 ++++++ spec/controllers/crops_controller_spec.rb | 16 ++++++++++++++++ spec/controllers/gardens_controller_spec.rb | 13 ++++++++++--- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 585966e54..a61d6cf88 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,5 +1,5 @@ class GardensController < ApplicationController - before_action :authenticate_member!, except: %i(index show) + before_action :authenticate_member!, except: %i(index show timeline) after_action :expire_homepage, only: %i(create delete) load_and_authorize_resource respond_to :html, :json diff --git a/app/models/ability.rb b/app/models/ability.rb index efba2aeb0..283bf45cc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -15,6 +15,12 @@ class Ability can :view_follows, Member can :view_followers, Member + # Everyone can see the charts + can :timeline, Garden + can :sunniness, Crop + can :planted_from, Crop + can :harvested_for, Crop + # except these, which don't make sense if you're not logged in cannot :read, Notification cannot :read, Authentication diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 5b682f6c2..9e54307bf 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -46,4 +46,20 @@ describe CropsController do it { expect(response.content_type).to eq("application/rss+xml") } end end + + describe 'GET charts' do + let(:crop) { FactoryBot.create :crop } + describe 'sunniness' do + before { get :sunniness, crop_id: crop.to_param } + it { expect(response).to be_success } + end + describe 'planted_from' do + before { get :planted_from, crop_id: crop.to_param } + it { expect(response).to be_success } + end + describe 'harvested_for' do + before { get :harvested_for, crop_id: crop.to_param } + it { expect(response).to be_success } + end + end end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 9253b5ddb..073d03d6b 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -4,9 +4,8 @@ RSpec.describe GardensController, type: :controller do include Devise::Test::ControllerHelpers let(:valid_params) { { name: 'My second Garden' } } + let(:garden) { FactoryBot.create :garden } context "when not signed in" do - let(:garden) { double('garden') } - describe 'GET new' do before { get :new, id: garden.to_param } it { expect(response).to redirect_to(new_member_session_path) } @@ -15,7 +14,10 @@ RSpec.describe GardensController, type: :controller do before { put :create, garden: valid_params } it { expect(response).to redirect_to(new_member_session_path) } end - + describe 'GET timeline' do + before { get :timeline, garden_id: garden.to_param } + it { expect(response).to be_success } + end describe 'changing existing records' do before do allow(Garden).to receive(:find).and_return(:garden) @@ -44,6 +46,11 @@ RSpec.describe GardensController, type: :controller do let!(:member) { FactoryBot.create(:member) } + describe 'GET timeline' do + before { get :timeline, garden_id: garden.to_param } + it { expect(response).to be_success } + end + describe "for another member's garden" do let(:not_my_garden) { double('garden') } From d9cc1dcae8af1382b83cc25986a44165959178e0 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sat, 13 Jan 2018 22:49:36 +0000 Subject: [PATCH 045/101] Auto corrected by following RSpec/MultipleSubjects --- spec/features/crops/crop_detail_page_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 1ee9bae80..90ab42761 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature "crop detail page", js: true do let(:crop) { create :crop } - subject { visit crop_path(crop) } + context "varieties" do scenario "The crop DOES NOT have varieties" do From 8c8d549cb1478d55f1c671ad20894ed7a6efbcff Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sat, 13 Jan 2018 22:49:49 +0000 Subject: [PATCH 046/101] Auto corrected by following RSpec/NotToNot --- spec/features/crops/alternate_name_spec.rb | 2 +- spec/features/crops/crop_detail_page_spec.rb | 6 +++--- spec/features/following_spec.rb | 4 ++-- spec/features/member_profile_spec.rb | 6 +++--- spec/features/places/searching_a_place_spec.rb | 2 +- spec/features/plantings/planting_a_crop_spec.rb | 6 +++--- spec/features/scientific_name_spec.rb | 2 +- spec/features/shared_examples/crop_suggest.rb | 4 ++-- spec/models/crop_spec.rb | 2 +- spec/models/like_spec.rb | 10 +++++----- spec/models/post_spec.rb | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 319f4d7e1..e3b36c4a8 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -45,7 +45,7 @@ feature "Alternate names", js: true do href: alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Delete" } expect(page.status_code).to equal 200 - expect(page).to_not have_content alternate_eggplant.name + expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 90ab42761..d9b7dc618 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -149,9 +149,9 @@ feature "crop detail page", js: true do scenario "User not signed in" do visit crop_path(seed.crop) - expect(page).to_not have_content "You have 20 seeds of this crop" - expect(page).to_not have_content "You don't have any seeds of this crop" - expect(page).to_not have_link "View your seeds" + expect(page).not_to have_content "You have 20 seeds of this crop" + expect(page).not_to have_content "You don't have any seeds of this crop" + expect(page).not_to have_link "View your seeds" end scenario "User signed in" do diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index ac7a207be..735883e77 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -6,8 +6,8 @@ feature "follows", :js do scenario "follow buttons on member profile page" do visit member_path(member) - expect(page).to_not have_link "Follow" - expect(page).to_not have_link "Unfollow" + expect(page).not_to have_link "Follow" + expect(page).not_to have_link "Unfollow" end end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 0c27c7be2..32b11bda1 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -125,8 +125,8 @@ feature "member profile", js: true do scenario "ordinary user's page" do visit member_path(other_member) - expect(page).to_not have_text "Crop Wrangler" - expect(page).to_not have_text "Admin" + expect(page).not_to have_text "Crop Wrangler" + expect(page).not_to have_text "Admin" end context "your own profile page" do @@ -163,7 +163,7 @@ feature "member profile", js: true do end scenario "does not have a button to edit profile" do - expect(page).to_not have_link "Edit profile", href: edit_member_registration_path + expect(page).not_to have_link "Edit profile", href: edit_member_registration_path end end end diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 10797d917..edbb06e59 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -13,7 +13,7 @@ feature "User searches" do expect(page).to have_content "community near Philippines" expect(page).to have_button "search_button" expect(page).to have_content "Nearby members" - expect(page).to_not have_content "No results found" + expect(page).not_to have_content "No results found" end scenario "with a blank search string" do diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 51ff69be2..0e26d7078 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -110,8 +110,8 @@ feature "Planting a crop", :js, :elasticsearch do end expect(page).to have_content "planting was successfully created" - expect(page).to_not have_content "Progress: 0% - not planted yet" - expect(page).to_not have_content "Not enough data" + expect(page).not_to have_content "Progress: 0% - not planted yet" + expect(page).not_to have_content "Not enough data" end it "should show that planting is 100% complete (no date specified)" do @@ -178,7 +178,7 @@ feature "Planting a crop", :js, :elasticsearch do fill_in "Finished date", with: "2015-06-25" click_button "Save" expect(page).to have_content "planting was successfully updated" - expect(page).to_not have_content "Progress: Not enough data" + expect(page).not_to have_content "Progress: Not enough data" end scenario "Marking a planting as finished" do diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index d7205d263..d6daf709b 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -45,7 +45,7 @@ feature "Scientific names", js: true do href: scientific_name_path(zea_mays) within('.scientific_names') { click_on "Delete" } expect(page.status_code).to equal 200 - expect(page).to_not have_content zea_mays.name + expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' end diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 8f45c1e96..0d2e688a1 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -17,8 +17,8 @@ shared_examples "crop suggest" do |resource| fill_autocomplete "crop", with: "pe" end - expect(page).to_not have_content("pear") - expect(page).to_not have_content("pea") + expect(page).not_to have_content("pear") + expect(page).not_to have_content("pea") within "form#new_#{resource}" do fill_autocomplete "crop", with: "pea" diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 515d0160c..9e6173221 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -553,7 +553,7 @@ describe Crop do end it "should not delete the posts" do - expect(Post.find(post.id)).to_not eq nil + expect(Post.find(post.id)).not_to eq nil end end end diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index 50a2c1116..c92e3c389 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -26,31 +26,31 @@ describe 'like' do it 'is invalid without a member' do like = Like.new like.likeable = post - expect(like).to_not be_valid + expect(like).not_to be_valid end it 'is invalid without a likeable item' do like = Like.new like.member = member - expect(like).to_not be_valid + expect(like).not_to be_valid end end it 'does not allow duplicate likes by the same member' do Like.create(member: member, likeable: post) second_like = Like.new(member: member, likeable: post) - expect(second_like).to_not be_valid + expect(second_like).not_to be_valid end it 'destroys like if post no longer exists' do like = Like.create(member: member, likeable: post) post.destroy - expect(Like.all).to_not include like + expect(Like.all).not_to include like end it 'destroys like if member no longer exists' do like = Like.create(member: member, likeable: post) member.destroy - expect(Like.all).to_not include like + expect(Like.all).not_to include like end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 062aba487..98880ce2b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -165,8 +165,8 @@ describe Post do end it "should not delete the crops" do - expect(Crop.find(tomato.id)).to_not eq nil - expect(Crop.find(maize.id)).to_not eq nil + expect(Crop.find(tomato.id)).not_to eq nil + expect(Crop.find(maize.id)).not_to eq nil end end end From 46267b2a1d6ec221f1e7abd4a821057dfe1fd3f8 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sat, 13 Jan 2018 22:51:04 +0000 Subject: [PATCH 047/101] Auto corrected by following Style/MutableConstant --- app/models/planting.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index c51166264..6fd4aec17 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -4,12 +4,12 @@ class Planting < ActiveRecord::Base friendly_id :planting_slug, use: %i(slugged finders) # Constants - SUNNINESS_VALUES = %w(sun semi-shade shade) + SUNNINESS_VALUES = %w(sun semi-shade shade).freeze PLANTED_FROM_VALUES = [ 'seed', 'seedling', 'cutting', 'root division', 'runner', 'bulb', 'root/tuber', 'bare root plant', 'advanced plant', 'graft', 'layering' - ] + ].freeze ## ## Triggers From 6f613635d228d90b825029a3f9a0ebc12299c0a4 Mon Sep 17 00:00:00 2001 From: Shiny Date: Sun, 14 Jan 2018 12:04:32 +1300 Subject: [PATCH 048/101] Update crop_detail_page_spec.rb --- spec/features/crops/crop_detail_page_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index d9b7dc618..bbf37e996 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' feature "crop detail page", js: true do let(:crop) { create :crop } - - context "varieties" do scenario "The crop DOES NOT have varieties" do visit crop_path(crop) From 196d37dee94f82f495fe8c9ab707490433a198db Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 18:13:13 +1300 Subject: [PATCH 049/101] Re-instated the extra fields on crop.json --- app/controllers/crops_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index d3bd5dcf9..67832c9b1 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -51,7 +51,11 @@ class CropsController < ApplicationController def show @crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:id]) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) - respond_with(@crop) + # respond_with(@crop) + respond_to do |format| + format.html + format.json { render json: @crop.to_json(crop_json_fields) } + end end def new From 625a035f445cac5abaad7dacc869b465a7c5c2e1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 18:36:23 +1300 Subject: [PATCH 050/101] Scope js variables so they are not global --- app/assets/javascripts/crops.js.erb | 26 +++++++++++++------------- app/assets/javascripts/members.js.erb | 19 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index 4e2a67e82..e4ee6d375 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -1,24 +1,27 @@ function showCropMap(cropmap) { + var mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; + var mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; + var mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; L.tileLayer(mapbox_base_url, { attribution: 'Map data © OpenStreetMap contributors under ODbL | Map imagery © Mapbox', maxZoom: 18 }).addTo(cropmap); - markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 }); + var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 }); - things_to_map = location.pathname + '.json'; + var things_to_map = location.pathname + '.json'; $.getJSON(things_to_map, function(crop) { $.each(crop.plantings, function(i, planting) { - owner = planting.owner; + var owner = planting.owner; if (owner.latitude && owner.longitude) { - marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); + var marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); - planting_url = "/plantings/" + planting.id; - planting_link = "" + owner.login_name + "'s " + crop.name + ""; + var planting_url = "/plantings/" + planting.id; + var planting_link = "" + owner.login_name + "'s " + crop.name + ""; - where = "

" + owner.location + "

"; + var where = "

" + owner.location + "

"; - details = "

"; + var details = "

"; if (planting.quantity) { details = details + "Quantity: " + planting.quantity + "
"; } @@ -41,13 +44,10 @@ function showCropMap(cropmap) { $(document).ready(function() { if (document.getElementById("cropmap") !== null) { - mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; - mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; - mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; - L.Icon.Default.imagePath = '/assets' + L.Icon.Default.imagePath = '/assets'; - cropmap = L.map('cropmap').setView([0.0, -0.0], 2); + var cropmap = L.map('cropmap').setView([0.0, -0.0], 2); showCropMap(cropmap); } diff --git a/app/assets/javascripts/members.js.erb b/app/assets/javascripts/members.js.erb index 500e79b25..795387cc4 100644 --- a/app/assets/javascripts/members.js.erb +++ b/app/assets/javascripts/members.js.erb @@ -1,25 +1,24 @@ if (document.getElementById("membermap") !== null) { - mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; - mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; - mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; - - L.Icon.Default.imagePath = '/assets' + var mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_map_id %>"; + var mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Growstuff::Application.config.mapbox_access_token %>"; + var mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; + L.Icon.Default.imagePath = '/assets'; $.getJSON(location.pathname + '.json', function(member) { if (member.latitude && member.longitude) { - membermap = L.map('membermap').setView([member.latitude, member.longitude], 4); + var membermap = L.map('membermap').setView([member.latitude, member.longitude], 4); L.tileLayer(mapbox_base_url, { attribution: 'Map data © OpenStreetMap contributors under ODbL | Map imagery © Mapbox', maxZoom: 18 }).addTo(membermap); - marker = new L.Marker(new L.LatLng(member.latitude, member.longitude)); + var marker = new L.Marker(new L.LatLng(member.latitude, member.longitude)); - member_url = "/members/" + member.slug; - member_link = "" + member.login_name + ""; + var member_url = "/members/" + member.slug; + var member_link = "" + member.login_name + ""; - where = "

" + member.location + "

"; + var where = "

" + member.location + "

"; marker.bindPopup(member_link + where).openPopup(); marker.addTo(membermap); From 86b9a3650b3958553a88c7903a4edca896313020 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 17:46:26 +1300 Subject: [PATCH 051/101] Move application.js loading last again --- app/assets/javascripts/application.js | 2 -- app/assets/javascripts/charts.js | 2 ++ app/views/crops/show.html.haml | 3 +++ app/views/gardens/show.html.haml | 1 + app/views/layouts/application.html.haml | 2 +- config/initializers/assets.rb | 1 + 6 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/charts.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e0d7b8463..fc3369264 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,8 +10,6 @@ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // -// = require Chart.bundle -// = require chartkick // = require leaflet // = require leaflet.markercluster // = require js-routes diff --git a/app/assets/javascripts/charts.js b/app/assets/javascripts/charts.js new file mode 100644 index 000000000..1c42da456 --- /dev/null +++ b/app/assets/javascripts/charts.js @@ -0,0 +1,2 @@ +// = require Chart.bundle +// = require chartkick diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 270c0db2b..cd9751469 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -8,6 +8,9 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +- content_for :scripts do + = javascript_include_tag "charts" + = render partial: 'approval_status_message', locals: { crop: @crop } - if @crop.approved? diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 3928cfa58..9d4158a00 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -11,6 +11,7 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) - content_for :scripts do + = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" .row diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7fa9b185f..3dcf02c39 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,6 @@ !!! 5 %html{ lang: "en", prefix: "og: http://ogp.me/ns#" } = yield :scripts - = javascript_include_tag "application" = render partial: "layouts/meta" %body = render partial: "layouts/header" @@ -28,4 +27,5 @@ Javascripts \================================================== / Placed at the end of the document so the pages load faster + = javascript_include_tag "application" != Growstuff::Application.config.analytics_code diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 4b828e80c..60484d4a4 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -12,3 +12,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules') # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) +Rails.application.config.assets.precompile += %w(charts.js) From cf93489af719a549249775b9496d594a043212a7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 17:24:42 +1300 Subject: [PATCH 052/101] Fixed crops chart permissions by moving to another controller --- app/controllers/charts/crops_controller.rb | 30 ++++++++++++++++++++++ app/controllers/crops_controller.rb | 22 ---------------- config/routes.rb | 6 ++--- 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 app/controllers/charts/crops_controller.rb diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb new file mode 100644 index 000000000..b5fe3d4a7 --- /dev/null +++ b/app/controllers/charts/crops_controller.rb @@ -0,0 +1,30 @@ +module Charts + class CropsController < ApplicationController + respond_to :json + + def sunniness + pie_chart_query 'sunniness' + end + + def planted_from + pie_chart_query 'planted_from' + end + + def harvested_for + @crop = Crop.find(params[:crop_id]) + render json: Harvest.joins(:plant_part) + .where(crop: @crop) + .group("plant_parts.name").count(:id) + end + + private + + def pie_chart_query(field) + @crop = Crop.find(params[:crop_id]) + render json: Planting.where(crop: @crop) + .where.not(field.to_sym => nil) + .where.not(field.to_sym => '') + .group(field.to_sym).count(:id) + end + end +end diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 67832c9b1..361e28031 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -106,30 +106,8 @@ class CropsController < ApplicationController respond_with @crop end - def sunniness - pie_chart_query 'sunniness' - end - - def planted_from - pie_chart_query 'planted_from' - end - - def harvested_for - @crop = Crop.find(params[:crop_id]) - render json: Harvest.joins(:plant_part).where(crop: @crop) - .group("plant_parts.name").count(:id) - end - private - def pie_chart_query(field) - @crop = Crop.find(params[:crop_id]) - render json: Planting.where(crop: @crop) - .where.not(field.to_sym => nil) - .where.not(field.to_sym => '') - .group(field.to_sym).count(:id) - end - def notifier case @crop.approval_status when "approved" diff --git a/config/routes.rb b/config/routes.rb index cba5c2853..133a1b89f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,9 +52,9 @@ Growstuff::Application.routes.draw do get 'crops/search' => 'crops#search', as: 'crops_search' resources :crops do get 'photos' => 'photos#index' - get 'sunniness' => 'crops#sunniness' - get 'planted_from' => 'crops#planted_from' - get 'harvested_for' => 'crops#harvested_for' + get 'sunniness' => 'charts/crops#sunniness' + get 'planted_from' => 'charts/crops#planted_from' + get 'harvested_for' => 'charts/crops#harvested_for' end resources :comments From 16ad5384d11ceb31d7802dbfb04ecf4eb860dbd5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 17:29:10 +1300 Subject: [PATCH 053/101] Moved gardens chart to dedicated controller --- app/controllers/charts/gardens_controller.rb | 16 +++++++++++++ app/controllers/gardens_controller.rb | 14 +---------- config/routes.rb | 2 +- spec/controllers/charts/crops_controller_spec | 19 +++++++++++++++ .../charts/gardens_controller_spec.rb | 23 +++++++++++++++++++ spec/controllers/crops_controller_spec.rb | 16 ------------- spec/controllers/gardens_controller_spec.rb | 9 -------- 7 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 app/controllers/charts/gardens_controller.rb create mode 100644 spec/controllers/charts/crops_controller_spec create mode 100644 spec/controllers/charts/gardens_controller_spec.rb diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb new file mode 100644 index 000000000..8b67bc106 --- /dev/null +++ b/app/controllers/charts/gardens_controller.rb @@ -0,0 +1,16 @@ +module Charts + class GardensController < ApplicationController + respond_to :json + def timeline + @data = [] + @garden = Garden.find(params[:garden_id]) + @garden.plantings.where.not(planted_at: nil) + .order(finished_at: :desc).each do |p| + # use finished_at if we have it, otherwise use predictions + finish = p.finished_at.presence || p.finish_predicted_at + @data << [p.crop.name, p.planted_at, finish] if finish.present? + end + render json: @data + end + end +end diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index a61d6cf88..ede5c2602 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,5 +1,5 @@ class GardensController < ApplicationController - before_action :authenticate_member!, except: %i(index show timeline) + before_action :authenticate_member!, except: %i(index show) after_action :expire_homepage, only: %i(create delete) load_and_authorize_resource respond_to :html, :json @@ -58,18 +58,6 @@ class GardensController < ApplicationController redirect_to(gardens_by_owner_path(owner: @garden.owner)) end - def timeline - @data = [] - @garden = Garden.find(params[:garden_id]) - @garden.plantings.where.not(planted_at: nil) - .order(finished_at: :desc).each do |p| - # use finished_at if we have it, otherwise use predictions - finish = p.finished_at.presence || p.finish_predicted_at - @data << [p.crop.name, p.planted_at, finish] if finish.present? - end - render json: @data - end - private def garden_params diff --git a/config/routes.rb b/config/routes.rb index 133a1b89f..f1588fa17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,7 +28,7 @@ Growstuff::Application.routes.draw do get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop' resources :gardens do - get 'timeline' => 'gardens#timeline' + get 'timeline' => 'charts/gardens#timeline' end get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner' diff --git a/spec/controllers/charts/crops_controller_spec b/spec/controllers/charts/crops_controller_spec new file mode 100644 index 000000000..5a4aa6548 --- /dev/null +++ b/spec/controllers/charts/crops_controller_spec @@ -0,0 +1,19 @@ +require 'rails_helper' + +describe Charts::CropsController do + describe 'GET charts' do + let(:crop) { FactoryBot.create :crop } + describe 'sunniness' do + before { get :sunniness, crop_id: crop.to_param } + it { expect(response).to be_success } + end + describe 'planted_from' do + before { get :planted_from, crop_id: crop.to_param } + it { expect(response).to be_success } + end + describe 'harvested_for' do + before { get :harvested_for, crop_id: crop.to_param } + it { expect(response).to be_success } + end + end +end diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb new file mode 100644 index 000000000..daa50a811 --- /dev/null +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +describe Charts::GardensController do + include Devise::Test::ControllerHelpers + let(:valid_params) { { name: 'My second Garden' } } + + let(:garden) { FactoryBot.create :garden } + context "when not signed in" do + describe 'GET timeline' do + before { get :timeline, garden_id: garden.to_param } + it { expect(response).to be_success } + end + end + context "when signed in" do + before(:each) { sign_in member } + + let!(:member) { FactoryBot.create(:member) } + describe 'GET timeline' do + before { get :timeline, garden_id: garden.to_param } + it { expect(response).to be_success } + end + end +end diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 9e54307bf..5b682f6c2 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -46,20 +46,4 @@ describe CropsController do it { expect(response.content_type).to eq("application/rss+xml") } end end - - describe 'GET charts' do - let(:crop) { FactoryBot.create :crop } - describe 'sunniness' do - before { get :sunniness, crop_id: crop.to_param } - it { expect(response).to be_success } - end - describe 'planted_from' do - before { get :planted_from, crop_id: crop.to_param } - it { expect(response).to be_success } - end - describe 'harvested_for' do - before { get :harvested_for, crop_id: crop.to_param } - it { expect(response).to be_success } - end - end end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 073d03d6b..2e31f2d78 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -14,10 +14,6 @@ RSpec.describe GardensController, type: :controller do before { put :create, garden: valid_params } it { expect(response).to redirect_to(new_member_session_path) } end - describe 'GET timeline' do - before { get :timeline, garden_id: garden.to_param } - it { expect(response).to be_success } - end describe 'changing existing records' do before do allow(Garden).to receive(:find).and_return(:garden) @@ -46,11 +42,6 @@ RSpec.describe GardensController, type: :controller do let!(:member) { FactoryBot.create(:member) } - describe 'GET timeline' do - before { get :timeline, garden_id: garden.to_param } - it { expect(response).to be_success } - end - describe "for another member's garden" do let(:not_my_garden) { double('garden') } From 56ed61b2b369b3f736c9e1d61a8445412870be3e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 20:59:15 +1300 Subject: [PATCH 054/101] Lock pg < 1.0.0 for now --- Gemfile | 2 +- Gemfile.lock | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 1e26e67fc..488a3b9ab 100644 --- a/Gemfile +++ b/Gemfile @@ -38,7 +38,7 @@ gem 'gibbon', '~>1.2.0' # for Mailchimp newsletter subscriptions gem 'leaflet-rails' gem 'rails-assets-leaflet.markercluster', source: 'https://rails-assets.org' -gem 'pg' +gem 'pg', '< 1.0.0' # Upstream bug, see https://github.com/Growstuff/growstuff/pull/1539 gem 'ruby-units' # for unit conversion gem 'unicorn' # http server diff --git a/Gemfile.lock b/Gemfile.lock index 637ee3f44..d1294ecc9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -611,7 +611,7 @@ DEPENDENCIES omniauth-facebook omniauth-flickr (>= 0.0.15) omniauth-twitter - pg + pg (< 1.0.0) platform-api poltergeist pry @@ -637,9 +637,8 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 BUNDLED WITH - 1.16.0 + 1.16.1 From 3dc356eb29029a07f74082ab44e7bbaf29911743 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 15:28:26 +1300 Subject: [PATCH 055/101] order gardens by name on plantings form --- app/views/plantings/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index de2e55c30..4b0d979b6 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -21,7 +21,7 @@ = f.label :garden_id, 'Where did you plant it?', class: 'control-label col-md-2' .col-md-8 = collection_select(:planting, :garden_id, - Garden.active.where(owner_id: current_member), + current_member.gardens.active.order("lower(gardens.name)"), :id, :name, selected: @planting.garden_id || @garden.id, class: 'form-control') From 92e56cfc1e2d289694cbd2f39283e45283c60040 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Jan 2018 21:11:40 +1300 Subject: [PATCH 056/101] Fixed up a spec, use sign_in member instead of stubing --- spec/views/plantings/_form.html.haml_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 692b53173..6371311ae 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe "plantings/_form" do before(:each) do - controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @garden = FactoryBot.create(:garden, owner: @member) @uppercase = FactoryBot.create(:uppercasecrop) @@ -14,6 +13,8 @@ describe "plantings/_form" do crop: @crop, owner: @member, planted_at: Date.new(2013, 3, 1)) + + sign_in @member render end From e8d9314cff281c112e8e3d23e920f4a36bd0e4cc Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sat, 13 Jan 2018 22:50:22 +0000 Subject: [PATCH 057/101] Auto corrected by following Style/Lambda --- spec/controllers/member_controller_spec.rb | 4 ++-- spec/models/photo_spec.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index b04bcd799..14ba85e08 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -44,12 +44,12 @@ describe MembersController do end it "doesn't show completely nonsense members" do - lambda { get :show, id: 9999 }.should raise_error(ActiveRecord::RecordNotFound) + -> { get :show, id: 9999 }.should raise_error(ActiveRecord::RecordNotFound) end it "doesn't show unconfirmed members" do @member2 = FactoryBot.create(:unconfirmed_member) - lambda { get :show, id: @member2.id }.should raise_error(ActiveRecord::RecordNotFound) + -> { get :show, id: @member2.id }.should raise_error(ActiveRecord::RecordNotFound) end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index c971ce2fd..5f07a3e29 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -50,7 +50,7 @@ describe Photo do it "automatically if unused" do photo.destroy_if_unused - expect(lambda { photo.reload }).to raise_error ActiveRecord::RecordNotFound + expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end it 'they are used by plantings but not harvests' do @@ -58,7 +58,7 @@ describe Photo do planting.photos << photo harvest.destroy # photo is now used by harvest but not planting photo.destroy_if_unused - expect(lambda { photo.reload }).not_to raise_error + expect(-> { photo.reload }).not_to raise_error end it 'they are used by harvests but not plantings' do @@ -66,7 +66,7 @@ describe Photo do planting.photos << photo planting.destroy # photo is now used by harvest but not planting photo.destroy_if_unused - expect(lambda { photo.reload }).not_to raise_error + expect(-> { photo.reload }).not_to raise_error end it 'they are used by gardens but not plantings' do @@ -74,7 +74,7 @@ describe Photo do planting.photos << photo planting.destroy # photo is now used by garden but not planting photo.destroy_if_unused - expect(lambda { photo.reload }).not_to raise_error + expect(-> { photo.reload }).not_to raise_error end it 'they are no longer used by anything' do @@ -99,7 +99,7 @@ describe Photo do expect(photo.harvests.size).to eq 0 expect(photo.gardens.size).to eq 0 photo.destroy_if_unused - expect(lambda { photo.reload }).to raise_error ActiveRecord::RecordNotFound + expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end it 'does not occur when a photo is still in use' do From 3453a648faf761e556bb13cb5ee4b46d003cced0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 14:54:50 +1300 Subject: [PATCH 058/101] Latest versions of bootstrap accessibility plugin --- app/assets/javascripts/bootstrap-accessibility.min.js | 6 +++--- app/assets/stylesheets/bootstrap-accessibility.css | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/bootstrap-accessibility.min.js b/app/assets/javascripts/bootstrap-accessibility.min.js index 8e5a2ef61..41a37c453 100644 --- a/app/assets/javascripts/bootstrap-accessibility.min.js +++ b/app/assets/javascripts/bootstrap-accessibility.min.js @@ -1,4 +1,4 @@ -/*! bootstrap-accessibility-plugin - v1.0.4 - 2015-07-27 +/*! bootstrap-accessibility-plugin - v1.0.5 - 2016-07-19 * https://github.com/paypal/bootstrap-accessibility-plugin -* Copyright (c) 2015 PayPal Accessibility Team; Licensed BSD */ -!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){var modalOpener=this.$element.parent().find('[data-target="#'+this.$element.attr("id")+'"]');modalhide.apply(this,arguments),modalOpener.focus(),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var focEls=this.$element.find(":tabbable"),lastEl=focEls[focEls.length-1];$(document).on("keydown.bs.modal",$.proxy(function(ev){!this.$element.has(ev.target).length&&ev.shiftKey&&9===ev.keyCode&&(lastEl.focus(),ev.preventDefault())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.dropdown",$.proxy(function(ev){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}),$(toggle).parent().on("hidden.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(e){var $this=$(this),that=this;setTimeout(function(){$.contains(that,document.activeElement)||($this.parent().removeClass("open"),$this.parent().find("[data-toggle=dropdown]").attr("aria-expanded","false"))},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(index){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container,callback){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(index){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse");colltab.attr("id",collid),collparent&&(colltab.attr({role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.hasClass("in")?(colltab.attr({"aria-controls":collpanel.attr("id"),"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({role:"tabpanel",tabindex:"0","aria-labelledby":collid,"aria-hidden":"false"})):(colltab.attr({"aria-controls":collpanel.attr("id"),tabindex:"-1"}),collpanel.attr({role:"tabpanel",tabindex:"-1","aria-labelledby":collid,"aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent;this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.click(),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(index){var $this=$(this),prev=$this.find('[data-slide="prev"]'),next=$this.find('[data-slide="next"]'),$options=$this.find(".item"),$listbox=$options.parent();$this.attr({"data-interval":"false","data-wrap":"false"}),$listbox.attr("role","listbox"),$options.attr("role","option");var spanPrev=document.createElement("span");spanPrev.setAttribute("class","sr-only"),spanPrev.innerHTML="Previous";var spanNext=document.createElement("span");spanNext.setAttribute("class","sr-only"),spanNext.innerHTML="Next",prev.attr("role","button"),next.attr("role","button"),prev.append(spanPrev),next.append(spanNext),$options.each(function(){var item=$(this);item.hasClass("active")?item.attr({"aria-selected":"true",tabindex:"0"}):item.attr({"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $active=this.$element.find(".item.active"),$next=next||$active[type]();slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){$active.attr({"aria-selected":!1,tabIndex:"-1"}),$next.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$ul=$this.closest("div[role=listbox]"),$items=$ul.find("[role=option]"),$parent=$ul.parent(),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$items.index($items.filter(".active")),(37==k||38==k)&&(index--,0>index?index=$items.length-1:($parent.carousel("prev"),setTimeout(function(){$items[index].focus()},150))),(39==k||40==k)&&(index++,index==$items.length?index=0:($parent.carousel("next"),setTimeout(function(){$items[index].focus()},150))),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","div[role=option]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery); +* Copyright (c) 2016 PayPal Accessibility Team; Licensed BSD */ +!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){modalhide.apply(this,arguments),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var $content=this.$element.find(".modal-content"),focEls=$content.find(":tabbable"),$lastEl=$(focEls[focEls.length-1]),$firstEl=$(focEls[0]);$lastEl.on("keydown.bs.modal",$.proxy(function(ev){9!==ev.keyCode||ev.shiftKey|ev.ctrlKey|ev.metaKey|ev.altKey||(ev.preventDefault(),$firstEl.focus())},this)),$firstEl.on("keydown.bs.modal",$.proxy(function(ev){9===ev.keyCode&&ev.shiftKey&&(ev.preventDefault(),$lastEl.focus())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.dropdown",$.proxy(function(ev){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}).on("hidden.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(e){var $this=$(this),that=this;$this.parent().hasClass("open")&&setTimeout(function(){$.contains(that,document.activeElement)||$this.parent().find("[data-toggle=dropdown]").dropdown("toggle")},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(index){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container,callback){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(index){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse");colltab.attr("id",collid),collparent&&(colltab.attr({role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.hasClass("in")?(colltab.attr({"aria-controls":collpanel.attr("id"),"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({role:"tabpanel",tabindex:"0","aria-labelledby":collid,"aria-hidden":"false"})):(colltab.attr({"aria-controls":collpanel.attr("id"),tabindex:"-1"}),collpanel.attr({role:"tabpanel",tabindex:"-1","aria-labelledby":collid,"aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent;this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.click(),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(index){function setTablistHighlightBox(){var $tab,offset,height,width,highlightBox={};highlightBox.top=0,highlightBox.left=32e3,highlightBox.height=0,highlightBox.width=0;for(var i=0;i<$tabs.length;i++){$tab=$tabs[i],offset=$($tab).offset(),height=$($tab).height(),width=$($tab).width(),highlightBox.topoffset.left&&(highlightBox.left=Math.round(offset.left));var w=offset.left-highlightBox.left+Math.round(width);highlightBox.widthA carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.

'),$this.prepend('

Carousel content with '+$tabpanels.length+" slides.

")),i=0;i<$tabs.length;i++){$tab=$tabs[i],$tab.setAttribute("role","tab"),$tab.setAttribute("id","tab-"+index+"-"+i),$tab.setAttribute("aria-controls","tabpanel-"+index+"-"+i);var tpId="#tabpanel-"+index+"-"+i,caption=$this.find(tpId).find("h1").text();("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h3").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h4").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h5").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h6").text()),("string"!=typeof caption||0===caption.length)&&(caption="no title");var tabName=document.createElement("span");tabName.setAttribute("class","sr-only"),tabName.innerHTML="Slide "+(i+1),caption&&(tabName.innerHTML+=": "+caption),$tab.appendChild(tabName)}$tablistHighlight=document.createElement("div"),$tablistHighlight.className="carousel-tablist-highlight",document.body.appendChild($tablistHighlight),$complementaryLandmark=document.createElement("aside"),$complementaryLandmark.setAttribute("class","carousel-aside-pause"),$complementaryLandmark.setAttribute("aria-label","carousel pause/play control"),$this.prepend($complementaryLandmark),$pauseCarousel=document.createElement("button"),$pauseCarousel.className="carousel-pause-button",$pauseCarousel.innerHTML="Pause Carousel",$pauseCarousel.setAttribute("title","Pause/Play carousel button can be used by screen reader users to stop carousel animations"),$($complementaryLandmark).append($pauseCarousel),$($pauseCarousel).click(function(){$is_paused?($pauseCarousel.innerHTML="Pause Carousel",$this.carousel("cycle"),$is_paused=!1):($pauseCarousel.innerHTML="Play Carousel",$this.carousel("pause"),$is_paused=!0)}),$($pauseCarousel).focus(function(){$(this).addClass("focus")}),$($pauseCarousel).blur(function(){$(this).removeClass("focus")}),setTablistHighlightBox(),$(window).resize(function(){setTablistHighlightBox()}),$prev.attr("aria-label","Previous Slide"),$prev.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$prev.trigger("click"))}),$prev.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$prev.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$next.attr("aria-label","Next Slide"),$next.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$next.trigger("click"))}),$next.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$next.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$(".carousel-inner a").focus(function(){$(this).parents(".carousel").addClass("contrast")}),$(".carousel-inner a").blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$tabs.each(function(){var item=$(this);item.hasClass("active")?item.attr({"aria-selected":"true",tabindex:"0"}):item.attr({"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $id,$element=this.$element,$active=$element.find("[role=tabpanel].active"),$next=next||$active[type](),$tab_count=$element.find("[role=tabpanel]").size(),$prev_side=$element.find('[data-slide="prev"]'),$next_side=$element.find('[data-slide="next"]'),$index=0,$prev_index=$tab_count-1,$next_index=1;$next&&$next.attr("id")&&($id=$next.attr("id"),$index=$id.lastIndexOf("-"),$index>=0&&($index=parseInt($id.substring($index+1),10)),$prev_index=$index-1,1>$prev_index&&($prev_index=$tab_count-1),$next_index=$index+1,$next_index>=$tab_count&&($next_index=0)),$prev_side.attr("aria-label","Show slide "+($prev_index+1)+" of "+$tab_count),$next_side.attr("aria-label","Show slide "+($next_index+1)+" of "+$tab_count),slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){var $tab;$tab=$element.find('li[aria-controls="'+$active.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!1,tabIndex:"-1"}),$tab=$element.find('li[aria-controls="'+$next.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){function selectTab(index){index>=$tabs.length||0>index||($carousel.carousel(index),setTimeout(function(){$tabs[index].focus()},150))}$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$carousel=$(e.target).closest(".carousel"),$tabs=$carousel.find("[role=tab]"),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$tabs.index($tabs.filter(".active")),(37==k||38==k)&&(index--,selectTab(index)),(39==k||40==k)&&(index++,selectTab(index)),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","li[role=tab]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery); \ No newline at end of file diff --git a/app/assets/stylesheets/bootstrap-accessibility.css b/app/assets/stylesheets/bootstrap-accessibility.css index b7de73ef0..abf715176 100644 --- a/app/assets/stylesheets/bootstrap-accessibility.css +++ b/app/assets/stylesheets/bootstrap-accessibility.css @@ -1 +1 @@ -.btn:focus{outline:dotted 2px #000}div.active:focus{outline:dotted 1px #000}a:focus{outline:dotted 1px #000}.close:hover,.close:focus{outline:dotted 1px #000}.nav>li>a:hover,.nav>li>a:focus{outline:dotted 1px #000}.carousel-inner>.item{position:absolute;top:-999999em;display:block;-moz-transition:ease-in-out 0.6s left;-o-transition:ease-in-out 0.6s left;-webkit-transition:ease-in-out 0.6s left;transition:ease-in-out 0.6s left}.carousel-inner>.active{top:0}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{position:relative}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.alert-success{color:#2d4821}.alert-info{color:#214c62}.alert-warning{color:#6c4a00;background-color:#f9f1c6}.alert-danger{color:#d2322d}.alert-danger:hover{color:#a82824} +.btn:focus{outline:dotted 2px #000}div.active:focus{outline:dotted 1px #000}a:focus{outline:dotted 1px #000}.close:hover,.close:focus{outline:dotted 1px #000}.nav>li>a:hover,.nav>li>a:focus{outline:dotted 1px #000}.carousel-indicators li,.carousel-indicators li.active{height:18px;width:18px;border-width:2px;position:relative;box-shadow:0px 0px 0px 1px #808080}.carousel-indicators.active li{background-color:rgba(100,149,253,0.6)}.carousel-indicators.active li.active{background-color:white}.carousel-tablist-highlight{display:block;position:absolute;outline:2px solid transparent;background-color:transparent;box-shadow:0px 0px 0px 1px transparent}.carousel-tablist-highlight.focus{outline:2px solid #6495ED;background-color:rgba(0,0,0,0.4)}a.carousel-control:focus{outline:2px solid #6495ED;background-image:linear-gradient(to right, transparent 0px, rgba(0,0,0,0.5) 100%);box-shadow:0px 0px 0px 1px #000000}.carousel-pause-button{position:absolute;top:-30em;left:-300em;display:block}.carousel-pause-button.focus{top:0.5em;left:0.5em}.carousel:hover .carousel-caption,.carousel.contrast .carousel-caption{background-color:rgba(0,0,0,0.5);z-index:10}.alert-success{color:#2d4821}.alert-info{color:#214c62}.alert-warning{color:#6c4a00;background-color:#f9f1c6}.alert-danger{color:#d2322d}.alert-danger:hover{color:#a82824} From 1e0565dd9be960a8c10571c23a97cdfd40a65d3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 3 Jan 2018 15:01:24 +1300 Subject: [PATCH 059/101] Tell hound to ignore the bootstrap plugin file --- .esignore | 1 + .hound.yml | 1 + 2 files changed, 2 insertions(+) create mode 100644 .esignore diff --git a/.esignore b/.esignore new file mode 100644 index 000000000..8430f8bb3 --- /dev/null +++ b/.esignore @@ -0,0 +1 @@ +app/assets/javascripts/bootstrap-accessibility.min.js diff --git a/.hound.yml b/.hound.yml index d62d2897a..a47896765 100644 --- a/.hound.yml +++ b/.hound.yml @@ -8,3 +8,4 @@ scss: config_file: .scss-lint.yml eslint: config_file: .eslintrc + ignore_file: .esignore From df5006c61c22b973340d0331add9580dbf540908 Mon Sep 17 00:00:00 2001 From: Shiny Date: Sun, 21 Jan 2018 21:35:28 +1300 Subject: [PATCH 060/101] Disable jshint this is on by default --- .hound.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hound.yml b/.hound.yml index a47896765..6fc0f560d 100644 --- a/.hound.yml +++ b/.hound.yml @@ -9,3 +9,5 @@ scss: eslint: config_file: .eslintrc ignore_file: .esignore +jshint: + enabled: false From 2eff7d67165baf5a9b849cad9570e83bf836b790 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sun, 21 Jan 2018 19:29:26 +0800 Subject: [PATCH 061/101] Bundle Update on 2018-01-21 --- Gemfile.lock | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d1294ecc9..91084e12c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,7 +34,7 @@ GEM activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.75.0) + activemerchant (1.76.0) activesupport (>= 3.2.14, < 6.x) builder (>= 2.1.2, < 4.0.0) i18n (>= 0.6.9) @@ -58,14 +58,14 @@ GEM public_suffix (>= 2.0.2, < 4.0) arel (6.0.4) ast (2.3.0) - autoprefixer-rails (7.2.3) + autoprefixer-rails (7.2.5) execjs bcrypt (3.1.11) better_errors (2.2.0) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) - binding_of_caller (0.7.3) + binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bluecloth (2.2.0) bonsai-elasticsearch-rails (0.2.0) @@ -81,18 +81,18 @@ GEM sass (>= 3.3.4) bootstrap_form (2.7.0) builder (3.2.3) - bullet (5.7.0) + bullet (5.7.2) activesupport (>= 3.0.0) - uniform_notifier (~> 1.10.0) + uniform_notifier (~> 1.11.0) byebug (9.1.0) - cancancan (2.1.2) - capybara (2.16.1) + cancancan (2.1.3) + capybara (2.17.0) addressable mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) - xpath (~> 2.0) + xpath (>= 2.0, < 4.0) capybara-email (2.5.0) capybara (~> 2.4) mail @@ -147,7 +147,7 @@ GEM dalli (2.7.6) database_cleaner (1.6.2) debug_inspector (0.0.3) - devise (4.3.0) + devise (4.4.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 5.2) @@ -155,8 +155,7 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) - easy_translate (0.5.0) - json + easy_translate (0.5.1) thread thread_safe elasticsearch (2.0.2) @@ -202,10 +201,10 @@ GEM gravatar-ultimate (2.0.0) activesupport (>= 2.3.14) rack - guard (2.14.1) + guard (2.14.2) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) + lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) @@ -263,12 +262,12 @@ GEM parser (>= 2.2.3.0) term-ansicolor (>= 1.3.2) terminal-table (>= 1.5.1) - jasmine (2.8.0) - jasmine-core (>= 2.8.0, < 3.0.0) + jasmine (2.9.0) + jasmine-core (>= 2.9.0, < 3.0.0) phantomjs rack (>= 1.2.1) rake - jasmine-core (2.8.0) + jasmine-core (2.9.1) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -300,9 +299,9 @@ GEM kramdown (1.16.2) launchy (2.4.3) addressable (~> 2.3) - leaflet-rails (1.2.0) + leaflet-rails (1.3.1) rails (>= 4.2.0) - letter_opener (1.4.1) + letter_opener (1.6.0) launchy (~> 2.2) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -322,7 +321,7 @@ GEM mimemagic (0.3.2) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.10.3) + minitest (5.11.1) moneta (0.8.1) multi_json (1.11.3) multi_xml (0.6.0) @@ -341,7 +340,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.7.1) + omniauth (1.8.1) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) omniauth-facebook (4.0.0) @@ -402,8 +401,8 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 4.2.10) sprockets-rails - rails-assets-leaflet (1.2.0) - rails-assets-leaflet.markercluster (1.2.0) + rails-assets-leaflet (1.3.1) + rails-assets-leaflet.markercluster (1.3.0) rails-assets-leaflet (>= 1.0.3) rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -444,7 +443,7 @@ GEM activemodel (>= 3.0) activesupport (>= 3.0) rspec-mocks (>= 2.99, < 4.0) - rspec-core (3.7.0) + rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) @@ -474,7 +473,7 @@ GEM ruby_parser (3.10.1) sexp_processor (~> 4.9) rubyzip (1.2.1) - sass (3.5.4) + sass (3.5.5) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -524,13 +523,13 @@ GEM trollop (1.16.2) tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (4.0.2) + uglifier (4.1.3) execjs (>= 0.3.0, < 3) unicode-display_width (1.3.0) unicorn (5.4.0) kgio (~> 2.6) raindrops (~> 0.7) - uniform_notifier (1.10.0) + uniform_notifier (1.11.0) warden (1.2.7) rack (>= 1.0) webrat (0.7.3) @@ -542,8 +541,8 @@ GEM websocket-extensions (0.1.3) will_paginate (3.1.6) xmlrpc (0.3.0) - xpath (2.1.0) - nokogiri (~> 1.3) + xpath (3.0.0) + nokogiri (~> 1.8) PLATFORMS ruby @@ -637,6 +636,7 @@ DEPENDENCIES will_paginate xmlrpc + RUBY VERSION ruby 2.4.1p111 From caf41e80c99488cb3571bcb91819ec36e303b0d9 Mon Sep 17 00:00:00 2001 From: Shiny Date: Wed, 24 Jan 2018 15:07:06 +1300 Subject: [PATCH 062/101] Patching paperclip gem --- Gemfile.lock | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 91084e12c..968e16d50 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -250,7 +250,7 @@ GEM ruby_parser (~> 3.5) httparty (0.15.6) multi_xml (>= 0.5.2) - i18n (0.9.1) + i18n (0.9.3) concurrent-ruby (~> 1.0) i18n-tasks (0.9.12) activesupport (>= 4.0.2) @@ -358,7 +358,7 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - paperclip (5.1.0) + paperclip (5.2.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) cocaine (~> 0.5.5) @@ -636,7 +636,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 From be1553410f88f92c8852af8214821abd1ddf938f Mon Sep 17 00:00:00 2001 From: deppbot Date: Wed, 24 Jan 2018 23:33:13 +0800 Subject: [PATCH 063/101] Bundle Update on 2018-01-24 --- Gemfile.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 968e16d50..a0cf19869 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,7 +147,7 @@ GEM dalli (2.7.6) database_cleaner (1.6.2) debug_inspector (0.0.3) - devise (4.4.0) + devise (4.4.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 5.2) @@ -523,7 +523,7 @@ GEM trollop (1.16.2) tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (4.1.3) + uglifier (4.1.4) execjs (>= 0.3.0, < 3) unicode-display_width (1.3.0) unicorn (5.4.0) @@ -636,6 +636,7 @@ DEPENDENCIES will_paginate xmlrpc + RUBY VERSION ruby 2.4.1p111 From 093a9489226fb0b143ea30b3e03213be2173aa79 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sun, 28 Jan 2018 03:08:58 +0800 Subject: [PATCH 064/101] Bundle Update on 2018-01-28 --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a0cf19869..e294842c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) arel (6.0.4) - ast (2.3.0) + ast (2.4.0) autoprefixer-rails (7.2.5) execjs bcrypt (3.1.11) @@ -84,7 +84,7 @@ GEM bullet (5.7.2) activesupport (>= 3.0.0) uniform_notifier (~> 1.11.0) - byebug (9.1.0) + byebug (10.0.0) cancancan (2.1.3) capybara (2.17.0) addressable @@ -321,7 +321,7 @@ GEM mimemagic (0.3.2) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.11.1) + minitest (5.11.3) moneta (0.8.1) multi_json (1.11.3) multi_xml (0.6.0) @@ -358,7 +358,7 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - paperclip (5.2.0) + paperclip (5.2.1) activemodel (>= 4.2.0) activesupport (>= 4.2.0) cocaine (~> 0.5.5) From 7f87ee1018e6bcc6c43422d579e9a64f2b282c73 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 22 Jan 2018 15:18:53 +1300 Subject: [PATCH 065/101] Fixed default_photo for seeds - uses own photos, not the crop --- app/models/seed.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/seed.rb b/app/models/seed.rb index 56c9f809d..7abae922c 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -16,8 +16,6 @@ class Seed < ActiveRecord::Base # # Validations validates :crop, approved: true - delegate :name, to: :crop - delegate :default_photo, to: :crop validates :crop, presence: { message: "must be present and exist in our database" } validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } @@ -38,6 +36,10 @@ class Seed < ActiveRecord::Base inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ "are heirloom, hybrid, or unknown" } + # + # Delegations + delegate :name, to: :crop + # # Scopes default_scope { joins(:owner) } # Ensure owner exists @@ -45,6 +47,10 @@ class Seed < ActiveRecord::Base scope :interesting, -> { tradable.has_location } scope :has_location, -> { joins(:owner).where.not("members.location": nil) } + def default_photo + photos.order(created_at: :desc).first + end + def tradable? tradable_to != 'nowhere' end From 767477df66ed530039fe6e62b972099e8b7d74a2 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sun, 28 Jan 2018 23:47:27 +0000 Subject: [PATCH 066/101] Auto corrected by following RSpec/LeadingSubject --- spec/features/crops/crop_detail_page_spec.rb | 18 +++++++++--------- spec/features/crops/crop_photos_spec.rb | 2 +- spec/features/seeds/seed_photos.rb | 6 +++--- spec/models/crop_spec.rb | 2 +- spec/models/role_spec.rb | 4 ++-- spec/requests/api/v1/crop_request_spec.rb | 2 +- spec/requests/api/v1/gardens_request_spec.rb | 2 +- spec/requests/api/v1/harvest_request_spec.rb | 2 +- spec/requests/api/v1/member_request_spec.rb | 2 +- spec/requests/api/v1/photos_request_spec.rb | 2 +- spec/requests/api/v1/plantings_request_spec.rb | 2 +- spec/requests/api/v1/seeds_request_spec.rb | 2 +- .../crops/_planting_advice.html.haml_spec.rb | 2 +- spec/views/harvests/show.html.haml_spec.rb | 2 +- spec/views/posts/show.html.haml_spec.rb | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index bbf37e996..0a28d875f 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,15 @@ require 'rails_helper' feature "crop detail page", js: true do + subject do + # Update the medians after all the + # data has been loaded + crop.reload + crop.update_medians + + visit crop_path(crop) + page + end let(:crop) { create :crop } context "varieties" do @@ -187,15 +196,6 @@ feature "crop detail page", js: true do end end - subject do - # Update the medians after all the - # data has been loaded - crop.reload - crop.update_medians - - visit crop_path(crop) - page - end context 'predictions' do let!(:planting) do diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 260283057..ccc5288f0 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' feature "crop detail page", js: true do + subject { page } let(:member) { create :member } let(:crop) { create :crop, plantings: [planting], harvests: [harvest] } @@ -27,7 +28,6 @@ feature "crop detail page", js: true do harvest.photos << photo4 visit crop_path(crop) end - subject { page } shared_examples "shows photos" do describe "show planting photos" do diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 3d57f2cfe..80fbf9bc3 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -2,14 +2,14 @@ require 'rails_helper' require 'custom_matchers' feature "Seeds", :js do - let(:member) { FactoryBot.create :member } - let!(:seed) { FactoryBot.create :seed, owner: member } - subject do login_as member visit seed_path(seed) page end + let(:member) { FactoryBot.create :member } + let!(:seed) { FactoryBot.create :seed, owner: member } + it { is_expected.to have_content 'Add photo' } diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 9e6173221..27521876a 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -276,6 +276,7 @@ describe Crop do end context 'interesting' do + subject { Crop.interesting } let(:photo) { FactoryBot.create :photo } # first, a couple of candidate crops let(:crop1) { FactoryBot.create(:crop) } @@ -284,7 +285,6 @@ describe Crop do let(:crop1_planting) { crop1.plantings.first } let(:crop2_planting) { crop2.plantings.first } - subject { Crop.interesting } describe 'lists interesting crops' do before do diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index a7cfbecd3..99c87701c 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' describe Role do - let(:member) { FactoryBot.create(:member) } - subject do role = FactoryBot.create(:role, name: 'Crop Wrangler') role.members << member role end + let(:member) { FactoryBot.create(:member) } + it 'has members' do subject.members.first.should eq member diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index cfac5fdb4..6a392eb74 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Plantings', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do @@ -54,7 +55,6 @@ RSpec.describe 'Plantings', type: :request do } end - subject { JSON.parse response.body } describe '#index' do before { get '/api/v1/crops', {}, headers } it { expect(subject['data']).to include(crop_encoded_as_json_api) } diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 65caf7044..d6005e286 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Gardens', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do @@ -36,7 +37,6 @@ RSpec.describe 'Gardens', type: :request do "related" => "#{resource_url}/photos" } } end - subject { JSON.parse response.body } scenario '#index' do get '/api/v1/gardens', {}, headers expect(subject['data']).to include(garden_encoded_as_json_api) diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index 7d97dea08..af2d4201e 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Harvests', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do @@ -55,7 +56,6 @@ RSpec.describe 'Harvests', type: :request do } end - subject { JSON.parse response.body } describe '#index' do before { get '/api/v1/harvests', {}, headers } it { expect(subject['data']).to include(harvest_encoded_as_json_api) } diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 0c74dc3cd..6067e59b6 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Members', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do @@ -55,7 +56,6 @@ RSpec.describe 'Members', type: :request do } end - subject { JSON.parse response.body } describe '#index' do before { get '/api/v1/members', {}, headers } it { expect(subject['data']).to include(member_encoded_as_json_api) } diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index cb205d972..e9e584a60 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Photos', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do @@ -53,7 +54,6 @@ RSpec.describe 'Photos', type: :request do } end - subject { JSON.parse response.body } describe '#index' do before { get '/api/v1/photos', {}, headers } it { expect(subject['data']).to include(photo_encoded_as_json_api) } diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 0591a28dc..4e96cefb4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Plantings', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do @@ -66,7 +67,6 @@ RSpec.describe 'Plantings', type: :request do } end - subject { JSON.parse response.body } scenario '#index' do get '/api/v1/plantings', {}, headers expect(subject['data']).to include(planting_encoded_as_json_api) diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index 41d622a1f..f518e91de 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Photos', type: :request do + subject { JSON.parse response.body } let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do @@ -42,7 +43,6 @@ RSpec.describe 'Photos', type: :request do } end - subject { JSON.parse response.body } describe '#index' do before { get '/api/v1/seeds', {}, headers } it { expect(subject['data']).to include(seed_encoded_as_json_api) } diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 38499e2d9..0229c23f0 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' describe "crops/_planting_advice" do + subject { rendered } let(:planting) { FactoryBot.create(:planting) } - subject { rendered } shared_examples "render planting_advice" do before { render 'crops/planting_advice', crop: planting.crop } diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 624cf88c4..f9295ac5f 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' describe "harvests/show" do + subject { render } let!(:harvest) { FactoryBot.create(:harvest) } before do @@ -10,7 +11,6 @@ describe "harvests/show" do render end - subject { render } describe "renders attributes" do it { is_expected.to have_content harvest.crop.name } diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index 273f400cc..ba6921e4e 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' describe "posts/show" do + subject { rendered } let(:author) { FactoryBot.create(:member) } before(:each) do controller.stub(:current_user) { nil } assign(:post, post) end - subject { rendered } describe 'render post' do before { render } From 94db28b3a9cb7f65a94bb5f261b0ba0d03b7266b Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sun, 28 Jan 2018 23:47:38 +0000 Subject: [PATCH 067/101] Auto corrected by following Style/AndOr --- lib/tasks/growstuff.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 03b2e3d0e..befff39a0 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -51,7 +51,7 @@ namespace :growstuff do send_on_day = 3 # wednesday every_n_weeks = 2 # send fortnightly - if Time.zone.today.cwday == send_on_day and Time.zone.today.cweek % every_n_weeks == 0 + if (Time.zone.today.cwday == send_on_day) && (Time.zone.today.cweek % every_n_weeks == 0) Member.confirmed.find_each do |m| Notifier.planting_reminder(m).deliver_now! end @@ -62,7 +62,7 @@ namespace :growstuff do # this fixes up anyone who has erroneously wound up with a 0,0 lat/long task depopulate_null_island: :environment do Member.find_each do |m| - if m.location and (m.latitude.nil? and m.longitude.nil?) + if m.location && (m.latitude.nil? && m.longitude.nil?) m.geocode m.save end @@ -88,7 +88,7 @@ namespace :growstuff do # site is small and there aren't many of them, so it shouldn't matter # for this one-off script. Garden.all.each do |g| - if g.name.nil? or g.name =~ /^\s*$/ + if g.name.nil? || g.name =~(/^\s*$/) g.name = "Garden" g.save end From 3d4598e4e1bc1f0ffd44771ca1c35c66ac72a397 Mon Sep 17 00:00:00 2001 From: Shiny Date: Mon, 29 Jan 2018 12:56:41 +1300 Subject: [PATCH 068/101] style clean up --- lib/tasks/growstuff.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index befff39a0..908b71337 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -88,7 +88,7 @@ namespace :growstuff do # site is small and there aren't many of them, so it shouldn't matter # for this one-off script. Garden.all.each do |g| - if g.name.nil? || g.name =~(/^\s*$/) + if g.name.nil? || g.name =~ /^\s*$/ g.name = "Garden" g.save end From b2cf02252268dda34f786a8e7f456dd7412e263b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Jan 2018 13:01:49 +1300 Subject: [PATCH 069/101] Removed extra blank lines --- spec/features/crops/crop_detail_page_spec.rb | 1 - spec/features/seeds/seed_photos.rb | 1 - spec/models/crop_spec.rb | 1 - spec/models/role_spec.rb | 1 - spec/views/crops/_planting_advice.html.haml_spec.rb | 1 - spec/views/harvests/show.html.haml_spec.rb | 1 - 6 files changed, 6 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 0a28d875f..b7dca2e8d 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -196,7 +196,6 @@ feature "crop detail page", js: true do end end - context 'predictions' do let!(:planting) do FactoryBot.create(:planting, crop: crop, diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 80fbf9bc3..7e26ece28 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -10,7 +10,6 @@ feature "Seeds", :js do let(:member) { FactoryBot.create :member } let!(:seed) { FactoryBot.create :seed, owner: member } - it { is_expected.to have_content 'Add photo' } # context 'no photos' do diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 27521876a..3f49a249d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -285,7 +285,6 @@ describe Crop do let(:crop1_planting) { crop1.plantings.first } let(:crop2_planting) { crop2.plantings.first } - describe 'lists interesting crops' do before do # they need 3+ plantings each to be interesting diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 99c87701c..76e309aa0 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -8,7 +8,6 @@ describe Role do end let(:member) { FactoryBot.create(:member) } - it 'has members' do subject.members.first.should eq member end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 0229c23f0..12064a1b8 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -4,7 +4,6 @@ describe "crops/_planting_advice" do subject { rendered } let(:planting) { FactoryBot.create(:planting) } - shared_examples "render planting_advice" do before { render 'crops/planting_advice', crop: planting.crop } end diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index f9295ac5f..4aec453ff 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -11,7 +11,6 @@ describe "harvests/show" do render end - describe "renders attributes" do it { is_expected.to have_content harvest.crop.name } it { is_expected.to have_content harvest.harvested_at.to_s } From 742c7e30a962d1b02b1b62ef2b0a05237d547eb5 Mon Sep 17 00:00:00 2001 From: deppbot Date: Wed, 31 Jan 2018 07:10:17 +0800 Subject: [PATCH 070/101] Bundle Update on 2018-01-31 --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e294842c3..fc5a1df92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -295,7 +295,7 @@ GEM activerecord kaminari-core (= 1.1.1) kaminari-core (1.1.1) - kgio (2.11.1) + kgio (2.11.2) kramdown (1.16.2) launchy (2.4.3) addressable (~> 2.3) @@ -328,7 +328,7 @@ GEM multipart-post (2.0.0) nenv (0.3.0) newrelic_rpm (4.7.1.340) - nokogiri (1.8.1) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) notiffany (0.1.1) nenv (~> 0.1) @@ -459,7 +459,7 @@ GEM rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) - rspec-support (3.7.0) + rspec-support (3.7.1) rubocop (0.49.1) parallel (~> 1.10) parser (>= 2.3.3.1, < 3.0) @@ -523,7 +523,7 @@ GEM trollop (1.16.2) tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (4.1.4) + uglifier (4.1.5) execjs (>= 0.3.0, < 3) unicode-display_width (1.3.0) unicorn (5.4.0) From 24931381af94b10bea5bf69c84912713cfe5d5a2 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sat, 3 Feb 2018 23:12:35 +0800 Subject: [PATCH 071/101] Bundle Update on 2018-02-03 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fc5a1df92..2686528e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,7 +34,7 @@ GEM activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.76.0) + activemerchant (1.77.0) activesupport (>= 3.2.14, < 6.x) builder (>= 2.1.2, < 4.0.0) i18n (>= 0.6.9) @@ -327,7 +327,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (4.7.1.340) + newrelic_rpm (4.8.0.341) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) notiffany (0.1.1) @@ -489,7 +489,7 @@ GEM rubyzip (~> 1.0) sexp_processor (4.10.0) shellany (0.0.1) - sidekiq (5.0.5) + sidekiq (5.1.0) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) From a69afd87e7368d56f3ce70e07628797905014804 Mon Sep 17 00:00:00 2001 From: Meir Taffel Date: Mon, 22 Jan 2018 10:07:01 +0000 Subject: [PATCH 072/101] Add date_taken to photos --- CONTRIBUTORS.md | 1 + app/controllers/plantings_controller.rb | 2 +- app/models/photo.rb | 3 ++- db/migrate/20180118112809_add_datetaken_to_photos.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180118112809_add_datetaken_to_photos.rb diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f984400ae..568137391 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -82,6 +82,7 @@ submit the change with your pull request. - Harry Brodsky / [hbrodsk1](https://github.com/hbrodsk1) - Jeff Kingswood / [ancyentmariner](https://github.com/ancyentmariner) - Logan Gingerich / [logangingerich](https://github.com/logangingerich) +- Mark Taffman / [mftaff](https://github.com/mftaff) ## Bots diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 0853b897a..f50083213 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -31,7 +31,7 @@ class PlantingsController < ApplicationController @planting = Planting.includes(:owner, :crop, :garden, :photos) .friendly .find(params[:id]) - @photos = @planting.photos.order(created_at: :desc).includes(:owner).paginate(page: params[:page]) + @photos = @planting.photos.order(date_taken: :desc).includes(:owner).paginate(page: params[:page]) respond_with @planting end diff --git a/app/models/photo.rb b/app/models/photo.rb index 5800ec6f9..a73d28825 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -27,7 +27,8 @@ class Photo < ActiveRecord::Base license_url: license.url, thumbnail_url: FlickRaw.url_q(info), fullsize_url: FlickRaw.url_z(info), - link_url: FlickRaw.url_photopage(info) + link_url: FlickRaw.url_photopage(info), + date_taken: info.dates.taken } end diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb new file mode 100644 index 000000000..42afaf23b --- /dev/null +++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb @@ -0,0 +1,5 @@ +class AddDatetakenToPhotos < ActiveRecord::Migration + def change + add_column :photos, :date_taken, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 473e756fa..be74dabfc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171129041341) do +ActiveRecord::Schema.define(version: 20180118112809) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -405,6 +405,7 @@ ActiveRecord::Schema.define(version: 20171129041341) do t.string "license_url" t.string "link_url", null: false t.string "flickr_photo_id" + t.datetime "date_taken" end create_table "photos_plantings", id: false, force: :cascade do |t| From 88da0da616093a85299e5e3b745cfef49fa2cbf7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 11:49:39 +1300 Subject: [PATCH 073/101] Re-fetches from flickr --- app/controllers/photos_controller.rb | 2 +- app/models/photo.rb | 6 +++++- db/migrate/20180118112809_add_datetaken_to_photos.rb | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 2866c1549..57b10e5d8 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -88,7 +88,7 @@ class PhotosController < ApplicationController photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param) photo ||= Photo.new(photo_params) photo.owner_id = current_member.id - photo.set_flickr_metadata + photo.set_flickr_metadata! photo end diff --git a/app/models/photo.rb b/app/models/photo.rb index a73d28825..07531672b 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -50,7 +50,11 @@ class Photo < ActiveRecord::Base end end - def set_flickr_metadata + def set_flickr_metadata! update_attributes(flickr_metadata) end + + def to_s + "#{title} by #{owner.login_name}" + end end diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb index 42afaf23b..48fb49e51 100644 --- a/db/migrate/20180118112809_add_datetaken_to_photos.rb +++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb @@ -1,5 +1,10 @@ class AddDatetakenToPhotos < ActiveRecord::Migration def change add_column :photos, :date_taken, :datetime + # Fetch from flickr, the photos updated the longest ago will be fetched first + Photo.all.order(:updated_at).each do |photo| + say "Fetch flickr data for #{photo}" + photo.set_flickr_metadata! + end end end From 5cda14f87a4c1a4f5b516f0cff0702be76a8a18f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 12:26:36 +1300 Subject: [PATCH 074/101] Don't update flickr meta data on db rollback --- db/migrate/20180118112809_add_datetaken_to_photos.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb index 48fb49e51..b8cb09118 100644 --- a/db/migrate/20180118112809_add_datetaken_to_photos.rb +++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb @@ -1,6 +1,16 @@ class AddDatetakenToPhotos < ActiveRecord::Migration - def change + def up add_column :photos, :date_taken, :datetime + update_flickr_metadata + end + + def down + add_column :photos, :date_taken + end + + private + + def update_flickr_metadata # Fetch from flickr, the photos updated the longest ago will be fetched first Photo.all.order(:updated_at).each do |photo| say "Fetch flickr data for #{photo}" From 7e1e2bef9133a8ed6a9dfc6921e242b00d1e21fa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 13:40:29 +1300 Subject: [PATCH 075/101] Removing shop, products, accounts, orders --- .rubocop_todo.yml | 2 - app/controllers/account_types_controller.rb | 53 ----- app/controllers/accounts_controller.rb | 31 --- app/controllers/admin/orders_controller.rb | 23 --- app/controllers/order_items_controller.rb | 36 ---- app/controllers/orders_controller.rb | 90 -------- app/controllers/products_controller.rb | 46 ----- app/controllers/shop_controller.rb | 19 -- app/models/ability.rb | 25 --- app/models/account.rb | 23 --- app/models/account_type.rb | 13 -- app/models/member.rb | 35 +--- app/models/order.rb | 90 -------- app/models/order_item.rb | 12 -- app/models/product.rb | 15 -- app/views/account_types/_form.html.haml | 21 -- app/views/account_types/edit.html.haml | 7 - app/views/account_types/index.html.haml | 23 --- app/views/account_types/new.html.haml | 5 - app/views/account_types/show.html.haml | 17 -- app/views/accounts/_form.html.haml | 21 -- app/views/accounts/edit.html.haml | 7 - app/views/accounts/index.html.haml | 23 --- app/views/accounts/new.html.haml | 5 - app/views/accounts/show.html.haml | 15 -- app/views/admin/index.html.haml | 7 - app/views/admin/orders/_searchform.html.haml | 8 - app/views/admin/orders/index.html.haml | 3 - app/views/admin/orders/search.html.haml | 41 ---- app/views/layouts/_header.html.haml | 2 - app/views/members/_account.html.haml | 24 --- app/views/members/_roles.html.haml | 9 + app/views/members/show.html.haml | 4 +- app/views/orders/complete.html.haml | 45 ---- app/views/orders/index.html.haml | 44 ---- app/views/orders/show.html.haml | 84 -------- app/views/products/_form.html.haml | 32 --- app/views/products/edit.html.haml | 7 - app/views/products/index.html.haml | 29 --- app/views/products/new.html.haml | 5 - app/views/products/show.html.haml | 25 --- app/views/shared/_account_status.html.haml | 13 -- app/views/shop/index.html.haml | 83 -------- config/application.rb | 3 - config/locales/en.yml | 10 - config/routes.rb | 17 +- db/migrate/20180205000612_remove_shop.rb | 9 + db/schema.rb | 48 +---- db/seeds.rb | 50 ----- lib/tasks/growstuff.rake | 73 ------- .../account_types_controller_spec.rb | 31 --- spec/controllers/accounts_controller_spec.rb | 18 -- .../admin/orders_controller_spec.rb | 18 -- .../order_items_controller_spec.rb | 51 ----- spec/controllers/orders_controller_spec.rb | 53 ----- spec/controllers/products_controller_spec.rb | 17 -- spec/controllers/shop_controller_spec.rb | 36 ---- spec/factories/account_types.rb | 33 --- spec/factories/accounts.rb | 7 - spec/factories/order_items.rb | 10 - spec/factories/orders.rb | 14 -- spec/factories/products.rb | 15 -- spec/features/admin/account_types_spec.rb | 58 ------ spec/features/admin/products_spec.rb | 44 ---- spec/features/member_profile_spec.rb | 5 - spec/features/members/deletion_spec.rb | 11 - spec/models/ability_spec.rb | 195 ------------------ spec/models/account_spec.rb | 27 --- spec/models/account_type_spec.rb | 4 - spec/models/member_spec.rb | 92 --------- spec/models/order_item_spec.rb | 26 --- spec/models/order_spec.rb | 133 ------------ spec/models/product_spec.rb | 8 - spec/routing/account_types_routing_spec.rb | 33 --- spec/routing/order_items_routing_spec.rb | 33 --- spec/routing/orders_routing_spec.rb | 33 --- spec/routing/products_routing_spec.rb | 33 --- .../account_types/edit.html.haml_spec.rb | 21 -- .../account_types/index.html.haml_spec.rb | 14 -- .../views/account_types/new.html.haml_spec.rb | 21 -- .../account_types/show.html.haml_spec.rb | 18 -- spec/views/accounts/edit.html.haml_spec.rb | 18 -- spec/views/accounts/index.html.haml_spec.rb | 15 -- spec/views/accounts/new.html.haml_spec.rb | 18 -- spec/views/accounts/show.html.haml_spec.rb | 16 -- spec/views/admin/index_spec.rb | 2 - spec/views/admin/orders/index_spec.rb | 20 -- spec/views/orders/index.html.haml_spec.rb | 23 --- spec/views/orders/show.html.haml_spec.rb | 69 ------- spec/views/products/edit.html.haml_spec.rb | 22 -- spec/views/products/index.html.haml_spec.rb | 16 -- spec/views/products/new.html.haml_spec.rb | 24 --- spec/views/products/show.html.haml_spec.rb | 15 -- spec/views/shop/index_spec.rb | 82 -------- 94 files changed, 22 insertions(+), 2762 deletions(-) delete mode 100644 app/controllers/account_types_controller.rb delete mode 100644 app/controllers/accounts_controller.rb delete mode 100644 app/controllers/admin/orders_controller.rb delete mode 100644 app/controllers/order_items_controller.rb delete mode 100644 app/controllers/orders_controller.rb delete mode 100644 app/controllers/products_controller.rb delete mode 100644 app/controllers/shop_controller.rb delete mode 100644 app/models/account.rb delete mode 100644 app/models/account_type.rb delete mode 100644 app/models/order.rb delete mode 100644 app/models/order_item.rb delete mode 100644 app/models/product.rb delete mode 100644 app/views/account_types/_form.html.haml delete mode 100644 app/views/account_types/edit.html.haml delete mode 100644 app/views/account_types/index.html.haml delete mode 100644 app/views/account_types/new.html.haml delete mode 100644 app/views/account_types/show.html.haml delete mode 100644 app/views/accounts/_form.html.haml delete mode 100644 app/views/accounts/edit.html.haml delete mode 100644 app/views/accounts/index.html.haml delete mode 100644 app/views/accounts/new.html.haml delete mode 100644 app/views/accounts/show.html.haml delete mode 100644 app/views/admin/orders/_searchform.html.haml delete mode 100644 app/views/admin/orders/index.html.haml delete mode 100644 app/views/admin/orders/search.html.haml delete mode 100644 app/views/members/_account.html.haml create mode 100644 app/views/members/_roles.html.haml delete mode 100644 app/views/orders/complete.html.haml delete mode 100644 app/views/orders/index.html.haml delete mode 100644 app/views/orders/show.html.haml delete mode 100644 app/views/products/_form.html.haml delete mode 100644 app/views/products/edit.html.haml delete mode 100644 app/views/products/index.html.haml delete mode 100644 app/views/products/new.html.haml delete mode 100644 app/views/products/show.html.haml delete mode 100644 app/views/shared/_account_status.html.haml delete mode 100644 app/views/shop/index.html.haml create mode 100644 db/migrate/20180205000612_remove_shop.rb delete mode 100644 spec/controllers/account_types_controller_spec.rb delete mode 100644 spec/controllers/accounts_controller_spec.rb delete mode 100644 spec/controllers/admin/orders_controller_spec.rb delete mode 100644 spec/controllers/order_items_controller_spec.rb delete mode 100644 spec/controllers/orders_controller_spec.rb delete mode 100644 spec/controllers/products_controller_spec.rb delete mode 100644 spec/controllers/shop_controller_spec.rb delete mode 100644 spec/factories/account_types.rb delete mode 100644 spec/factories/accounts.rb delete mode 100644 spec/factories/order_items.rb delete mode 100644 spec/factories/orders.rb delete mode 100644 spec/factories/products.rb delete mode 100644 spec/features/admin/account_types_spec.rb delete mode 100644 spec/features/admin/products_spec.rb delete mode 100644 spec/models/account_spec.rb delete mode 100644 spec/models/account_type_spec.rb delete mode 100644 spec/models/order_item_spec.rb delete mode 100644 spec/models/order_spec.rb delete mode 100644 spec/models/product_spec.rb delete mode 100644 spec/routing/account_types_routing_spec.rb delete mode 100644 spec/routing/order_items_routing_spec.rb delete mode 100644 spec/routing/orders_routing_spec.rb delete mode 100644 spec/routing/products_routing_spec.rb delete mode 100644 spec/views/account_types/edit.html.haml_spec.rb delete mode 100644 spec/views/account_types/index.html.haml_spec.rb delete mode 100644 spec/views/account_types/new.html.haml_spec.rb delete mode 100644 spec/views/account_types/show.html.haml_spec.rb delete mode 100644 spec/views/accounts/edit.html.haml_spec.rb delete mode 100644 spec/views/accounts/index.html.haml_spec.rb delete mode 100644 spec/views/accounts/new.html.haml_spec.rb delete mode 100644 spec/views/accounts/show.html.haml_spec.rb delete mode 100644 spec/views/admin/orders/index_spec.rb delete mode 100644 spec/views/orders/index.html.haml_spec.rb delete mode 100644 spec/views/orders/show.html.haml_spec.rb delete mode 100644 spec/views/products/edit.html.haml_spec.rb delete mode 100644 spec/views/products/index.html.haml_spec.rb delete mode 100644 spec/views/products/new.html.haml_spec.rb delete mode 100644 spec/views/products/show.html.haml_spec.rb delete mode 100644 spec/views/shop/index_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e0d899c7..9c3ccad34 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -39,7 +39,6 @@ Rails/SkipsModelValidations: # SupportedStyles: strict, flexible Rails/TimeZone: Exclude: - - 'spec/controllers/accounts_controller_spec.rb' - 'spec/factories/member.rb' - 'spec/factories/post.rb' - 'spec/models/post_spec.rb' @@ -60,7 +59,6 @@ Style/AsciiComments: # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: - - 'app/controllers/admin/orders_controller.rb' - 'lib/actions/oauth_signup_action.rb' - 'lib/haml/filters/escaped_markdown.rb' diff --git a/app/controllers/account_types_controller.rb b/app/controllers/account_types_controller.rb deleted file mode 100644 index f86892346..000000000 --- a/app/controllers/account_types_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -class AccountTypesController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /account_types - def index - @account_types = AccountType.all.order(:name) - respond_with(@account_types) - end - - # GET /account_types/1 - def show - respond_with(@account_types) - end - - # GET /account_types/new - def new - @account_type = AccountType.new - respond_with(@account_type) - end - - # GET /account_types/1/edit - def edit - respond_with(@account_type) - end - - # POST /account_types - def create - @account_type = AccountType.new(account_type_params) - flash[:notice] = I18n.t('account_types.created') if @account_type.save - respond_with(@account_type) - end - - # PUT /account_types/1 - def update - flash[:notice] = I18n.t('account_types.updated') if @account_type.update(account_type_params) - respond_with(@account_type) - end - - # DELETE /account_types/1 - def destroy - @account_type.destroy - flash[:notice] = I18n.t('account_types.deleted') - respond_with(@account_type) - end - - private - - def account_type_params - params.require(:account_type).permit(:is_paid, :is_permanent_paid, :name) - end -end diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb deleted file mode 100644 index 040092aba..000000000 --- a/app/controllers/accounts_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class AccountsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /accounts - def index - @accounts = Account.all.order(created_at: :desc) - respond_with(@accounts) - end - - # GET /accounts/1 - def show - respond_with(@account) - end - - # GET /accounts/1/edit - def edit; end - - # PUT /accounts/1 - def update - flash[:notice] = I18n.t('account.update') if @account.update(params[:account]) - respond_with(@account) - end - - private - - def account_params - params.require(:account).permit(:account_type_id, :member_id, :paid_until) - end -end diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb deleted file mode 100644 index d4f727ec0..000000000 --- a/app/controllers/admin/orders_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Admin - class OrdersController < ApplicationController - def index - authorize! :manage, :all - respond_to do |format| - format.html # index.html.haml - end - end - - def search - authorize! :manage, :all - @orders = Order.search(by: params[:search_by], for: params[:search_text]) - - if @orders.empty? - flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}" - end - - respond_to do |format| - format.html # index.html.haml - end - end - end -end diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb deleted file mode 100644 index 326cff21f..000000000 --- a/app/controllers/order_items_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -class OrderItemsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - # POST /order_items - def create - if params[:order_item][:price] - params[:order_item][:price] = params[:order_item][:price].to_f * 100 # convert to cents - end - - @order_item = OrderItem.new(order_item_params) - @order_item.order = current_member.current_order || Order.create(member_id: current_member.id) - - if @order_item.save - redirect_to @order_item.order, notice: 'Added item to your order.' - else - redirect_to shop_path, alert: errors - end - end - - private - - def errors - if @order_item.errors.empty? - "There was a problem with your order." - else - @order_item.errors.full_messages.to_sentence - end - end - - def order_item_params - params.require(:order_item).permit(:order_id, :price, :product_id, :quantity) - end -end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb deleted file mode 100644 index 3bc9fe45c..000000000 --- a/app/controllers/orders_controller.rb +++ /dev/null @@ -1,90 +0,0 @@ -class OrdersController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - - # GET /orders - def index - @orders = Order.by_member(current_member) - - respond_to do |format| - format.html # index.html.erb - end - end - - # GET /orders/1 - def show - respond_to do |format| - format.html # show.html.erb - end - end - - # GET /orders/new - def new - @order = Order.new - - respond_to do |format| - format.html # new.html.erb - end - end - - # checkout with PayPal - def checkout - respond_to do |format| - if @order.update_attributes(referral_code: params[:referral_code]) - response = EXPRESS_GATEWAY.setup_purchase( - @order.total, - items: @order.activemerchant_items, - currency: Growstuff::Application.config.currency, - no_shipping: true, - ip: request.remote_ip, - return_url: complete_order_url, - cancel_return_url: shop_url - ) - format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } - else - format.html { render action: "show" } - end - end - end - - def complete - if params[:token] && params['PayerID'] - purchase = EXPRESS_GATEWAY.purchase( - @order.total, - currency: Growstuff::Application.config.currency, - ip: request.remote_ip, - payer_id: params['PayerID'], - token: params[:token] - ) - if purchase.success? - @order.completed_at = Time.zone.now - @order.record_paypal_details(params[:token]) - else - flash[:alert] = "Could not complete your order. Please notify support." - end - else - flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." - end - - @order.update_account # apply paid account benefits, etc. - - respond_to do |format| - format.html # new.html.erb - end - end - - def cancel - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was cancelled.' } - end - end - - # DELETE /orders/1 - def destroy - @order.destroy - - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was deleted.' } - end - end -end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb deleted file mode 100644 index 8e0a1fb08..000000000 --- a/app/controllers/products_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class ProductsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - def index - @products = Product.all.order(:name) - respond_with @products - end - - def show - respond_with @product - end - - def new - @product = Product.new - respond_with @product - end - - def edit - respond_with @product - end - - def create - @product = Product.create(product_params) - respond_with @product - end - - def update - @product.update(product_params) - respond_with @product - end - - def destroy - @product.destroy - respond_with @product - end - - private - - def product_params - params.require(:product).permit(:description, :min_price, :recommended_price, :name, - :account_type_id, :paid_months) - end -end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb deleted file mode 100644 index 964511e50..000000000 --- a/app/controllers/shop_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ShopController < ApplicationController - respond_to :html - def index - @products = Product.all - @order_item = OrderItem.new - - # this is (hopefully) part of a short-term hack to prevent people from - # ordering multiple subscriptions, which would be very confusing to deal - # with. We check whether they have an order already in progress, and if - # so, point that out to them and encourage them to checkout, rather than - # letting them add more stuff to their order. - - @order = nil - @most_recent_item = nil - return unless current_member - @order = current_member.current_order - @most_recent_item = @order.order_items.first if @order - end -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 283bf45cc..89a304257 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,14 +24,9 @@ class Ability # except these, which don't make sense if you're not logged in cannot :read, Notification cannot :read, Authentication - cannot :read, Order - cannot :read, OrderItem # and nobody should be able to view this except admins cannot :read, Role - cannot :read, Product - cannot :read, Account - cannot :read, AccountType # nobody should be able to view unapproved crops unless they # are wranglers or admins @@ -120,20 +115,6 @@ class Ability can :update, Seed, owner_id: member.id can :destroy, Seed, owner_id: member.id - # orders/shop/etc - can :create, Order - can :read, Order, member_id: member.id - can :complete, Order, member_id: member.id, completed_at: nil - can :checkout, Order, member_id: member.id, completed_at: nil - can :cancel, Order, member_id: member.id, completed_at: nil - can :destroy, Order, member_id: member.id, completed_at: nil - - can :create, OrderItem - # for now, let's not let people mess with individual order items - cannot :read, OrderItem, order: { member_id: member.id } - cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil } - cannot :destroy, OrderItem, order: { member_id: member.id, completed_at: nil } - # following/unfollowing permissions can :create, Follow cannot :create, Follow, followed_id: member.id # can't follow yourself @@ -148,12 +129,6 @@ class Ability can :read, :all can :manage, :all - # can't change order history, because it's *history* - cannot :create, Order - cannot :complete, Order - cannot :destroy, Order - cannot :manage, OrderItem - # can't delete plant parts if they have harvests associated with them cannot :destroy, PlantPart can :destroy, PlantPart do |pp| diff --git a/app/models/account.rb b/app/models/account.rb deleted file mode 100644 index 646e9db78..000000000 --- a/app/models/account.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Account < ActiveRecord::Base - belongs_to :member - belongs_to :account_type - - validates :member_id, uniqueness: { - message: 'already has account details associated with it' - } - - before_create do |account| - unless account.account_type - account.account_type = AccountType.find_or_create_by(name: - Growstuff::Application.config.default_account_type) - end - end - - def paid_until_string - if account_type.is_permanent_paid - "forever" - elsif account_type.is_paid - paid_until.to_s - end - end -end diff --git a/app/models/account_type.rb b/app/models/account_type.rb deleted file mode 100644 index 06416751a..000000000 --- a/app/models/account_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AccountType < ActiveRecord::Base - # - # Relationships - has_many :products - - # - # Validations - validates :name, presence: true, uniqueness: true - - def to_s - name - end -end diff --git a/app/models/member.rb b/app/models/member.rb index 9828a005c..e7601f43d 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -7,7 +7,7 @@ class Member < ActiveRecord::Base friendly_id :login_name, use: %i(slugged finders) # - # Relationshops + # Relationships has_many :posts, foreign_key: 'author_id' has_many :comments, foreign_key: 'author_id' has_many :forums, foreign_key: 'owner_id' @@ -19,9 +19,6 @@ class Member < ActiveRecord::Base has_many :notifications, foreign_key: 'recipient_id' has_many :sent_notifications, foreign_key: 'sender_id' has_many :authentications - has_many :orders - has_one :account - has_one :account_type, through: :account has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy @@ -79,11 +76,9 @@ class Member < ActiveRecord::Base after_save :update_newsletter_subscription # Give each new member a default garden - # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } - after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address def self.find_first_by_auth_conditions(warden_conditions) @@ -101,34 +96,6 @@ class Member < ActiveRecord::Base roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end - def current_order - orders.find_by(completed_at: nil) - end - - # when purchasing a product that gives you a paid account, this method - # does all the messing around to actually make sure the account is - # updated correctly -- account type, paid until, etc. Usually this is - # called by order.update_account, which loops through all order items - # and does this for each one. - def update_account_after_purchase(product) - account.account_type = product.account_type if product.account_type - if product.paid_months - start_date = account.paid_until || Time.zone.now - account.paid_until = start_date + product.paid_months.months - end - account.save - end - - def paid? - if account.account_type.is_permanent_paid - true - elsif account.account_type.is_paid && account.paid_until >= Time.zone.now - true - else - false - end - end - def auth(provider) authentications.find_by(provider: provider) end diff --git a/app/models/order.rb b/app/models/order.rb deleted file mode 100644 index 53a309c35..000000000 --- a/app/models/order.rb +++ /dev/null @@ -1,90 +0,0 @@ -class Order < ActiveRecord::Base - # - # Relationships - belongs_to :member, with_deleted: true - has_many :order_items, dependent: :destroy - - # - # Validations - validates :referral_code, format: { - with: /\A[a-zA-Z0-9 ]*\z/, - message: "may only include letters and numbers" - } - - # - # Teiggers - before_save :standardize_referral_code - - # - # Scopes - scope :by_member, ->(member) { where(member: member) } - - # total price of an order - def total - sum = 0 - order_items.each do |i| - subtotal = i.price * i.quantity - sum += subtotal - end - sum - end - - # return items in the format ActiveMerchant/PayPal want them - def activemerchant_items - items = [] - order_items.each do |i| - items.push(name: i.product.name, - quantity: i.quantity, - amount: i.price) - end - items - end - - # record the paypal details for reference - def record_paypal_details(token) - self.paypal_express_token = token - details = EXPRESS_GATEWAY.details_for(token) - self.paypal_express_payer_id = details.payer_id - save - end - - # when an order is completed, we update the member's account to mark - # them as paid, or whatever, based on what products they ordered - def update_account - order_items.each do |i| - member.update_account_after_purchase(i.product) - end - end - - # removes whitespace and forces to uppercase (we're somewhat liberal - # in what we accept, but we clean it up anyway.) - def standardize_referral_code - self.referral_code = referral_code.upcase.gsub(/\s/, '') if referral_code - end - - # search orders (used by admin/orders) - # usage: Order.search({ :by => 'member', :for => 'Skud' }) - # can search by: member, order_id, paypal_token, paypal_payer_id, - def self.search(args = {}) - if args[:for] - case args[:by] - when "member" - member = Member.with_deleted.find_by(login_name: args[:for]) - return member.orders if member - when "order_id" - order = Order.find_by(id: args[:for]) - return [order] if order - when "paypal_token" - order = Order.find_by(paypal_express_token: args[:for]) - return [order] if order - when "paypal_payer_id" - order = Order.find_by(paypal_express_payer_id: args[:for]) - return [order] if order - when "referral_code" - # coerce to uppercase - return Order.where(referral_code: args[:for].upcase) - end - end - [] - end -end diff --git a/app/models/order_item.rb b/app/models/order_item.rb deleted file mode 100644 index 380fbff58..000000000 --- a/app/models/order_item.rb +++ /dev/null @@ -1,12 +0,0 @@ -class OrderItem < ActiveRecord::Base - belongs_to :order - belongs_to :product - - validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: "may only have one item." } - - def price_must_be_greater_than_minimum - @product = Product.find(product_id) - errors.add(:price, "must be greater than the product's minimum value") if price < @product.min_price - end -end diff --git a/app/models/product.rb b/app/models/product.rb deleted file mode 100644 index 01b5a8902..000000000 --- a/app/models/product.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Product < ActiveRecord::Base - # - # Relationships - belongs_to :account_type - has_and_belongs_to_many :orders # rubocop:disable Rails/HasAndBelongsToMany - - # - # Validations - validates :paid_months, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :min_price, presence: true - - def to_s - name - end -end diff --git a/app/views/account_types/_form.html.haml b/app/views/account_types/_form.html.haml deleted file mode 100644 index 5bfbb539a..000000000 --- a/app/views/account_types/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account_type do |f| - - if @account_type.errors.any? - #error_explanation - %h2 - = pluralize(@account_type.errors.size, "error") - prohibited this account_type from being saved: - %ul - - @account_type.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name - .field - = f.label :is_paid - = f.check_box :is_paid - .field - = f.label :is_permanent_paid - = f.check_box :is_permanent_paid - .actions - = f.submit 'Save' diff --git a/app/views/account_types/edit.html.haml b/app/views/account_types/edit.html.haml deleted file mode 100644 index c994c4ff1..000000000 --- a/app/views/account_types/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account type" - -= render 'form' - -= link_to 'Show', @account_type -\| -= link_to 'Back', account_types_path diff --git a/app/views/account_types/index.html.haml b/app/views/account_types/index.html.haml deleted file mode 100644 index 6af6d129d..000000000 --- a/app/views/account_types/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing account types" - -%table - %tr - %th Name - %th Is paid - %th Is permanent paid - %th - %th - %th - - - @account_types.each do |account_type| - %tr - %td= account_type.name - %td= account_type.is_paid - %td= account_type.is_permanent_paid - %td= link_to 'Show', account_type - %td= link_to 'Edit', edit_account_type_path(account_type) - %td= link_to 'Destroy', account_type, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account type', new_account_type_path diff --git a/app/views/account_types/new.html.haml b/app/views/account_types/new.html.haml deleted file mode 100644 index 92d309715..000000000 --- a/app/views/account_types/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account type" - -= render 'form' - -= link_to 'Back', account_types_path diff --git a/app/views/account_types/show.html.haml b/app/views/account_types/show.html.haml deleted file mode 100644 index a3f7f690b..000000000 --- a/app/views/account_types/show.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @account_type.name -%p - %b Is paid: - = @account_type.is_paid -%p - %b Is permanent paid: - = @account_type.is_permanent_paid - -= link_to 'Edit', edit_account_type_path(@account_type) -\| -= link_to 'Delete', @account_type, method: :delete, data: { confirm: 'Are you sure?' } -\| -= link_to 'Back', account_types_path diff --git a/app/views/accounts/_form.html.haml b/app/views/accounts/_form.html.haml deleted file mode 100644 index 410b717fa..000000000 --- a/app/views/accounts/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account do |f| - - if @account.errors.any? - #error_explanation - %h2 - = pluralize(@account.errors.size, "error") - prohibited this account from being saved: - %ul - - @account.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :member_id - = f.number_field :member_id - .field - = f.label :account_type - = f.text_field :account_type - .field - = f.label :paid_until - = f.datetime_select :paid_until - .actions - = f.submit 'Save' diff --git a/app/views/accounts/edit.html.haml b/app/views/accounts/edit.html.haml deleted file mode 100644 index ef8d08801..000000000 --- a/app/views/accounts/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account" - -= render 'form' - -= link_to 'Show', @account -\| -= link_to 'Back', accounts_path diff --git a/app/views/accounts/index.html.haml b/app/views/accounts/index.html.haml deleted file mode 100644 index 8d929dd0f..000000000 --- a/app/views/accounts/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing accounts" - -%table - %tr - %th Member - %th Account type - %th Paid until - %th - %th - %th - - - @accounts.each do |account| - %tr - %td= account.member_id - %td= account.account_type - %td= account.paid_until - %td= link_to 'Show', account - %td= link_to 'Edit', edit_account_path(account) - %td= link_to 'Destroy', account, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account detail', new_account_path diff --git a/app/views/accounts/new.html.haml b/app/views/accounts/new.html.haml deleted file mode 100644 index 9430cc2ed..000000000 --- a/app/views/accounts/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account" - -= render 'form' - -= link_to 'Back', accounts_path diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml deleted file mode 100644 index 5c5288674..000000000 --- a/app/views/accounts/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -%p#notice= notice - -%p - %b Member: - = @account.member_id -%p - %b Account type: - = @account.account_type.name -%p - %b Paid until: - = @account.paid_until - -= link_to 'Edit', edit_account_path(@account) -\| -= link_to 'Back', accounts_path diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index 294e16199..e7b164280 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -6,8 +6,6 @@ .col-md-4 %h2 Site admin %ul#site_admin - %li= link_to "Account types", account_types_path - %li= link_to "Products", products_path %li= link_to "Roles", roles_path %li= link_to "Forums", forums_path %li= link_to "CMS", comfy_admin_cms_path @@ -22,8 +20,3 @@ %ul %li= link_to "Newsletter subscribers", admin_newsletter_path %li= link_to "Members", admin_members_path - -.row - .col-md-12 - %h2 Orders - = render "admin/orders/searchform" diff --git a/app/views/admin/orders/_searchform.html.haml b/app/views/admin/orders/_searchform.html.haml deleted file mode 100644 index e0a4dc22c..000000000 --- a/app/views/admin/orders/_searchform.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= form_tag(url_for(controller: 'admin/orders', action: 'search'), method: :get, class: 'form-inline') do - = label_tag :distance, "Search orders:", class: 'control-label' - = text_field_tag :search_text - = select_tag :search_by, - options_for_select('Member': 'member', 'Referral code': 'referral_code', - 'Order ID': 'order_id', 'Paypal Token': 'paypal_token', - 'Paypal Payer ID': 'paypal_payer_id') - = submit_tag "Search", class: 'btn btn-primary' diff --git a/app/views/admin/orders/index.html.haml b/app/views/admin/orders/index.html.haml deleted file mode 100644 index e5f67f6c3..000000000 --- a/app/views/admin/orders/index.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :title, 'Admin Orders' - -= render "admin/orders/searchform" diff --git a/app/views/admin/orders/search.html.haml b/app/views/admin/orders/search.html.haml deleted file mode 100644 index 23c93d01a..000000000 --- a/app/views/admin/orders/search.html.haml +++ /dev/null @@ -1,41 +0,0 @@ -- content_for :title, 'Search Orders' - -= render "admin/orders/searchform" - -- unless @orders.empty? - %h2 - Found - = pluralize(@orders.size, "result") - - %table.table.table-striped - %tr - %th Member - %th Order number - %th Date completed - %th Referral code - %th Items - %th - - - @orders.each do |order| - %tr - %td - = link_to order.member.login_name, order.member - = "(deleted)" if order.member.deleted_at - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - = order.referral_code - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 3eb0d8ca0..d2b8fd01c 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -47,7 +47,6 @@ %li= link_to t('.browse_members'), members_path %li= link_to t('.posts'), posts_path %li= link_to t('.forums'), forums_path - %li= link_to t('.support_growstuff'), shop_path - if member_signed_in? %li.dropdown< @@ -64,7 +63,6 @@ %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li= link_to t('.account'), orders_path %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_account.html.haml b/app/views/members/_account.html.haml deleted file mode 100644 index cda792ace..000000000 --- a/app/views/members/_account.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%h3 Account details - -%p - %strong Member since: - = member.created_at.to_s(:date) - -%p - %strong Account type: - = member.account_type - account - -%p - %strong Last Login: - = member.last_sign_in_at - -%p - %strong Member Roles: - %br - - if member.role? :admin - Administrator - - if member.role? :crop_wrangler - Crop Wrangler - - else - Member diff --git a/app/views/members/_roles.html.haml b/app/views/members/_roles.html.haml new file mode 100644 index 000000000..cbfd0b576 --- /dev/null +++ b/app/views/members/_roles.html.haml @@ -0,0 +1,9 @@ +%p + %strong Member Roles: + %br + - if member.role? :admin + Administrator + - if member.role? :crop_wrangler + Crop Wrangler + - unless (member.role?(:admin) || member.role?(:crop_wrangler)) + Member diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index f0214a52f..478574b3b 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -10,8 +10,6 @@ - content_for :buttonbar do - if can? :update, @member = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default' - - if @member == current_member && !@member.paid? - = link_to "Upgrade account", shop_path, class: 'btn btn-default' - if can?(:create, Notification) && current_member != @member = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' @@ -33,7 +31,7 @@ = render partial: "gardens", locals: { member: @member, gardens: @gardens } .col-md-3 = render partial: "avatar", locals: { member: @member } - = render partial: "account", locals: { member: @member } + = render partial: "roles", locals: { member: @member } = render partial: "stats", locals: { member: @member } = render partial: "contact", locals: { member: @member, twitter_auth: @twitter_auth, diff --git a/app/views/orders/complete.html.haml b/app/views/orders/complete.html.haml deleted file mode 100644 index e2f4b97ad..000000000 --- a/app/views/orders/complete.html.haml +++ /dev/null @@ -1,45 +0,0 @@ -- content_for :title, "Completed order" - -%p Thank you for your order. - -%p - %strong Completed at: - = @order.completed_at - -%p - %strong Order number: - = @order.id - -= render "shared/account_status" - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - total = 0 - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - - total += subtotal - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(total) - -%p - = link_to "View other orders/order history", orders_path diff --git a/app/views/orders/index.html.haml b/app/views/orders/index.html.haml deleted file mode 100644 index b4741c44e..000000000 --- a/app/views/orders/index.html.haml +++ /dev/null @@ -1,44 +0,0 @@ -- content_for :title, "Your Account" - -= render "shared/account_status" - - -%h2 Orders - - -- if current_member.orders.present? - - %p - Your order history shows what you have bought via our - = succeed "." do - = link_to "shop", shop_path - - %table.table.table-striped - %tr - %th Order number - %th Date completed - %th Items - %th - - @orders.each do |order| - %tr - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' -- else - %p - You have not made any orders. You can place an order via our - = succeed "." do - = link_to "shop", shop_path diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml deleted file mode 100644 index 0998407f9..000000000 --- a/app/views/orders/show.html.haml +++ /dev/null @@ -1,84 +0,0 @@ -- content_for :title, @order.completed_at ? "Order details (##{@order.id})" : "Current order" - -%p - %strong Order number: - = @order.id - -%p - %strong Ordered by: - = link_to @order.member, @order.member - -%p - %strong Date begun: - = @order.created_at.to_s - -- if @order.completed_at - %p - %strong Date completed: - = @order.completed_at.to_s - -- if @order.referral_code - %p - %strong Referral code: - = @order.referral_code - -- if current_member.role? :admin - %p - %strong Paypal Express token: - = @order.paypal_express_token - %p - %strong Paypal Express payer ID: - = @order.paypal_express_payer_id - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(@order.total) - = forex_link(@order.total) - -- if @order.errors.any? - .alert - #error_explanation - %h3 - = pluralize(@order.errors.size, "error") - stopped you from checking out: - %ul - - @order.errors.full_messages.each do |msg| - %li= msg - -- if can?(:complete, @order) || can?(:destroy, @order) - = form_tag(checkout_order_path(@order), method: :get, class: 'form-inline') do - %p - - if can? :complete, @order - = label_tag :referral_code, "Do you have a referral code?" - = text_field_tag :referral_code, @order.referral_code, class: 'input-medium' - = submit_tag "Checkout with PayPal", class: 'btn btn-primary' - - if can? :destroy, @order - = link_to 'Delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default' - = link_to "View other orders/order history", orders_path, class: 'btn btn-default' - -%p diff --git a/app/views/products/_form.html.haml b/app/views/products/_form.html.haml deleted file mode 100644 index a3aa8a2f0..000000000 --- a/app/views/products/_form.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= form_for @product do |f| - - if @product.errors.any? - #error_explanation - %h2 - = pluralize(@product.errors.size, "error") - prohibited this product from being saved: - %ul - - @product.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name, class: 'form-control' - .field - = f.label :description - = f.text_area :description, class: 'form-control' - .field - = f.label :min_price, "Minimum price (in cents)" - = f.text_field :min_price - .field - = f.label :recommended_price, "Recommended price (in cents)" - = f.text_field :recommended_price - .field - = f.label :account_type - = collection_select(:product, :account_type_id, AccountType.all, :id, - :name, selected: @product.account_type_id) - .field - = f.label :paid_months - = f.text_field :paid_months - .form-group - .actions - = f.submit 'Save' diff --git a/app/views/products/edit.html.haml b/app/views/products/edit.html.haml deleted file mode 100644 index 84ebcb870..000000000 --- a/app/views/products/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing product" - -= render 'form' - -= link_to 'Show', @product -\| -= link_to 'Back', products_path diff --git a/app/views/products/index.html.haml b/app/views/products/index.html.haml deleted file mode 100644 index 4945d130e..000000000 --- a/app/views/products/index.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -- content_for :title, "Listing products" - -%table - %tr - %th Name - %th Description - %th Min price - %th Recommended price - %th Account type - %th Paid months - %th - %th - %th - - - @products.each do |product| - %tr - %td= product.name - %td= product.description - %td= product.min_price - %td= product.recommended_price - %td= product.account_type ? product.account_type.name : "" - %td= product.paid_months - %td= link_to 'Show', product - %td= link_to 'Edit', edit_product_path(product) - %td= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Product', new_product_path diff --git a/app/views/products/new.html.haml b/app/views/products/new.html.haml deleted file mode 100644 index 57b944d9a..000000000 --- a/app/views/products/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New product" - -= render 'form' - -= link_to 'Back', products_path diff --git a/app/views/products/show.html.haml b/app/views/products/show.html.haml deleted file mode 100644 index 61b35519f..000000000 --- a/app/views/products/show.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @product.name -%p - %b Description: - :growstuff_markdown - #{strip_tags(@product.description)} -%p - %b Min price: - = @product.min_price -%p - %b Recommended price: - = @product.recommended_price -%p - %b Account type: - = @product.account_type.name -%p - %b Paid months: - = @product.paid_months - -= link_to 'Edit', edit_product_path(@product) -\| -= link_to 'Back', products_path diff --git a/app/views/shared/_account_status.html.haml b/app/views/shared/_account_status.html.haml deleted file mode 100644 index a39870956..000000000 --- a/app/views/shared/_account_status.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%h2 Your current account status - -%p - %strong Account type: - = current_member.account_type.name - -- if current_member.account.paid_until_string - %p - %strong Paid until: - = current_member.account.paid_until_string - -- unless current_member.paid? - = link_to "Upgrade and support #{ENV['GROWSTUFF_SITE_NAME']}", shop_path, class: 'btn btn-primary' diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml deleted file mode 100644 index 6266050f0..000000000 --- a/app/views/shop/index.html.haml +++ /dev/null @@ -1,83 +0,0 @@ -- content_for :title, t('.title') - -%p - Growstuff relies on your support to build and run this open source - platform for food growers. We do not have outside investment, and do - not accept ads. Instead, we offer paid memberships, which give you - access to premium features, and ensure that we focus our efforts on - keeping you, our members, happy. - -%p - We are currently developing a number of advanced features for paid - members. We will announce our progress on these in our - = link_to "Feedback and Support forum", "http://www.growstuff.org/forums/growstuff-feedback-support" - as well as via other channels. - -%p - All our accounts are priced on a sliding scale. You can choose how - much you want to pay. Remember, your subscription supports an open - source, open data platform supporting home food growers and promoting - sustainable food systems! - -- if current_member && current_member.paid? - %h2 Thank you for supporting Growstuff - - %p You currently have a paid membership, and can't buy another one at this time. - - = render "shared/account_status" - -- elsif @order && !@order.order_items.empty? - %h2 Your current order - - %p - You currently have the following item in your cart: - %strong - = @most_recent_item.product - @ - = price_with_currency(@most_recent_item.price) - - %p - = link_to "View order and checkout", order_path(@order) - or - = succeed "." do - = link_to 'delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' } - -- else - - @products.each do |p| - %h2= p.name - - %div - :growstuff_markdown - #{ strip_tags p.description } - - %p - Pay what you want, starting at - = succeed "." do - = price_with_currency(p.min_price) - = forex_link(p.min_price) - - if p.recommended_price - Recommended price: - = succeed "." do - = price_with_currency(p.recommended_price) - = forex_link(p.recommended_price) - - %div - - if can? :create, Order - - = form_for @order_item do |f| - .field - = f.text_field :price, value: price_in_dollars(p.recommended_price || p.min_price) - .field - = f.hidden_field :product_id, value: p.id - .field - = f.hidden_field :quantity, value: 1 - .actions - = f.submit 'Buy', class: 'btn btn-primary' - - - else - Please - = link_to "sign in", new_member_session_path - or - = link_to "sign up", new_member_registration_path - to purchase. diff --git a/config/application.rb b/config/application.rb index 5280dce7e..ae8d6e95f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,9 +44,6 @@ module Growstuff # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" - # Configure a default account type - config.default_account_type = "Free" - # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] diff --git a/config/locales/en.yml b/config/locales/en.yml index d2848cecd..d5d3364a6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,11 +1,5 @@ --- en: - account: - update: Account detail was successfully updated. - account_types: - created: Account type was successfully created. - deleted: Account type was successfully deleted. - updated: Account type was successfully updated. activerecord: models: comment: @@ -99,7 +93,6 @@ en: open: ad_free_linktext: ad-free api_docs_linktext: API documentation - buy_account_linktext: buying a paid account creative_commons_linktext: Creative Commons license get_involved_body_html: > We believe in collaboration, and work closely with our members and the wider food-growing community. @@ -213,9 +206,6 @@ en: default: Everyone's seeds owner_seeds: "%{owner} seeds" string: "%{crop} seeds belonging to %{owner}" - shop: - index: - title: Shop unauthorized: create: all: Please sign in or sign up to create a %{subject}. diff --git a/config/routes.rb b/config/routes.rb index f1588fa17..777536e38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,17 +72,6 @@ Growstuff::Application.routes.draw do get '/places/search' => 'places#search', as: 'search_places' get '/places/:place' => 'places#show', as: 'place' - # everything for paid accounts etc - resources :account_types - resources :accounts - resources :orders - get 'orders/:id/checkout' => 'orders#checkout', as: 'checkout_order' - get 'orders/:id/complete' => 'orders#complete', as: 'complete_order' - get 'orders/:id/cancel' => 'orders#cancel', as: 'cancel_order' - - resources :order_items - resources :products - resources :likes, only: %i(create destroy) get "home/index" @@ -91,15 +80,11 @@ Growstuff::Application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - get '/shop' => 'shop#index' - get '/shop/:action' => 'shop#:action' - comfy_route :cms_admin, path: '/admin/cms' namespace :admin do resources :members end - get '/admin/orders' => 'admin/orders#index' - get '/admin/orders/:action' => 'admin/orders#:action' + get '/admin' => 'admin#index' get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter get '/admin/:action' => 'admin#:action' diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb new file mode 100644 index 000000000..fa0fc8793 --- /dev/null +++ b/db/migrate/20180205000612_remove_shop.rb @@ -0,0 +1,9 @@ +class RemoveShop < ActiveRecord::Migration + def up + drop_table :order_items + drop_table :orders + drop_table :products + drop_table :account_types + drop_table :accounts + end +end diff --git a/db/schema.rb b/db/schema.rb index be74dabfc..c38e122e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,27 +11,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180118112809) do +ActiveRecord::Schema.define(version: 20180205000612) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "account_types", force: :cascade do |t| - t.string "name", null: false - t.boolean "is_paid" - t.boolean "is_permanent_paid" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "accounts", force: :cascade do |t| - t.integer "member_id", null: false - t.integer "account_type_id" - t.datetime "paid_until" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "alternate_names", force: :cascade do |t| t.string "name", null: false t.integer "crop_id", null: false @@ -359,25 +343,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do t.datetime "updated_at" end - create_table "order_items", force: :cascade do |t| - t.integer "order_id" - t.integer "product_id" - t.integer "price" - t.integer "quantity" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "orders", force: :cascade do |t| - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "completed_at" - t.integer "member_id" - t.string "paypal_express_token" - t.string "paypal_express_payer_id" - t.string "referral_code" - end - create_table "orders_products", id: false, force: :cascade do |t| t.integer "order_id" t.integer "product_id" @@ -461,17 +426,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do add_index "posts", ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id", using: :btree add_index "posts", ["slug"], name: "index_posts_on_slug", unique: true, using: :btree - create_table "products", force: :cascade do |t| - t.string "name", null: false - t.text "description", null: false - t.integer "min_price", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "account_type_id" - t.integer "paid_months" - t.integer "recommended_price" - end - create_table "roles", force: :cascade do |t| t.string "name", null: false t.text "description" diff --git a/db/seeds.rb b/db/seeds.rb index be885a352..703113be3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,12 +7,9 @@ def load_data Crop.transaction do # for all Growstuff sites, including production ones load_roles - load_basic_account_types create_cropbot load_crops load_plant_parts - load_paid_account_types - load_products # We don't load these in an environment except development to # prevent creating users in the wild - especially admins - with @@ -44,20 +41,6 @@ def load_roles @wrangler = Role.create(name: 'Crop Wrangler') end -def load_basic_account_types - puts "Adding 'free' and 'staff' account types..." - AccountType.create!( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - AccountType.create!( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) -end - def load_test_users # rubocop:disable Metrics/AbcSize puts "Loading test users..." @@ -141,39 +124,6 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") - @cropbot_user.account.save -end - -def load_paid_account_types - puts "Adding 'paid' and 'seed' account types..." - @paid_account = AccountType.create!( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.create!( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) -end - -def load_products - puts "Adding products..." - Product.create!( - name: "Annual subscription", - description: "Paid account, 1 year", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.create!( - name: "Seed account", - description: "Paid account, in perpetuity", - min_price: 15_000, - account_type_id: @seed_account.id - ) end def load_plant_parts diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 03b2e3d0e..656330ea2 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -95,77 +95,6 @@ namespace :growstuff do end end - desc "June 2013: create account types and products." - task setup_shop: :environment do - puts "Adding account types..." - AccountType.find_or_create_by( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - @paid_account = AccountType.find_or_create_by( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.find_or_create_by( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) - @staff_account = AccountType.find_or_create_by( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) - - puts "Adding products..." - Product.find_or_create_by( - name: "Annual subscription", - description: "An annual subscription gives you access "\ - "to paid account features for one year. Does not auto-renew.", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.find_or_create_by( - name: "Seed account", - description: "A seed account helps Growstuff grow in its "\ - "early days. It gives you all the features of "\ - "a paid account, in perpetuity. This account "\ - "type never expires.", - min_price: 15_000, - account_type_id: @seed_account.id - ) - - puts "Giving each member an account record..." - Member.all.each do |m| - Account.create(member_id: m.id) unless m.account - end - - puts "Making Skud a staff account..." - @skud = Member.find_by(login_name: 'Skud') - if @skud - @skud.account.account_type = @staff_account - @skud.account.save - end - - puts "Done setting up shop." - end - - desc "June 2013: replace nil account_types with free accounts" - task nil_account_type: :environment do - free = AccountType.find_by(name: "Free") - raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ - unless free - Account.all.each do |a| - unless a.account_type - a.account_type = free - a.save - end - end - end - desc "July 2013: replace nil seed.tradable_to with nowhere" task tradable_to_nowhere: :environment do Seed.all.each do |s| @@ -187,8 +116,6 @@ namespace :growstuff do task set_default_crop_creator: :environment do cropbot = Member.find_by(login_name: "cropbot") raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot - cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice - cropbot.account.save Crop.find_each do |crop| unless crop.creator crop.creator = cropbot diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb deleted file mode 100644 index 010c8bf1f..000000000 --- a/spec/controllers/account_types_controller_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -describe AccountTypesController do - subject { response } - - context 'anon' do - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'member' do - login_member(:member) - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'admin' do - login_member(:admin_member) - describe '#index' do - let!(:aaa) { FactoryBot.create :account_type, name: 'aaa' } - let!(:zzz) { FactoryBot.create :account_type, name: 'zzz' } - - before { get :index } - it { is_expected.to be_success } - it { expect(assigns[:account_types].first).to eql(aaa) } - it { expect(assigns[:account_types].last).to eql(zzz) } - end - end -end diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb deleted file mode 100644 index 2b4222f1d..000000000 --- a/spec/controllers/accounts_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe AccountsController do - login_member(:admin_member) - - def valid_attributes - { "paid_until" => Time.now } - end - - def create_account - # account details are automatically created when you create a new - # member; creating them manually will just cause errors as only one is - # allowed. This method has been left here in case it's useful in - # future. - member = FactoryBot.create(:member) - member.account - end -end diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb deleted file mode 100644 index fb475b34c..000000000 --- a/spec/controllers/admin/orders_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe Admin::OrdersController do - login_member(:admin_member) - - describe "GET search" do - it "assigns @orders" do - order = FactoryBot.create(:order) - get :search, search_by: 'order_id', search_text: order.id - assigns(:orders).should eq([order]) - end - - it "sets an error message if nothing found" do - get :search, search_by: 'order_id', search_text: 'foo' - flash[:alert].should have_text "Couldn't find order with" - end - end -end diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb deleted file mode 100644 index 4de8eb98d..000000000 --- a/spec/controllers/order_items_controller_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rails_helper' - -describe OrderItemsController do - login_member(:admin_member) - - let(:member) { FactoryBot.create(:member) } - let(:product) { FactoryBot.create(:product) } - let(:order) { FactoryBot.create(:order, member: member) } - let(:order_item) do - FactoryBot.create(:order_item, - order: order, - product: product, - price: product.min_price) - end - - context 'signed in' do - before { sign_in member } - - describe "POST create" do - describe "redirects to order" do - before do - post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } - end - it { expect(response).to redirect_to(OrderItem.last.order) } - it { expect(OrderItem.last.order).to be_an_instance_of Order } - end - - describe 'creates an order for you' do - it do - expect do - post :create, order_item: { - product_id: product.id, - price: product.min_price - } - end.to change(Order, :count).by(1) - end - end - - describe "with non-int price" do - it "converts 3.33 to 333 cents" do - order = FactoryBot.create(:order, member: member) - product = FactoryBot.create(:product, min_price: 1) - expect do - post :create, order_item: { order_id: order.id, product_id: product.id, price: 3.33 } - end.to change(OrderItem, :count).by(1) - OrderItem.last.price.should eq 333 - end - end - end - end -end diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb deleted file mode 100644 index 3c6631d8c..000000000 --- a/spec/controllers/orders_controller_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'rails_helper' - -describe OrdersController do - login_member(:admin_member) - - def valid_attributes - { "member_id" => 1 } - end - - def valid_session - {} - end - - describe "GET checkout" do - it 'sets the referral_code' do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param, referral_code: 'FOOBAR' - order.reload - order.referral_code.should eq 'FOOBAR' - end - - it "redirects to Paypal" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param - response.status.should eq 302 - response.redirect_url.should match(/paypal\.com/) - end - end - - describe "GET complete" do - it "assigns the requested order as @order" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :complete, id: order.to_param - assigns(:order).should eq(order) - end - end - - describe "DELETE destroy" do - it "redirects to the shop" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - delete :destroy, id: order.id - response.should redirect_to(shop_url) - end - end -end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb deleted file mode 100644 index 173ef9ba4..000000000 --- a/spec/controllers/products_controller_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -describe ProductsController do - login_member(:admin_member) - - def valid_attributes - { - name: "product name", - description: 'some description', - min_price: 9.99 - } - end - - def valid_session - {} - end -end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb deleted file mode 100644 index 2fc6b77f7..000000000 --- a/spec/controllers/shop_controller_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -describe ShopController do - let!(:product1) { FactoryBot.create(:product, name: 'aaa') } - let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - - describe "GET index" do - describe 'not logged in' do - before { get :index, {} } - - describe "assigns all products as @products ordered by name" do - it { expect(assigns(:products)).to eq([product1, product2]) } - end - - describe "assigns a new @order_item to build forms" do - it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } - end - - describe "assigns @order as nil if the user doesn't have one" do - it { expect(assigns(:order)).to be_nil } - end - end - describe 'logged in' do - describe "assigns @order as current_order if there is one" do - let(:member) { FactoryBot.create(:member) } - let!(:order) { FactoryBot.create(:order, member: member) } - - before do - sign_in member - get :index, {} - end - it { expect(assigns(:order)).to eq order } - end - end - end -end diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb deleted file mode 100644 index 66717492f..000000000 --- a/spec/factories/account_types.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :account_type do - name { Faker::Name.unique.name } - is_paid false - is_permanent_paid false - - factory :free_account_type do - name "Free" - is_paid false - is_permanent_paid false - end - - factory :paid_account_type do - name "Paid" - is_paid true - is_permanent_paid false - end - - factory :permanent_paid_account_type do - name "Permanent paid" - is_paid true - is_permanent_paid true - end - - factory :staff_account_type do - name "Staff" - is_paid true - is_permanent_paid true - end - end -end diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb deleted file mode 100644 index fb4805964..000000000 --- a/spec/factories/accounts.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - # never do this directly. - # create a member then look at member.account_detail instead. - # (because it's auto-created, and there can only be one.) -end diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb deleted file mode 100644 index 5dfba00ab..000000000 --- a/spec/factories/order_items.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order_item do - order - product - price "999" - quantity 42 - end -end diff --git a/spec/factories/orders.rb b/spec/factories/orders.rb deleted file mode 100644 index 514eb4a22..000000000 --- a/spec/factories/orders.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order do - member - factory :completed_order do - completed_at '2013-05-08 01:01:01' - end - - factory :referred_order do - referral_code 'CAMPAIGN1' - end - end -end diff --git a/spec/factories/products.rb b/spec/factories/products.rb deleted file mode 100644 index 444c8597d..000000000 --- a/spec/factories/products.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :product do - name "annual subscription" - description "paid membership, renewing yearly, *hurrah*" - min_price "999" - account_type - paid_months 12 - - factory :product_with_recommended_price do - recommended_price "1200" - end - end -end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb deleted file mode 100644 index dac241586..000000000 --- a/spec/features/admin/account_types_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rails_helper' - -feature "account types", js: true do - context "admin user" do - let(:member) { create :admin_member } - let(:account_type) { create :account_type } - - background do - login_as member - end - - scenario "navigating to account type admin with JavaScript on" do - visit root_path - # Extra click for the expandable login menu - click_link member.login_name - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "navigating to account type admin without JavaScript - Accessility version", js: false do - visit root_path - # Extra link not needed as menu is already expanded - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "adding an account type" do - visit account_types_path - click_link "New Account type" - expect(current_path).to eq new_account_type_path - fill_in 'Name', with: 'Guest' - click_button 'Save' - expect(current_path).to eq account_type_path(AccountType.last) - expect(page).to have_content 'Account type was successfully created' - end - - scenario 'editing account type' do - visit account_type_path account_type - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq account_type_path(account_type) - expect(page).to have_content 'Account type was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting account type' do - visit account_type_path account_type - click_link 'Delete' - expect(current_path).to eq account_types_path - expect(page).to have_content 'Account type was successfully deleted' - end - end -end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb deleted file mode 100644 index ca24daf83..000000000 --- a/spec/features/admin/products_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'rails_helper' - -feature "products" do - context "admin user" do - let(:member) { create :admin_member } - let(:product) { create :product } - - background do - login_as member - end - - scenario "navigating to product admin" do - visit admin_path - click_link "Products" - expect(current_path).to eq products_path - end - - scenario "adding a product" do - visit products_path - click_link "New Product" - expect(current_path).to eq new_product_path - fill_in 'Name', with: 'Special offer' - # note that failing to fill in a mandatory field has a messy error. - # This is not a priority defect but should be raised at some point. - fill_in 'Minimum price', with: '150' - click_button 'Save' - expect(current_path).to eq product_path(Product.last) - expect(page).to have_content 'Product was successfully created' - end - - scenario 'editing product' do - visit product_path product - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq product_path(product) - expect(page).to have_content 'Product was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting product' - # this isn't possible. Should it be? - end -end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 32b11bda1..9f1005894 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -9,7 +9,6 @@ feature "member profile", js: true do expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content "Account type: Free account" expect(page).to have_content "#{member.login_name}'s gardens" expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end @@ -141,10 +140,6 @@ feature "member profile", js: true do scenario "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path end - - scenario "has a button to upgrade account" do - expect(page).to have_link "Upgrade account", href: shop_path - end end context "someone else's profile page" do diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 793a6ada5..22b91a33b 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -10,7 +10,6 @@ feature "member deletion" do let!(:harvest) { FactoryBot.create(:harvest, owner: member) } let!(:seed) { FactoryBot.create(:seed, owner: member) } let!(:secondgarden) { FactoryBot.create(:garden, owner: member) } - let!(:order) { FactoryBot.create(:order, member: member, completed_at: Time.zone.now) } let(:admin) { FactoryBot.create(:admin_member) } background do @@ -115,16 +114,6 @@ feature "member deletion" do expect(page).to have_content "Member Deleted" end - scenario "leaves a record of orders and payments intact" do - login_as(admin) - visit admin_path - fill_in "search_text", with: member.login_name.to_s - find("#maincontainer").click_button("Search", exact: true) - expect(page).to have_content member.login_name.to_s - expect(page).to have_content "Found 1 result" - logout - end - scenario "can't be interesting" do expect(Member.interesting).not_to include(member) expect(Planting.interesting).not_to include(planting) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index ef746c8bc..e95dfbdc6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -71,201 +71,6 @@ describe Ability do end end - context "products" do - let(:product) { FactoryBot.create(:product) } - - context "standard member" do - it "can't read or manage products" do - ability.should_not be_able_to(:read, product) - ability.should_not be_able_to(:create, Product) - ability.should_not be_able_to(:update, product) - ability.should_not be_able_to(:destroy, product) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read products" do - ability.should be_able_to(:read, product) - end - it "can create products" do - ability.should be_able_to(:create, Product) - end - it "can update products" do - ability.should be_able_to(:update, product) - end - it "can destroy products" do - ability.should be_able_to(:destroy, product) - end - end - end - - context "orders" do - let(:order) { FactoryBot.create(:order, member: member) } - let(:strangers_order) do - FactoryBot.create(:order, - member: FactoryBot.create(:member)) - end - let(:completed_order) do - FactoryBot.create(:completed_order, - member: member) - end - let(:order_item) { FactoryBot.create(:order_item, order: order) } - let(:strangers_order_item) do - FactoryBot.create(:order_item, - order: strangers_order) - end - let(:completed_order_item) do - FactoryBot.create(:order_item, - order: completed_order) - end - - context "standard member" do - it "can read their own orders" do - ability.should be_able_to(:read, order) - ability.should be_able_to(:read, completed_order) - end - - it "can't read other people's orders" do - ability.should_not be_able_to(:read, strangers_order) - end - - it "can create a new order" do - ability.should be_able_to(:create, Order) - end - - it "can complete their own current order" do - ability.should be_able_to(:complete, order) - end - - it "can't complete someone else's order" do - ability.should_not be_able_to(:complete, strangers_order) - end - - it "can't complete a completed order" do - ability.should_not be_able_to(:complete, completed_order) - end - - it "can delete a current order" do - ability.should be_able_to(:destroy, order) - end - - it "can't delete someone else's order" do - ability.should_not be_able_to(:destroy, strangers_order) - end - - it "can't delete a completed order" do - ability.should_not be_able_to(:destroy, completed_order) - end - - it "can't read their own order items" do - ability.should_not be_able_to(:read, order_item) - ability.should_not be_able_to(:read, completed_order_item) - end - - it "can't read other people's order items" do - ability.should_not be_able_to(:read, strangers_order_item) - end - - it "can create a new order item" do - ability.should be_able_to(:create, OrderItem) - end - - it "can't update their own order items" do - ability.should_not be_able_to(:update, order_item) - end - - it "can't update other people's order items" do - ability.should_not be_able_to(:update, strangers_order_item) - end - - it "can't updated items in completed orders" do - ability.should_not be_able_to(:update, completed_order_item) - end - - it "can't delete their own order item" do - ability.should_not be_able_to(:destroy, order_item) - end - - it "can't delete someone else's order item" do - ability.should_not be_able_to(:destroy, strangers_order_item) - end - - it "can't delete items from completed orders" do - ability.should_not be_able_to(:destroy, completed_order_item) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read orders" do - ability.should be_able_to(:read, order) - end - - it "cannot create orders" do - ability.should_not be_able_to(:create, order) - end - - it "cannot complete orders" do - ability.should_not be_able_to(:complete, order) - end - - it "cannot delete orders" do - ability.should_not be_able_to(:destroy, order) - end - end - end - - context 'account details' do - let(:account) { member.account } - - context 'ordinary member' do - it "can't read account details" do - ability.should_not be_able_to(:read, account) - end - it "can't manage account details" do - ability.should_not be_able_to(:create, Account) - ability.should_not be_able_to(:update, account) - ability.should_not be_able_to(:destroy, account) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "can read account details" do - ability.should be_able_to(:read, account) - end - it "can manage account details" do - ability.should be_able_to(:create, Account) - ability.should be_able_to(:update, account) - ability.should be_able_to(:destroy, account) - end - end - end - context 'plant parts' do let(:plant_part) { FactoryBot.create(:plant_part) } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb deleted file mode 100644 index 15eb68084..000000000 --- a/spec/models/account_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -describe Account do - let(:member) { FactoryBot.create(:member) } - - it "auto-creates an account detail record when a member is created" do - member.account.should be_an_instance_of Account - end - - it "won't let you create two account details for the same member" do - @details = Account.new(member_id: member.id) - @details.should_not be_valid - end - - it "formats the 'paid until' date nicely" do - member.account.account_type = FactoryBot.create(:account_type) - member.account.paid_until_string.should eq nil - - member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq "forever" - - member.account.account_type = FactoryBot.create(:paid_account_type) - @time = Time.zone.now - member.account.paid_until = @time - member.account.paid_until_string.should eq @time.to_s - end -end diff --git a/spec/models/account_type_spec.rb b/spec/models/account_type_spec.rb deleted file mode 100644 index c65c113ba..000000000 --- a/spec/models/account_type_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -describe AccountType do -end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index cf7b81486..01d793ded 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -24,15 +24,6 @@ describe 'member' do member.gardens.size.should == 1 end - it 'should have a accounts entry' do - member.account.should be_an_instance_of Account - end - - it "should have a default-type account by default" do - member.account.account_type.name.should eq Growstuff::Application.config.default_account_type - member.paid?.should be(false) - end - it "doesn't show email by default" do member.show_email.should be(false) end @@ -294,89 +285,6 @@ describe 'member' do end end - context 'orders' do - it 'finds the current order' do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - order2 = FactoryBot.create(:order, member: member) - member.current_order.should eq order2 - end - - it "copes if there's no current order" do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - FactoryBot.create(:completed_order, member: member) - member.current_order.should be_nil - end - end - - context "paid accounts" do - let(:member) { FactoryBot.create(:member) } - - it "recognises a permanent paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: true) - member.account.account_type = account_type - member.paid?.should be(true) - end - - it "recognises a current paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(true) - end - - it "recognises an expired paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now - 1.minute - member.paid?.should be(false) - end - - it "recognises a free account" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.paid?.should be(false) - end - - it "recognises a free account even with paid_until set" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(false) - end - end - - context "update account" do - let(:product) do - FactoryBot.create(:product, - paid_months: 3) - end - let(:member) { FactoryBot.create(:member) } - - it "sets account_type" do - member.update_account_after_purchase(product) - member.account.account_type.should eq product.account_type - end - - it "sets paid_until" do - member.account.paid_until = nil # blank for now, as if never paid before - member.update_account_after_purchase(product) - - # stringify to avoid millisecond problems... - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months).to_s) - - # and again to make sure it works for currently paid accounts - member.update_account_after_purchase(product) - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months + 3.months).to_s) - end - end - context 'harvests' do it 'has harvests' do member = FactoryBot.create(:member) diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb deleted file mode 100644 index 7c2de24c6..000000000 --- a/spec/models/order_item_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe OrderItem do - let(:order_item) { FactoryBot.create(:order_item) } - - it "has an order and a product" do - order_item.order.should be_an_instance_of Order - order_item.product.should be_an_instance_of Product - end - - it "validates price > product.min_price" do - @product = FactoryBot.create(:product) - order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) - order_item.should_not be_valid - end - - it "doesn't let you add two items to an order" do - @product = FactoryBot.create(:product) - @order = FactoryBot.create(:order) - order_item = FactoryBot.build(:order_item, order: @order) - order_item.should be_valid - order_item.save - @order_item2 = FactoryBot.build(:order_item, order: @order) - @order_item2.should_not be_valid - end -end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb deleted file mode 100644 index 9abb381ba..000000000 --- a/spec/models/order_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'rails_helper' - -describe Order do - before(:each) do - @order = FactoryBot.create(:order) - @product = FactoryBot.create(:product) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - end - - describe '#by_member_id' do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @order1 = Order.create!(member_id: @member1.id) - @order2 = Order.create!(member_id: @member2.id) - end - - it "only returns orders belonging to member" do - Order.by_member(@member1).should eq [@order1] - end - end - - it 'has order_items' do - @order.order_items.first.should eq @order_item - end - - it 'updates the account details' do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @account_type = FactoryBot.create(:account_type, name: 'paid') - @product = FactoryBot.create(:product, - account_type: @account_type, - paid_months: 3) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - - @member.account.paid_until.should be_nil - - @order.update_account - - @member.account.account_type.should eq @account_type - @member.account.paid_until.should_not be_nil - end - - it "totals the amount due" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.total.should eq 1111 - end - - it "gives the correct total for quantities more than 1" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 2) - - @order.total.should eq 2222 - end - - it "formats order items for activemerchant" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - name: 'foo', - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.activemerchant_items.should eq [{ - name: 'foo', - quantity: 1, - amount: 1111 - }] - end - - context "referral codes" do - it "has a referral code" do - referred_order = FactoryBot.create(:referred_order) - referred_order.referral_code.should_not be nil - end - - it "validates referral codes" do - referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') - referred_order.should_not be_valid - end - - it "cleans up messy referral codes" do - referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') - referred_order.referral_code.should eq 'CAMPAIGN1' - end - end - - context 'search' do - it 'finds orders by member' do - order = FactoryBot.create(:order) - Order.search(by: 'member', for: order.member.login_name).should eq [order] - end - - it 'finds orders by order_id' do - order = FactoryBot.create(:order) - Order.search(by: 'order_id', for: order.id).should eq [order] - end - - it 'finds orders by paypal_token' do - order = FactoryBot.create(:order, paypal_express_token: 'foo') - Order.search(by: 'paypal_token', for: 'foo').should eq [order] - end - - it 'finds orders by paypal_payer_id' do - order = FactoryBot.create(:order, paypal_express_payer_id: 'bar') - Order.search(by: 'paypal_payer_id', for: 'bar').should eq [order] - end - - it 'finds orders by referral_code' do - order = FactoryBot.create(:order, referral_code: 'baz') - Order.search(by: 'referral_code', for: 'baz').should eq [order] - end - end -end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb deleted file mode 100644 index 2cc684667..000000000 --- a/spec/models/product_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rails_helper' - -describe Product do - it "stringifies using the name" do - @product = FactoryBot.create(:product) - @product.to_s.should eq @product.name - end -end diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb deleted file mode 100644 index 8402dd727..000000000 --- a/spec/routing/account_types_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe AccountTypesController do - describe "routing" do - it "routes to #index" do - get("/account_types").should route_to("account_types#index") - end - - it "routes to #new" do - get("/account_types/new").should route_to("account_types#new") - end - - it "routes to #show" do - get("/account_types/1").should route_to("account_types#show", id: "1") - end - - it "routes to #edit" do - get("/account_types/1/edit").should route_to("account_types#edit", id: "1") - end - - it "routes to #create" do - post("/account_types").should route_to("account_types#create") - end - - it "routes to #update" do - put("/account_types/1").should route_to("account_types#update", id: "1") - end - - it "routes to #destroy" do - delete("/account_types/1").should route_to("account_types#destroy", id: "1") - end - end -end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb deleted file mode 100644 index 7487cb9f5..000000000 --- a/spec/routing/order_items_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrderItemsController do - describe "routing" do - it "routes to #index" do - get("/order_items").should route_to("order_items#index") - end - - it "routes to #new" do - get("/order_items/new").should route_to("order_items#new") - end - - it "routes to #show" do - get("/order_items/1").should route_to("order_items#show", id: "1") - end - - it "routes to #edit" do - get("/order_items/1/edit").should route_to("order_items#edit", id: "1") - end - - it "routes to #create" do - post("/order_items").should route_to("order_items#create") - end - - it "routes to #update" do - put("/order_items/1").should route_to("order_items#update", id: "1") - end - - it "routes to #destroy" do - delete("/order_items/1").should route_to("order_items#destroy", id: "1") - end - end -end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb deleted file mode 100644 index 38184ef33..000000000 --- a/spec/routing/orders_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrdersController do - describe "routing" do - it "routes to #index" do - get("/orders").should route_to("orders#index") - end - - it "routes to #new" do - get("/orders/new").should route_to("orders#new") - end - - it "routes to #show" do - get("/orders/1").should route_to("orders#show", id: "1") - end - - it "routes to #edit" do - get("/orders/1/edit").should route_to("orders#edit", id: "1") - end - - it "routes to #create" do - post("/orders").should route_to("orders#create") - end - - it "routes to #update" do - put("/orders/1").should route_to("orders#update", id: "1") - end - - it "routes to #destroy" do - delete("/orders/1").should route_to("orders#destroy", id: "1") - end - end -end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb deleted file mode 100644 index 15166a805..000000000 --- a/spec/routing/products_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe ProductsController do - describe "routing" do - it "routes to #index" do - get("/products").should route_to("products#index") - end - - it "routes to #new" do - get("/products/new").should route_to("products#new") - end - - it "routes to #show" do - get("/products/1").should route_to("products#show", id: "1") - end - - it "routes to #edit" do - get("/products/1/edit").should route_to("products#edit", id: "1") - end - - it "routes to #create" do - post("/products").should route_to("products#create") - end - - it "routes to #update" do - put("/products/1").should route_to("products#update", id: "1") - end - - it "routes to #destroy" do - delete("/products/1").should route_to("products#destroy", id: "1") - end - end -end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb deleted file mode 100644 index 1bd22be03..000000000 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/edit" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders the edit account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path(@account_type), method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb deleted file mode 100644 index 56020fc35..000000000 --- a/spec/views/account_types/index.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -describe "account_types/index" do - before(:each) do - @type = FactoryBot.create(:account_type) - assign(:account_types, [@type, @type]) - end - - it "renders a list of account_types" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @type.name.to_s, count: 2 - end -end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb deleted file mode 100644 index 027a1b7c1..000000000 --- a/spec/views/account_types/new.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/new" do - before(:each) do - assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false).as_new_record) - end - - it "renders new account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path, method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb deleted file mode 100644 index a31d4bc33..000000000 --- a/spec/views/account_types/show.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "account_types/show" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "Name", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - rendered.should match(/false/) - rendered.should match(/false/) - end -end diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb deleted file mode 100644 index bc5c3b5a3..000000000 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "accounts/edit" do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it "renders the edit account form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path(@account), method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" - end - end -end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb deleted file mode 100644 index 4ec76151e..000000000 --- a/spec/views/accounts/index.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe "accounts/index" do - before(:each) do - @member = FactoryBot.create(:member) - @account = @member.account - assign(:accounts, [@account, @account]) - end - - it "renders a list of accounts" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @account.member_id.to_s, count: 2 - end -end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb deleted file mode 100644 index 77f6ff20f..000000000 --- a/spec/views/accounts/new.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "accounts/new" do - before(:each) do - @member = FactoryBot.create(:member) - assign(:account, @member.account) - end - - it "renders new account form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path, method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" - end - end -end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb deleted file mode 100644 index d96fbbd96..000000000 --- a/spec/views/accounts/show.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe "accounts/show" do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @account.member_id.to_s - rendered.should have_content 'Free' - rendered.should have_content @account.paid_until.to_s - end -end diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index beb0eacbd..cc8b145d3 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -9,8 +9,6 @@ describe 'admin/index.html.haml', type: "view" do end it "includes links to manage various things" do - assert_select "a", href: account_types_path - assert_select "a", href: products_path assert_select "a", href: roles_path assert_select "a", href: forums_path end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb deleted file mode 100644 index 8d80dc3ef..000000000 --- a/spec/views/admin/orders/index_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -describe 'admin/orders/index.html.haml', type: "view" do - before(:each) do - @member = FactoryBot.create(:admin_member) - sign_in @member - controller.stub(:current_user) { @member } - render - end - - it "includes a search form for orders" do - assert_select "form" - assert_select "input#search_text" - assert_select "select#search_by" - end - - it "lets you search by referral code" do - assert_select "option[value=referral_code]", text: "Referral code" - end -end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb deleted file mode 100644 index c95f204e2..000000000 --- a/spec/views/orders/index.html.haml_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe "orders/index" do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - @order1 = FactoryBot.create(:order, member: @member) - @order2 = FactoryBot.create(:completed_order, member: @member) - assign(:orders, [@order1, @order2]) - end - - it "shows your current account status" do - render - rendered.should have_content "Your current account status" - end - - it "renders a list of orders" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td a/@href", text: "/orders/#{@order1.id}" - assert_select "tr>td a/@href", text: "/orders/#{@order2.id}" - end -end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb deleted file mode 100644 index a9f662de9..000000000 --- a/spec/views/orders/show.html.haml_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'rails_helper' - -describe "orders/show" do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - controller.stub(:current_user) { @member } - end - - context "current order" do - before(:each) do - @order = assign(:order, FactoryBot.create(:order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it "displays order number" do - rendered.should have_content "Order number" - end - - it "shows order items in a table" do - assert_select "table>tr>th", text: "Product" - end - - it "shows the total" do - rendered.should have_content "Total:" - assert_select "strong", /198.00/ - end - - it "shows a foreign exchange link for the total" do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") - end - - it "asks for a referral code" do - assert_select "input[id='referral_code']" - end - - it "shows a checkout button" do - assert_select "input[value='Checkout with PayPal']" - end - - it "shows a delete order button" do - assert_select "a", text: "Delete this order" - end - end - - context "completed order" do - before(:each) do - @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it "doesn't show a checkout button" do - assert_select "a", text: "Checkout", count: 0 - end - - it "doesn't show delete order button" do - assert_select "a", text: "Delete this order", count: 0 - end - end -end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb deleted file mode 100644 index 3d60c9e95..000000000 --- a/spec/views/products/edit.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -describe "products/edit" do - before(:each) do - @product = assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99")) - end - - it "renders the edit product form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path(@product), method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" - end - end -end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb deleted file mode 100644 index 90e08e2a3..000000000 --- a/spec/views/products/index.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe "products/index" do - before(:each) do - @product = FactoryBot.create(:product) - assign(:products, [@product, @product]) - end - - it "renders a list of products" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @product.name, count: 2 - assert_select "tr>td", text: @product.description, count: 2 - assert_select "tr>td", text: @product.min_price.to_s, count: 2 - end -end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb deleted file mode 100644 index 336c6bac1..000000000 --- a/spec/views/products/new.html.haml_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -describe "products/new" do - before(:each) do - assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99").as_new_record) - end - - it "renders new product form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path, method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" - assert_select "select#product_account_type_id", name: "product[account_type_id]" - assert_select "input#product_paid_months", name: "product[paid_months]" - end - end -end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb deleted file mode 100644 index 315d9caae..000000000 --- a/spec/views/products/show.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe "products/show" do - before(:each) do - @product = assign(:product, FactoryBot.create(:product)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @product.name - rendered.should have_content @product.min_price.to_s - rendered.should have_content @product.recommended_price.to_s - end -end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb deleted file mode 100644 index 754f05c09..000000000 --- a/spec/views/shop/index_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rails_helper' - -describe 'shop/index.html.haml', type: "view" do - before(:each) do - @product1 = FactoryBot.create(:product) - @product2 = FactoryBot.create(:product_with_recommended_price) - assign(:products, [@product1, @product2]) - assign(:order_item, OrderItem.new) - end - - context "signed in" do - before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - render - end - - it 'shows products' do - assert_select("h2", text: @product1.name) - end - - it 'shows prices in configured currency' do - rendered.should have_content format('9.99 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=9.99+#{currency}']") - end - - it 'shows recommended price for products that have it' do - rendered.should have_content format('12.00 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link for recommended price' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=12.00+#{currency}']") - end - - it 'displays the order form' do - assert_select "form", count: 2 - end - - it 'renders markdown in product descriptions' do - assert_select "em", text: 'hurrah', count: 2 - end - end - - context "is paid" do - before(:each) do - @member = FactoryBot.create(:member) - @member.account.account_type = FactoryBot.create(:paid_account_type) - @member.account.paid_until = Time.zone.now + 1.year - controller.stub(:current_member) { @member } - end - - it "recognises the paid member" do - @member.paid?.should be(true) - end - - it "tells you you have a paid membership" do - render - rendered.should have_content "You currently have a paid" - end - - it "doesn't show shop" do - render - assert_select "form", false - end - end - - context "signed out" do - before(:each) do - controller.stub(:current_user) { nil } - render - end - - it "tells you to sign up/sign in" do - rendered.should have_content "sign in or sign up" - end - end -end From dcf528627585eac5f5b5e8991d573c73e52b3c23 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:38:08 +1300 Subject: [PATCH 076/101] Re-gen rubocop todo --- .rubocop_todo.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9c3ccad34..769bcb9b6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-offense-counts` -# on 2017-12-06 11:20:15 +1300 using RuboCop version 0.49.1. +# on 2018-02-05 14:37:22 +1300 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -66,24 +66,11 @@ Style/IdenticalConditionalBranches: Exclude: - 'app/controllers/follows_controller.rb' -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'spec/controllers/member_controller_spec.rb' - - 'spec/models/photo_spec.rb' - # Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - 'spec/rails_helper.rb' -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/planting.rb' - # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison @@ -94,11 +81,6 @@ Style/NumericPredicate: - 'app/helpers/plantings_helper.rb' - 'lib/tasks/growstuff.rake' -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'app/mailers/notifier.rb' - # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed From 3c411f15b860fcaf37987cce7671f168d4a833a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:05 +1300 Subject: [PATCH 077/101] Re-instated the member-since text on profiles --- app/views/members/_stats.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 346d71296..8bb9613e9 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,3 +1,7 @@ +%p + %strong Member since: + = member.created_at.to_s(:date) + %h3 Activity %ul.list-inline @@ -33,4 +37,3 @@ = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else 0 followers - From 0699677d051756d91502400a498920145843be2a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:41 +1300 Subject: [PATCH 078/101] Added back the member's last login --- app/views/members/_stats.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 8bb9613e9..a2ebab47d 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,6 +1,9 @@ %p %strong Member since: = member.created_at.to_s(:date) +%p + %strong Last Login: + = member.last_sign_in_at %h3 Activity From 54c880a66cbe535563ad188700568c5b3937a439 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 15:36:32 +1300 Subject: [PATCH 079/101] Removed active merchant --- Gemfile | 2 -- Gemfile.lock | 10 ---------- config/application.yml.example | 5 ----- config/environments/development.rb | 11 ----------- config/environments/production.rb | 11 ----------- config/environments/staging.rb | 11 ----------- config/environments/test.rb | 7 ------- 7 files changed, 57 deletions(-) diff --git a/Gemfile b/Gemfile index 488a3b9ab..f49aaa60d 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'bootstrap-kaminari-views' # bootstrap views for kaminari gem 'kaminari' # pagination gem 'active_utils' -gem 'activemerchant' gem 'sidekiq' # Markdown formatting for updates etc @@ -125,7 +124,6 @@ group :development do end group :development, :test do - gem "active_merchant-paypal-bogus-gateway" gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Gemfile.lock b/Gemfile.lock index 2686528e1..392b497e9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,19 +26,12 @@ GEM addressable active_median (0.1.4) activerecord - active_merchant-paypal-bogus-gateway (0.1.0) - activemerchant active_utils (3.3.9) activesupport (>= 3.2, < 5.2.0) i18n activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.77.0) - activesupport (>= 3.2.14, < 6.x) - builder (>= 2.1.2, < 4.0.0) - i18n (>= 0.6.9) - nokogiri (~> 1.4) activemodel (4.2.10) activesupport (= 4.2.10) builder (~> 3.1) @@ -549,9 +542,7 @@ PLATFORMS DEPENDENCIES active_median - active_merchant-paypal-bogus-gateway active_utils - activemerchant acts_as_paranoid (~> 0.5.0) better_errors (~> 2.2.0) binding_of_caller @@ -636,7 +627,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 diff --git a/config/application.yml.example b/config/application.yml.example index 4aa23e439..ba343b6d0 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -57,11 +57,6 @@ GROWSTUFF_TWITTER_SECRET: "" GROWSTUFF_FLICKR_KEY: "" GROWSTUFF_FLICKR_SECRET: "" -# Paypal is used for payments, obviously. -GROWSTUFF_PAYPAL_USERNAME: "dummy" -GROWSTUFF_PAYPAL_PASSWORD: "dummy" -GROWSTUFF_PAYPAL_SIGNATURE: "dummy" - # https://developers.facebook.com/ GROWSTUFF_FACEBOOK_KEY: "" GROWSTUFF_FACEBOOK_SECRET: "" diff --git a/config/environments/development.rb b/config/environments/development.rb index d3242353e..a66a807f7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -63,17 +63,6 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2il6a' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy', - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy', - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy' - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.action_controller.action_on_unpermitted_parameters = :raise config.active_job.queue_adapter = :sidekiq diff --git a/config/environments/production.rb b/config/environments/production.rb index c931c058e..81cbddefd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -91,16 +91,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2c4ie' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :production - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index a9e242381..d4b381577 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -89,16 +89,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2hao7' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/test.rb b/config/environments/test.rb index bf4135f64..d3ad694dd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -51,13 +51,6 @@ Growstuff::Application.configure do config.analytics_code = '' config.currency = 'AUD' end - - config.after_initialize do - require "active_merchant/ext/paypal_bogus_gateway" - ActiveMerchant::Billing::Base.mode = :test - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - end end Geocoder.configure(lookup: :test) From ed2fcc2ada88e5d0c9c131f8ae84add9f2568f3f Mon Sep 17 00:00:00 2001 From: deppbot Date: Wed, 7 Feb 2018 03:10:49 +0800 Subject: [PATCH 080/101] Bundle Update on 2018-02-07 --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2686528e1..2101269a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -183,7 +183,7 @@ GEM i18n (>= 0.7) faraday (0.12.2) multipart-post (>= 1.2, < 3) - ffi (1.9.18) + ffi (1.9.21) figaro (1.1.1) thor (~> 0.14) flickraw (0.9.9) @@ -267,7 +267,7 @@ GEM phantomjs rack (>= 1.2.1) rake - jasmine-core (2.9.1) + jasmine-core (2.99.0) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -484,9 +484,9 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.8.0) + selenium-webdriver (3.9.0) childprocess (~> 0.5) - rubyzip (~> 1.0) + rubyzip (~> 1.2) sexp_processor (4.10.0) shellany (0.0.1) sidekiq (5.1.0) @@ -521,7 +521,7 @@ GEM timecop (0.9.1) tins (1.16.3) trollop (1.16.2) - tzinfo (1.2.4) + tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.5) execjs (>= 0.3.0, < 3) From ab56a3c6b32f0cabe9ea116f317e4727631adc81 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Tue, 6 Feb 2018 19:44:34 +0000 Subject: [PATCH 081/101] Auto corrected by following Style/StringLiterals --- Gemfile | 14 +- Guardfile | 6 +- app/controllers/alternate_names_controller.rb | 4 +- app/controllers/application_controller.rb | 14 +- app/controllers/authentications_controller.rb | 4 +- app/controllers/charts/crops_controller.rb | 2 +- app/controllers/crops_controller.rb | 16 +- app/controllers/follows_controller.rb | 2 +- app/controllers/likes_controller.rb | 2 +- app/controllers/members_controller.rb | 4 +- app/controllers/notifications_controller.rb | 4 +- .../omniauth_callbacks_controller.rb | 8 +- app/controllers/order_items_controller.rb | 2 +- app/controllers/orders_controller.rb | 4 +- app/controllers/pages_controller.rb | 2 +- .../photo_associations_controller.rb | 2 +- app/controllers/photos_controller.rb | 6 +- app/controllers/registrations_controller.rb | 6 +- app/controllers/sessions_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +- app/helpers/crops_helper.rb | 2 +- app/helpers/gardens_helper.rb | 10 +- app/helpers/harvests_helper.rb | 2 +- app/helpers/plantings_helper.rb | 8 +- app/helpers/seeds_helper.rb | 4 +- app/mailers/notifier.rb | 8 +- app/models/ability.rb | 2 +- app/models/account.rb | 2 +- app/models/alternate_name.rb | 2 +- app/models/comment.rb | 2 +- app/models/crop.rb | 48 +-- app/models/csv_importer.rb | 2 +- app/models/follow.rb | 4 +- app/models/forum.rb | 2 +- app/models/garden.rb | 10 +- app/models/harvest.rb | 48 +-- app/models/member.rb | 20 +- app/models/notification.rb | 2 +- app/models/order.rb | 12 +- app/models/order_item.rb | 2 +- app/models/planting.rb | 14 +- app/models/scientific_name.rb | 2 +- app/models/seed.rb | 14 +- app/services/crop_search_service.rb | 16 +- config.rb | 10 +- config/application.rb | 8 +- config/environments/test.rb | 20 +- config/initializers/devise.rb | 2 +- config/initializers/geocoder.rb | 4 +- config/initializers/time_formats.rb | 8 +- config/routes.rb | 10 +- config/setup_load_paths.rb | 2 +- .../20120903092956_devise_create_users.rb | 4 +- ...0201053200_add_approval_status_to_crops.rb | 2 +- .../20171105011017_set_prediction_data.rb | 4 +- .../20171129041341_create_photographings.rb | 8 +- db/seeds.rb | 52 +-- lib/actions/oauth_signup_action.rb | 2 +- lib/tasks/growstuff.rake | 108 +++--- lib/tasks/hooks.rake | 2 +- lib/tasks/i18n.rake | 4 +- lib/tasks/testing.rake | 4 +- script/heroku_maintenance.rb | 4 +- spec/controllers/accounts_controller_spec.rb | 2 +- .../admin/orders_controller_spec.rb | 6 +- spec/controllers/admin_controller_spec.rb | 4 +- .../charts/gardens_controller_spec.rb | 4 +- spec/controllers/comments_controller_spec.rb | 50 +-- spec/controllers/crops_controller_spec.rb | 24 +- spec/controllers/forums_controller_spec.rb | 6 +- spec/controllers/gardens_controller_spec.rb | 4 +- spec/controllers/harvests_controller_spec.rb | 84 ++--- spec/controllers/home_controller_spec.rb | 2 +- spec/controllers/likes_controller_spec.rb | 18 +- spec/controllers/member_controller_spec.rb | 24 +- .../notifications_controller_spec.rb | 36 +- .../order_items_controller_spec.rb | 8 +- spec/controllers/orders_controller_spec.rb | 14 +- .../photo_associations_controller_spec.rb | 6 +- spec/controllers/photos_controller_spec.rb | 88 ++--- spec/controllers/places_controller_spec.rb | 14 +- spec/controllers/plantings_controller_spec.rb | 14 +- spec/controllers/posts_controller_spec.rb | 22 +- spec/controllers/products_controller_spec.rb | 2 +- .../registrations_controller_spec.rb | 8 +- spec/controllers/roles_controller_spec.rb | 6 +- .../scientific_names_controller_spec.rb | 4 +- spec/controllers/seeds_controller_spec.rb | 4 +- spec/controllers/shop_controller_spec.rb | 8 +- spec/factories/account_types.rb | 8 +- spec/factories/alternate_names.rb | 4 +- spec/factories/crop.rb | 46 +-- spec/factories/forums.rb | 4 +- spec/factories/garden.rb | 6 +- spec/factories/harvests.rb | 12 +- spec/factories/like.rb | 2 +- spec/factories/member.rb | 2 +- spec/factories/notifications.rb | 4 +- spec/factories/order_items.rb | 2 +- spec/factories/photos.rb | 8 +- spec/factories/plant_parts.rb | 2 +- spec/factories/planting.rb | 2 +- spec/factories/post.rb | 6 +- spec/factories/products.rb | 8 +- spec/factories/roles.rb | 10 +- spec/factories/scientific_name.rb | 6 +- spec/factories/seeds.rb | 8 +- spec/features/admin/account_types_spec.rb | 20 +- spec/features/admin/forums_spec.rb | 26 +- spec/features/admin/products_spec.rb | 12 +- spec/features/cms_spec.rb | 8 +- .../comments/commenting_a_comment_spec.rb | 22 +- spec/features/crops/alternate_name_spec.rb | 48 +-- spec/features/crops/browse_crops_spec.rb | 12 +- spec/features/crops/creating_a_crop_spec.rb | 40 +-- spec/features/crops/crop_detail_page_spec.rb | 100 +++--- spec/features/crops/crop_photos_spec.rb | 24 +- spec/features/crops/crop_search_spec.rb | 20 +- spec/features/crops/crop_wranglers_spec.rb | 32 +- .../crops/crop_wrangling_button_spec.rb | 14 +- spec/features/crops/inflections_spec.rb | 28 +- spec/features/crops/request_new_crop_spec.rb | 40 +-- spec/features/crops/requested_crops_spec.rb | 6 +- spec/features/following_spec.rb | 40 +-- spec/features/footer_spec.rb | 4 +- spec/features/gardens/adding_gardens_spec.rb | 32 +- spec/features/gardens/gardens_index_spec.rb | 28 +- spec/features/gardens_spec.rb | 82 ++--- .../features/harvests/browse_harvests_spec.rb | 8 +- .../harvests/harvesting_a_crop_spec.rb | 84 ++--- spec/features/locale_spec.rb | 8 +- spec/features/member_profile_spec.rb | 108 +++--- spec/features/members/deletion_spec.rb | 72 ++-- spec/features/members_list_spec.rb | 28 +- spec/features/notifications_spec.rb | 18 +- spec/features/photos/new_photo_spec.rb | 26 +- spec/features/photos/show_photo_spec.rb | 20 +- .../features/places/searching_a_place_spec.rb | 44 +-- spec/features/planting_reminder_spec.rb | 34 +- .../plantings/planting_a_crop_spec.rb | 328 +++++++++--------- spec/features/posts/posting_a_post_spec.rb | 24 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/features/scientific_name_spec.rb | 48 +-- spec/features/seeds/adding_seeds_spec.rb | 64 ++-- spec/features/seeds/misc_seeds_spec.rb | 32 +- spec/features/seeds/seed_photos.rb | 10 +- spec/features/shared_examples/append_date.rb | 18 +- spec/features/shared_examples/crop_suggest.rb | 50 +-- spec/features/signin_spec.rb | 26 +- spec/features/signout_spec.rb | 18 +- spec/features/signup_spec.rb | 12 +- spec/features/unsubscribing_spec.rb | 12 +- spec/helpers/application_helper_spec.rb | 6 +- spec/helpers/crops_helper_spec.rb | 12 +- spec/helpers/gardens_helper_spec.rb | 50 +-- spec/helpers/harvests_helper_spec.rb | 4 +- spec/helpers/notifications_helper_spec.rb | 6 +- spec/helpers/plantings_helper_spec.rb | 30 +- spec/helpers/seeds_helper_spec.rb | 14 +- spec/lib/actions/oauth_signup_action_spec.rb | 4 +- .../lib/haml/filters/escaped_markdown_spec.rb | 4 +- .../haml/filters/growstuff_markdown_spec.rb | 24 +- spec/mailers/notifier_spec.rb | 20 +- spec/models/ability_spec.rb | 76 ++-- spec/models/account_spec.rb | 4 +- spec/models/alternate_name_spec.rb | 2 +- spec/models/comment_spec.rb | 14 +- spec/models/crop_spec.rb | 154 ++++---- spec/models/follow_spec.rb | 12 +- spec/models/forum_spec.rb | 6 +- spec/models/garden_spec.rb | 42 +-- spec/models/harvest_spec.rb | 56 +-- spec/models/member_spec.rb | 74 ++-- spec/models/notification_spec.rb | 24 +- spec/models/order_item_spec.rb | 4 +- spec/models/order_spec.rb | 16 +- spec/models/photo_spec.rb | 6 +- spec/models/planting_spec.rb | 26 +- spec/models/post_spec.rb | 56 +-- spec/models/product_spec.rb | 2 +- spec/models/seed_spec.rb | 8 +- spec/rails_helper.rb | 8 +- spec/requests/api/v1/crop_request_spec.rb | 68 ++-- spec/requests/api/v1/gardens_request_spec.rb | 40 +-- spec/requests/api/v1/harvest_request_spec.rb | 68 ++-- spec/requests/api/v1/member_request_spec.rb | 68 ++-- spec/requests/api/v1/photos_request_spec.rb | 64 ++-- .../requests/api/v1/plantings_request_spec.rb | 90 ++--- spec/requests/api/v1/seeds_request_spec.rb | 54 +-- spec/requests/authentications_spec.rb | 4 +- spec/requests/comments_spec.rb | 6 +- spec/requests/forums_spec.rb | 6 +- spec/requests/gardens_spec.rb | 6 +- spec/requests/harvests_spec.rb | 6 +- spec/requests/notifications_spec.rb | 6 +- spec/requests/photos_spec.rb | 6 +- spec/requests/plant_parts_spec.rb | 6 +- spec/requests/plantings_spec.rb | 6 +- spec/requests/post_spec.rb | 6 +- spec/requests/scientific_names_spec.rb | 6 +- spec/requests/seeds_spec.rb | 6 +- spec/routing/account_types_routing_spec.rb | 32 +- spec/routing/authentications_routing_spec.rb | 12 +- spec/routing/comments_routing_spec.rb | 32 +- spec/routing/crops_routing_spec.rb | 32 +- spec/routing/follows_routing_spec.rb | 12 +- spec/routing/forums_routing_spec.rb | 32 +- spec/routing/gardens_routing_spec.rb | 32 +- spec/routing/harvests_routing_spec.rb | 32 +- spec/routing/notifications_routing_spec.rb | 32 +- spec/routing/order_items_routing_spec.rb | 32 +- spec/routing/orders_routing_spec.rb | 32 +- spec/routing/photos_routing_spec.rb | 32 +- spec/routing/plant_parts_routing_spec.rb | 32 +- spec/routing/plantings_routing_spec.rb | 32 +- spec/routing/products_routing_spec.rb | 32 +- spec/routing/roles_routing_spec.rb | 32 +- spec/routing/scientific_names_routing_spec.rb | 32 +- spec/routing/seeds_routing_spec.rb | 32 +- spec/routing/updates_routing_spec.rb | 32 +- spec/spec_helper.rb | 2 +- spec/support/controller_macros.rb | 2 +- spec/support/elasticsearch_helpers.rb | 4 +- spec/support/is_likeable.rb | 4 +- .../account_types/edit.html.haml_spec.rb | 14 +- .../account_types/index.html.haml_spec.rb | 6 +- .../views/account_types/new.html.haml_spec.rb | 14 +- .../account_types/show.html.haml_spec.rb | 6 +- spec/views/accounts/edit.html.haml_spec.rb | 10 +- spec/views/accounts/index.html.haml_spec.rb | 6 +- spec/views/accounts/new.html.haml_spec.rb | 10 +- spec/views/accounts/show.html.haml_spec.rb | 4 +- spec/views/admin/index_spec.rb | 16 +- spec/views/admin/newsletter_spec.rb | 4 +- spec/views/admin/orders/index_spec.rb | 14 +- spec/views/comments/edit.html.haml_spec.rb | 8 +- spec/views/comments/index.html.haml_spec.rb | 8 +- spec/views/comments/index.rss.haml_spec.rb | 4 +- spec/views/comments/new.html.haml_spec.rb | 16 +- spec/views/comments/show.html.haml_spec.rb | 4 +- spec/views/crops/_grown_for.html.haml_spec.rb | 4 +- .../crops/_planting_advice.html.haml_spec.rb | 52 +-- spec/views/crops/_popover.html.haml_spec.rb | 2 +- spec/views/crops/edit.html.haml_spec.rb | 4 +- spec/views/crops/hierarchy.html.haml_spec.rb | 6 +- spec/views/crops/index.html.haml_spec.rb | 28 +- spec/views/crops/index.rss.haml_spec.rb | 2 +- spec/views/crops/new.html.haml_spec.rb | 6 +- spec/views/crops/wrangle.html.haml_spec.rb | 14 +- spec/views/devise/confirmations/new_spec.rb | 6 +- .../mailer/confirmation_instructions_spec.rb | 4 +- .../reset_password_instructions_spec.rb | 8 +- .../devise/mailer/unlock_instructions_spec.rb | 10 +- spec/views/devise/registrations/edit_spec.rb | 34 +- spec/views/devise/registrations/new_spec.rb | 8 +- spec/views/devise/sessions/new_spec.rb | 6 +- spec/views/devise/shared/_links_spec.rb | 12 +- spec/views/devise/unlocks/new_spec.rb | 6 +- spec/views/forums/edit.html.haml_spec.rb | 16 +- spec/views/forums/index.html.haml_spec.rb | 18 +- spec/views/forums/new.html.haml_spec.rb | 12 +- spec/views/forums/show.html.haml_spec.rb | 14 +- spec/views/gardens/edit.html.haml_spec.rb | 20 +- spec/views/gardens/new.html.haml_spec.rb | 18 +- spec/views/gardens/show.html.haml_spec.rb | 14 +- spec/views/harvests/edit.html.haml_spec.rb | 22 +- spec/views/harvests/index.html.haml_spec.rb | 10 +- spec/views/harvests/new.html.haml_spec.rb | 22 +- spec/views/harvests/show.html.haml_spec.rb | 4 +- spec/views/home/_blurb.html.haml_spec.rb | 10 +- spec/views/home/_crops.html.haml_spec.rb | 2 +- spec/views/home/_members.html.haml_spec.rb | 4 +- spec/views/home/_seeds.html.haml_spec.rb | 2 +- spec/views/home/_stats.html.haml_spec.rb | 4 +- spec/views/home/index_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 28 +- spec/views/layouts/_meta_spec.rb | 4 +- spec/views/layouts/application_spec.rb | 4 +- .../views/members/_location.html.haml_spec.rb | 14 +- spec/views/members/index.html.haml_spec.rb | 6 +- spec/views/members/show.rss.haml_spec.rb | 6 +- .../notifications/index.html.haml_spec.rb | 28 +- .../views/notifications/new.html.haml_spec.rb | 28 +- .../notifications/show.html.haml_spec.rb | 12 +- spec/views/notifier/notify.html.haml_spec.rb | 6 +- spec/views/orders/index.html.haml_spec.rb | 12 +- spec/views/orders/show.html.haml_spec.rb | 34 +- spec/views/photos/edit.html.haml_spec.rb | 6 +- spec/views/photos/index.html.haml_spec.rb | 8 +- spec/views/photos/new.html.haml_spec.rb | 20 +- spec/views/photos/show.html.haml_spec.rb | 60 ++-- .../places/_map_attribution.html.haml_spec.rb | 18 +- spec/views/places/index.html.haml_spec.rb | 6 +- spec/views/places/show.html.haml_spec.rb | 10 +- spec/views/plant_parts/edit.html.haml_spec.rb | 10 +- .../views/plant_parts/index.html.haml_spec.rb | 6 +- spec/views/plant_parts/new.html.haml_spec.rb | 10 +- spec/views/plant_parts/show.html.haml_spec.rb | 6 +- spec/views/plantings/_form.html.haml_spec.rb | 4 +- spec/views/plantings/edit.html.haml_spec.rb | 26 +- spec/views/plantings/index.html.haml_spec.rb | 18 +- spec/views/plantings/index.rss.haml_spec.rb | 4 +- spec/views/plantings/new.html.haml_spec.rb | 28 +- spec/views/plantings/show.html.haml_spec.rb | 26 +- spec/views/posts/_single.html.haml_spec.rb | 84 ++--- spec/views/posts/edit.html.haml_spec.rb | 18 +- spec/views/posts/index.html.haml_spec.rb | 22 +- spec/views/posts/index.rss.haml_spec.rb | 6 +- spec/views/posts/new.html.haml_spec.rb | 16 +- spec/views/posts/show.html.haml_spec.rb | 36 +- spec/views/posts/show.rss.haml_spec.rb | 2 +- spec/views/products/edit.html.haml_spec.rb | 20 +- spec/views/products/index.html.haml_spec.rb | 10 +- spec/views/products/new.html.haml_spec.rb | 24 +- spec/views/products/show.html.haml_spec.rb | 4 +- spec/views/roles/edit.html.haml_spec.rb | 14 +- spec/views/roles/index.html.haml_spec.rb | 16 +- spec/views/roles/new.html.haml_spec.rb | 14 +- spec/views/roles/show.html.haml_spec.rb | 8 +- .../scientific_names/edit.html.haml_spec.rb | 14 +- .../scientific_names/index.html.haml_spec.rb | 20 +- .../scientific_names/new.html.haml_spec.rb | 12 +- .../scientific_names/show.html.haml_spec.rb | 4 +- spec/views/seeds/edit.html.haml_spec.rb | 20 +- spec/views/seeds/index.rss.haml_spec.rb | 2 +- spec/views/seeds/new.html.haml_spec.rb | 20 +- spec/views/seeds/show.html.haml_spec.rb | 22 +- spec/views/shop/index_spec.rb | 26 +- 330 files changed, 3121 insertions(+), 3121 deletions(-) diff --git a/Gemfile b/Gemfile index 488a3b9ab..4e6dc5797 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' -gem "chartkick" +gem 'chartkick' # client for Elasticsearch. Elasticsearch is a flexible # and powerful, distributed, real-time search and analytics engine. @@ -87,15 +87,15 @@ gem "chartkick" # Project does not use semver, so we want to be in sync with the version of # elasticsearch we use # See https://github.com/elastic/elasticsearch-ruby#compatibility -gem "elasticsearch-api", "~> 2.0.0" -gem "elasticsearch-model" -gem "elasticsearch-rails" -gem "hashie", ">= 3.5.3" +gem 'elasticsearch-api', '~> 2.0.0' +gem 'elasticsearch-model' +gem 'elasticsearch-rails' +gem 'hashie', '>= 3.5.3' gem 'rake', '>= 10.0.0' # locale based flash notices for controllers -gem "responders" +gem 'responders' # allows soft delete. Used for members. gem 'acts_as_paranoid', '~> 0.5.0' @@ -125,7 +125,7 @@ group :development do end group :development, :test do - gem "active_merchant-paypal-bogus-gateway" + gem 'active_merchant-paypal-bogus-gateway' gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Guardfile b/Guardfile index 4b5f3ccb5..dabd4b9d5 100644 --- a/Guardfile +++ b/Guardfile @@ -3,11 +3,11 @@ guard :rspec, failed_mode: :keep do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { "spec" } + watch('spec/spec_helper.rb') { 'spec' } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^spec/support/(.+)\.rb$}) { "spec" } - watch('config/routes.rb') { "spec/routing" } + watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } + watch('config/routes.rb') { 'spec/routing' } end diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index 0f1471a8c..e06a07b5a 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -30,7 +30,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.save redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.' else - render action: "new" + render action: 'new' end end @@ -40,7 +40,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.update(alternate_name_params) redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.' else - render action: "edit" + render action: 'edit' end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3e6221d06..7b5a0bf32 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,12 +7,12 @@ class ApplicationController < ActionController::Base before_action :set_locale def store_location - unless request.path.in?(["/members/sign_in", - "/members/sign_up", - "/members/password/new", - "/members/password/edit", - "/members/confirmation", - "/members/sign_out"]) || request.xhr? + unless request.path.in?(['/members/sign_in', + '/members/sign_up', + '/members/password/new', + '/members/password/edit', + '/members/confirmation', + '/members/sign_out']) || request.xhr? store_location_for(:member, request.fullpath) end end @@ -77,6 +77,6 @@ class ApplicationController < ActionController::Base end def expire_homepage - expire_fragment("homepage_stats") + expire_fragment('homepage_stats') end end diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index fc18ff4d7..7c603eb6a 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -22,9 +22,9 @@ class AuthenticationsController < ApplicationController name: name ) - flash[:notice] = "Authentication successful." + flash[:notice] = 'Authentication successful.' else - flash[:notice] = "Authentication failed." + flash[:notice] = 'Authentication failed.' end redirect_to request.env['omniauth.origin'] || edit_member_registration_path end diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index b5fe3d4a7..17c774c14 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -14,7 +14,7 @@ module Charts @crop = Crop.find(params[:crop_id]) render json: Harvest.joins(:plant_part) .where(crop: @crop) - .group("plant_parts.name").count(:id) + .group('plant_parts.name').count(:id) end private diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 361e28031..e6ff7c7e0 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -23,9 +23,9 @@ class CropsController < ApplicationController def wrangle @approval_status = params[:approval_status] @crops = case @approval_status - when "pending" + when 'pending' Crop.pending_approval - when "rejected" + when 'rejected' Crop.rejected else Crop.recent @@ -78,7 +78,7 @@ class CropsController < ApplicationController @crop.creator = current_member else @crop.requester = current_member - @crop.approval_status = "pending" + @crop.approval_status = 'pending' end notify_wranglers if Crop.transaction { @crop.save && save_crop_names } @@ -89,13 +89,13 @@ class CropsController < ApplicationController def update previous_status = @crop.approval_status - @crop.creator = current_member if previous_status == "pending" + @crop.creator = current_member if previous_status == 'pending' if @crop.update(crop_params) recreate_names('alt_name', 'alternate') recreate_names('sci_name', 'scientific') - notifier.deliver_now! if previous_status == "pending" + notifier.deliver_now! if previous_status == 'pending' end respond_with @crop @@ -110,9 +110,9 @@ class CropsController < ApplicationController def notifier case @crop.approval_status - when "approved" + when 'approved' Notifier.crop_request_approved(@crop.requester, @crop) - when "rejected" + when 'rejected' Notifier.crop_request_rejected(@crop.requester, @crop) end end @@ -185,7 +185,7 @@ class CropsController < ApplicationController def crops q = Crop.approved.includes(:scientific_names, plantings: :photos) q = q.popular unless @sort == 'alpha' - q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page]) + q.order('LOWER(crops.name)').includes(:photos).paginate(page: params[:page]) end def requested_crops diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 2c4b2daab..80341035f 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -11,7 +11,7 @@ class FollowsController < ApplicationController flash[:notice] = "Followed #{@follow.followed.login_name}" redirect_to :back else - flash[:error] = "Already following or error while following." + flash[:error] = 'Already following or error while following.' redirect_to :back end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 5f7c5dac9..d5a8506d7 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -26,7 +26,7 @@ class LikesController < ApplicationController { id: like.likeable.id, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, 'like'), url: like_path(like, format: :json) } end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index c346eb8e3..e435ef08a 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -49,8 +49,8 @@ class MembersController < ApplicationController end EMAIL_TYPE_STRING = { - send_notification_email: "direct message notifications", - send_planting_reminder: "planting reminders" + send_notification_email: 'direct message notifications', + send_planting_reminder: 'planting reminders' }.freeze def unsubscribe diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 7c3c1f322..61dbea6dd 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -21,7 +21,7 @@ class NotificationsController < ApplicationController def new @notification = Notification.new @recipient = Member.find_by(id: params[:recipient_id]) - @subject = params[:subject] || "" + @subject = params[:subject] || '' end # GET /notifications/1/reply @@ -53,7 +53,7 @@ class NotificationsController < ApplicationController if @notification.save redirect_to notifications_path, notice: 'Message was successfully sent.' else - render action: "new" + render action: 'new' end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 3d642cd3d..c70da1443 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -12,8 +12,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def failure - flash[:alert] = "Authentication failed." - redirect_to request.env['omniauth.origin'] || "/" + flash[:alert] = 'Authentication failed.' + redirect_to request.env['omniauth.origin'] || '/' end private @@ -30,9 +30,9 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) if action.member_created? - raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s) + raise 'Invalid provider' unless %w(facebook twitter flickr).index(auth['provider'].to_s) - session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] + session["devise.#{auth['provider']}_data"] = request.env['omniauth.auth'] sign_in member redirect_to finish_signup_url(member) else diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 326cff21f..9c3e79dae 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -24,7 +24,7 @@ class OrderItemsController < ApplicationController def errors if @order_item.errors.empty? - "There was a problem with your order." + 'There was a problem with your order.' else @order_item.errors.full_messages.to_sentence end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 3bc9fe45c..0929d3948 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -42,7 +42,7 @@ class OrdersController < ApplicationController ) format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } else - format.html { render action: "show" } + format.html { render action: 'show' } end end end @@ -60,7 +60,7 @@ class OrdersController < ApplicationController @order.completed_at = Time.zone.now @order.record_paypal_details(params[:token]) else - flash[:alert] = "Could not complete your order. Please notify support." + flash[:alert] = 'Could not complete your order. Please notify support.' end else flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 9ffb98af8..ec270b2a6 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def letsencrypt # use your code here, not mine - render text: "y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" + render text: 'y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU' end end diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 126aaf9b3..35ef97632 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -3,7 +3,7 @@ class PhotoAssociationsController < ApplicationController respond_to :json, :html def destroy - raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class + raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class @photo = Photo.find_by!(id: params[:photo_id], owner: current_member) @item = Photographing.item(item_id, item_class) @item.photos.delete(@photo) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 57b10e5d8..3757894a8 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -75,10 +75,10 @@ class PhotosController < ApplicationController # Item with photos attached def item_to_link_to - raise "No item id provided" if item_id.nil? - raise "No item type provided" if item_type.nil? + raise 'No item id provided' if item_id.nil? + raise 'No item type provided' if item_type.nil? item_class = item_type.capitalize - raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class + raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class item_class.constantize.find_by!(id: params[:id], owner_id: current_member.id) end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 72e92b9fd..a83d6b466 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,7 +5,7 @@ class RegistrationsController < Devise::RegistrationsController @twitter_auth = current_member.auth('twitter') @flickr_auth = current_member.auth('flickr') @facebook_auth = current_member.auth('facebook') - render "edit" + render 'edit' end # we need this subclassed method so that Devise doesn't force people to @@ -32,7 +32,7 @@ class RegistrationsController < Devise::RegistrationsController sign_in @member, bypass: true redirect_to edit_member_registration_path else - render "edit" + render 'edit' end end @@ -40,7 +40,7 @@ class RegistrationsController < Devise::RegistrationsController if @member.destroy_with_password(params.require(:member)[:current_password]) redirect_to root_path else - render "edit" + render 'edit' end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 6106e0c75..ee1fddc3c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ class SessionsController < Devise::SessionsController def create super do |_resource| if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) - flash[:alert] = "There are crops waiting to be wrangled." + flash[:alert] = 'There are crops waiting to be wrangled.' end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 639d27686..6076d98ef 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper currency = Growstuff::Application.config.currency link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" - link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer" + link_to '(convert)', link, target: '_blank', rel: 'noopener noreferrer' end def build_alert_classes(alert_type = :info) @@ -37,7 +37,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier = "all") + def cache_key_for(klass, identifier = 'all') count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" @@ -102,7 +102,7 @@ module ApplicationHelper elsif planting t(".title.planting_#{type}", planting: planting.to_s) else - t(".title.default") + t('.title.default') end end diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index b99d687aa..c96ff8fa1 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -13,7 +13,7 @@ module CropsHelper if total_quantity != 0 "You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop." else - "You have an unknown quantity of seeds of this crop." + 'You have an unknown quantity of seeds of this crop.' end end diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index a72505558..cfbf90024 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,10 +1,10 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - "no description provided." + 'no description provided.' else truncate(garden.description, length: 130, separator: ' ', omission: '... ') do - link_to "Read more", garden_path(garden) + link_to 'Read more', garden_path(garden) end end end @@ -19,12 +19,12 @@ module GardensHelper def display_garden_plantings(plantings) if plantings.blank? - "None" + 'None' else output = '

    ' plantings.each do |planting| - output += "
  • " - output += planting.quantity.nil? ? "0 " : "#{planting.quantity} " + output += '
  • ' + output += planting.quantity.nil? ? '0 ' : "#{planting.quantity} " output += link_to planting.crop.name, planting.crop output += ", planted on #{planting.planted_at}
  • " end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 14277817b..6d9430b74 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -28,7 +28,7 @@ module HarvestsHelper end def display_harvest_description(harvest) - return "No description provided." if harvest.description.nil? + return 'No description provided.' if harvest.description.nil? harvest.description end end diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index f71dc8158..3e093d1e9 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -3,18 +3,18 @@ module PlantingsHelper if planting.finished_at.present? planting.finished_at elsif planting.finished - "Yes (no date specified)" + 'Yes (no date specified)' else - "(no date specified)" + '(no date specified)' end end def display_planted_from(planting) - planting.planted_from.present? ? planting.planted_from : "not specified" + planting.planted_from.present? ? planting.planted_from : 'not specified' end def display_planting_quantity(planting) - planting.quantity.present? ? planting.quantity : "not specified" + planting.quantity.present? ? planting.quantity : 'not specified' end def display_planting(planting) diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb index f0bc76dd9..7a7948dec 100644 --- a/app/helpers/seeds_helper.rb +++ b/app/helpers/seeds_helper.rb @@ -1,9 +1,9 @@ module SeedsHelper def display_seed_description(seed) if seed.description.nil? - "no description provided." + 'no description provided.' else - truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) } + truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to 'Read more', seed_path(seed) } end end end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 6c479f51f..f191263bc 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,11 +1,11 @@ class Notifier < ActionMailer::Base include NotificationsHelper - default from: "Growstuff " + default from: 'Growstuff ' def verifier unless ENV['RAILS_SECRET_TOKEN'] - raise "RAILS_SECRET_TOKEN environment variable"\ - "not set - have you created config/application.yml?" + raise 'RAILS_SECRET_TOKEN environment variable'\ + 'not set - have you created config/application.yml?' end ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN']) @@ -33,7 +33,7 @@ class Notifier < ActionMailer::Base message = { member_id: @member.id, type: :send_planting_reminder } @signed_message = verifier.generate(message) - mail(to: @member.email, subject: "What have you planted lately?") if @member.send_planting_reminder + mail(to: @member.email, subject: 'What have you planted lately?') if @member.send_planting_reminder end def new_crop_request(member, request) diff --git a/app/models/ability.rb b/app/models/ability.rb index 283bf45cc..e0e99dc30 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -36,7 +36,7 @@ class Ability # nobody should be able to view unapproved crops unless they # are wranglers or admins cannot :read, Crop - can :read, Crop, approval_status: "approved" + can :read, Crop, approval_status: 'approved' # scientific names should only be viewable if associated crop is approved cannot :read, ScientificName can :read, ScientificName do |sn| diff --git a/app/models/account.rb b/app/models/account.rb index 646e9db78..cfd4b2979 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -15,7 +15,7 @@ class Account < ActiveRecord::Base def paid_until_string if account_type.is_permanent_paid - "forever" + 'forever' elsif account_type.is_paid paid_until.to_s end diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb index aa960e1f4..1e989cbca 100644 --- a/app/models/alternate_name.rb +++ b/app/models/alternate_name.rb @@ -1,5 +1,5 @@ class AlternateName < ActiveRecord::Base - after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } + after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/comment.rb b/app/models/comment.rb index 7098e0b46..0f11bfb6f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ class Comment < ActiveRecord::Base belongs_to :author, class_name: 'Member' belongs_to :post - scope :post_order, -> { reorder("created_at ASC") } # for display on post page + scope :post_order, -> { reorder('created_at ASC') } # for display on post page after_create do recipient = post.author.id diff --git a/app/models/crop.rb b/app/models/crop.rb index 15787f6f1..4466e31e7 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -15,7 +15,7 @@ class Crop < ActiveRecord::Base has_many :photos, through: :plantings has_many :seeds has_many :harvests - has_many :plant_parts, -> { uniq.reorder("plant_parts.name") }, through: :harvests + has_many :plant_parts, -> { uniq.reorder('plant_parts.name') }, through: :harvests belongs_to :creator, class_name: 'Member' belongs_to :requester, class_name: 'Member' belongs_to :parent, class_name: 'Crop' @@ -26,12 +26,12 @@ class Crop < ActiveRecord::Base ## Scopes scope :recent, -> { approved.order(created_at: :desc) } scope :toplevel, -> { approved.where(parent_id: nil) } - scope :popular, -> { approved.reorder("plantings_count desc, lower(name) asc") } + scope :popular, -> { approved.reorder('plantings_count desc, lower(name) asc') } # ok on sqlite and psql, but not on mysql scope :randomized, -> { approved.reorder('random()') } - scope :pending_approval, -> { where(approval_status: "pending") } - scope :approved, -> { where(approval_status: "approved") } - scope :rejected, -> { where(approval_status: "rejected") } + scope :pending_approval, -> { where(approval_status: 'pending') } + scope :approved, -> { where(approval_status: 'approved') } + scope :rejected, -> { where(approval_status: 'rejected') } scope :interesting, -> { approved.has_photos.randomized } scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } @@ -53,17 +53,17 @@ class Crop < ActiveRecord::Base #################################### # Elastic search configuration - if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" + if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' include Elasticsearch::Model include Elasticsearch::Model::Callbacks # In order to avoid clashing between different environments, # use Rails.env as a part of index name (eg. development_growstuff) - index_name [Rails.env, "growstuff"].join('_') + index_name [Rails.env, 'growstuff'].join('_') settings index: { number_of_shards: 1 }, analysis: { tokenizer: { gs_edgeNGram_tokenizer: { - type: "edgeNGram", # edgeNGram: NGram match from the start of a token + type: 'edgeNGram', # edgeNGram: NGram match from the start of a token min_gram: 3, max_gram: 10, # token_chars: Elasticsearch will split on characters @@ -73,8 +73,8 @@ class Crop < ActiveRecord::Base }, analyzer: { gs_edgeNGram_analyzer: { - tokenizer: "gs_edgeNGram_tokenizer", - filter: ["lowercase"] + tokenizer: 'gs_edgeNGram_tokenizer', + filter: ['lowercase'] } } } do @@ -104,7 +104,7 @@ class Crop < ActiveRecord::Base # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) - __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" + __elasticsearch__.index_document if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' end # End Elasticsearch section @@ -148,10 +148,10 @@ class Crop < ActiveRecord::Base # value: count of how many times it's been used by harvests def popular_plant_parts PlantPart.joins(:harvests) - .where("crop_id = ?", id) - .order("count_harvests_id DESC") - .group("plant_parts.id", "plant_parts.name") - .count("harvests.id") + .where('crop_id = ?', id) + .order('count_harvests_id DESC') + .group('plant_parts.id', 'plant_parts.name') + .count('harvests.id') end def annual? @@ -167,15 +167,15 @@ class Crop < ActiveRecord::Base end def pending? - approval_status == "pending" + approval_status == 'pending' end def approved? - approval_status == "approved" + approval_status == 'approved' end def rejected? - approval_status == "rejected" + approval_status == 'rejected' end def approval_statuses @@ -183,11 +183,11 @@ class Crop < ActiveRecord::Base end def reasons_for_rejection - ["already in database", "not edible", "not enough information", "other"] + ['already in database', 'not edible', 'not enough information', 'other'] end def rejection_explanation - return rejection_notes if reason_for_rejection == "other" + return rejection_notes if reason_for_rejection == 'other' reason_for_rejection end @@ -212,7 +212,7 @@ class Crop < ActiveRecord::Base end def self.case_insensitive_name(name) - where(["lower(crops.name) = :value", { value: name.downcase }]) + where(['lower(crops.name) = :value', { value: name.downcase }]) end private @@ -235,11 +235,11 @@ class Crop < ActiveRecord::Base def must_be_rejected_if_rejected_reasons_present return if rejected? return unless reason_for_rejection.present? || rejection_notes.present? - errors.add(:approval_status, "must be rejected if a reason for rejection is present") + errors.add(:approval_status, 'must be rejected if a reason for rejection is present') end def must_have_meaningful_reason_for_rejection - return unless reason_for_rejection == "other" && rejection_notes.blank? - errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") + return unless reason_for_rejection == 'other' && rejection_notes.blank? + errors.add(:rejection_notes, 'must be added if the reason for rejection is "other"') end end diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index 2f646b6ab..477ac1a37 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -65,6 +65,6 @@ class CsvImporter @cropbot ||= Member.find_by!(login_name: 'cropbot') @cropbot rescue StandardError - raise "cropbot account not found: run rake db:seed" + raise 'cropbot account not found: run rake db:seed' end end diff --git a/app/models/follow.rb b/app/models/follow.rb index 557887cb6..b00a50138 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,6 +1,6 @@ class Follow < ActiveRecord::Base - belongs_to :follower, class_name: "Member" - belongs_to :followed, class_name: "Member" + belongs_to :follower, class_name: 'Member' + belongs_to :followed, class_name: 'Member' validates :follower_id, uniqueness: { scope: :followed_id } after_create do diff --git a/app/models/forum.rb b/app/models/forum.rb index 7cbc0d43d..47fea88cc 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -4,7 +4,7 @@ class Forum < ActiveRecord::Base friendly_id :name, use: %i(slugged finders) has_many :posts - belongs_to :owner, class_name: "Member" + belongs_to :owner, class_name: 'Member' def to_s name diff --git a/app/models/garden.rb b/app/models/garden.rb index 0c3378b00..3f7defffa 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -35,13 +35,13 @@ class Garden < ActiveRecord::Base allow_nil: true AREA_UNITS_VALUES = { - "square metres" => "square metre", - "square feet" => "square foot", - "hectares" => "hectare", - "acres" => "acre" + 'square metres' => 'square metre', + 'square feet' => 'square foot', + 'hectares' => 'hectare', + 'acres' => 'acre' }.freeze validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values, - message: "%s is not a valid area unit" }, + message: '%s is not a valid area unit' }, allow_nil: true, allow_blank: true diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 6bb9aa048..9d73ab100 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -7,22 +7,22 @@ class Harvest < ActiveRecord::Base # Constants UNITS_VALUES = { - "individual" => "individual", - "bunches" => "bunch", - "sprigs" => "sprig", - "handfuls" => "handful", - "litres" => "litre", - "pints" => "pint", - "quarts" => "quart", - "buckets" => "bucket", - "baskets" => "basket", - "bushels" => "bushel" + 'individual' => 'individual', + 'bunches' => 'bunch', + 'sprigs' => 'sprig', + 'handfuls' => 'handful', + 'litres' => 'litre', + 'pints' => 'pint', + 'quarts' => 'quart', + 'buckets' => 'bucket', + 'baskets' => 'basket', + 'bushels' => 'bushel' }.freeze WEIGHT_UNITS_VALUES = { - "kg" => "kg", - "lb" => "lb", - "oz" => "oz" + 'kg' => 'kg', + 'lb' => 'lb', + 'oz' => 'oz' }.freeze ## @@ -44,18 +44,18 @@ class Harvest < ActiveRecord::Base ## ## Validations validates :crop, approved: true - validates :crop, presence: { message: "must be present and exist in our database" } - validates :plant_part, presence: { message: "must be present and exist in our database" } + validates :crop, presence: { message: 'must be present and exist in our database' } + validates :plant_part, presence: { message: 'must be present and exist in our database' } validates :harvested_at, presence: true validates :quantity, allow_nil: true, numericality: { only_integer: false, greater_than_or_equal_to: 0 } validates :unit, allow_nil: true, allow_blank: true, inclusion: { - in: UNITS_VALUES.values, message: "%s is not a valid unit" + in: UNITS_VALUES.values, message: '%s is not a valid unit' } validates :weight_quantity, allow_nil: true, numericality: { only_integer: false } validates :weight_unit, allow_nil: true, allow_blank: true, inclusion: { - in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" + in: WEIGHT_UNITS_VALUES.values, message: '%s is not a valid unit' } validate :crop_must_match_planting validate :owner_must_match_planting @@ -71,7 +71,7 @@ class Harvest < ActiveRecord::Base def set_si_weight return if weight_unit.nil? weight_string = "#{weight_quantity} #{weight_unit}" - self.si_weight = Unit.new(weight_string).convert_to("kg").to_s("%0.3f").delete(" kg").to_f + self.si_weight = Unit.new(weight_string).convert_to('kg').to_s('%0.3f').delete(' kg').to_f end def cleanup_quantities @@ -94,11 +94,11 @@ class Harvest < ActiveRecord::Base def quantity_to_human return number_to_human(quantity.to_s, strip_insignificant_zeros: true) if quantity - "" + '' end def unit_to_human - return "" unless quantity + return '' unless quantity if unit == 'individual' 'individual' elsif quantity == 1 @@ -109,7 +109,7 @@ class Harvest < ActiveRecord::Base end def weight_to_human - return "" unless weight_quantity + return '' unless weight_quantity "weighing #{number_to_human(weight_quantity, strip_insignificant_zeros: true)} #{weight_unit}" end @@ -131,17 +131,17 @@ class Harvest < ActiveRecord::Base def crop_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:planting, "must be the same crop") unless crop == planting.crop + errors.add(:planting, 'must be the same crop') unless crop == planting.crop end def owner_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner + errors.add(:owner, 'of harvest must be the same as planting') unless owner == planting.owner end def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? - errors.add(:planting, "cannot be harvested before planting") unless harvested_at > planting.planted_at + errors.add(:planting, 'cannot be harvested before planting') unless harvested_at > planting.planted_at end end diff --git a/app/models/member.rb b/app/models/member.rb index 9828a005c..07840383a 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -25,8 +25,8 @@ class Member < ActiveRecord::Base has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy - has_many :follows, class_name: "Follow", foreign_key: "follower_id", dependent: :destroy - has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id", dependent: :destroy + has_many :follows, class_name: 'Follow', foreign_key: 'follower_id', dependent: :destroy + has_many :inverse_follows, class_name: 'Follow', foreign_key: 'followed_id', dependent: :destroy has_many :followed, through: :follows has_many :followers, through: :inverse_follows, source: :follower @@ -38,7 +38,7 @@ class Member < ActiveRecord::Base scope :recently_joined, -> { reorder(confirmed_at: :desc) } scope :wants_newsletter, -> { where(newsletter: true) } scope :interesting, -> { confirmed.located.recently_signed_in.has_plantings } - scope :has_plantings, -> { joins(:plantings).group("members.id") } + scope :has_plantings, -> { joins(:plantings).group('members.id') } # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, @@ -60,13 +60,13 @@ class Member < ActiveRecord::Base validates :tos_agreement, acceptance: { allow_nil: true, accept: true } validates :login_name, length: { - minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long" + minimum: 2, maximum: 25, message: 'should be between 2 and 25 characters long' }, exclusion: { - in: %w(growstuff admin moderator staff nearby), message: "name is reserved" + in: %w(growstuff admin moderator staff nearby), message: 'name is reserved' }, format: { - with: /\A\w+\z/, message: "may only include letters, numbers, or underscores" + with: /\A\w+\z/, message: 'may only include letters, numbers, or underscores' }, uniqueness: { case_sensitive: false @@ -82,7 +82,7 @@ class Member < ActiveRecord::Base # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations - after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } + after_create { |member| Garden.create(name: 'Garden', owner_id: member.id) } after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address @@ -98,7 +98,7 @@ class Member < ActiveRecord::Base end def role?(role_sym) - roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } + roles.any? { |r| r.name.gsub(/\s+/, '_').underscore.to_sym == role_sym } end def current_order @@ -179,11 +179,11 @@ class Member < ActiveRecord::Base end def self.login_name_or_email(login) - where(["lower(login_name) = :value OR lower(email) = :value", { value: login.downcase }]) + where(['lower(login_name) = :value OR lower(email) = :value', { value: login.downcase }]) end def self.case_insensitive_login_name(login) - where(["lower(login_name) = :value", { value: login.downcase }]) + where(['lower(login_name) = :value', { value: login.downcase }]) end def self.nearest_to(place) diff --git a/app/models/notification.rb b/app/models/notification.rb index 1b09b1e5e..071dcc2b0 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -16,7 +16,7 @@ class Notification < ActiveRecord::Base end def replace_blank_subject - self.subject = "(no subject)" if subject.nil? || subject =~ /^\s*$/ + self.subject = '(no subject)' if subject.nil? || subject =~ /^\s*$/ end def send_email diff --git a/app/models/order.rb b/app/models/order.rb index 53a309c35..1356df8be 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -8,7 +8,7 @@ class Order < ActiveRecord::Base # Validations validates :referral_code, format: { with: /\A[a-zA-Z0-9 ]*\z/, - message: "may only include letters and numbers" + message: 'may only include letters and numbers' } # @@ -68,19 +68,19 @@ class Order < ActiveRecord::Base def self.search(args = {}) if args[:for] case args[:by] - when "member" + when 'member' member = Member.with_deleted.find_by(login_name: args[:for]) return member.orders if member - when "order_id" + when 'order_id' order = Order.find_by(id: args[:for]) return [order] if order - when "paypal_token" + when 'paypal_token' order = Order.find_by(paypal_express_token: args[:for]) return [order] if order - when "paypal_payer_id" + when 'paypal_payer_id' order = Order.find_by(paypal_express_payer_id: args[:for]) return [order] if order - when "referral_code" + when 'referral_code' # coerce to uppercase return Order.where(referral_code: args[:for].upcase) end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 380fbff58..b693c2cd3 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -3,7 +3,7 @@ class OrderItem < ActiveRecord::Base belongs_to :product validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: "may only have one item." } + validates :order_id, uniqueness: { message: 'may only have one item.' } def price_must_be_greater_than_minimum @product = Product.find(product_id) diff --git a/app/models/planting.rb b/app/models/planting.rb index 6fd4aec17..165dcfcd3 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -30,7 +30,7 @@ class Planting < ActiveRecord::Base scope :one_per_owner, lambda { joins("JOIN members m ON (m.id=plantings.owner_id) LEFT OUTER JOIN plantings p2 - ON (m.id=p2.owner_id AND plantings.id < p2.id)").where("p2 IS NULL") + ON (m.id=p2.owner_id AND plantings.id < p2.id)").where('p2 IS NULL') } ## @@ -41,17 +41,17 @@ class Planting < ActiveRecord::Base ## ## Validations validates :garden, presence: true - validates :crop, presence: true, approved: { message: "must be present and exist in our database" } + validates :crop, presence: true, approved: { message: 'must be present and exist in our database' } validate :finished_must_be_after_planted validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :sunniness, allow_nil: true, allow_blank: true, inclusion: { - in: SUNNINESS_VALUES, message: "%s is not a valid sunniness value" + in: SUNNINESS_VALUES, message: '%s is not a valid sunniness value' } validates :planted_from, allow_nil: true, allow_blank: true, inclusion: { - in: PLANTED_FROM_VALUES, message: "%s is not a valid planting method" + in: PLANTED_FROM_VALUES, message: '%s is not a valid planting method' } def planting_slug @@ -64,7 +64,7 @@ class Planting < ActiveRecord::Base # location = garden owner + garden name, i.e. "Skud's backyard" def location - I18n.t("gardens.location", garden: garden.name, owner: garden.owner.login_name) + I18n.t('gardens.location', garden: garden.name, owner: garden.owner.login_name) end # stringify as "beet in Skud's backyard" or similar @@ -134,10 +134,10 @@ class Planting < ActiveRecord::Base # check that any finished_at date occurs after planted_at def finished_must_be_after_planted return unless planted_at && finished_at # only check if we have both - errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at + errors.add(:finished_at, 'must be after the planting date') unless planted_at < finished_at end def owner_must_match_garden_owner - errors.add(:owner, "must be the same as garden") unless owner == garden.owner + errors.add(:owner, 'must be the same as garden') unless owner == garden.owner end end diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb index bca467b5b..b25b06a76 100644 --- a/app/models/scientific_name.rb +++ b/app/models/scientific_name.rb @@ -1,5 +1,5 @@ class ScientificName < ActiveRecord::Base - after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } + after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/seed.rb b/app/models/seed.rb index 7abae922c..525bbf105 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -16,7 +16,7 @@ class Seed < ActiveRecord::Base # # Validations validates :crop, approved: true - validates :crop, presence: { message: "must be present and exist in our database" } + validates :crop, presence: { message: 'must be present and exist in our database' } validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :days_until_maturity_min, allow_nil: true, @@ -24,17 +24,17 @@ class Seed < ActiveRecord::Base validates :days_until_maturity_max, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :tradable_to, allow_nil: false, allow_blank: false, - inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\ - "locally, nationally, or internationally" } + inclusion: { in: TRADABLE_TO_VALUES, message: 'You may only trade seed nowhere, '\ + 'locally, nationally, or internationally' } validates :organic, allow_nil: false, allow_blank: false, - inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\ + inclusion: { in: ORGANIC_VALUES, message: 'You must say whether the seeds '\ "are organic or not, or that you don't know" } validates :gmo, allow_nil: false, allow_blank: false, - inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\ + inclusion: { in: GMO_VALUES, message: 'You must say whether the seeds are '\ "genetically modified or not, or that you don't know" } validates :heirloom, allow_nil: false, allow_blank: false, - inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ - "are heirloom, hybrid, or unknown" } + inclusion: { in: HEIRLOOM_VALUES, message: 'You must say whether the seeds'\ + 'are heirloom, hybrid, or unknown' } # # Delegations diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index af6085737..82d6933fb 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -1,21 +1,21 @@ class CropSearchService # Crop.search(string) def self.search(query) - if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" - search_str = query.nil? ? "" : query.downcase + if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + search_str = query.nil? ? '' : query.downcase response = Crop.__elasticsearch__.search( # Finds documents which match any field, but uses the _score from # the best field insead of adding up _score from each field. query: { multi_match: { query: search_str.to_s, - analyzer: "standard", - fields: ["name", - "scientific_names.scientific_name", - "alternate_names.name"] + analyzer: 'standard', + fields: ['name', + 'scientific_names.scientific_name', + 'alternate_names.name'] } }, filter: { - term: { approval_status: "approved" } + term: { approval_status: 'approved' } }, size: 50 ) @@ -26,7 +26,7 @@ class CropSearchService # collection, so it matches what we get from elasticsearch and we can # manipulate it in the same ways (eg. deleting elements without deleting # the whole record from the db) - matches = Crop.approved.where("name ILIKE ?", "%#{query}%").to_a + matches = Crop.approved.where('name ILIKE ?', "%#{query}%").to_a # we want to make sure that exact matches come first, even if not # using elasticsearch (eg. in development) diff --git a/config.rb b/config.rb index f816551c1..89ca5df52 100644 --- a/config.rb +++ b/config.rb @@ -1,11 +1,11 @@ # Require any additional compass plugins here. # rubocop:disable Lint/UselessAssignment # Set this to the root of your project when deployed: -http_path = "/" -css_dir = "app/assets/stylesheets" -sass_dir = "app/assets/stylesheets" -javascripts_dir = "app/assets/javascripts" -images_dir = "app/assets/images" +http_path = '/' +css_dir = 'app/assets/stylesheets' +sass_dir = 'app/assets/stylesheets' +javascripts_dir = 'app/assets/javascripts' +images_dir = 'app/assets/images' # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed diff --git a/config/application.rb b/config/application.rb index 5280dce7e..36ccf09e5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -42,10 +42,10 @@ module Growstuff config.i18n.fallbacks = [:en] # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" + config.encoding = 'utf-8' # Configure a default account type - config.default_account_type = "Free" + config.default_account_type = 'Free' # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] @@ -84,9 +84,9 @@ module Growstuff # Growstuff-specific configuration variables config.currency = 'AUD' - config.bot_email = "noreply@growstuff.org" + config.bot_email = 'noreply@growstuff.org' config.user_agent = 'Growstuff' - config.user_agent_email = "info@growstuff.org" + config.user_agent_email = 'info@growstuff.org' Gibbon::API.api_key = ENV['GROWSTUFF_MAILCHIMP_APIKEY'] || 'notarealkey' # API key can't be blank or tests fail diff --git a/config/environments/test.rb b/config/environments/test.rb index bf4135f64..b3f6b46d5 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -20,7 +20,7 @@ Growstuff::Application.configure do # Configure static asset server for tests with Cache-Control for performance config.serve_static_files = true - config.static_cache_control = "public, max-age=3600" + config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching config.consider_all_requests_local = true @@ -53,7 +53,7 @@ Growstuff::Application.configure do end config.after_initialize do - require "active_merchant/ext/paypal_bogus_gateway" + require 'active_merchant/ext/paypal_bogus_gateway' ActiveMerchant::Billing::Base.mode = :test ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new @@ -63,7 +63,7 @@ end Geocoder.configure(lookup: :test) Geocoder::Lookup::Test.add_stub( - "Amundsen-Scott Base, Antarctica", [ + 'Amundsen-Scott Base, Antarctica', [ { 'latitude' => -90.0, 'longitude' => 0.0 @@ -72,7 +72,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - "Philippines", [ + 'Philippines', [ { 'latitude' => 12.7503486, 'longitude' => 122.7312101, @@ -86,7 +86,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - "Greenwich, UK", [ + 'Greenwich, UK', [ { 'latitude' => 51.483061, 'longitude' => -0.004151 @@ -95,7 +95,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - "Edinburgh", [ + 'Edinburgh', [ { 'latitude' => 55.953252, 'longitude' => -3.188267 @@ -104,7 +104,7 @@ Geocoder::Lookup::Test.add_stub( ) # Unknown location -Geocoder::Lookup::Test.add_stub("Tatooine", []) +Geocoder::Lookup::Test.add_stub('Tatooine', []) Capybara.configure do |config| config.always_include_port = true @@ -115,12 +115,12 @@ OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(provider: 'facebook', uid: '123545', info: { - name: "John Testerson", + name: 'John Testerson', nickname: 'JohnnyT', email: 'example.oauth.facebook@example.com', image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, credentials: { - token: "token", - secret: "donttell" + token: 'token', + secret: 'donttell' }) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ec28eb983..40f94b72a 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -5,7 +5,7 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = "Growstuff " + config.mailer_sender = 'Growstuff ' config.secret_key = ENV['RAILS_SECRET_TOKEN'] diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index afe41f574..a16483e35 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -4,9 +4,9 @@ Geocoder.configure( units: :km, timeout: 10, http_headers: { - "User-Agent" => + 'User-Agent' => "#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}", - "From" => Growstuff::Application.config.user_agent_email + 'From' => Growstuff::Application.config.user_agent_email } ) # This configuration takes precedence over environment/test.rb diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index 3f3adf454..f6f268bc8 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1,9 +1,9 @@ Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' -Date::DATE_FORMATS[:default] = "%B %d, %Y" +Date::DATE_FORMATS[:default] = '%B %d, %Y' -Time::DATE_FORMATS[:date] = "%B %d, %Y" -Date::DATE_FORMATS[:date] = "%B %d, %Y" +Time::DATE_FORMATS[:date] = '%B %d, %Y' +Date::DATE_FORMATS[:date] = '%B %d, %Y' -Date::DATE_FORMATS[:ymd] = "%Y-%m-%d" +Date::DATE_FORMATS[:ymd] = '%Y-%m-%d' Time::DATE_FORMATS[:datetime] = '%B %d, %Y at %H:%M' diff --git a/config/routes.rb b/config/routes.rb index f1588fa17..f4a22a2c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,10 @@ Growstuff::Application.routes.draw do resources :plant_parts devise_for :members, controllers: { - registrations: "registrations", - passwords: "passwords", - sessions: "sessions", - omniauth_callbacks: "omniauth_callbacks" + registrations: 'registrations', + passwords: 'passwords', + sessions: 'sessions', + omniauth_callbacks: 'omniauth_callbacks' } devise_scope :member do get '/members/unsubscribe/:message' => 'members#unsubscribe', as: 'unsubscribe_member' @@ -85,7 +85,7 @@ Growstuff::Application.routes.draw do resources :likes, only: %i(create destroy) - get "home/index" + get 'home/index' root to: 'home#index' get 'auth/:provider/callback' => 'authentications#create' diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index c1a0f95fd..4f891ff40 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -4,7 +4,7 @@ if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') RVM.use_from_path! File.dirname(File.dirname(__FILE__)) rescue LoadError # RVM is unavailable at this point. - raise "RVM ruby lib is currently unavailable." + raise 'RVM ruby lib is currently unavailable.' end end diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb index cf02cbe2a..4eac342d8 100644 --- a/db/migrate/20120903092956_devise_create_users.rb +++ b/db/migrate/20120903092956_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable - t.string :email, null: false, default: "" - t.string :encrypted_password, null: false, default: "" + t.string :email, null: false, default: '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb index 07b1e0879..b338f43ef 100644 --- a/db/migrate/20150201053200_add_approval_status_to_crops.rb +++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb @@ -1,5 +1,5 @@ class AddApprovalStatusToCrops < ActiveRecord::Migration def change - add_column :crops, :approval_status, :string, default: "approved" + add_column :crops, :approval_status, :string, default: 'approved' end end diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb index 149001927..dce1225aa 100644 --- a/db/migrate/20171105011017_set_prediction_data.rb +++ b/db/migrate/20171105011017_set_prediction_data.rb @@ -1,8 +1,8 @@ class SetPredictionData < ActiveRecord::Migration def up - say "Updating all plantings time to first harvest" + say 'Updating all plantings time to first harvest' Planting.all.each(&:update_harvest_days) - say "Updating crop median time to first harvest, and lifespan" + say 'Updating crop median time to first harvest, and lifespan' Crop.all.each do |crop| crop.update_lifespan_medians crop.update_harvest_medians diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb index 8054ba9cd..ed099382c 100644 --- a/db/migrate/20171129041341_create_photographings.rb +++ b/db/migrate/20171129041341_create_photographings.rb @@ -18,19 +18,19 @@ class CreatePhotographings < ActiveRecord::Migration end def migrate_data - say "migrating garden photos" + say 'migrating garden photos' GardensPhoto.all.each do |g| Photographing.create! photo_id: g.photo_id, photographable_id: g.garden_id, photographable_type: 'Garden' end - say "migrating planting photos" + say 'migrating planting photos' PhotosPlanting.all.each do |p| Photographing.create! photo_id: p.photo_id, photographable_id: p.planting_id, photographable_type: 'Planting' end - say "migrating harvest photos" + say 'migrating harvest photos' HarvestsPhoto.all.each do |h| Photographing.create! photo_id: h.photo_id, photographable_id: h.harvest_id, photographable_type: 'Harvest' end - say "migrating seed photos" + say 'migrating seed photos' PhotosSeed.all.each do |s| Photographing.create! photo_id: s.photo_id, photographable_id: s.seed_id, photographable_type: 'Seed' end diff --git a/db/seeds.rb b/db/seeds.rb index be885a352..637467ee3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -23,7 +23,7 @@ def load_data end end - puts "Done!" + puts 'Done!' end def load_crops @@ -34,39 +34,39 @@ def load_crops CsvImporter.new.import_crop(row) end end - puts "Finished loading crops" + puts 'Finished loading crops' end def load_roles - puts "Creating admin role..." + puts 'Creating admin role...' @admin = Role.create(name: 'Admin') - puts "Creating crop wrangler role..." + puts 'Creating crop wrangler role...' @wrangler = Role.create(name: 'Crop Wrangler') end def load_basic_account_types puts "Adding 'free' and 'staff' account types..." AccountType.create!( - name: "Free", + name: 'Free', is_paid: false, is_permanent_paid: false ) AccountType.create!( - name: "Staff", + name: 'Staff', is_paid: true, is_permanent_paid: true ) end def load_test_users # rubocop:disable Metrics/AbcSize - puts "Loading test users..." + puts 'Loading test users...' # Open suburb csv source_path = Rails.root.join('db', 'seeds') begin suburb_file = File.open("#{source_path}/suburbs.csv") rescue StandardError - puts "Warning: unable to open suburbs.csv" + puts 'Warning: unable to open suburbs.csv' end # rake parameter (eg. 'rake db:seed member_size=10') @@ -105,15 +105,15 @@ def load_test_users # rubocop:disable Metrics/AbcSize ) end - puts "Finished loading test users" + puts 'Finished loading test users' end def load_admin_users - puts "Adding admin and crop wrangler members..." + puts 'Adding admin and crop wrangler members...' @admin_user = Member.new( - login_name: "admin1", - email: "admin1@example.com", - password: "password1", + login_name: 'admin1', + email: 'admin1@example.com', + password: 'password1', tos_agreement: true ) @admin_user.skip_confirmation! @@ -121,9 +121,9 @@ def load_admin_users @admin_user.save! @wrangler_user = Member.new( - login_name: "wrangler1", - email: "wrangler1@example.com", - password: "password1", + login_name: 'wrangler1', + email: 'wrangler1@example.com', + password: 'password1', tos_agreement: true ) @wrangler_user.skip_confirmation! @@ -133,7 +133,7 @@ end def create_cropbot @cropbot_user = Member.new( - login_name: "cropbot", + login_name: 'cropbot', email: Growstuff::Application.config.bot_email, password: SecureRandom.urlsafe_base64(64), tos_agreement: true @@ -141,43 +141,43 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") + @cropbot_user.account.account_type = AccountType.find_by(name: 'Staff') @cropbot_user.account.save end def load_paid_account_types puts "Adding 'paid' and 'seed' account types..." @paid_account = AccountType.create!( - name: "Paid", + name: 'Paid', is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.create!( - name: "Seed", + name: 'Seed', is_paid: true, is_permanent_paid: true ) end def load_products - puts "Adding products..." + puts 'Adding products...' Product.create!( - name: "Annual subscription", - description: "Paid account, 1 year", + name: 'Annual subscription', + description: 'Paid account, 1 year', min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.create!( - name: "Seed account", - description: "Paid account, in perpetuity", + name: 'Seed account', + description: 'Paid account, in perpetuity', min_price: 15_000, account_type_id: @seed_account.id ) end def load_plant_parts - puts "Loading plant parts..." + puts 'Loading plant parts...' plant_parts = [ 'fruit', 'flower', diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index de274dc35..f3b22c24b 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -14,7 +14,7 @@ class Growstuff::OauthSignupAction m.password = Devise.friendly_token[0, 20] # First, try the nickname or friendly generate from the email - m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore + m.login_name = auth.info.nickname || auth.info.email.split('@').first.gsub(/[^A-Za-z]+/, '_').underscore # Do we have a collision with an existing account? Generate a 20 character long random name # so the user can update it later diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 03b2e3d0e..8b3c670ff 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -1,12 +1,12 @@ namespace :growstuff do - desc "Add an admin user, by name" + desc 'Add an admin user, by name' # usage: rake growstuff:admin_user name=skud task admin_user: :environment do add_role_to_member! ENV['name'], 'admin' end - desc "Add a crop wrangler user, by name" + desc 'Add a crop wrangler user, by name' # usage: rake growstuff:cropwrangler_user name=skud task cropwrangler_user: :environment do @@ -15,7 +15,7 @@ namespace :growstuff do def add_role_to_member!(login_name, role_name) unless login_name && role_name - raise "Usage: rake growstuff:[rolename] name=[username] "\ + raise 'Usage: rake growstuff:[rolename] name=[username] '\ "\n (login name is case-sensitive)\n" end member = Member.find_by!(login_name: login_name) @@ -23,23 +23,23 @@ namespace :growstuff do member.roles << role end - desc "Upload crops from a CSV file" + desc 'Upload crops from a CSV file' # usage: rake growstuff:import_crops file=filename.csv task import_crops: :environment do require 'csv' - @file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv" + @file = ENV['file'] or raise 'Usage: rake growstuff:import_crops file=file.csv' puts "Loading crops from #{@file}..." CSV.foreach(@file) do |row| CsvImporter.new.import_crop(row) end Rails.cache.delete('full_crop_hierarchy') - puts "Finished loading crops" + puts 'Finished loading crops' end - desc "Send planting reminder email" + desc 'Send planting reminder email' # usage: rake growstuff:send_planting_reminder task send_planting_reminder: :environment do @@ -58,7 +58,7 @@ namespace :growstuff do end end - desc "Depopulate Null Island" + desc 'Depopulate Null Island' # this fixes up anyone who has erroneously wound up with a 0,0 lat/long task depopulate_null_island: :environment do Member.find_each do |m| @@ -69,9 +69,9 @@ namespace :growstuff do end end - desc "One-off tasks needed at various times and kept for posterity" + desc 'One-off tasks needed at various times and kept for posterity' namespace :oneoff do - desc "May 2013: replace any empty notification subjects with (no subject)" + desc 'May 2013: replace any empty notification subjects with (no subject)' task empty_subjects: :environment do # this is inefficient as it checks every Notification, but the # site is small and there aren't many of them, so it shouldn't matter @@ -82,81 +82,81 @@ namespace :growstuff do end end - desc "May 2013: replace any empty garden names with Garden" + desc 'May 2013: replace any empty garden names with Garden' task empty_garden_names: :environment do # this is inefficient as it checks every Garden, but the # site is small and there aren't many of them, so it shouldn't matter # for this one-off script. Garden.all.each do |g| if g.name.nil? or g.name =~ /^\s*$/ - g.name = "Garden" + g.name = 'Garden' g.save end end end - desc "June 2013: create account types and products." + desc 'June 2013: create account types and products.' task setup_shop: :environment do - puts "Adding account types..." + puts 'Adding account types...' AccountType.find_or_create_by( - name: "Free", + name: 'Free', is_paid: false, is_permanent_paid: false ) @paid_account = AccountType.find_or_create_by( - name: "Paid", + name: 'Paid', is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.find_or_create_by( - name: "Seed", + name: 'Seed', is_paid: true, is_permanent_paid: true ) @staff_account = AccountType.find_or_create_by( - name: "Staff", + name: 'Staff', is_paid: true, is_permanent_paid: true ) - puts "Adding products..." + puts 'Adding products...' Product.find_or_create_by( - name: "Annual subscription", - description: "An annual subscription gives you access "\ - "to paid account features for one year. Does not auto-renew.", + name: 'Annual subscription', + description: 'An annual subscription gives you access '\ + 'to paid account features for one year. Does not auto-renew.', min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.find_or_create_by( - name: "Seed account", - description: "A seed account helps Growstuff grow in its "\ - "early days. It gives you all the features of "\ - "a paid account, in perpetuity. This account "\ - "type never expires.", + name: 'Seed account', + description: 'A seed account helps Growstuff grow in its '\ + 'early days. It gives you all the features of '\ + 'a paid account, in perpetuity. This account '\ + 'type never expires.', min_price: 15_000, account_type_id: @seed_account.id ) - puts "Giving each member an account record..." + puts 'Giving each member an account record...' Member.all.each do |m| Account.create(member_id: m.id) unless m.account end - puts "Making Skud a staff account..." + puts 'Making Skud a staff account...' @skud = Member.find_by(login_name: 'Skud') if @skud @skud.account.account_type = @staff_account @skud.account.save end - puts "Done setting up shop." + puts 'Done setting up shop.' end - desc "June 2013: replace nil account_types with free accounts" + desc 'June 2013: replace nil account_types with free accounts' task nil_account_type: :environment do - free = AccountType.find_by(name: "Free") - raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ + free = AccountType.find_by(name: 'Free') + raise 'Free account type not found: run rake growstuff:oneoff:setup_shop'\ unless free Account.all.each do |a| unless a.account_type @@ -166,7 +166,7 @@ namespace :growstuff do end end - desc "July 2013: replace nil seed.tradable_to with nowhere" + desc 'July 2013: replace nil seed.tradable_to with nowhere' task tradable_to_nowhere: :environment do Seed.all.each do |s| unless s.tradable_to @@ -176,18 +176,18 @@ namespace :growstuff do end end - desc "August 2013: set up plantings_count cache on crop" + desc 'August 2013: set up plantings_count cache on crop' task reset_crop_plantings_count: :environment do Crop.find_each do |c| Crop.reset_counters c.id, :plantings end end - desc "August 2013: set default creator on existing crops" + desc 'August 2013: set default creator on existing crops' task set_default_crop_creator: :environment do - cropbot = Member.find_by(login_name: "cropbot") - raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot - cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice + cropbot = Member.find_by(login_name: 'cropbot') + raise 'cropbot not found: create cropbot member on site or run rake db:seed' unless cropbot + cropbot.account.account_type = AccountType.find_by(name: 'Staff') # set this just because it's nice cropbot.account.save Crop.find_each do |crop| unless crop.creator @@ -203,7 +203,7 @@ namespace :growstuff do end end - desc "August 2013: set planting owner" + desc 'August 2013: set planting owner' task set_planting_owner: :environment do Planting.find_each do |p| p.owner = p.garden.owner @@ -211,14 +211,14 @@ namespace :growstuff do end end - desc "August 2013: initialize member planting counter" + desc 'August 2013: initialize member planting counter' task initialize_member_planting_count: :environment do Member.find_each do |m| Member.reset_counters m.id, :plantings end end - desc "October 2013: set garden locations to member locations" + desc 'October 2013: set garden locations to member locations' task initialize_garden_locations: :environment do Member.located.find_each do |m| m.gardens.each do |g| @@ -231,7 +231,7 @@ namespace :growstuff do end end - desc "October 2013: import initial plant parts" + desc 'October 2013: import initial plant parts' task import_plant_parts: :environment do plant_parts = [ 'fruit', @@ -252,7 +252,7 @@ namespace :growstuff do end end - desc "July 2014: set planting_count to 0 by default, not nil" + desc 'July 2014: set planting_count to 0 by default, not nil' task zero_plantings_count: :environment do Crop.find_each do |c| if c.plantings_count.nil? @@ -262,32 +262,32 @@ namespace :growstuff do end end - desc "August 2014: fix ping to pint in database" + desc 'August 2014: fix ping to pint in database' task ping_to_pint: :environment do Harvest.find_each do |h| - if h.unit == "ping" - h.unit = "pint" + if h.unit == 'ping' + h.unit = 'pint' h.save end end end - desc "October 2014: remove unused photos" + desc 'October 2014: remove unused photos' task remove_unused_photos: :environment do Photo.find_each(&:destroy_if_unused) end - desc "October 2014: generate crops_posts records for existing posts" + desc 'October 2014: generate crops_posts records for existing posts' task generate_crops_posts_records: :environment do Post.find_each(&:save) end - desc "October 2014: add alternate names for crops" + desc 'October 2014: add alternate names for crops' task add_alternate_names: :environment do require 'csv' - file = "db/seeds/alternate_names_201410.csv" + file = 'db/seeds/alternate_names_201410.csv' puts "Loading alternate names from #{file}..." - cropbot = Member.find_by(login_name: "cropbot") + cropbot = Member.find_by(login_name: 'cropbot') CSV.foreach(file) do |row| _crop_id, crop_name, alternate_names = row next if alternate_names.blank? @@ -305,7 +305,7 @@ namespace :growstuff do end end - desc "January 2015: fill in si_weight column" + desc 'January 2015: fill in si_weight column' task populate_si_weight: :environment do Harvest.find_each do |h| h.set_si_weight @@ -313,7 +313,7 @@ namespace :growstuff do end end - desc "January 2015: build Elasticsearch index" + desc 'January 2015: build Elasticsearch index' task elasticsearch_create_index: :environment do Crop.__elasticsearch__.create_index! force: true Crop.import diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake index 7543404b2..07113f935 100644 --- a/lib/tasks/hooks.rake +++ b/lib/tasks/hooks.rake @@ -1,4 +1,4 @@ -desc "Install git hooks" +desc 'Install git hooks' task :hooks do FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', force: true diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index 04fa8001b..4ed2ae2ee 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -1,10 +1,10 @@ namespace :i18n do - desc "sort all i18n locale keys" + desc 'sort all i18n locale keys' task :normalize do `i18n-tasks normalize` end - desc "translate haml strings into i18 en locale using haml-i18n-extractor" + desc 'translate haml strings into i18 en locale using haml-i18n-extractor' task :extractor, [:haml_path] do |_t, args| require 'haml-i18n-extractor' haml_path = args[:haml_path] diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 1120f6ca9..7ab937e27 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -10,13 +10,13 @@ begin rescue LoadError end -desc "Run static code-quality checks" +desc 'Run static code-quality checks' task :static do system('script/check_static') end namespace :spec do - desc "Run only unit tests" + desc 'Run only unit tests' task unit: ['jasmine:ci'] do suites = %w(controllers helpers lib mailers models requests routing views) system('rspec', *suites.collect { |s| "spec/#{s}" }) diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb index d2a20d67a..375d03117 100755 --- a/script/heroku_maintenance.rb +++ b/script/heroku_maintenance.rb @@ -13,9 +13,9 @@ else end case ARGV[0] -when "on" +when 'on' maintenance_state = true -when "off" +when 'off' maintenance_state = false else abort "usage: #{$PROGRAM_NAME} (on|off)" diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index 2b4222f1d..a63890bf3 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -4,7 +4,7 @@ describe AccountsController do login_member(:admin_member) def valid_attributes - { "paid_until" => Time.now } + { 'paid_until' => Time.now } end def create_account diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index fb475b34c..0a23dd88a 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' describe Admin::OrdersController do login_member(:admin_member) - describe "GET search" do - it "assigns @orders" do + describe 'GET search' do + it 'assigns @orders' do order = FactoryBot.create(:order) get :search, search_by: 'order_id', search_text: order.id assigns(:orders).should eq([order]) end - it "sets an error message if nothing found" do + it 'sets an error message if nothing found' do get :search, search_by: 'order_id', search_text: 'foo' flash[:alert].should have_text "Couldn't find order with" end diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index 9f134bbab..e123b2b02 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe AdminController do login_member(:admin_member) - describe "GET admin/newsletter" do + describe 'GET admin/newsletter' do it 'fetches the admin newsletter page' do get :newsletter response.should be_success - response.should render_template("admin/newsletter") + response.should render_template('admin/newsletter') end it 'assigns @members' do diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index daa50a811..288e652b3 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -5,13 +5,13 @@ describe Charts::GardensController do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context "when not signed in" do + context 'when not signed in' do describe 'GET timeline' do before { get :timeline, garden_id: garden.to_param } it { expect(response).to be_success } end end - context "when signed in" do + context 'when signed in' do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 2d265de5f..c705917ce 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -11,106 +11,106 @@ describe CommentsController do def valid_attributes @post = FactoryBot.create(:post) - { post_id: @post.id, body: "some text" } + { post_id: @post.id, body: 'some text' } end - describe "GET RSS feed" do + describe 'GET RSS feed' do let!(:first_comment) { FactoryBot.create :comment, created_at: 10.days.ago } let!(:last_comment) { FactoryBot.create :comment, created_at: 4.minutes.ago } - describe "returns an RSS feed" do - before { get :index, format: "rss" } + describe 'returns an RSS feed' do + before { get :index, format: 'rss' } it { is_expected.to be_success } - it { is_expected.to render_template("comments/index") } - it { expect(response.content_type).to eq("application/rss+xml") } + it { is_expected.to render_template('comments/index') } + it { expect(response.content_type).to eq('application/rss+xml') } it { expect(assigns(:comments)).to eq([last_comment, first_comment]) } end end - describe "GET new" do + describe 'GET new' do let(:post) { FactoryBot.create(:post) } - describe "with valid params" do + describe 'with valid params' do before { get :new, post_id: post.id } - it "picks up post from params" do + it 'picks up post from params' do assigns(:post).should eq(post) end let(:old_comment) { FactoryBot.create(:comment, post: post) } - it "assigns the old comments as @comments" do + it 'assigns the old comments as @comments' do assigns(:comments).should eq [old_comment] end end - it "dies if no post specified" do + it 'dies if no post specified' do get :new expect(response).not_to be_success end end - describe "GET edit" do + describe 'GET edit' do let(:post) { FactoryBot.create(:post) } before { get :edit, id: comment.to_param } - describe "my comment" do + describe 'my comment' do let!(:comment) { FactoryBot.create :comment, author: member, post: post } let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) } - it "assigns previous comments as @comments" do + it 'assigns previous comments as @comments' do expect(assigns(:comments)).to eq([comment, old_comment]) end end - describe "not my comment" do + describe 'not my comment' do let(:comment) { FactoryBot.create :comment, post: post } it { expect(response).not_to be_success } end end - describe "PUT update" do + describe 'PUT update' do before { put :update, id: comment.to_param, comment: valid_attributes } - describe "my comment" do + describe 'my comment' do let(:comment) { FactoryBot.create :comment, author: member } it "redirects to the comment's post" do expect(response).to redirect_to(comment.post) end end - describe "not my comment" do + describe 'not my comment' do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } end - describe "attempting to change post_id" do + describe 'attempting to change post_id' do let(:post) { FactoryBot.create :post, subject: 'our post' } let(:other_post) { FactoryBot.create :post, subject: 'the other post' } - let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } } + let(:valid_attributes) { { post_id: other_post.id, body: 'kōrero' } } let(:comment) { FactoryBot.create :comment, author: member, post: post } - it "does not change post_id" do + it 'does not change post_id' do comment.reload expect(comment.post_id).to eq(post.id) end end end - describe "DELETE destroy" do + describe 'DELETE destroy' do before { delete :destroy, id: comment.to_param } - describe "my comment" do + describe 'my comment' do let(:comment) { FactoryBot.create :comment, author: member } - it "redirects to the post the comment was on" do + it 'redirects to the post the comment was on' do expect(response).to redirect_to(comment.post) end end - describe "not my comment" do + describe 'not my comment' do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 5b682f6c2..ab6aaced4 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -5,7 +5,7 @@ describe CropsController do def valid_attributes { - name: "Tomato", + name: 'Tomato', en_wikipedia_url: 'http://en.wikipedia.org/wiki/Tomato', approval_status: 'approved' } @@ -13,37 +13,37 @@ describe CropsController do subject { response } - describe "GET crop wrangler homepage" do + describe 'GET crop wrangler homepage' do describe 'fetches the crop wrangler homepage' do before { get :wrangle } it { is_expected.to be_success } - it { is_expected.to render_template("crops/wrangle") } + it { is_expected.to render_template('crops/wrangle') } it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) } end end - describe "GET crop hierarchy " do + describe 'GET crop hierarchy ' do describe 'fetches the crop hierarchy page' do before { get :hierarchy } it { is_expected.to be_success } - it { is_expected.to render_template("crops/hierarchy") } + it { is_expected.to render_template('crops/hierarchy') } end end - describe "GET crop search" do + describe 'GET crop search' do describe 'fetches the crop search page' do before { get :search } it { is_expected.to be_success } - it { is_expected.to render_template("crops/search") } + it { is_expected.to render_template('crops/search') } end end - describe "GET RSS feed" do - describe "returns an RSS feed" do - before { get :index, format: "rss" } + describe 'GET RSS feed' do + describe 'returns an RSS feed' do + before { get :index, format: 'rss' } it { is_expected.to be_success } - it { is_expected.to render_template("crops/index") } - it { expect(response.content_type).to eq("application/rss+xml") } + it { is_expected.to render_template('crops/index') } + it { expect(response.content_type).to eq('application/rss+xml') } end end end diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index 5c59473cb..995c4aabd 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -5,9 +5,9 @@ describe ForumsController do def valid_attributes { - "name" => "MyString", - "description" => "Something", - "owner_id" => 1 + 'name' => 'MyString', + 'description' => 'Something', + 'owner_id' => 1 } end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 2e31f2d78..4d4c77d8e 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -5,7 +5,7 @@ RSpec.describe GardensController, type: :controller do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context "when not signed in" do + context 'when not signed in' do describe 'GET new' do before { get :new, id: garden.to_param } it { expect(response).to redirect_to(new_member_session_path) } @@ -37,7 +37,7 @@ RSpec.describe GardensController, type: :controller do end end end - context "when signed in" do + context 'when signed in' do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 705f954b5..1dbdfe431 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -12,7 +12,7 @@ describe HarvestsController do } end - describe "GET index" do + describe 'GET index' do let(:member1) { FactoryBot.create(:member) } let(:member2) { FactoryBot.create(:member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -20,7 +20,7 @@ describe HarvestsController do let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } - describe "assigns all harvests as @harvests" do + describe 'assigns all harvests as @harvests' do before { get :index, {} } it { assigns(:harvests).should =~ [harvest1, harvest2] } end @@ -31,68 +31,68 @@ describe HarvestsController do it { expect(assigns(:harvests)).to eq [harvest1] } end - describe "picks up crop from params and shows the harvests for the crop only" do + describe 'picks up crop from params and shows the harvests for the crop only' do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:harvests)).to eq [harvest2] } end - describe "generates a csv" do - before { get :index, format: "csv" } + describe 'generates a csv' do + before { get :index, format: 'csv' } it { expect(response.status).to eq 200 } end end - describe "GET show" do + describe 'GET show' do let(:harvest) { Harvest.create! valid_attributes } - describe "assigns the requested harvest as @harvest" do + describe 'assigns the requested harvest as @harvest' do before { get :show, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe "GET new" do + describe 'GET new' do before { get :new, {} } - describe "assigns a new harvest as @harvest" do + describe 'assigns a new harvest as @harvest' do it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - describe "sets the date of the harvest to today" do + describe 'sets the date of the harvest to today' do it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end - describe "GET edit" do + describe 'GET edit' do let(:harvest) { Harvest.create! valid_attributes } - describe "assigns the requested harvest as @harvest" do + describe 'assigns the requested harvest as @harvest' do before { get :edit, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe "POST create" do - describe "with valid params" do - it "creates a new Harvest" do + describe 'POST create' do + describe 'with valid params' do + it 'creates a new Harvest' do expect do post :create, harvest: valid_attributes end.to change(Harvest, :count).by(1) end - it "assigns a newly created harvest as @harvest" do + it 'assigns a newly created harvest as @harvest' do post :create, harvest: valid_attributes assigns(:harvest).should be_a(Harvest) assigns(:harvest).should be_persisted end - it "redirects to the created harvest" do + it 'redirects to the created harvest' do post :create, harvest: valid_attributes response.should redirect_to(Harvest.last) end - describe "links to planting" do + describe 'links to planting' do let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } @@ -100,26 +100,26 @@ describe HarvestsController do end end - describe "with invalid params" do - it "assigns a newly created but unsaved harvest as @harvest" do + describe 'with invalid params' do + it 'assigns a newly created but unsaved harvest as @harvest' do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - post :create, harvest: { "crop_id" => "invalid value" } + post :create, harvest: { 'crop_id' => 'invalid value' } assigns(:harvest).should be_a_new(Harvest) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted - post :create, harvest: { "crop_id" => "invalid value" } - response.should render_template("new") + post :create, harvest: { 'crop_id' => 'invalid value' } + response.should render_template('new') end end - describe "not my planting" do + describe 'not my planting' do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe "does not save planting_id" do + describe 'does not save planting_id' do before do allow(Harvest).to receive(:new).and_return(harvest) post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -129,52 +129,52 @@ describe HarvestsController do end end - describe "PUT update" do - describe "with valid params" do - it "updates the requested harvest" do + describe 'PUT update' do + describe 'with valid params' do + it 'updates the requested harvest' do harvest = Harvest.create! valid_attributes # Assuming there are no other harvests in the database, this # specifies that the Harvest created on the previous line # receives the :update message with whatever params are # submitted in the request. - Harvest.any_instance.should_receive(:update).with("crop_id" => "1", "owner_id": member.id) - put :update, id: harvest.to_param, harvest: { "crop_id" => "1" } + Harvest.any_instance.should_receive(:update).with('crop_id' => '1', "owner_id": member.id) + put :update, id: harvest.to_param, harvest: { 'crop_id' => '1' } end - it "assigns the requested harvest as @harvest" do + it 'assigns the requested harvest as @harvest' do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes assigns(:harvest).should eq(harvest) end - it "redirects to the harvest" do + it 'redirects to the harvest' do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes response.should redirect_to(harvest) end end - describe "with invalid params" do - it "assigns the harvest as @harvest" do + describe 'with invalid params' do + it 'assigns the harvest as @harvest' do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } + put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } assigns(:harvest).should eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes - put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } - response.should render_template("edit") + put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } + response.should render_template('edit') end end - describe "not my planting" do + describe 'not my planting' do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe "does not save planting_id" do + describe 'does not save planting_id' do before do put :update, id: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -184,15 +184,15 @@ describe HarvestsController do end end - describe "DELETE destroy" do - it "destroys the requested harvest" do + describe 'DELETE destroy' do + it 'destroys the requested harvest' do harvest = Harvest.create! valid_attributes expect do delete :destroy, id: harvest.to_param end.to change(Harvest, :count).by(-1) end - it "redirects to the harvests list" do + it 'redirects to the harvests list' do harvest = Harvest.create! valid_attributes delete :destroy, id: harvest.to_param response.should redirect_to(harvests_url) diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index cb12b2bb4..44615dbd2 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' describe HomeController do - describe "GET index" do + describe 'GET index' do end end diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index a80fc0d56..6ed93b136 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -8,36 +8,36 @@ describe LikesController do before { sign_in member } - describe "POST create" do - it { expect(response.content_type).to eq "application/json" } + describe 'POST create' do + it { expect(response.content_type).to eq 'application/json' } before { post :create, post_id: blogpost.id, format: :json } it { expect(Like.last.likeable_id).to eq(blogpost.id) } it { expect(Like.last.likeable_type).to eq('Post') } - it { JSON.parse(response.body)["description"] == "1 like" } + it { JSON.parse(response.body)['description'] == '1 like' } describe "Liking someone else's post" do it { expect(response.code).to eq('201') } end - describe "Liking your own post" do + describe 'Liking your own post' do let(:blogpost) { FactoryBot.create(:post, author: member) } end end - describe "DELETE destroy" do + describe 'DELETE destroy' do before { delete :destroy, id: like.id, format: :json } - it { expect(response.content_type).to eq "application/json" } + it { expect(response.content_type).to eq 'application/json' } - describe "un-liking something i liked before" do + describe 'un-liking something i liked before' do it { expect(response.code).to eq('200') } - it { JSON.parse(response.body)["description"] == "0 likes" } + it { JSON.parse(response.body)['description'] == '0 likes' } end describe "Deleting someone else's like" do let(:like) { FactoryBot.create :like } it { expect(response.code).to eq('403') } - it { JSON.parse(response.body)["error"] == "Unable to like" } + it { JSON.parse(response.body)['error'] == 'Unable to like' } end end end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 14ba85e08..9be56ccfd 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -8,22 +8,22 @@ describe MembersController do @flickr_auth = FactoryBot.create(:flickr_authentication, member: @member) end - describe "GET index" do - it "assigns only confirmed members as @members" do + describe 'GET index' do + it 'assigns only confirmed members as @members' do get :index, {} assigns(:members).should eq([@member]) end end - describe "GET JSON index" do - it "provides JSON for members" do + describe 'GET JSON index' do + it 'provides JSON for members' do get :index, format: 'json' response.should be_success end end - describe "GET show" do - it "provides JSON for member profile" do + describe 'GET show' do + it 'provides JSON for member profile' do get :show, id: @member.id, format: 'json' response.should be_success end @@ -33,12 +33,12 @@ describe MembersController do assigns(:posts).should eq(@posts) end - it "assigns @twitter_auth" do + it 'assigns @twitter_auth' do get :show, id: @member.id assigns(:twitter_auth).should eq(@twitter_auth) end - it "assigns @flickr_auth" do + it 'assigns @flickr_auth' do get :show, id: @member.id assigns(:flickr_auth).should eq(@flickr_auth) end @@ -54,11 +54,11 @@ describe MembersController do end describe "GET member's RSS feed" do - it "returns an RSS feed" do - get :show, id: @member.to_param, format: "rss" + it 'returns an RSS feed' do + get :show, id: @member.to_param, format: 'rss' response.should be_success - response.should render_template("members/show") - response.content_type.should eq("application/rss+xml") + response.should render_template('members/show') + response.content_type.should eq('application/rss+xml') end end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index fd6f40aa1..8340ac4fb 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -5,9 +5,9 @@ describe NotificationsController do def valid_attributes { - "recipient_id" => subject.current_member.id, - "sender_id" => FactoryBot.create(:member).id, - "subject" => 'test' + 'recipient_id' => subject.current_member.id, + 'sender_id' => FactoryBot.create(:member).id, + 'subject' => 'test' } end @@ -18,9 +18,9 @@ describe NotificationsController do # attributes. def valid_attributes_for_sender { - "sender_id" => subject.current_member.id, - "recipient_id" => FactoryBot.create(:member).id, - "subject" => 'test' + 'sender_id' => subject.current_member.id, + 'recipient_id' => FactoryBot.create(:member).id, + 'subject' => 'test' } end @@ -28,22 +28,22 @@ describe NotificationsController do {} end - describe "GET index" do - it "assigns all notifications as @notifications" do + describe 'GET index' do + it 'assigns all notifications as @notifications' do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :index, {} assigns(:notifications).should eq([notification]) end end - describe "GET show" do - it "assigns the requested notification as @notification" do + describe 'GET show' do + it 'assigns the requested notification as @notification' do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param assigns(:notification).should eq(notification) end - it "assigns the reply link for a post comment" do + it 'assigns the reply link for a post comment' do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param @@ -53,7 +53,7 @@ describe NotificationsController do ) end - it "marks notifications as read" do + it 'marks notifications as read' do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -62,8 +62,8 @@ describe NotificationsController do end end - describe "GET reply" do - it "marks notifications as read" do + describe 'GET reply' do + it 'marks notifications as read' do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :reply, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -72,16 +72,16 @@ describe NotificationsController do end end - describe "GET new" do - it "assigns a recipient" do + describe 'GET new' do + it 'assigns a recipient' do @recipient = FactoryBot.create(:member) get :new, recipient_id: @recipient.id assigns(:recipient).should be_an_instance_of(Member) end end - describe "POST create" do - describe "with valid params" do + describe 'POST create' do + describe 'with valid params' do it "redirects to the recipient's profile" do @recipient = FactoryBot.create(:member) post :create, notification: { recipient_id: @recipient.id, subject: 'foo' } diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 4de8eb98d..08203c852 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -16,8 +16,8 @@ describe OrderItemsController do context 'signed in' do before { sign_in member } - describe "POST create" do - describe "redirects to order" do + describe 'POST create' do + describe 'redirects to order' do before do post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } end @@ -36,8 +36,8 @@ describe OrderItemsController do end end - describe "with non-int price" do - it "converts 3.33 to 333 cents" do + describe 'with non-int price' do + it 'converts 3.33 to 333 cents' do order = FactoryBot.create(:order, member: member) product = FactoryBot.create(:product, min_price: 1) expect do diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index 3c6631d8c..ef792ab69 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -4,14 +4,14 @@ describe OrdersController do login_member(:admin_member) def valid_attributes - { "member_id" => 1 } + { 'member_id' => 1 } end def valid_session {} end - describe "GET checkout" do + describe 'GET checkout' do it 'sets the referral_code' do member = FactoryBot.create(:member) sign_in member @@ -21,7 +21,7 @@ describe OrdersController do order.referral_code.should eq 'FOOBAR' end - it "redirects to Paypal" do + it 'redirects to Paypal' do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -31,8 +31,8 @@ describe OrdersController do end end - describe "GET complete" do - it "assigns the requested order as @order" do + describe 'GET complete' do + it 'assigns the requested order as @order' do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -41,8 +41,8 @@ describe OrdersController do end end - describe "DELETE destroy" do - it "redirects to the shop" do + describe 'DELETE destroy' do + it 'redirects to the shop' do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index f021d5aa8..30c629576 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe PhotoAssociationsController do login_member - describe "destroy" do + describe 'destroy' do let(:valid_params) do { id: harvest.id, @@ -14,11 +14,11 @@ describe PhotoAssociationsController do before { photo.harvests << harvest } - describe "my harvest my photo" do + describe 'my harvest my photo' do let(:harvest) { FactoryBot.create :harvest, owner: member } let(:photo) { FactoryBot.create :photo, owner: member } - it "removes link" do + it 'removes link' do expect { delete :destroy, valid_params }.to change { photo.harvests.count }.by(-1) end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 76869ebf3..ce5c71b66 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -8,13 +8,13 @@ describe PhotosController do def valid_attributes member = FactoryBot.create(:member) { - "owner_id" => member.id, - "flickr_photo_id" => 1, - "title" => "Photo", - "license_name" => "CC-BY", - "thumbnail_url" => 'http://example.com/thumb.jpg', - "fullsize_url" => 'http://example.com/full.jpg', - "link_url" => 'http://example.com' + 'owner_id' => member.id, + 'flickr_photo_id' => 1, + 'title' => 'Photo', + 'license_name' => 'CC-BY', + 'thumbnail_url' => 'http://example.com/thumb.jpg', + 'fullsize_url' => 'http://example.com/full.jpg', + 'link_url' => 'http://example.com' } end @@ -22,7 +22,7 @@ describe PhotosController do {} end - describe "GET new" do + describe 'GET new' do let(:tomato) { FactoryBot.create(:tomato) } let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -33,39 +33,39 @@ describe PhotosController do before(:each) do sign_in member member.stub(:flickr_photos) { [[], 0] } - member.stub(:flickr_sets) { { "foo" => "bar" } } + member.stub(:flickr_sets) { { 'foo' => 'bar' } } controller.stub(:current_member) { member } end - describe "planting photos" do - before(:each) { get :new, type: "planting", id: planting.id } + describe 'planting photos' do + before(:each) { get :new, type: 'planting', id: planting.id } it { assigns(:flickr_auth).should be_an_instance_of(Authentication) } it { assigns(:item).should eq planting } it { expect(flash[:alert]).not_to be_present } it { expect(flash[:alert]).not_to be_present } end - describe "harvest photos" do - before { get :new, type: "harvest", id: harvest.id } + describe 'harvest photos' do + before { get :new, type: 'harvest', id: harvest.id } it { assigns(:item).should eq harvest } it { expect(flash[:alert]).not_to be_present } end - describe "garden photos" do - before { get :new, type: "garden", id: garden.id } + describe 'garden photos' do + before { get :new, type: 'garden', id: garden.id } it { assigns(:item).should eq garden } it { expect(flash[:alert]).not_to be_present } end end - describe "POST create" do + describe 'POST create' do before(:each) do - Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", - license_name: "CC-BY", - license_url: "http://example.com/aybpl", - thumbnail_url: "http://example.com/thumb.jpg", - fullsize_url: "http://example.com/full.jpg", - link_url: "http://example.com") + Photo.any_instance.stub(:flickr_metadata).and_return(title: 'A Heartbreaking work of staggering genius', + license_name: 'CC-BY', + license_url: 'http://example.com/aybpl', + thumbnail_url: 'http://example.com/thumb.jpg', + fullsize_url: 'http://example.com/full.jpg', + link_url: 'http://example.com') end let(:member) { FactoryBot.create(:member) } @@ -74,32 +74,32 @@ describe PhotosController do let(:harvest) { FactoryBot.create(:harvest, owner: member) } let(:photo) { FactoryBot.create(:photo, owner: member) } - describe "with valid params" do + describe 'with valid params' do before { controller.stub(:current_member) { member } } - it "attaches the photo to a planting" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + it 'attaches the photo to a planting' do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end describe "doesn't attach a photo to a planting twice" do before do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id end it { expect(flash[:alert]).not_to be_present } it { expect(Photo.last.plantings.size).to eq 1 } end - it "attaches the photo to a harvest" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + it 'attaches the photo to a harvest' do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end it "doesn't attach a photo to a harvest twice" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.size.should eq 1 end @@ -107,15 +107,15 @@ describe PhotosController do it "doesn't attach photo to a comment" do comment = FactoryBot.create(:comment) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'comment', id: comment.id end.to raise_error end end - describe "for the second time" do + describe 'for the second time' do let(:planting) { FactoryBot.create :planting, owner: member } - it "does not add a photo twice" do + it 'does not add a photo twice' do expect do post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' end.to change(Photo, :count).by(1) @@ -125,40 +125,40 @@ describe PhotosController do end end - describe "with matching owners" do + describe 'with matching owners' do before { controller.stub(:current_member) { member } } - it "creates the planting/photo link" do + it 'creates the planting/photo link' do planting = FactoryBot.create(:planting, garden: garden, owner: member) photo = FactoryBot.create(:photo, owner: member) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end - it "creates the harvest/photo link" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + it 'creates the harvest/photo link' do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end end - describe "with mismatched owners" do + describe 'with mismatched owners' do let(:photo) { FactoryBot.create(:photo) } - it "does not create the planting/photo link" do + it 'does not create the planting/photo link' do # members will be auto-created, and different another_planting = FactoryBot.create(:planting) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: another_planting.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.plantings.first.should_not eq another_planting end - it "does not create the harvest/photo link" do + it 'does not create the harvest/photo link' do # members will be auto-created, and different another_harvest = FactoryBot.create(:harvest) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: another_harvest.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.harvests.first.should_not eq another_harvest end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 8b6cb0a31..761334e43 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -5,27 +5,27 @@ describe PlacesController do controller.stub(:current_member) { nil } end - describe "GET show" do + describe 'GET show' do before(:each) do @member_london = FactoryBot.create(:london_member) @member_south_pole = FactoryBot.create(:south_pole_member) end - it "assigns place name" do + it 'assigns place name' do get :show, place: @member_london.location assigns(:place).should eq @member_london.location end - it "assigns nearby members" do + it 'assigns nearby members' do get :show, place: @member_london.location assigns(:nearby_members).should eq [@member_london, @member_south_pole] end end - describe "GET search" do - it "redirects to the new place" do - get :search, new_place: "foo" - response.should redirect_to place_path("foo") + describe 'GET search' do + it 'redirects to the new place' do + get :search, new_place: 'foo' + response.should redirect_to place_path('foo') end end end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index abe5ea626..bdfdfc2bf 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -10,7 +10,7 @@ describe PlantingsController do } end - describe "GET index" do + describe 'GET index' do let!(:member1) { FactoryBot.create(:member) } let!(:member2) { FactoryBot.create(:member) } let!(:tomato) { FactoryBot.create(:tomato) } @@ -18,7 +18,7 @@ describe PlantingsController do let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - describe "assigns all plantings as @plantings" do + describe 'assigns all plantings as @plantings' do before { get :index, {} } it { expect(assigns(:plantings)).to match [planting1, planting2] } end @@ -29,15 +29,15 @@ describe PlantingsController do it { expect(assigns(:plantings)).to eq [planting1] } end - describe "picks up crop from params and shows the plantings for the crop only" do + describe 'picks up crop from params and shows the plantings for the crop only' do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:plantings)).to eq [planting2] } end end - describe "GET new" do - describe "picks up crop from params" do + describe 'GET new' do + describe 'picks up crop from params' do let(:crop) { FactoryBot.create(:crop) } before { get :new, crop_id: crop.id } @@ -85,12 +85,12 @@ describe PlantingsController do it { expect(assigns(:garden)).to be_a_new(Garden) } end - describe "sets the date of the planting to today" do + describe 'sets the date of the planting to today' do before { get :new, {} } it { expect(assigns(:planting).planted_at).to eq Time.zone.today } end - describe "sets the owner automatically" do + describe 'sets the owner automatically' do before { post :create, planting: valid_attributes } it { expect(assigns(:planting).owner).to eq subject.current_member } end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index cbfe8b46c..4c2aadf28 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -5,25 +5,25 @@ describe PostsController do def valid_attributes member = FactoryBot.create(:member) - { author_id: member.id, subject: "blah", body: "blah blah" } + { author_id: member.id, subject: 'blah', body: 'blah blah' } end - describe "GET RSS feed" do - it "returns an RSS feed" do - get :index, format: "rss" + describe 'GET RSS feed' do + it 'returns an RSS feed' do + get :index, format: 'rss' response.should be_success - response.should render_template("posts/index") - response.content_type.should eq("application/rss+xml") + response.should render_template('posts/index') + response.content_type.should eq('application/rss+xml') end end - describe "GET RSS feed for individual post" do - it "returns an RSS feed" do + describe 'GET RSS feed for individual post' do + it 'returns an RSS feed' do post = Post.create! valid_attributes - get :show, format: "rss", id: post.slug + get :show, format: 'rss', id: post.slug response.should be_success - response.should render_template("posts/show") - response.content_type.should eq("application/rss+xml") + response.should render_template('posts/show') + response.content_type.should eq('application/rss+xml') end end end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 173ef9ba4..4e28e70c3 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -5,7 +5,7 @@ describe ProductsController do def valid_attributes { - name: "product name", + name: 'product name', description: 'some description', min_price: 9.99 } diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 015bbb705..210357fa8 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -8,19 +8,19 @@ describe RegistrationsController do controller.stub(:devise_mapping).and_return(Devise.mappings[:member]) end - describe "GET edit" do - it "assigns the requested member as @member" do + describe 'GET edit' do + it 'assigns the requested member as @member' do get :edit assigns(:member).should eq(@member) end - it "picks up the twitter auth" do + it 'picks up the twitter auth' do @auth = FactoryBot.create(:authentication, member: @member) get :edit assigns(:twitter_auth).should eq @auth end - it "picks up the flickr auth" do + it 'picks up the flickr auth' do @auth = FactoryBot.create(:flickr_authentication, member: @member) get :edit assigns(:flickr_auth).should eq @auth diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index 9bf0ea1b5..8901c8d61 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -2,13 +2,13 @@ require 'rails_helper' describe RolesController do def valid_attributes - { "name" => "MyString" } + { 'name' => 'MyString' } end login_member(:admin_member) - describe "GET index" do - it "assigns all roles as @roles" do + describe 'GET index' do + it 'assigns all roles as @roles' do role = Role.create! valid_attributes get :index, {} # note that admin role exists because of login_admin_member diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index 412f53224..bd2da752c 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -11,8 +11,8 @@ describe ScientificNamesController do { name: 'Solanum lycopersicum', crop_id: @crop.id } end - describe "GET new" do - it "assigns crop if specified" do + describe 'GET new' do + it 'assigns crop if specified' do get :new, crop_id: 1 assigns(:crop).should be_an_instance_of Crop end diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index c2fd699eb..4c73a1d49 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe SeedsController do - describe "GET index" do - it "picks up owner from params" do + describe 'GET index' do + it 'picks up owner from params' do owner = FactoryBot.create(:member) get :index, owner: owner.slug assigns(:owner).should eq(owner) diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 2fc6b77f7..0b5931ec9 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -4,15 +4,15 @@ describe ShopController do let!(:product1) { FactoryBot.create(:product, name: 'aaa') } let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - describe "GET index" do + describe 'GET index' do describe 'not logged in' do before { get :index, {} } - describe "assigns all products as @products ordered by name" do + describe 'assigns all products as @products ordered by name' do it { expect(assigns(:products)).to eq([product1, product2]) } end - describe "assigns a new @order_item to build forms" do + describe 'assigns a new @order_item to build forms' do it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } end @@ -21,7 +21,7 @@ describe ShopController do end end describe 'logged in' do - describe "assigns @order as current_order if there is one" do + describe 'assigns @order as current_order if there is one' do let(:member) { FactoryBot.create(:member) } let!(:order) { FactoryBot.create(:order, member: member) } diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb index 66717492f..ccd8aa0c6 100644 --- a/spec/factories/account_types.rb +++ b/spec/factories/account_types.rb @@ -7,25 +7,25 @@ FactoryBot.define do is_permanent_paid false factory :free_account_type do - name "Free" + name 'Free' is_paid false is_permanent_paid false end factory :paid_account_type do - name "Paid" + name 'Paid' is_paid true is_permanent_paid false end factory :permanent_paid_account_type do - name "Permanent paid" + name 'Permanent paid' is_paid true is_permanent_paid true end factory :staff_account_type do - name "Staff" + name 'Staff' is_paid true is_permanent_paid true end diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb index 32c609cc3..95db4a7c2 100644 --- a/spec/factories/alternate_names.rb +++ b/spec/factories/alternate_names.rb @@ -2,13 +2,13 @@ FactoryBot.define do factory :alternate_name do - name "alternate name" + name 'alternate name' crop creator factory :alternate_eggplant do association :crop, factory: :eggplant - name "aubergine" + name 'aubergine' end end end diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index 2a8c6b656..221023fd2 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :crop do - name "magic bean" - en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean" - approval_status "approved" + name 'magic bean' + en_wikipedia_url 'http://en.wikipedia.org/wiki/Magic_bean' + approval_status 'approved' creator factory :annual_crop, parent: :crop do @@ -13,71 +13,71 @@ FactoryBot.define do end factory :tomato do - name "tomato" - en_wikipedia_url "http://en.wikipedia.org/wiki/Tomato" + name 'tomato' + en_wikipedia_url 'http://en.wikipedia.org/wiki/Tomato' end factory :maize do - name "maize" - en_wikipedia_url "http://en.wikipedia.org/wiki/Maize" + name 'maize' + en_wikipedia_url 'http://en.wikipedia.org/wiki/Maize' end factory :chard do - name "chard" + name 'chard' end factory :walnut do - name "walnut" + name 'walnut' end factory :apple do - name "apple" + name 'apple' end factory :pear do - name "pear" + name 'pear' end # for testing varieties factory :roma do - name "roma tomato" + name 'roma tomato' end factory :popcorn do - name "popcorn" + name 'popcorn' end factory :eggplant do - name "eggplant" + name 'eggplant' end # This should have a name that is alphabetically earlier than :uppercase # crop to ensure that the ordering tests work. factory :lowercasecrop do - name "ffrench bean" + name 'ffrench bean' end factory :uppercasecrop do - name "Swiss chard" + name 'Swiss chard' end factory :autoloaded_crop do - creator "cropbot" + creator 'cropbot' end # for testing crop request factory :crop_request do - name "Ultra berry" - en_wikipedia_url "" - approval_status "pending" + name 'Ultra berry' + en_wikipedia_url '' + approval_status 'pending' association :requester, factory: :member request_notes "Please approve this even though it's fake." end factory :rejected_crop do - name "Fail bean" - approval_status "rejected" - reason_for_rejection "Totally fake" + name 'Fail bean' + approval_status 'rejected' + reason_for_rejection 'Totally fake' end end end diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb index 5636981fb..7c3828604 100644 --- a/spec/factories/forums.rb +++ b/spec/factories/forums.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :forum do - name "Permaculture" - description "*Everything* about permaculture!" + name 'Permaculture' + description '*Everything* about permaculture!' owner end end diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb index 1f3d7461d..3dfa11ac5 100644 --- a/spec/factories/garden.rb +++ b/spec/factories/garden.rb @@ -1,12 +1,12 @@ FactoryBot.define do factory :garden do name 'Springfield Community Garden' - description "This is a **totally** cool garden" + description 'This is a **totally** cool garden' owner active true area 23 - area_unit "acre" - location "Greenwich, UK" + area_unit 'acre' + location 'Greenwich, UK' factory :inactive_garden do active false diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index ae3144a1e..ce41589c1 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -7,11 +7,11 @@ FactoryBot.define do planting nil owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at { Time.zone.local(2015, 9, 17) } - quantity "3" - unit "individual" + quantity '3' + unit 'individual' weight_quantity 6 - weight_unit "kg" - description "A lovely harvest" + weight_unit 'kg' + description 'A lovely harvest' factory :harvest_with_planting do planting @@ -19,10 +19,10 @@ FactoryBot.define do end trait :long_description do - description "This is a very long description that is so very long that it will need to be cut off" + description 'This is a very long description that is so very long that it will need to be cut off' end trait :no_description do - description "" + description '' end end diff --git a/spec/factories/like.rb b/spec/factories/like.rb index bf19554bb..43500ddbe 100644 --- a/spec/factories/like.rb +++ b/spec/factories/like.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :like do member - association :likeable, factory: "post" + association :likeable, factory: 'post' end end diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 016b12263..2f9373b82 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -77,7 +77,7 @@ FactoryBot.define do end factory :invalid_member_spaces do - login_name "a b" + login_name 'a b' end factory :invalid_member_badchars do diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index b893fcc1b..215fb83ab 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -4,8 +4,8 @@ FactoryBot.define do factory :notification, aliases: [:message] do sender recipient - subject "MyString" - body "MyText" + subject 'MyString' + body 'MyText' read false post diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb index 5dfba00ab..b4089f4b1 100644 --- a/spec/factories/order_items.rb +++ b/spec/factories/order_items.rb @@ -4,7 +4,7 @@ FactoryBot.define do factory :order_item do order product - price "999" + price '999' quantity 42 end end diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index 455d721c7..305121c30 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -5,15 +5,15 @@ FactoryBot.define do owner flickr_photo_id 1 title { Faker::HarryPotter.quote } - license_name "CC-BY" - license_url "http://example.com/license.html" + license_name 'CC-BY' + license_url 'http://example.com/license.html' thumbnail_url { "http://example.com/#{Faker::File.file_name}.jpg" } fullsize_url { "http://example.com/#{Faker::File.file_name}.jpg" } link_url { Faker::Internet.url } factory :unlicensed_photo do - license_name "All rights reserved" - license_url "" + license_name 'All rights reserved' + license_url '' end end end diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb index 695bf7542..ad0576129 100644 --- a/spec/factories/plant_parts.rb +++ b/spec/factories/plant_parts.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :plant_part do - name "pollen" + name 'pollen' end end diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 5b7311025..adba79848 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -5,7 +5,7 @@ FactoryBot.define do crop planted_at { Time.zone.local(2014, 7, 30) } quantity 33 - description "This is a *really* good plant." + description 'This is a *really* good plant.' factory :seed_planting do planted_from 'seed' diff --git a/spec/factories/post.rb b/spec/factories/post.rb index da6390ef8..e7e72c0b5 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -1,13 +1,13 @@ FactoryBot.define do factory :post do - subject "A Post" - body "This is some text." + subject 'A Post' + body 'This is some text.' author created_at { Time.now } # Markdown is allowed in posts factory :markdown_post do - body "This is some **strong** text." + body 'This is some **strong** text.' end # HTML isn't allowed in posts diff --git a/spec/factories/products.rb b/spec/factories/products.rb index 444c8597d..ab9d9556b 100644 --- a/spec/factories/products.rb +++ b/spec/factories/products.rb @@ -2,14 +2,14 @@ FactoryBot.define do factory :product do - name "annual subscription" - description "paid membership, renewing yearly, *hurrah*" - min_price "999" + name 'annual subscription' + description 'paid membership, renewing yearly, *hurrah*' + min_price '999' account_type paid_months 12 factory :product_with_recommended_price do - recommended_price "1200" + recommended_price '1200' end end end diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index fed5e5e00..833191aac 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -2,17 +2,17 @@ FactoryBot.define do factory :role do - name "Moderator" - description "These people moderate the forums" + name 'Moderator' + description 'These people moderate the forums' initialize_with { Role.find_or_create_by(name: name) } factory :admin do - name "admin" + name 'admin' end factory :crop_wrangler do - name "Crop Wrangler" - description "they wrangle crops" + name 'Crop Wrangler' + description 'they wrangle crops' end end end diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb index aa0911504..3032eaa21 100644 --- a/spec/factories/scientific_name.rb +++ b/spec/factories/scientific_name.rb @@ -1,17 +1,17 @@ FactoryBot.define do factory :scientific_name do association :crop, factory: :crop - name "Beanus Magicus" + name 'Beanus Magicus' creator factory :zea_mays do association :crop, factory: :maize - name "Zea mays" + name 'Zea mays' end factory :solanum_lycopersicum do association :crop, factory: :tomato - name "Solanum lycopersicum" + name 'Solanum lycopersicum' end end end diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index 41b3d404f..9509750f9 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -4,9 +4,9 @@ FactoryBot.define do factory :seed do owner crop - description "MyText" + description 'MyText' quantity 1 - plant_before "2013-07-15" + plant_before '2013-07-15' tradable_to 'nowhere' organic 'unknown' gmo 'unknown' @@ -15,11 +15,11 @@ FactoryBot.define do days_until_maturity_max nil factory :tradable_seed do - tradable_to "locally" + tradable_to 'locally' end factory :untradable_seed do - tradable_to "nowhere" + tradable_to 'nowhere' end end end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb index dac241586..5dddeeaab 100644 --- a/spec/features/admin/account_types_spec.rb +++ b/spec/features/admin/account_types_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "account types", js: true do - context "admin user" do +feature 'account types', js: true do + context 'admin user' do let(:member) { create :admin_member } let(:account_type) { create :account_type } @@ -9,28 +9,28 @@ feature "account types", js: true do login_as member end - scenario "navigating to account type admin with JavaScript on" do + scenario 'navigating to account type admin with JavaScript on' do visit root_path # Extra click for the expandable login menu click_link member.login_name - click_link "Admin" + click_link 'Admin' expect(current_path).to eq admin_path - click_link "Account types" + click_link 'Account types' expect(current_path).to eq account_types_path end - scenario "navigating to account type admin without JavaScript - Accessility version", js: false do + scenario 'navigating to account type admin without JavaScript - Accessility version', js: false do visit root_path # Extra link not needed as menu is already expanded - click_link "Admin" + click_link 'Admin' expect(current_path).to eq admin_path - click_link "Account types" + click_link 'Account types' expect(current_path).to eq account_types_path end - scenario "adding an account type" do + scenario 'adding an account type' do visit account_types_path - click_link "New Account type" + click_link 'New Account type' expect(current_path).to eq new_account_type_path fill_in 'Name', with: 'Guest' click_button 'Save' diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 87f44f26d..da6704134 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "forums", js: true do - context "as an admin user" do +feature 'forums', js: true do + context 'as an admin user' do let(:member) { create :admin_member } let(:forum) { create :forum } @@ -9,35 +9,35 @@ feature "forums", js: true do login_as member end - scenario "navigating to forum admin without js", js: false do + scenario 'navigating to forum admin without js', js: false do visit root_path - click_link "Admin" + click_link 'Admin' expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link "Forums" + click_link 'Forums' end expect(current_path).to eq forums_path - expect(page).to have_content "New forum" + expect(page).to have_content 'New forum' end - scenario "navigating to forum admin with js" do + scenario 'navigating to forum admin with js' do visit root_path click_link member.login_name - click_link "Admin" + click_link 'Admin' expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link "Forums" + click_link 'Forums' end expect(current_path).to eq forums_path - expect(page).to have_content "New forum" + expect(page).to have_content 'New forum' end - scenario "adding a forum" do + scenario 'adding a forum' do visit forums_path - click_link "New forum" + click_link 'New forum' expect(current_path).to eq new_forum_path fill_in 'Name', with: 'Discussion' - fill_in 'Description', with: "this is a new forum" + fill_in 'Description', with: 'this is a new forum' click_button 'Save' expect(current_path).to eq forum_path(Forum.last) expect(page).to have_content 'Forum was successfully created' diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index ca24daf83..918e3fd7c 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "products" do - context "admin user" do +feature 'products' do + context 'admin user' do let(:member) { create :admin_member } let(:product) { create :product } @@ -9,15 +9,15 @@ feature "products" do login_as member end - scenario "navigating to product admin" do + scenario 'navigating to product admin' do visit admin_path - click_link "Products" + click_link 'Products' expect(current_path).to eq products_path end - scenario "adding a product" do + scenario 'adding a product' do visit products_path - click_link "New Product" + click_link 'New Product' expect(current_path).to eq new_product_path fill_in 'Name', with: 'Special offer' # note that failing to fill in a mandatory field has a messy error. diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index 176c531a8..e41d1d25d 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -feature "cms admin" do +feature 'cms admin' do let(:member) { create :member } let(:admin_member) { create :admin_member } scenario "can't view CMS admin if not signed in" do visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content "Please sign in as an admin user" + expect(page).to have_content 'Please sign in as an admin user' end scenario "can't view CMS admin if not an admin member" do @@ -15,10 +15,10 @@ feature "cms admin" do login_as member visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content "Please sign in as an admin user" + expect(page).to have_content 'Please sign in as an admin user' end - scenario "admin members can view CMS admin area" do + scenario 'admin members can view CMS admin area' do login_as admin_member visit comfy_admin_cms_path expect(current_path).to match(/#{comfy_admin_cms_path}/) # match any CMS admin page diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 75024ffb6..604bf311e 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -9,25 +9,25 @@ feature 'Commenting on a post' do visit new_comment_path post_id: post.id end - scenario "creating a comment" do - fill_in "comment_body", with: "This is a sample test for comment" - click_button "Post comment" - expect(page).to have_content "comment was successfully created." - expect(page).to have_content "Posted by" + scenario 'creating a comment' do + fill_in 'comment_body', with: 'This is a sample test for comment' + click_button 'Post comment' + expect(page).to have_content 'comment was successfully created.' + expect(page).to have_content 'Posted by' end - context "editing a comment" do + context 'editing a comment' do let(:existing_comment) { create :comment, post: post, author: member } background do visit edit_comment_path existing_comment end - scenario "saving edit" do - fill_in "comment_body", with: "Testing edit for comment" - click_button "Post comment" - expect(page).to have_content "comment was successfully updated." - expect(page).to have_content "edited at" + scenario 'saving edit' do + fill_in 'comment_body', with: 'Testing edit for comment' + click_button 'Post comment' + expect(page).to have_content 'comment was successfully updated.' + expect(page).to have_content 'edited at' end end end diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index e3b36c4a8..fe4667cf5 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature "Alternate names", js: true do +feature 'Alternate names', js: true do let!(:alternate_eggplant) { create :alternate_eggplant } let(:crop) { alternate_eggplant.crop } - scenario "Display alternate names on crop page" do + scenario 'Display alternate names on crop page' do visit crop_path(alternate_eggplant.crop) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end - scenario "Index page for alternate names" do + scenario 'Index page for alternate names' do visit alternate_names_path expect(page).to have_content alternate_eggplant.name end - context "User is a crop wrangler" do + context 'User is a crop wrangler' do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -23,59 +23,59 @@ feature "Alternate names", js: true do login_as member end - scenario "Crop wranglers can edit alternate names" do + scenario 'Crop wranglers can edit alternate names' do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content "CROP WRANGLER" + expect(page).to have_content 'CROP WRANGLER' expect(page).to have_content alternate_eggplant.name - expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on "Edit" } + expect(page).to have_link 'Edit', href: edit_alternate_name_path(alternate_eggplant) + within('.alternate_names') { click_on 'Edit' } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: "alternative aubergine" - click_on "Save" + fill_in 'Name', with: 'alternative aubergine' + click_on 'Save' expect(page.status_code).to equal 200 - expect(page).to have_content "alternative aubergine" + expect(page).to have_content 'alternative aubergine' expect(page).to have_content 'Alternate name was successfully updated' end - scenario "Crop wranglers can delete alternate names" do + scenario 'Crop wranglers can delete alternate names' do visit crop_path(alternate_eggplant.crop) - expect(page).to have_link "Delete", + expect(page).to have_link 'Delete', href: alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on "Delete" } + within('.alternate_names') { click_on 'Delete' } expect(page.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end - scenario "Crop wranglers can add alternate names" do + scenario 'Crop wranglers can add alternate names' do visit crop_path(crop) - expect(page).to have_link "Add", + expect(page).to have_link 'Add', href: new_alternate_name_path(crop_id: crop.id) - within('.alternate_names') { click_on "Add" } + within('.alternate_names') { click_on 'Add' } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: "not an aubergine" - click_on "Save" + fill_in 'Name', with: 'not an aubergine' + click_on 'Save' expect(page.status_code).to equal 200 - expect(page).to have_content "not an aubergine" + expect(page).to have_content 'not an aubergine' expect(page).to have_content 'Alternate name was successfully created' end - scenario "The show-alternate-name page works" do + scenario 'The show-alternate-name page works' do visit alternate_name_path(alternate_eggplant) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name end - context "When alternate name is rejected" do + context 'When alternate name is rejected' do let(:rejected_crop) { create :rejected_crop } let(:pending_alt_name) { create :alternate_name, crop: rejected_crop } - scenario "Displays crop rejection message" do + scenario 'Displays crop rejection message' do visit alternate_name_path(pending_alt_name) - expect(page).to have_content "This crop was rejected for the following reason: Totally fake" + expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' end end end diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 72e63c8fd..7f8b87467 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature "browse crops" do +feature 'browse crops' do let(:tomato) { create :tomato } let(:maize) { create :maize } let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } - scenario "has a form for sorting by" do + scenario 'has a form for sorting by' do visit crops_path - expect(page).to have_css "select#sort" + expect(page).to have_css 'select#sort' end - scenario "shows a list of crops" do + scenario 'shows a list of crops' do crop1 = tomato visit crops_path expect(page).to have_content crop1.name end - scenario "pending crops are not listed" do + scenario 'pending crops are not listed' do visit crops_path expect(page).not_to have_content pending_crop.name end - scenario "rejected crops are not listed" do + scenario 'rejected crops are not listed' do visit crops_path expect(page).not_to have_content rejected_crop.name end diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index 2b1300485..c5c12617e 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Crop - " do +feature 'Crop - ' do let!(:crop_wrangler) { create :crop_wrangling_member } let!(:member) { create :member } @@ -9,27 +9,27 @@ feature "Crop - " do visit new_crop_path end - scenario "creating a crop with multiple scientific and alternate name", :js do - within "form#new_crop" do - fill_in "crop_name", with: "Philippine flower" - fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac" - click_button "add-sci_name-row" - fill_in "sci_name[1]", with: "Jasminum sambac 1" - fill_in "sci_name[2]", with: "Jasminum sambac 2" - fill_in "alt_name[1]", with: "Sampaguita" - click_button "add-alt_name-row" - click_button "add-alt_name-row" - fill_in "alt_name[2]", with: "Manol" - click_button "add-alt_name-row" - fill_in "alt_name[3]", with: "Jazmin" - fill_in "alt_name[4]", with: "Matsurika" - fill_in "request_notes", with: "This is the Philippine national flower." - click_button "Save" + scenario 'creating a crop with multiple scientific and alternate name', :js do + within 'form#new_crop' do + fill_in 'crop_name', with: 'Philippine flower' + fill_in 'en_wikipedia_url', with: 'https://en.wikipedia.org/wiki/Jasminum_sambac' + click_button 'add-sci_name-row' + fill_in 'sci_name[1]', with: 'Jasminum sambac 1' + fill_in 'sci_name[2]', with: 'Jasminum sambac 2' + fill_in 'alt_name[1]', with: 'Sampaguita' + click_button 'add-alt_name-row' + click_button 'add-alt_name-row' + fill_in 'alt_name[2]', with: 'Manol' + click_button 'add-alt_name-row' + fill_in 'alt_name[3]', with: 'Jazmin' + fill_in 'alt_name[4]', with: 'Matsurika' + fill_in 'request_notes', with: 'This is the Philippine national flower.' + click_button 'Save' end expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content "This crop is currently pending approval." - expect(page).to have_content "Jasminum sambac 2" - expect(page).to have_content "Matsurika" + expect(page).to have_content 'This crop is currently pending approval.' + expect(page).to have_content 'Jasminum sambac 2' + expect(page).to have_content 'Matsurika' end end diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index b7dca2e8d..8270660e7 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop detail page", js: true do +feature 'crop detail page', js: true do subject do # Update the medians after all the # data has been loaded @@ -12,22 +12,22 @@ feature "crop detail page", js: true do end let(:crop) { create :crop } - context "varieties" do - scenario "The crop DOES NOT have varieties" do + context 'varieties' do + scenario 'The crop DOES NOT have varieties' do visit crop_path(crop) - within ".varieties" do + within '.varieties' do expect(page).to have_no_selector('li', text: /tomato/i) expect(page).to have_no_selector('button', text: /Show+/i) end end - scenario "The crop has one variety" do + scenario 'The crop has one variety' do create :crop, name: 'Roma tomato 1', parent: crop subject - within ".varieties" do + within '.varieties' do # It lists all 2 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 2) # It DOES NOT have "Show all/less" toggle link @@ -35,16 +35,16 @@ feature "crop detail page", js: true do end end - context "many" do + context 'many' do let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop } let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop } let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop } let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop } - scenario "The crop has 4 varieties" do + scenario 'The crop has 4 varieties' do subject - within ".varieties" do + within '.varieties' do # It lists all 5 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 5) # It DOES NOT have "Show all/less" toggle link @@ -52,12 +52,12 @@ feature "crop detail page", js: true do end end - scenario "The crop has 5 varieties, including grandchild", js: true do + scenario 'The crop has 5 varieties, including grandchild', js: true do create :crop, name: 'Roma tomato child 1', parent: roma4 subject - within ".varieties" do + within '.varieties' do # It lists the first 5 items (note: including the top level item.) # It HAS have "Show all" toggle link but not "Show less" link expect(page).to have_selector('li', text: /tomato/i, count: 5) @@ -93,90 +93,90 @@ feature "crop detail page", js: true do end end - context "signed in member" do + context 'signed in member' do let(:member) { create :member } background do login_as(member) end - context "action buttons" do + context 'action buttons' do background { subject } - scenario "has a link to plant the crop" do - expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) + scenario 'has a link to plant the crop' do + expect(page).to have_link 'Plant this', href: new_planting_path(crop_id: crop.id) end - scenario "has a link to harvest the crop" do - expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) + scenario 'has a link to harvest the crop' do + expect(page).to have_link 'Harvest this', href: new_harvest_path(crop_id: crop.id) end - scenario "has a link to add seeds" do - expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) + scenario 'has a link to add seeds' do + expect(page).to have_link 'Add seeds to stash', href: new_seed_path(crop_id: crop.id) end end - context "SEO" do + context 'SEO' do background { subject } - scenario "has seed heading with SEO" do + scenario 'has seed heading with SEO' do expect(page).to have_content "Find #{crop.name} seeds" end - scenario "has harvest heading with SEO" do + scenario 'has harvest heading with SEO' do expect(page).to have_content "#{crop.name.capitalize} harvests" end - scenario "has planting heading with SEO" do + scenario 'has planting heading with SEO' do expect(page).to have_content "See who's planted #{crop.name.pluralize}" end - scenario "has planting advice with SEO" do + scenario 'has planting advice with SEO' do expect(page).to have_content "How to grow #{crop.name}" end - scenario "has a link to Wikipedia with SEO" do + scenario 'has a link to Wikipedia with SEO' do expect(page).to have_content "Learn more about #{crop.name}" - expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url + expect(page).to have_link 'Wikipedia (English)', href: crop.en_wikipedia_url end - scenario "has a link to OpenFarm" do - expect(page).to have_link "OpenFarm - Growing guide", + scenario 'has a link to OpenFarm' do + expect(page).to have_link 'OpenFarm - Growing guide', href: "https://openfarm.cc/en/crops/#{URI.escape crop.name}" end - scenario "has a link to gardenate" do - expect(page).to have_link "Gardenate - Planting reminders", + scenario 'has a link to gardenate' do + expect(page).to have_link 'Gardenate - Planting reminders', href: "http://www.gardenate.com/plant/#{URI.escape crop.name}" end end end - context "seed quantity for a crop" do + context 'seed quantity for a crop' do let(:member) { create :member } let(:seed) { create :seed, crop: crop, quantity: 20, owner: member } - scenario "User not signed in" do + scenario 'User not signed in' do visit crop_path(seed.crop) - expect(page).not_to have_content "You have 20 seeds of this crop" + expect(page).not_to have_content 'You have 20 seeds of this crop' expect(page).not_to have_content "You don't have any seeds of this crop" - expect(page).not_to have_link "View your seeds" + expect(page).not_to have_link 'View your seeds' end - scenario "User signed in" do + scenario 'User signed in' do login_as(member) visit crop_path(seed.crop) - expect(page).to have_content "You have 20 seeds of this crop." - expect(page).to have_link "View your seeds" + expect(page).to have_content 'You have 20 seeds of this crop.' + expect(page).to have_link 'View your seeds' end - scenario "click link to your owned seeds" do + scenario 'click link to your owned seeds' do login_as(member) visit crop_path(seed.crop) - click_link "View your seeds" + click_link 'View your seeds' expect(current_path).to eq seeds_by_owner_path(owner: member.slug) end end - shared_examples "predicts harvest" do + shared_examples 'predicts harvest' do describe 'with harvest history data' do before do # 50 days to harvest @@ -190,8 +190,8 @@ feature "crop detail page", js: true do planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) planting.crop.update_medians end - it "predicts harvest" do - is_expected.to have_text("First harvest expected 20 days after planting") + it 'predicts harvest' do + is_expected.to have_text('First harvest expected 20 days after planting') end end end @@ -210,15 +210,15 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "predicts harvest" + include_examples 'predicts harvest' end - it "predicts lifespan" do - is_expected.to have_text "Median lifespan" - is_expected.to have_text "99 days" + it 'predicts lifespan' do + is_expected.to have_text 'Median lifespan' + is_expected.to have_text '99 days' end - it "describes annual crops" do + it 'describes annual crops' do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -232,10 +232,10 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "predicts harvest" + include_examples 'predicts harvest' end - it "describes perennial crops" do + it 'describes perennial crops' do is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end end @@ -247,7 +247,7 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "predicts harvest" + include_examples 'predicts harvest' end end end diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index ccc5288f0..0c79d55d8 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop detail page", js: true do +feature 'crop detail page', js: true do subject { page } let(:member) { create :member } @@ -29,29 +29,29 @@ feature "crop detail page", js: true do visit crop_path(crop) end - shared_examples "shows photos" do - describe "show planting photos" do + shared_examples 'shows photos' do + describe 'show planting photos' do it { is_expected.to have_xpath("//img[contains(@src,'#{photo1.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo2.thumbnail_url}')]") } end - describe "show harvest photos" do + describe 'show harvest photos' do it { is_expected.to have_xpath("//img[contains(@src,'#{photo3.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo4.thumbnail_url}')]") } end - describe "link to more photos" do - it { is_expected.to have_link "more photos" } + describe 'link to more photos' do + it { is_expected.to have_link 'more photos' } end end - context "when signed in" do + context 'when signed in' do background { login_as(create(:member)) } - include_examples "shows photos" + include_examples 'shows photos' end - context "when signed in as photos owner" do + context 'when signed in as photos owner' do background { login_as(member) } - include_examples "shows photos" + include_examples 'shows photos' end - context "when not signed in " do - include_examples "shows photos" + context 'when not signed in ' do + include_examples 'shows photos' end end diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index f2f86980c..b10aa043d 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature "crop search" do - scenario "search results show the search term in title" do +feature 'crop search' do + scenario 'search results show the search term in title' do visit root_path - within "form#navbar-search" do - fill_in "term", with: "tomato" - click_button "Search" + within 'form#navbar-search' do + fill_in 'term', with: 'tomato' + click_button 'Search' end - expect(page).to have_css "h1", text: "Crops matching \"tomato\"" + expect(page).to have_css 'h1', text: 'Crops matching "tomato"' end - scenario "search page with no search term shows suitable title" do + scenario 'search page with no search term shows suitable title' do visit crops_search_path - expect(page).to have_css "h1", text: "Crop search" + expect(page).to have_css 'h1', text: 'Crop search' end - scenario "search page has a search form on it" do + scenario 'search page has a search form on it' do visit crops_search_path - expect(page).to have_css "form#crop-search" + expect(page).to have_css 'form#crop-search' end end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index eafc7039f..c5ae2c9a2 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "crop wranglers", js: true do - context "signed in wrangler" do +feature 'crop wranglers', js: true do + context 'signed in wrangler' do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:wrangler) { crop_wranglers.first } let!(:crops) { create_list :crop, 2 } @@ -10,7 +10,7 @@ feature "crop wranglers", js: true do background { login_as wrangler } - scenario "sees crop wranglers listed on the crop wrangler page" do + scenario 'sees crop wranglers listed on the crop wrangler page' do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -23,7 +23,7 @@ feature "crop wranglers", js: true do end end - scenario "can see list of crops with extra detail of who created a crop" do + scenario 'can see list of crops with extra detail of who created a crop' do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -32,39 +32,39 @@ feature "crop wranglers", js: true do end end - scenario "visiting a crop can see wrangler links" do + scenario 'visiting a crop can see wrangler links' do visit crop_path(crops.first) expect(page).to have_content 'You are a CROP WRANGLER' expect(page).to have_link 'Edit crop' expect(page).to have_link 'Delete crop' end - scenario "can create a new crop" do + scenario 'can create a new crop' do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' click_link 'Add Crop' - fill_in 'Name', with: "aubergine" - fill_in 'en_wikipedia_url', with: "http://en.wikipedia.org/wiki/Maize" - fill_in 'sci_name[1]', with: "planticus maximus" + fill_in 'Name', with: 'aubergine' + fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Maize' + fill_in 'sci_name[1]', with: 'planticus maximus' click_on 'Save' expect(page).to have_content 'crop was successfully created.' expect(page).to have_content 'planticus maximus' end - scenario "View pending crops" do + scenario 'View pending crops' do visit crop_path(requested_crop) - expect(page).to have_content "This crop is currently pending approval." + expect(page).to have_content 'This crop is currently pending approval.' expect(page).to have_content "Please approve this even though it's fake." end - scenario "View rejected crops" do + scenario 'View rejected crops' do visit crop_path(rejected_crop) - expect(page).to have_content "This crop was rejected for the following reason: Totally fake" + expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' end end - context "signed in non-wrangler" do + context 'signed in non-wrangler' do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { create :member } @@ -72,13 +72,13 @@ feature "crop wranglers", js: true do scenario "can't see wrangling page without js", js: false do visit root_path - expect(page).not_to have_link "Crop Wrangling" + expect(page).not_to have_link 'Crop Wrangling' end scenario "can't see wrangling page with js" do visit root_path click_link member.login_name - expect(page).not_to have_link "Crop Wrangling" + expect(page).not_to have_link 'Crop Wrangling' end end end diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index ede88f003..dd1f439c8 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature "crop wrangling button" do +feature 'crop wrangling button' do let(:crop_wrangler) { create :crop_wrangling_member } let(:member) { create :member } - context "crop wrangling button" do + context 'crop wrangling button' do background do login_as crop_wrangler visit crops_path end - scenario "has a link to crop wrangling page" do - expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path + scenario 'has a link to crop wrangling page' do + expect(page).to have_link 'Wrangle Crops', href: wrangle_crops_path end end - context "crop wrangling button" do + context 'crop wrangling button' do background do login_as member visit crops_path end - scenario "has no link to crop wrangling page" do - expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path + scenario 'has no link to crop wrangling page' do + expect(page).to have_no_link 'Wrangle Crops', href: wrangle_crops_path end end end diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index d08f2490b..015b19d6d 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature "irregular crop inflections" do +feature 'irregular crop inflections' do # We're just testing a couple of representative crops to # check that inflection works: you don't need to add # every crop here. - scenario "crops which are mass nouns" do - expect("kale".pluralize).to eq "kale" - expect("broccoli".pluralize).to eq "broccoli" - expect("square foot".pluralize).to eq "square feet" - expect("squash".pluralize).to eq "squash" - expect("bok choy".pluralize).to eq "bok choy" - expect("achiote".pluralize).to eq "achiote" - expect("alfalfa".pluralize).to eq "alfalfa" - expect("allspice".pluralize).to eq "allspice" - expect("spinach".pluralize).to eq "spinach" - expect("garlic".pluralize).to eq "garlic" - expect("licorice".pluralize).to eq "licorice" - expect("lillipilli".pluralize).to eq "lillipillies" + scenario 'crops which are mass nouns' do + expect('kale'.pluralize).to eq 'kale' + expect('broccoli'.pluralize).to eq 'broccoli' + expect('square foot'.pluralize).to eq 'square feet' + expect('squash'.pluralize).to eq 'squash' + expect('bok choy'.pluralize).to eq 'bok choy' + expect('achiote'.pluralize).to eq 'achiote' + expect('alfalfa'.pluralize).to eq 'alfalfa' + expect('allspice'.pluralize).to eq 'allspice' + expect('spinach'.pluralize).to eq 'spinach' + expect('garlic'.pluralize).to eq 'garlic' + expect('licorice'.pluralize).to eq 'licorice' + expect('lillipilli'.pluralize).to eq 'lillipillies' end end diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index 9cccac4f8..5dc54d8cb 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "Requesting a new crop" do - context "As a regular member" do +feature 'Requesting a new crop' do + context 'As a regular member' do let(:member) { create :member } let!(:wrangler) { create :crop_wrangling_member } @@ -9,39 +9,39 @@ feature "Requesting a new crop" do login_as member end - scenario "Submit request" do + scenario 'Submit request' do visit new_crop_path - fill_in "Name", with: "Couch potato" - fill_in "request_notes", with: "Couch potatoes are real for real." - click_button "Save" + fill_in 'Name', with: 'Couch potato' + fill_in 'request_notes', with: 'Couch potatoes are real for real.' + click_button 'Save' expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content "This crop is currently pending approval." + expect(page).to have_content 'This crop is currently pending approval.' end end - context "As a crop wrangler" do + context 'As a crop wrangler' do let(:wrangler) { create :crop_wrangling_member } let!(:crop) { create :crop_request } let!(:already_approved) { create :crop } background { login_as wrangler } - scenario "Approve a request" do + scenario 'Approve a request' do visit edit_crop_path(crop) - select "approved", from: "Approval status" - click_button "Save" - expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL" - fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi" - click_button "Save" - expect(page).to have_content "crop was successfully updated." + select 'approved', from: 'Approval status' + click_button 'Save' + expect(page).to have_content 'En wikipedia url is not a valid English Wikipedia URL' + fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi' + click_button 'Save' + expect(page).to have_content 'crop was successfully updated.' end - scenario "Rejecting a crop" do + scenario 'Rejecting a crop' do visit edit_crop_path(crop) - select "rejected", from: "Approval status" - select "not edible", from: "Reason for rejection" - click_button "Save" - expect(page).to have_content "crop was successfully updated." + select 'rejected', from: 'Approval status' + select 'not edible', from: 'Reason for rejection' + click_button 'Save' + expect(page).to have_content 'crop was successfully updated.' end end end diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index 15226efe4..c3329635a 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Crop - " do +feature 'Crop - ' do let(:member) { create :member } let!(:requested_crop) { create :crop, requester: member, approval_status: 'pending', name: 'puha for dinner' } @@ -9,7 +9,7 @@ feature "Crop - " do visit requested_crops_path end - scenario "creating a crop with multiple scientific and alternate name", :js do - expect(page).to have_content "puha for dinner" + scenario 'creating a crop with multiple scientific and alternate name', :js do + expect(page).to have_content 'puha for dinner' end end diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 735883e77..5fbeb5296 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature "follows", :js do - context "when signed out" do +feature 'follows', :js do + context 'when signed out' do let(:member) { create :member } - scenario "follow buttons on member profile page" do + scenario 'follow buttons on member profile page' do visit member_path(member) - expect(page).not_to have_link "Follow" - expect(page).not_to have_link "Unfollow" + expect(page).not_to have_link 'Follow' + expect(page).not_to have_link 'Unfollow' end end - context "when signed in" do + context 'when signed in' do let(:member) { create :member } let(:other_member) { create :member } @@ -21,45 +21,45 @@ feature "follows", :js do scenario "your profile doesn't have a follow button" do visit member_path(member) - expect(page).not_to have_link "Follow" - expect(page).not_to have_link "Unfollow" + expect(page).not_to have_link 'Follow' + expect(page).not_to have_link 'Unfollow' end - context "following another member" do + context 'following another member' do background do visit member_path(other_member) end - scenario "has a follow button" do - expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) + scenario 'has a follow button' do + expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) end - scenario "has correct message and unfollow button" do + scenario 'has correct message and unfollow button' do click_link 'Follow' expect(page).to have_content "Followed #{other_member.login_name}" - expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member)) + expect(page).to have_link 'Unfollow', href: follow_path(member.get_follow(other_member)) end - scenario "has a followed member listed in the following page" do + scenario 'has a followed member listed in the following page' do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s end - scenario "does not die when passed an authenticity_token" do - visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" } + scenario 'does not die when passed an authenticity_token' do + visit member_follows_path member, params: { authenticity_token: 'Ultima ratio regum' } expect(page.status_code).to equal 200 end - scenario "has correct message and follow button after unfollow" do + scenario 'has correct message and follow button after unfollow' do click_link 'Follow' click_link 'Unfollow' expect(page).to have_content "Unfollowed #{other_member.login_name}" visit member_path(other_member) # unfollowing redirects to root - expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) + expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) end - scenario "has member in following list" do + scenario 'has member in following list' do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s @@ -71,7 +71,7 @@ feature "follows", :js do expect(page).to have_content member.login_name.to_s end - scenario "removes members from following and followers lists after unfollow" do + scenario 'removes members from following and followers lists after unfollow' do click_link 'Follow' click_link 'Unfollow' visit member_follows_path(member) diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index b7d109773..3023212f7 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature "footer", js: true do +feature 'footer', js: true do before { visit root_path } - scenario "footer is on home page" do + scenario 'footer is on home page' do expect(page).to have_css 'footer' end diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index c3f78dd18..746acc1f0 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature "Gardens", :js do +feature 'Gardens', :js do let(:member) { FactoryBot.create :member } background do @@ -9,30 +9,30 @@ feature "Gardens", :js do visit new_garden_path end - it "has the required fields help text" do - expect(page).to have_content "* denotes a required field" + it 'has the required fields help text' do + expect(page).to have_content '* denotes a required field' end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "Name" + it 'displays required and optional fields properly' do + expect(page).to have_selector '.form-group.required', text: 'Name' expect(page).to have_optional 'textarea#garden_description' expect(page).to have_optional 'input#garden_location' expect(page).to have_optional 'input#garden_area' end - scenario "Create new garden" do - fill_in "Name", with: "New garden" - click_button "Save" - expect(page).to have_content "Garden was successfully created" - expect(page).to have_content "New garden" + scenario 'Create new garden' do + fill_in 'Name', with: 'New garden' + click_button 'Save' + expect(page).to have_content 'Garden was successfully created' + expect(page).to have_content 'New garden' end - scenario "Refuse to create new garden with negative area" do + scenario 'Refuse to create new garden with negative area' do visit new_garden_path - fill_in "Name", with: "Negative Garden" - fill_in "Area", with: -5 - click_button "Save" - expect(page).not_to have_content "Garden was successfully created" - expect(page).to have_content "Area must be greater than or equal to 0" + fill_in 'Name', with: 'Negative Garden' + fill_in 'Area', with: -5 + click_button 'Save' + expect(page).not_to have_content 'Garden was successfully created' + expect(page).to have_content 'Area must be greater than or equal to 0' end end diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/gardens_index_spec.rb index 39161d5c8..9cd03a930 100644 --- a/spec/features/gardens/gardens_index_spec.rb +++ b/spec/features/gardens/gardens_index_spec.rb @@ -1,46 +1,46 @@ require 'rails_helper' require 'custom_matchers' -feature "Gardens#index", :js do - context "Logged in as member" do +feature 'Gardens#index', :js do + context 'Logged in as member' do let(:member) { FactoryBot.create :member } background { login_as member } - context "with 10 gardens" do + context 'with 10 gardens' do before do FactoryBot.create_list :garden, 10, owner: member visit gardens_path(member: member) end - it "displays each of the gardens" do + it 'displays each of the gardens' do member.gardens.each do |garden| expect(page).to have_text garden.name end end - it "links to each garden" do + it 'links to each garden' do member.gardens.each do |garden| expect(page).to have_link(garden.name, href: garden_path(garden)) end end end - context "with inactive gardens" do - let!(:active_garden) { FactoryBot.create :garden, name: "My active garden", owner: member } - let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: "retired garden", owner: member } + context 'with inactive gardens' do + let!(:active_garden) { FactoryBot.create :garden, name: 'My active garden', owner: member } + let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: 'retired garden', owner: member } before { visit gardens_path(member: member) } - it "show active garden" do + it 'show active garden' do expect(page).to have_text active_garden.name end - it "should not show inactive garden" do + it 'should not show inactive garden' do expect(page).not_to have_text inactive_garden.name end - it "links to active garden" do + it 'links to active garden' do expect(page).to have_link(active_garden.name, href: garden_path(active_garden)) end - it "does not link to inactive gardens" do + it 'does not link to inactive gardens' do expect(page).not_to have_link(inactive_garden.name, href: garden_path(inactive_garden)) end end @@ -59,10 +59,10 @@ feature "Gardens#index", :js do before do visit gardens_path(member: member) end - it "shows planting in garden" do + it 'shows planting in garden' do expect(page).to have_link(planting.crop.name, href: planting_path(planting)) end - it "does not show finished planting" do + it 'does not show finished planting' do expect(page).not_to have_text(finished_planting.crop.name) end end diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 0954d35eb..613fb688d 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature "Planting a crop", js: true do +feature 'Planting a crop', js: true do # name is aaa to ensure it is ordered first let!(:garden) { create :garden, name: 'aaa' } - let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") } + let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse('2013-3-10') } let!(:tomato) { create :tomato } let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } @@ -11,88 +11,88 @@ feature "Planting a crop", js: true do login_as garden.owner end - scenario "View gardens" do + scenario 'View gardens' do visit gardens_path expect(page).to have_content "Everyone's gardens" - click_link "My Gardens" + click_link 'My Gardens' expect(page).to have_content "#{garden.owner.login_name}'s gardens" click_link "Everyone's gardens" expect(page).to have_content "Everyone's gardens" end - scenario "Marking a garden as inactive" do + scenario 'Marking a garden as inactive' do visit garden_path(garden) - click_link "Mark as inactive" - expect(page).to have_content "Garden was successfully updated" - expect(page).to have_content "This garden is inactive" - expect(page).to have_content "Mark as active" - expect(page).not_to have_content "Mark as inactive" + click_link 'Mark as inactive' + expect(page).to have_content 'Garden was successfully updated' + expect(page).to have_content 'This garden is inactive' + expect(page).to have_content 'Mark as active' + expect(page).not_to have_content 'Mark as inactive' end - scenario "List only active gardens" do + scenario 'List only active gardens' do visit garden_path(garden) - click_link "Mark as inactive" + click_link 'Mark as inactive' visit gardens_path expect(page).not_to have_link garden_path(garden) end - scenario "Create new garden" do + scenario 'Create new garden' do visit new_garden_path - fill_in "Name", with: "New garden" - click_button "Save" - expect(page).to have_content "Garden was successfully created" - expect(page).to have_content "New garden" + fill_in 'Name', with: 'New garden' + click_button 'Save' + expect(page).to have_content 'Garden was successfully created' + expect(page).to have_content 'New garden' end - scenario "Refuse to create new garden with negative area" do + scenario 'Refuse to create new garden with negative area' do visit new_garden_path - fill_in "Name", with: "Negative Garden" - fill_in "Area", with: -5 - click_button "Save" - expect(page).not_to have_content "Garden was successfully created" - expect(page).to have_content "Area must be greater than or equal to 0" + fill_in 'Name', with: 'Negative Garden' + fill_in 'Area', with: -5 + click_button 'Save' + expect(page).not_to have_content 'Garden was successfully created' + expect(page).to have_content 'Area must be greater than or equal to 0' end - context "Clicking edit from the index page" do + context 'Clicking edit from the index page' do background do visit gardens_path end - scenario "button on index to edit garden" do - first(".garden-info").click_link("edit_garden_link") + scenario 'button on index to edit garden' do + first('.garden-info').click_link('edit_garden_link') expect(page).to have_content 'Edit garden' end end - scenario "Edit garden" do + scenario 'Edit garden' do visit new_garden_path - fill_in "Name", with: "New garden" - click_button "Save" + fill_in 'Name', with: 'New garden' + click_button 'Save' click_link 'edit_garden_link' - fill_in "Name", with: "Different name" - click_button "Save" - expect(page).to have_content "Garden was successfully updated" - expect(page).to have_content "Different name" + fill_in 'Name', with: 'Different name' + click_button 'Save' + expect(page).to have_content 'Garden was successfully updated' + expect(page).to have_content 'Different name' end - scenario "Delete garden" do + scenario 'Delete garden' do visit new_garden_path - fill_in "Name", with: "New garden" - click_button "Save" + fill_in 'Name', with: 'New garden' + click_button 'Save' visit garden_path(Garden.last) click_link 'delete_garden_link' - expect(page).to have_content "Garden was successfully deleted" + expect(page).to have_content 'Garden was successfully deleted' expect(page).to have_content "#{garden.owner}'s gardens" end - describe "Making a planting inactive from garden show" do + describe 'Making a planting inactive from garden show' do let(:path) { garden_path garden } - let(:link_text) { "Mark as finished" } + let(:link_text) { 'Mark as finished' } - it_behaves_like "append date" + it_behaves_like 'append date' end - scenario "List only active plantings on a garden" do + scenario 'List only active plantings on a garden' do visit gardens_path expect(page).not_to have_content finished_planting.crop_name end diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 2a8400c2e..30339219a 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "browse harvests" do +feature 'browse harvests' do let!(:member) { create :member } let!(:harvest) { create :harvest, owner: member } @@ -16,11 +16,11 @@ feature "browse harvests" do end scenario 'read more' do - expect(page).not_to have_link "Read more" + expect(page).not_to have_link 'Read more' end end - feature "filled in optional fields" do + feature 'filled in optional fields' do let!(:harvest) { create :harvest, :long_description } before(:each) do @@ -28,7 +28,7 @@ feature "browse harvests" do end scenario 'read more' do - expect(page).to have_link "Read more" + expect(page).to have_link 'Read more' end it 'links to #show' do diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 84c4b5a7f..6c2b253c0 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature "Harvesting a crop", :js, :elasticsearch do +feature 'Harvesting a crop', :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let!(:plant_part) { create :plant_part } @@ -13,44 +13,44 @@ feature "Harvesting a crop", :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like "crop suggest", "harvest", "crop" + it_behaves_like 'crop suggest', 'harvest', 'crop' - it "has the required fields help text" do - expect(page).to have_content "* denotes a required field" + it 'has the required fields help text' do + expect(page).to have_content '* denotes a required field' end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "What did you harvest?" + it 'displays required and optional fields properly' do + expect(page).to have_selector '.form-group.required', text: 'What did you harvest?' expect(page).to have_optional 'input#harvest_quantity' expect(page).to have_optional 'input#harvest_weight_quantity' expect(page).to have_optional 'textarea#harvest_description' end - scenario "Creating a new harvest", :js do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" + scenario 'Creating a new harvest', :js do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' - within "form#new_harvest" do + within 'form#new_harvest' do select plant_part.name, from: 'harvest[plant_part_id]' - fill_in "When?", with: "2014-06-15" - fill_in "How many?", with: 42 - fill_in "Weighing (in total):", with: 42 - fill_in "Notes", with: "It's killer." - click_button "Save" + fill_in 'When?', with: '2014-06-15' + fill_in 'How many?', with: 42 + fill_in 'Weighing (in total):', with: 42 + fill_in 'Notes', with: "It's killer." + click_button 'Save' end - expect(page).to have_content "harvest was successfully created." + expect(page).to have_content 'harvest was successfully created.' end - context "Clicking edit from the index page" do + context 'Clicking edit from the index page' do let!(:harvest) { create :harvest, crop: maize, owner: member } background do visit harvests_path end - scenario "button on index to edit harvest" do - click_link "edit_harvest_glyphicon" + scenario 'button on index to edit harvest' do + click_link 'edit_harvest_glyphicon' expect(current_path).to eq edit_harvest_path(harvest) expect(page).to have_content 'Editing harvest' end @@ -62,58 +62,58 @@ feature "Harvesting a crop", :js, :elasticsearch do expect(current_path).to eq member_path member end - scenario "Harvesting from crop page" do + scenario 'Harvesting from crop page' do visit crop_path(maize) - click_link "Harvest this" - within "form#new_harvest" do + click_link 'Harvest this' + within 'form#new_harvest' do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" - click_button "Save" + click_button 'Save' end - expect(page).to have_content "harvest was successfully created." - expect(page).to have_content "maize" + expect(page).to have_content 'harvest was successfully created.' + expect(page).to have_content 'maize' end - scenario "Harvesting from planting page" do + scenario 'Harvesting from planting page' do planting = create :planting, crop: maize, owner: member, garden: member.gardens.first visit planting_path(planting) - click_link "Harvest" + click_link 'Harvest' select plant_part.name, from: 'harvest[plant_part_id]' - click_button "Save" + click_button 'Save' - expect(page).to have_content "harvest was successfully created." + expect(page).to have_content 'harvest was successfully created.' expect(page).to have_content planting.garden.name - expect(page).to have_content "maize" + expect(page).to have_content 'maize' end - context "Editing a harvest" do + context 'Editing a harvest' do let(:existing_harvest) { create :harvest, crop: maize, owner: member } let!(:other_plant_part) { create :plant_part, name: 'chocolate' } background do visit harvest_path(existing_harvest) - click_link "Edit" + click_link 'Edit' end - scenario "Saving without edits" do + scenario 'Saving without edits' do # Check that the autosuggest helper properly fills inputs with # existing resource's data - click_button "Save" - expect(page).to have_content "harvest was successfully updated." - expect(page).to have_content "maize" + click_button 'Save' + expect(page).to have_content 'harvest was successfully updated.' + expect(page).to have_content 'maize' end - scenario "change plant part" do + scenario 'change plant part' do select other_plant_part.name, from: 'harvest[plant_part_id]' - click_button "Save" - expect(page).to have_content "harvest was successfully updated." + click_button 'Save' + expect(page).to have_content 'harvest was successfully updated.' expect(page).to have_content other_plant_part.name end end - context "Viewing a harvest" do + context 'Viewing a harvest' do let(:existing_harvest) do create :harvest, crop: maize, owner: member, harvested_at: Time.zone.today @@ -127,10 +127,10 @@ feature "Harvesting a crop", :js, :elasticsearch do visit harvest_path(existing_harvest) end - scenario "linking to a planting" do + scenario 'linking to a planting' do expect(page).to have_content planting.to_s choose("harvest_planting_id_#{existing_planting.id}") - click_button "save" + click_button 'save' expect(page).to have_link(href: planting_path(existing_planting)) end end diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 01d164f3c..5dabbfa5e 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature "Changing locales", js: true do +feature 'Changing locales', js: true do after { I18n.locale = :en } - scenario "Locale can be set with a query param" do + scenario 'Locale can be set with a query param' do visit root_path - expect(page).to have_content("a community of food gardeners.") + expect(page).to have_content('a community of food gardeners.') visit root_path(locale: 'ja') - expect(page).to have_content("はガーデナーのコミュニティです。") + expect(page).to have_content('はガーデナーのコミュニティです。') end end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 32b11bda1..bf54c637f 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -1,109 +1,109 @@ require 'rails_helper' -feature "member profile", js: true do - context "signed out member" do +feature 'member profile', js: true do + context 'signed out member' do let(:member) { create :member } - scenario "basic details on member profile page" do + scenario 'basic details on member profile page' do visit member_path(member) - expect(page).to have_css("h1", text: member.login_name) + expect(page).to have_css('h1', text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content "Account type: Free account" + expect(page).to have_content 'Account type: Free account' expect(page).to have_content "#{member.login_name}'s gardens" - expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) + expect(page).to have_link 'More about this garden...', href: garden_path(member.gardens.first) end - scenario "no bio" do + scenario 'no bio' do member.bio = nil member.save visit member_path(member) expect(page).to have_content "hasn't written a bio yet" end - scenario "gravatar" do + scenario 'gravatar' do visit member_path(member) - expect(page).to have_css "img.avatar" + expect(page).to have_css 'img.avatar' end - context "location" do - scenario "member has set location" do + context 'location' do + scenario 'member has set location' do london_member = create :london_member visit member_path(london_member) - expect(page).to have_css("h1>small", text: london_member.location) - expect(page).to have_css("#membermap") + expect(page).to have_css('h1>small', text: london_member.location) + expect(page).to have_css('#membermap') expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}" end - scenario "member has not set location" do + scenario 'member has not set location' do visit member_path(member) - expect(page).not_to have_css("h1>small") - expect(page).not_to have_css("#membermap") - expect(page).not_to have_content "See other members" + expect(page).not_to have_css('h1>small') + expect(page).not_to have_css('#membermap') + expect(page).not_to have_content 'See other members' end end - context "email privacy" do - scenario "public email address" do + context 'email privacy' do + scenario 'public email address' do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario "private email address" do + scenario 'private email address' do visit member_path(member) expect(page).not_to have_content member.email end end - context "email privacy" do - scenario "public email address" do + context 'email privacy' do + scenario 'public email address' do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario "private email address" do + scenario 'private email address' do visit member_path(member) expect(page).not_to have_content member.email end end - context "activity stats" do - scenario "with no activity" do + context 'activity stats' do + scenario 'with no activity' do visit member_path(member) - expect(page).to have_content "Activity" - expect(page).to have_content "0 plantings" - expect(page).to have_content "0 harvests" - expect(page).to have_content "0 seeds" - expect(page).to have_content "0 posts" + expect(page).to have_content 'Activity' + expect(page).to have_content '0 plantings' + expect(page).to have_content '0 harvests' + expect(page).to have_content '0 seeds' + expect(page).to have_content '0 posts' end - scenario "with some activity" do + scenario 'with some activity' do create_list :planting, 2, owner: member create_list :harvest, 3, owner: member create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member) - expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member) - expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member) - expect(page).to have_link "5 posts", href: posts_by_author_path(author: member) + expect(page).to have_link '2 plantings', href: plantings_by_owner_path(owner: member) + expect(page).to have_link '3 harvests', href: harvests_by_owner_path(owner: member) + expect(page).to have_link '4 seeds', href: seeds_by_owner_path(owner: member) + expect(page).to have_link '5 posts', href: posts_by_author_path(author: member) end end - scenario "twitter link" do + scenario 'twitter link' do twitter_auth = create :authentication, member: member visit member_path(member) expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}" end - scenario "flickr link" do + scenario 'flickr link' do flickr_auth = create :flickr_authentication, member: member visit member_path(member) expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}" end end - context "signed in member" do + context 'signed in member' do let(:member) { create :member } let(:other_member) { create :member } let(:admin_member) { create :admin_member } @@ -115,35 +115,35 @@ feature "member profile", js: true do scenario "admin user's page" do visit member_path(admin_member) - expect(page).to have_text "Admin" + expect(page).to have_text 'Admin' end scenario "crop wrangler's page" do visit member_path(crop_wrangler) - expect(page).to have_text "Crop Wrangler" + expect(page).to have_text 'Crop Wrangler' end scenario "ordinary user's page" do visit member_path(other_member) - expect(page).not_to have_text "Crop Wrangler" - expect(page).not_to have_text "Admin" + expect(page).not_to have_text 'Crop Wrangler' + expect(page).not_to have_text 'Admin' end - context "your own profile page" do + context 'your own profile page' do background do visit member_path(member) end - scenario "has a link to create new garden" do - expect(page).to have_link "New Garden", href: new_garden_path + scenario 'has a link to create new garden' do + expect(page).to have_link 'New Garden', href: new_garden_path end - scenario "has a button to edit profile" do - expect(page).to have_link "Edit profile", href: edit_member_registration_path + scenario 'has a button to edit profile' do + expect(page).to have_link 'Edit profile', href: edit_member_registration_path end - scenario "has a button to upgrade account" do - expect(page).to have_link "Upgrade account", href: shop_path + scenario 'has a button to upgrade account' do + expect(page).to have_link 'Upgrade account', href: shop_path end end @@ -152,18 +152,18 @@ feature "member profile", js: true do visit member_path(other_member) end - scenario "has a private message button" do - expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) + scenario 'has a private message button' do + expect(page).to have_link 'Send message', href: new_notification_path(recipient_id: other_member.id) end end - context "home page" do + context 'home page' do background do visit root_path end - scenario "does not have a button to edit profile" do - expect(page).not_to have_link "Edit profile", href: edit_member_registration_path + scenario 'does not have a button to edit profile' do + expect(page).not_to have_link 'Edit profile', href: edit_member_registration_path end end end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 793a6ada5..58041c581 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "member deletion" do - context "with activity and followers" do +feature 'member deletion' do + context 'with activity and followers' do let(:member) { FactoryBot.create(:member) } let(:other_member) { FactoryBot.create(:member) } let(:memberpost) { FactoryBot.create(:post, author: member) } @@ -24,86 +24,86 @@ feature "member deletion" do logout login_as(member) FactoryBot.create(:comment, author: member, post: othermemberpost) - FactoryBot.create(:comment, author: other_member, post: memberpost, body: "Fun comment-y thing") + FactoryBot.create(:comment, author: other_member, post: memberpost, body: 'Fun comment-y thing') # deletion breaks if no wranglers exist FactoryBot.create(:cropbot) # deletion breaks if ex_member doesn't exist - FactoryBot.create(:member, login_name: "ex_member") + FactoryBot.create(:member, login_name: 'ex_member') end - scenario "has option to delete on member profile page" do + scenario 'has option to delete on member profile page' do visit member_path(member) click_link 'Edit profile' - expect(page).to have_link "Delete Account" + expect(page).to have_link 'Delete Account' end - scenario "asks for password before deletion" do + scenario 'asks for password before deletion' do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - click_button "Delete" + click_button 'Delete' expect(page).to have_content "Current password can't be blank" end - scenario "password must be correct" do + scenario 'password must be correct' do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in "current_pw_for_delete", with: "wrongpassword" - click_button "Delete" - expect(page).to have_content "Current password is invalid" + fill_in 'current_pw_for_delete', with: 'wrongpassword' + click_button 'Delete' + expect(page).to have_content 'Current password is invalid' end - scenario "deletes and removes bio" do + scenario 'deletes and removes bio' do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact - click_button "Delete" + fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact + click_button 'Delete' visit member_path(member) expect(page.status_code).to eq(404) end - context "deletes and" do + context 'deletes and' do background do logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact - click_button "Delete" + fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact + click_button 'Delete' logout end - scenario "removes plantings" do + scenario 'removes plantings' do visit planting_path(planting) expect(page.status_code).to eq(404) end - scenario "removes gardens" do + scenario 'removes gardens' do visit garden_path(secondgarden) expect(page.status_code).to eq(404) end - scenario "removes harvests and seeds" do + scenario 'removes harvests and seeds' do visit harvest_path(harvest) expect(page.status_code).to eq(404) end - scenario "removes seeds" do + scenario 'removes seeds' do visit seed_path(seed) expect(page.status_code).to eq(404) end - scenario "removes members from following" do + scenario 'removes members from following' do visit member_follows_path(other_member) expect(page).not_to have_content member.login_name.to_s visit member_followers_path(other_member) expect(page).not_to have_content member.login_name.to_s end - scenario "replaces posts with deletion note" do + scenario 'replaces posts with deletion note' do visit post_path(memberpost) expect(page.status_code).to eq(404) end @@ -112,16 +112,16 @@ feature "member deletion" do visit post_path(othermemberpost) expect(page).not_to have_content member.login_name expect(page).to have_content other_member.login_name - expect(page).to have_content "Member Deleted" + expect(page).to have_content 'Member Deleted' end - scenario "leaves a record of orders and payments intact" do + scenario 'leaves a record of orders and payments intact' do login_as(admin) visit admin_path - fill_in "search_text", with: member.login_name.to_s - find("#maincontainer").click_button("Search", exact: true) + fill_in 'search_text', with: member.login_name.to_s + find('#maincontainer').click_button('Search', exact: true) expect(page).to have_content member.login_name.to_s - expect(page).to have_content "Found 1 result" + expect(page).to have_content 'Found 1 result' logout end @@ -133,7 +133,7 @@ feature "member deletion" do pending "doesn't show in nearby" - scenario "can no longer sign in" do + scenario 'can no longer sign in' do visit new_member_session_path fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password @@ -143,25 +143,25 @@ feature "member deletion" do end end - context "for a crop wrangler" do + context 'for a crop wrangler' do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:otherwrangler) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop, creator: member) } FactoryBot.create(:cropbot) - let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: "ex_wrangler") } + let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: 'ex_wrangler') } - scenario "leaves crops behind" do + scenario 'leaves crops behind' do login_as(otherwrangler) visit edit_crop_path(crop) expect(page).to have_content member.login_name - expect(page).not_to have_content "cropbot" + expect(page).not_to have_content 'cropbot' logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact - click_button "Delete" + fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact + click_button 'Delete' login_as(otherwrangler) visit edit_crop_path(crop) expect(page).not_to have_content member.login_name diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 01b6ee8bd..395766fb9 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature "members list" do - context "list all members" do - let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') } - let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') } - let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') } +feature 'members list' do + context 'list all members' do + let!(:member1) { create :member, login_name: 'Archaeopteryx', confirmed_at: Time.zone.parse('2013-02-10') } + let!(:member2) { create :member, login_name: 'Zephyrosaurus', confirmed_at: Time.zone.parse('2014-01-11') } + let!(:member3) { create :member, login_name: 'Testingname', confirmed_at: Time.zone.parse('2014-05-09') } - scenario "default alphabetical sort" do + scenario 'default alphabetical sort' do visit members_path - expect(page).to have_css "#sort" - expect(page).to have_selector "form" + expect(page).to have_css '#sort' + expect(page).to have_selector 'form' click_button('Show') - all_links = page.all("#maincontainer p.login-name") + all_links = page.all('#maincontainer p.login-name') expect(all_links.first).to have_text member1.login_name expect(all_links.last).to have_text member2.login_name end - scenario "recently joined sort" do + scenario 'recently joined sort' do visit members_path - expect(page).to have_css "#sort" - expect(page).to have_selector "form" - select("recently", from: 'sort') + expect(page).to have_css '#sort' + expect(page).to have_selector 'form' + select('recently', from: 'sort') click_button('Show') - all_links = page.all("#maincontainer p.login-name") + all_links = page.all('#maincontainer p.login-name') expect(all_links.first).to have_text member3.login_name expect(all_links.last).to have_text member1.login_name end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index aa81403d6..1c0f31110 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature "Notifications", :js do +feature 'Notifications', :js do let(:sender) { create :member } let(:recipient) { create :member } - context "On existing notification" do + context 'On existing notification' do let!(:notification) do create :notification, sender: sender, recipient: recipient, - body: "Notification body", + body: 'Notification body', post_id: nil end @@ -18,14 +18,14 @@ feature "Notifications", :js do visit notification_path(notification) end - scenario "Replying to the notification" do - click_link "Reply" - expect(page).to have_content "Notification body" + scenario 'Replying to the notification' do + click_link 'Reply' + expect(page).to have_content 'Notification body' - fill_in 'notification_body', with: "Response body" - click_button "Send" + fill_in 'notification_body', with: 'Response body' + click_button 'Send' - expect(page).to have_content "Message was successfully sent" + expect(page).to have_content 'Message was successfully sent' end end diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 1c13b2793..cc2c16593 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -1,49 +1,49 @@ require 'rails_helper' -feature "new photo page" do +feature 'new photo page' do let(:photo) { FactoryBot.create :photo } - context "signed in member" do + context 'signed in member' do let(:member) { FactoryBot.create :member } background { login_as member } - context "viewing a planting" do + context 'viewing a planting' do let(:planting) { FactoryBot.create :planting, owner: member } - scenario "add photo" do + scenario 'add photo' do visit planting_path(planting) click_link('Add photo', match: :first) expect(page).to have_text planting.crop.name end end - context "viewing a harvest" do + context 'viewing a harvest' do let(:harvest) { FactoryBot.create :harvest, owner: member } - scenario "add photo" do + scenario 'add photo' do visit harvest_path(harvest) - click_link "Add photo" + click_link 'Add photo' expect(page).to have_text harvest.crop.name end end - context "viewing a garden" do + context 'viewing a garden' do let(:garden) { FactoryBot.create :garden, owner: member } - scenario "add photo" do + scenario 'add photo' do visit garden_path(garden) - click_link "Add photo" + click_link 'Add photo' expect(page).to have_text garden.name end end - pending "viewing a seed" do + pending 'viewing a seed' do let(:seed) { FactoryBot.create :seed, owner: member } - scenario "add photo" do + scenario 'add photo' do visit seed_path(seed) - click_link "Add photo" + click_link 'Add photo' expect(page).to have_text seed.to_s end end diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index bac25b370..4d96a0193 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature "show photo page" do +feature 'show photo page' do let(:photo) { create :photo } - context "signed in member" do + context 'signed in member' do let(:member) { create :member } background { login_as member } - context "linked to planting" do + context 'linked to planting' do let(:planting) { create :planting } - scenario "shows linkback to planting" do + scenario 'shows linkback to planting' do planting.photos << photo visit photo_path(photo) expect(page).to have_link "#{planting.crop.name} planting in #{planting.garden.name} by #{planting.owner}", @@ -19,30 +19,30 @@ feature "show photo page" do end end - context "linked to harvest" do + context 'linked to harvest' do let(:harvest) { create :harvest } - scenario "shows linkback to harvest" do + scenario 'shows linkback to harvest' do harvest.photos << photo visit photo_path(photo) expect(page).to have_link "#{harvest.crop.name} harvest by #{harvest.owner}", href: harvest_path(harvest) end end - context "linked to garden" do + context 'linked to garden' do let(:garden) { create :garden } - scenario "shows linkback to garden" do + scenario 'shows linkback to garden' do garden.photos << photo visit photo_path(photo) expect(page).to have_link "garden named \"#{garden.name}\" by #{garden.owner}", href: garden_path(garden) end end - context "linked to seed" do + context 'linked to seed' do let(:seed) { create :seed } - scenario "shows linkback to seed" do + scenario 'shows linkback to seed' do seed.photos << photo visit photo_path(photo) expect(page).to have_link "#{seed.crop.name} seeds belonging to #{seed.owner}", href: seed_path(seed) diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index edbb06e59..dd2b47712 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -1,39 +1,39 @@ -require "rails_helper" +require 'rails_helper' -feature "User searches" do - let(:member) { create :member, location: "Philippines" } +feature 'User searches' do + let(:member) { create :member, location: 'Philippines' } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:seed1) { create :seed, owner: member } - let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") } + let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') } - scenario "with a valid place" do + scenario 'with a valid place' do visit places_path - search_with "Philippines" - expect(page).to have_content "community near Philippines" - expect(page).to have_button "search_button" - expect(page).to have_content "Nearby members" - expect(page).not_to have_content "No results found" + search_with 'Philippines' + expect(page).to have_content 'community near Philippines' + expect(page).to have_button 'search_button' + expect(page).to have_content 'Nearby members' + expect(page).not_to have_content 'No results found' end - scenario "with a blank search string" do + scenario 'with a blank search string' do visit places_path - search_with "" - expect(page).to have_content "Please enter a valid location" - expect(page).to have_button "search_button" + search_with '' + expect(page).to have_content 'Please enter a valid location' + expect(page).to have_button 'search_button' end - describe "Nearby plantings, seed, and members" do + describe 'Nearby plantings, seed, and members' do before do login_as member visit places_path - search_with "Philippines" + search_with 'Philippines' end - it "should show that there are nearby seeds, plantings, and members" do - expect(page).to have_content "Nearby members" - expect(page).to have_content "Seeds available for trade near Philippines" - expect(page).to have_content "Recent plantings near Philippines" + it 'should show that there are nearby seeds, plantings, and members' do + expect(page).to have_content 'Nearby members' + expect(page).to have_content 'Seeds available for trade near Philippines' + expect(page).to have_content 'Recent plantings near Philippines' end it "should go to members' index page" do @@ -55,7 +55,7 @@ feature "User searches" do private def search_with(search_string) - fill_in "new_place", with: search_string - click_button "search_button" + fill_in 'new_place', with: search_string + click_button 'search_button' end end diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 3b407c3df..5a9d954b8 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature "Planting reminder email", :js do +feature 'Planting reminder email', :js do let(:member) { create :member } let(:mail) { Notifier.planting_reminder(member) } @@ -11,13 +11,13 @@ feature "Planting reminder email", :js do { host: 'localhost', port: 8080 } end - scenario "has a greeting" do - expect(mail).to have_content "Hello" + scenario 'has a greeting' do + expect(mail).to have_content 'Hello' end - context "when member has no plantings" do - scenario "tells you to track your plantings" do - expect(mail).to have_content "planting your first crop" + context 'when member has no plantings' do + scenario 'tells you to track your plantings' do + expect(mail).to have_content 'planting your first crop' end scenario "doesn't list plantings" do @@ -25,41 +25,41 @@ feature "Planting reminder email", :js do end end - context "when member has some plantings" do + context 'when member has some plantings' do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the email is generated: otherwise, they won't be present in the email. let!(:p1) { create :planting, garden: member.gardens.first, owner: member } let!(:p2) { create :planting, garden: member.gardens.first, owner: member } - scenario "lists plantings" do + scenario 'lists plantings' do expect(mail).to have_content "most recent plantings you've told us about" expect(mail).to have_link p1.to_s, href: planting_url(p1) expect(mail).to have_link p2.to_s, href: planting_url(p2) - expect(mail).to have_content "keep your garden records up to date" + expect(mail).to have_content 'keep your garden records up to date' end end - context "when member has no harvests" do - scenario "tells you to tracking plantings" do - expect(mail).to have_content "Get started now by tracking your first harvest" + context 'when member has no harvests' do + scenario 'tells you to tracking plantings' do + expect(mail).to have_content 'Get started now by tracking your first harvest' end scenario "doesn't list plantings" do - expect(mail).not_to have_content "the last few things you harvested were" + expect(mail).not_to have_content 'the last few things you harvested were' end end - context "when member has some harvests" do + context 'when member has some harvests' do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the spec is run. let!(:h1) { create :harvest, owner: member } let!(:h2) { create :harvest, owner: member } - scenario "lists harvests" do - expect(mail).to have_content "the last few things you harvested were" + scenario 'lists harvests' do + expect(mail).to have_content 'the last few things you harvested were' expect(mail).to have_link h1.to_s, href: harvest_url(h1) expect(mail).to have_link h2.to_s, href: harvest_url(h2) - expect(mail).to have_content "Harvested anything else lately?" + expect(mail).to have_content 'Harvested anything else lately?' end end end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 0e26d7078..ad1cfb5ff 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,12 +1,12 @@ -require "rails_helper" +require 'rails_helper' require 'custom_matchers' -feature "Planting a crop", :js, :elasticsearch do +feature 'Planting a crop', :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:planting) do - create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") + create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') end background do @@ -15,15 +15,15 @@ feature "Planting a crop", :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like "crop suggest", "planting" + it_behaves_like 'crop suggest', 'planting' - it "has the required fields help text" do - expect(page).to have_content "* denotes a required field" + it 'has the required fields help text' do + expect(page).to have_content '* denotes a required field' end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "What did you plant?" - expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" + it 'displays required and optional fields properly' do + expect(page).to have_selector '.form-group.required', text: 'What did you plant?' + expect(page).to have_selector '.form-group.required', text: 'Where did you plant it?' expect(page).to have_optional 'input#planting_planted_at' expect(page).to have_optional 'input#planting_quantity' expect(page).to have_optional 'select#planting_planted_from' @@ -32,20 +32,20 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_optional 'input#planting_finished_at' end - scenario "Creating a new planting" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: "2014-06-15" - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - click_button "Save" + scenario 'Creating a new planting' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: '2014-06-15' + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "Progress: Not enough data" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'Progress: Not enough data' end scenario "Clicking link to owner's profile" do @@ -54,230 +54,230 @@ feature "Planting a crop", :js, :elasticsearch do expect(current_path).to eq member_path(member) end - describe "Progress bar status on planting creation" do + describe 'Progress bar status on planting creation' do before do login_as member visit new_planting_path - @a_past_date = 15.days.ago.strftime("%Y-%m-%d") - @right_now = Time.zone.today.strftime("%Y-%m-%d") - @a_future_date = 1.year.from_now.strftime("%Y-%m-%d") + @a_past_date = 15.days.ago.strftime('%Y-%m-%d') + @right_now = Time.zone.today.strftime('%Y-%m-%d') + @a_future_date = 1.year.from_now.strftime('%Y-%m-%d') end - it "should show that it is not planted yet" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: @a_future_date - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - click_button "Save" + it 'should show that it is not planted yet' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: @a_future_date + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "Progress: 0% - not planted yet" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'Progress: 0% - not planted yet' end - it "should show that days before maturity is unknown" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: @a_past_date - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - click_button "Save" + it 'should show that days before maturity is unknown' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: @a_past_date + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "Progress: Not enough data" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'Progress: Not enough data' end - it "should show that planting is in progress" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: @right_now - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - fill_in "Finished date", with: @a_future_date - click_button "Save" + it 'should show that planting is in progress' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: @right_now + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + fill_in 'Finished date', with: @a_future_date + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).not_to have_content "Progress: 0% - not planted yet" - expect(page).not_to have_content "Not enough data" + expect(page).to have_content 'planting was successfully created' + expect(page).not_to have_content 'Progress: 0% - not planted yet' + expect(page).not_to have_content 'Not enough data' end - it "should show that planting is 100% complete (no date specified)" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: @right_now - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - check "Mark as finished" - click_button "Save" + it 'should show that planting is 100% complete (no date specified)' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: @right_now + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + check 'Mark as finished' + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "100%" - expect(page).to have_content "Yes (no date specified)" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content '100%' + expect(page).to have_content 'Yes (no date specified)' end - it "should show that planting is 100% complete (date specified)" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: @a_past_date - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "semi-shade", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - fill_in "Finished date", with: @right_now - click_button "Save" + it 'should show that planting is 100% complete (date specified)' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: @a_past_date + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'semi-shade', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + fill_in 'Finished date', with: @right_now + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "100%" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content '100%' end end - scenario "Planting from crop page" do + scenario 'Planting from crop page' do visit crop_path(maize) - click_link "Plant this" - within "form#new_planting" do + click_link 'Plant this' + within 'form#new_planting' do expect(page).to have_selector "input[value='maize']" - click_button "Save" + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "maize" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'maize' end - scenario "Editing a planting to add details" do + scenario 'Editing a planting to add details' do visit planting_path(planting) - click_link "Edit" - fill_in "Tell us more about it", with: "Some extra notes" - click_button "Save" - expect(page).to have_content "planting was successfully updated" + click_link 'Edit' + fill_in 'Tell us more about it', with: 'Some extra notes' + click_button 'Save' + expect(page).to have_content 'planting was successfully updated' end - scenario "Editing a planting to fill in the finished date" do + scenario 'Editing a planting to fill in the finished date' do visit planting_path(planting) - expect(page).to have_content "Progress: Not enough data" - click_link "Edit" - check "finished" - fill_in "Finished date", with: "2015-06-25" - click_button "Save" - expect(page).to have_content "planting was successfully updated" - expect(page).not_to have_content "Progress: Not enough data" + expect(page).to have_content 'Progress: Not enough data' + click_link 'Edit' + check 'finished' + fill_in 'Finished date', with: '2015-06-25' + click_button 'Save' + expect(page).to have_content 'planting was successfully updated' + expect(page).not_to have_content 'Progress: Not enough data' end - scenario "Marking a planting as finished" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When?", with: "2014-07-01" - check "Mark as finished" - fill_in "Finished date", with: "2014-08-30" + scenario 'Marking a planting as finished' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When?', with: '2014-07-01' + check 'Mark as finished' + fill_in 'Finished date', with: '2014-08-30' # Trigger click instead of using Capybara"s uncheck # because a date selection widget is overlapping # the checkbox preventing interaction. - find("#planting_finished").trigger 'click' + find('#planting_finished').trigger 'click' end # Javascript removes the finished at date when the # planting is marked unfinished. - expect(find("#planting_finished_at").value).to eq("") + expect(find('#planting_finished_at').value).to eq('') - within "form#new_planting" do - find("#planting_finished").trigger 'click' + within 'form#new_planting' do + find('#planting_finished').trigger 'click' end # The finished at date was cached in Javascript in # case the user clicks unfinished accidentally. - expect(find("#planting_finished_at").value).to eq("2014-08-30") + expect(find('#planting_finished_at').value).to eq('2014-08-30') - within "form#new_planting" do - click_button "Save" + within 'form#new_planting' do + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "Finished: August 30, 2014" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'Finished: August 30, 2014' # shouldn't be on the page visit plantings_path - expect(page).not_to have_content "maize" + expect(page).not_to have_content 'maize' # show all plantings to see this finished planting visit plantings_path(all: 1) - expect(page).to have_content "August 30, 2014" + expect(page).to have_content 'August 30, 2014' end - scenario "Marking a planting as finished without a date" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - check "Mark as finished" - click_button "Save" + scenario 'Marking a planting as finished without a date' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + check 'Mark as finished' + click_button 'Save' end - expect(page).to have_content "planting was successfully created" - expect(page).to have_content "Finished: Yes (no date specified)" - expect(page).to have_content "100%" + expect(page).to have_content 'planting was successfully created' + expect(page).to have_content 'Finished: Yes (no date specified)' + expect(page).to have_content '100%' end - describe "Planting sunniness" do - it "should show the a sunny image" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: "2015-10-15" - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - select "sun", from: "Sun or shade?" - fill_in "Tell us more about it", with: "It's rad." - check "Mark as finished" - click_button "Save" + describe 'Planting sunniness' do + it 'should show the a sunny image' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: '2015-10-15' + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + select 'sun', from: 'Sun or shade?' + fill_in 'Tell us more about it', with: "It's rad." + check 'Mark as finished' + click_button 'Save' end expect(page).to have_css("img[alt='sun']") end - it "should show a sunniness not specified image" do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_planting" do - fill_in "When", with: "2015-10-15" - fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" - fill_in "Tell us more about it", with: "It's rad." - check "Mark as finished" - click_button "Save" + it 'should show a sunniness not specified image' do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_planting' do + fill_in 'When', with: '2015-10-15' + fill_in 'How many?', with: 42 + select 'cutting', from: 'Planted from:' + fill_in 'Tell us more about it', with: "It's rad." + check 'Mark as finished' + click_button 'Save' end expect(page).to have_css("img[alt='not specified']") end end - describe "Marking a planting as finished from the show page" do + describe 'Marking a planting as finished from the show page' do let(:path) { planting_path(planting) } - let(:link_text) { "Mark as finished" } + let(:link_text) { 'Mark as finished' } - it_behaves_like "append date" + it_behaves_like 'append date' end - describe "Marking a planting as finished from the list page" do + describe 'Marking a planting as finished from the list page' do let(:path) { plantings_path } - let(:link_text) { "Mark as finished" } + let(:link_text) { 'Mark as finished' } - it_behaves_like "append date" + it_behaves_like 'append date' end end diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index ac31b6fec..6e1b7aa55 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -8,26 +8,26 @@ feature 'Post a post' do visit new_post_path end - scenario "creating a post" do - fill_in "post_subject", with: "Testing" - fill_in "post_body", with: "This is a sample test" - click_button "Post" - expect(page).to have_content "Post was successfully created" - expect(page).to have_content "Posted by" + scenario 'creating a post' do + fill_in 'post_subject', with: 'Testing' + fill_in 'post_body', with: 'This is a sample test' + click_button 'Post' + expect(page).to have_content 'Post was successfully created' + expect(page).to have_content 'Posted by' end - context "editing a post" do + context 'editing a post' do let(:existing_post) { create :post, author: member } background do visit edit_post_path(existing_post) end - scenario "saving edit" do - fill_in "post_subject", with: "Testing Edit" - click_button "Post" - expect(page).to have_content "Post was successfully updated" - expect(page).to have_content "edited at" + scenario 'saving edit' do + fill_in 'post_subject', with: 'Testing Edit' + click_button 'Post' + expect(page).to have_content 'Post was successfully updated' + expect(page).to have_content 'edited at' end end end diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 59833eff1..a7b15d1a9 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -8,7 +8,7 @@ feature 'Plantings RSS feed' do scenario 'The index title is what we expect' do visit plantings_path(format: 'rss') - expect(page).to have_content "Recent plantings from "\ + expect(page).to have_content 'Recent plantings from '\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 445a50cca..869c00214 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -8,7 +8,7 @@ feature 'Posts RSS feed' do scenario 'The index title is what we expect' do visit posts_path(format: 'rss') - expect(page).to have_content "Recent posts from "\ + expect(page).to have_content 'Recent posts from '\ "#{@author ? @author : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index 888cc42ec..d4981aea5 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -8,7 +8,7 @@ feature 'Seeds RSS feed' do scenario 'The index title is what we expect' do visit seeds_path(format: 'rss') - expect(page).to have_content "Recent seeds from "\ + expect(page).to have_content 'Recent seeds from '\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index d6daf709b..a232b9d0d 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature "Scientific names", js: true do +feature 'Scientific names', js: true do let!(:zea_mays) { create :zea_mays } let(:crop) { zea_mays.crop } - scenario "Display scientific names on crop page" do + scenario 'Display scientific names on crop page' do visit crop_path(zea_mays.crop) expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - scenario "Index page for scientific names" do + scenario 'Index page for scientific names' do visit scientific_names_path expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - context "User is a crop wrangler" do + context 'User is a crop wrangler' do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -24,59 +24,59 @@ feature "Scientific names", js: true do login_as(member) end - scenario "Crop wranglers can edit scientific names" do + scenario 'Crop wranglers can edit scientific names' do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content "CROP WRANGLER" + expect(page).to have_content 'CROP WRANGLER' expect(page).to have_content zea_mays.name - expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays) - within('.scientific_names') { click_on "Edit" } + expect(page).to have_link 'Edit', href: edit_scientific_name_path(zea_mays) + within('.scientific_names') { click_on 'Edit' } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: "Zea mirabila" - click_on "Save" - expect(page).to have_content "Zea mirabila" + fill_in 'Name', with: 'Zea mirabila' + click_on 'Save' + expect(page).to have_content 'Zea mirabila' expect(page).to have_content 'crop was successfully updated' end - scenario "Crop wranglers can delete scientific names" do + scenario 'Crop wranglers can delete scientific names' do visit crop_path(zea_mays.crop) - expect(page).to have_link "Delete", + expect(page).to have_link 'Delete', href: scientific_name_path(zea_mays) - within('.scientific_names') { click_on "Delete" } + within('.scientific_names') { click_on 'Delete' } expect(page.status_code).to equal 200 expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' end - scenario "Crop wranglers can add scientific names" do + scenario 'Crop wranglers can add scientific names' do visit crop_path(crop) - expect(page).to have_link "Add", + expect(page).to have_link 'Add', href: new_scientific_name_path(crop_id: crop.id) - within('.scientific_names') { click_on "Add" } + within('.scientific_names') { click_on 'Add' } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: "Zea mirabila" - click_on "Save" + fill_in 'Name', with: 'Zea mirabila' + click_on 'Save' expect(page.status_code).to equal 200 - expect(page).to have_content "Zea mirabila" + expect(page).to have_content 'Zea mirabila' expect(page).to have_content 'crop was successfully created.' end - scenario "The show-scientific-name page works" do + scenario 'The show-scientific-name page works' do visit scientific_name_path(zea_mays) expect(page.status_code).to equal 200 expect(page).to have_link zea_mays.crop.name, href: crop_path(zea_mays.crop) end - context "When scientific name is pending" do + context 'When scientific name is pending' do let(:pending_crop) { create :crop_request } let(:pending_sci_name) { create :scientific_name, crop: pending_crop } - scenario "Displays crop pending message" do + scenario 'Displays crop pending message' do visit scientific_name_path(pending_sci_name) - expect(page).to have_content "This crop is currently pending approval" + expect(page).to have_content 'This crop is currently pending approval' end end end diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 4c183ae24..d1f6acfac 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature "Seeds", :js, :elasticsearch do +feature 'Seeds', :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } @@ -11,14 +11,14 @@ feature "Seeds", :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like "crop suggest", "seed", "crop" + it_behaves_like 'crop suggest', 'seed', 'crop' - it "has the required fields help text" do - expect(page).to have_content "* denotes a required field" + it 'has the required fields help text' do + expect(page).to have_content '* denotes a required field' end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "Crop:" + it 'displays required and optional fields properly' do + expect(page).to have_selector '.form-group.required', text: 'Crop:' expect(page).to have_optional 'input#seed_quantity' expect(page).to have_optional 'input#seed_plant_before' expect(page).to have_optional 'input#seed_days_until_maturity_min' @@ -30,40 +30,40 @@ feature "Seeds", :js, :elasticsearch do expect(page).to have_selector '.form-group.required', text: 'Will trade:' end - scenario "Adding a new seed", js: true do - fill_autocomplete "crop", with: "mai" - select_from_autocomplete "maize" - within "form#new_seed" do - fill_in "Quantity:", with: 42 - fill_in "Plant before:", with: "2014-06-15" - fill_in "Days until maturity:", with: 999 - fill_in "to", with: 1999 - select "certified organic", from: "Organic?" - select "non-certified GMO-free", from: "GMO?" - select "heirloom", from: "Heirloom?" - fill_in "Description", with: "It's killer." - select "internationally", from: "Will trade:" - click_button "Save" + scenario 'Adding a new seed', js: true do + fill_autocomplete 'crop', with: 'mai' + select_from_autocomplete 'maize' + within 'form#new_seed' do + fill_in 'Quantity:', with: 42 + fill_in 'Plant before:', with: '2014-06-15' + fill_in 'Days until maturity:', with: 999 + fill_in 'to', with: 1999 + select 'certified organic', from: 'Organic?' + select 'non-certified GMO-free', from: 'GMO?' + select 'heirloom', from: 'Heirloom?' + fill_in 'Description', with: "It's killer." + select 'internationally', from: 'Will trade:' + click_button 'Save' end - expect(page).to have_content "Successfully added maize seed to your stash" - expect(page).to have_content "Quantity: 42" - expect(page).to have_content "Days until maturity: 999–1999" - expect(page).to have_content "certified organic" - expect(page).to have_content "non-certified GMO-free" - expect(page).to have_content "Heirloom? heirloom" + expect(page).to have_content 'Successfully added maize seed to your stash' + expect(page).to have_content 'Quantity: 42' + expect(page).to have_content 'Days until maturity: 999–1999' + expect(page).to have_content 'certified organic' + expect(page).to have_content 'non-certified GMO-free' + expect(page).to have_content 'Heirloom? heirloom' expect(page).to have_content "It's killer." end - scenario "Adding a seed from crop page" do + scenario 'Adding a seed from crop page' do visit crop_path(maize) - click_link "Add seeds to stash" - within "form#new_seed" do + click_link 'Add seeds to stash' + within 'form#new_seed' do expect(page).to have_selector "input[value='maize']" - click_button "Save" + click_button 'Save' end - expect(page).to have_content "Successfully added maize seed to your stash" - expect(page).to have_content "maize" + expect(page).to have_content 'Successfully added maize seed to your stash' + expect(page).to have_content 'maize' end end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 1db053a80..824a2f5c7 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "seeds", js: true do - context "signed in user" do +feature 'seeds', js: true do + context 'signed in user' do let(:member) { create :member } let(:crop) { create :crop } @@ -9,17 +9,17 @@ feature "seeds", js: true do login_as member end - scenario "button on index to edit seed" do + scenario 'button on index to edit seed' do seed = create :seed, owner: member visit seeds_path - click_link "edit_seed_glyphicon" + click_link 'edit_seed_glyphicon' expect(current_path).to eq edit_seed_path(seed) expect(page).to have_content 'Editing seeds' end - scenario "button on front page to add seeds" do + scenario 'button on front page to add seeds' do visit root_path - click_link "Add seeds" + click_link 'Add seeds' expect(current_path).to eq new_seed_path expect(page).to have_content 'Add seeds' end @@ -32,7 +32,7 @@ feature "seeds", js: true do # actually adding seeds is in spec/features/seeds_new_spec.rb - scenario "edit seeds" do + scenario 'edit seeds' do seed = create :seed, owner: member visit seed_path(seed) click_link 'Edit' @@ -42,35 +42,35 @@ feature "seeds", js: true do expect(current_path).to eq seed_path(seed) end - scenario "delete seeds" do + scenario 'delete seeds' do seed = create :seed, owner: member visit seed_path(seed) click_link 'Delete' expect(current_path).to eq seeds_path end - scenario "view seeds with max and min days until maturity" do + scenario 'view seeds with max and min days until maturity' do seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content "Days until maturity: 5–7" + expect(page).to have_content 'Days until maturity: 5–7' end - scenario "view seeds with only max days until maturity" do + scenario 'view seeds with only max days until maturity' do seed = create :seed, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content "Days until maturity: 7" + expect(page).to have_content 'Days until maturity: 7' end - scenario "view seeds with only min days until maturity" do + scenario 'view seeds with only min days until maturity' do seed = create :seed, days_until_maturity_min: 5 visit seed_path(seed) - expect(page).to have_content "Days until maturity: 5" + expect(page).to have_content 'Days until maturity: 5' end - scenario "view seeds with neither max nor min days until maturity" do + scenario 'view seeds with neither max nor min days until maturity' do seed = create :seed visit seed_path(seed) - expect(page).to have_content "Days until maturity: unknown" + expect(page).to have_content 'Days until maturity: unknown' end end end diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 7e26ece28..d0bd8531b 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature "Seeds", :js do +feature 'Seeds', :js do subject do login_as member visit seed_path(seed) @@ -26,16 +26,16 @@ feature "Seeds", :js do before { seed.photos = photos } let!(:photos) { FactoryBot.create_list :photo, 50 } - it "shows newest photo" do + it 'shows newest photo' do is_expected.to have_xpath("//img[contains(@src,'#{photos.last.thumbnail_url}')]") end - it "links to newest photo" do + it 'links to newest photo' do is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photos.last)}')]") end - it "does not show oldest photo" do + it 'does not show oldest photo' do is_expected.not_to have_xpath("//img[contains(@src,'#{photos.first.thumbnail_url}')]") end - it "does not link to oldest photo" do + it 'does not link to oldest photo' do is_expected.not_to have_xpath("//a[contains(@href,'#{photo_path(photos.first)}')]") end end diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index 03e29c5f4..eda8257ba 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -1,21 +1,21 @@ -shared_examples "append date" do - let(:this_month) { Time.zone.today.strftime("%B") } - let(:this_year) { Time.zone.today.strftime("%Y") } +shared_examples 'append date' do + let(:this_month) { Time.zone.today.strftime('%B') } + let(:this_year) { Time.zone.today.strftime('%Y') } background { visit path } - scenario "Selecting a date with datepicker" do + scenario 'Selecting a date with datepicker' do click_link link_text - within "div.datepicker" do + within 'div.datepicker' do expect(page).to have_content this_month.to_s - find(".datepicker-days td.day", text: "21").click + find('.datepicker-days td.day', text: '21').click end expect(page).to have_content "Finished: #{this_month} 21, #{this_year}" end - scenario "Confirming without selecting date" do + scenario 'Confirming without selecting date' do click_link link_text - click_link "Confirm without date" - expect(page).to have_content("Finished: Yes (no date specified) ") + click_link 'Confirm without date' + expect(page).to have_content('Finished: Yes (no date specified) ') end end diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 0d2e688a1..5bd51205d 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -1,6 +1,6 @@ require 'rails_helper' -shared_examples "crop suggest" do |resource| +shared_examples 'crop suggest' do |resource| let!(:pea) { create :crop, name: 'pea' } let!(:pear) { create :pear } let!(:tomato) { create :tomato } @@ -8,66 +8,66 @@ shared_examples "crop suggest" do |resource| background { sync_elasticsearch [pea, pear, maize, tomato] } - scenario "placeholder text in crop auto suggest field" do + scenario 'placeholder text in crop auto suggest field' do expect(page).to have_selector("input[placeholder='e.g. lettuce']") end - scenario "typing in the crop name displays suggestions" do + scenario 'typing in the crop name displays suggestions' do within "form#new_#{resource}" do - fill_autocomplete "crop", with: "pe" + fill_autocomplete 'crop', with: 'pe' end - expect(page).not_to have_content("pear") - expect(page).not_to have_content("pea") + expect(page).not_to have_content('pear') + expect(page).not_to have_content('pea') within "form#new_#{resource}" do - fill_autocomplete "crop", with: "pea" + fill_autocomplete 'crop', with: 'pea' end - expect(page).to have_content("pear") - expect(page).to have_content("pea") + expect(page).to have_content('pear') + expect(page).to have_content('pea') within "form#new_#{resource}" do - fill_autocomplete "crop", with: "pear" + fill_autocomplete 'crop', with: 'pear' end - expect(page).to have_content("pear") + expect(page).to have_content('pear') end - scenario "selecting crop from dropdown" do + scenario 'selecting crop from dropdown' do within "form#new_#{resource}" do - fill_autocomplete "crop", with: "pear" + fill_autocomplete 'crop', with: 'pear' end - select_from_autocomplete("pear") + select_from_autocomplete('pear') expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", visible: false) end - scenario "Typing and pausing does not affect input" do + scenario 'Typing and pausing does not affect input' do within "form#new_#{resource}" do - fill_autocomplete "crop", with: "pea" + fill_autocomplete 'crop', with: 'pea' end - expect(page).to have_content("pear") - expect(find_field("crop").value).to eq("pea") + expect(page).to have_content('pear') + expect(find_field('crop').value).to eq('pea') end - scenario "Searching for a crop casts a wide net on results" do + scenario 'Searching for a crop casts a wide net on results' do within "form#new_#{resource}" do - fill_autocomplete "crop", with: "tom" + fill_autocomplete 'crop', with: 'tom' end - expect(page).to have_content("tomato") - expect(page).to have_content("roma tomato") + expect(page).to have_content('tomato') + expect(page).to have_content('roma tomato') end scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do within "form#new_#{resource}" do - fill_autocomplete "crop", with: "Ryan Gosling" - click_button "Save" + fill_autocomplete 'crop', with: 'Ryan Gosling' + click_button 'Save' end - expect(page).to have_content("Crop must be present and exist in our database") + expect(page).to have_content('Crop must be present and exist in our database') end end diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index acd9f5295..e2817517b 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "signin", js: true do +feature 'signin', js: true do let(:member) { create :member } let(:recipient) { create :member } let(:wrangler) { create :crop_wrangling_member } @@ -12,14 +12,14 @@ feature "signin", js: true do click_button 'Sign in' end - scenario "via email address" do + scenario 'via email address' do visit crops_path # some random page click_link 'Sign in' login - expect(page).to have_content("Sign out") + expect(page).to have_content('Sign out') end - scenario "redirect to previous page after signin" do + scenario 'redirect to previous page after signin' do visit crops_path # some random page click_link 'Sign in' login @@ -33,12 +33,12 @@ feature "signin", js: true do expect(current_path).to eq root_path end - scenario "redirect to signin page for if not authenticated to view notification" do + scenario 'redirect to signin page for if not authenticated to view notification' do visit notification_path(notification) expect(current_path).to eq new_member_session_path end - shared_examples "redirects to what you were trying to do" do + shared_examples 'redirects to what you were trying to do' do scenario do visit "/#{model_name}/new" expect(current_path).to eq new_member_session_path @@ -47,33 +47,33 @@ feature "signin", js: true do end end - describe "redirects to what you were trying to do" do + describe 'redirects to what you were trying to do' do %w(plantings harvests posts photos gardens seeds).each do |m| - it_behaves_like "redirects to what you were trying to do" do + it_behaves_like 'redirects to what you were trying to do' do let(:model_name) { m } end end end - scenario "after signin, redirect to new notifications page" do + scenario 'after signin, redirect to new notifications page' do visit new_notification_path(recipient: recipient) expect(current_path).to eq new_member_session_path login expect(current_path).to eq new_notification_path end - scenario "after crop wrangler signs in and crops await wrangling, show alert" do + scenario 'after crop wrangler signs in and crops await wrangling, show alert' do create :crop_request visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: wrangler.login_name fill_in 'Password', with: wrangler.password click_button 'Sign in' - expect(page).to have_content("There are crops waiting to be wrangled.") + expect(page).to have_content('There are crops waiting to be wrangled.') end - context "with facebook" do - scenario "sign in" do + context 'with facebook' do + scenario 'sign in' do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 35cd8af9b..e97d31db2 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature "signout" do +feature 'signout' do let(:member) { create :member } - scenario "redirect to previous page after signout" do + scenario 'redirect to previous page after signout' do visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: member.login_name @@ -13,8 +13,8 @@ feature "signout" do expect(current_path).to eq crops_path end - shared_examples "sign-in redirects" do |path| - scenario "after signout, redirect to signin page if page needs authentication" do + shared_examples 'sign-in redirects' do |path| + scenario 'after signout, redirect to signin page if page needs authentication' do visit path expect(current_path).to eq new_member_session_path expect(page).to have_http_status(200) @@ -32,11 +32,11 @@ feature "signout" do let(:path) {} describe 'after signout, redirect to signin page if page needs authentication' do - include_examples "sign-in redirects", "/plantings/new" - include_examples "sign-in redirects", "/harvests/new" - include_examples "sign-in redirects", "/posts/new" - include_examples "sign-in redirects", "/gardens/new" - include_examples "sign-in redirects", "/seeds/new" + include_examples 'sign-in redirects', '/plantings/new' + include_examples 'sign-in redirects', '/harvests/new' + include_examples 'sign-in redirects', '/posts/new' + include_examples 'sign-in redirects', '/gardens/new' + include_examples 'sign-in redirects', '/seeds/new' end scenario 'photos' do diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 6afb28119..968158879 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "signup", js: true do - scenario "sign up for new account from top menubar" do +feature 'signup', js: true do + scenario 'sign up for new account from top menubar' do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -13,7 +13,7 @@ feature "signup", js: true do expect(current_path).to eq root_path end - scenario "sign up for new account with existing username" do + scenario 'sign up for new account with existing username' do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -32,7 +32,7 @@ feature "signup", js: true do click_button 'Sign up' end - scenario "sign up for new account without accepting TOS" do + scenario 'sign up for new account without accepting TOS' do visit root_path first('.signup a').click # click the 'Sign up' button in the middle of the page fill_in 'Login name', with: 'person123' @@ -44,8 +44,8 @@ feature "signup", js: true do expect(current_path).to eq members_path end - context "with facebook" do - scenario "sign up" do + context 'with facebook' do + scenario 'sign up' do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all Member.where(email: 'tdawg@hotmail.com').delete_all diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 8244d207a..96dfa92de 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature "unsubscribe" do +feature 'unsubscribe' do let(:member) { create :member } let(:notification) { create :notification } @@ -9,7 +9,7 @@ feature "unsubscribe" do clear_emails end - scenario "from planting reminder mailing list" do + scenario 'from planting reminder mailing list' do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -20,13 +20,13 @@ feature "unsubscribe" do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from planting reminders' - expect(page).to have_content "You have been unsubscribed from planting reminders" + expect(page).to have_content 'You have been unsubscribed from planting reminders' updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(false) expect(updated_member.send_notification_email).to eq(true) end - scenario "from inbox notification mailing list" do + scenario 'from inbox notification mailing list' do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -38,13 +38,13 @@ feature "unsubscribe" do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from direct message notifications' - expect(page).to have_content "You have been unsubscribed from direct message notifications" + expect(page).to have_content 'You have been unsubscribed from direct message notifications' updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(true) expect(updated_member.send_notification_email).to eq(false) end - scenario "visit unsubscribe page with a non-encrypted parameter" do + scenario 'visit unsubscribe page with a non-encrypted parameter' do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index b3ea0ce52..64369860f 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe ApplicationHelper do - it "formats prices" do + it 'formats prices' do price_in_dollars(999).should eq '9.99' price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency) end - it "parses dates" do + it 'parses dates' do parse_date(nil).should eq nil parse_date('').should eq nil parse_date('2012-05-12').should eq Date.new(2012, 5, 12) parse_date('may 12th 2012').should eq Date.new(2012, 5, 12) end - it "shows required field marker help text with proper formatting" do + it 'shows required field marker help text with proper formatting' do output = required_field_help_text expect(output).to have_selector '.margin-bottom' expect(output).to have_selector '.red', text: '*' diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb index 49a570836..d47fd90cd 100644 --- a/spec/helpers/crops_helper_spec.rb +++ b/spec/helpers/crops_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe CropsHelper do - describe "display_seed_availability" do + describe 'display_seed_availability' do before :each do @member = create :member @crop = create :tomato end - context "with no seeds" do + context 'with no seeds' do it 'should render' do expect(helper.display_seed_availability(@member, @crop)).to eq "You don't have any seeds of this crop." end end - context "with an unknown quantity of seeds" do + context 'with an unknown quantity of seeds' do before do create :seed, crop: @crop, quantity: nil, owner: @member end @@ -21,11 +21,11 @@ describe CropsHelper do it 'should render' do expect( helper.display_seed_availability(@member, @crop) - ).to eq "You have an unknown quantity of seeds of this crop." + ).to eq 'You have an unknown quantity of seeds of this crop.' end end - context "with an quantity of seeds" do + context 'with an quantity of seeds' do before do a_different_crop = create :apple @@ -36,7 +36,7 @@ describe CropsHelper do end it 'should render' do - expect(helper.display_seed_availability(@member, @crop)).to eq "You have 33 seeds of this crop." + expect(helper.display_seed_availability(@member, @crop)).to eq 'You have 33 seeds of this crop.' end end end diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb index c22b51b79..bfb9e1bbc 100644 --- a/spec/helpers/gardens_helper_spec.rb +++ b/spec/helpers/gardens_helper_spec.rb @@ -1,55 +1,55 @@ require 'rails_helper' describe GardensHelper do - describe "garden description" do - it "is missing" do + describe 'garden description' do + it 'is missing' do garden = FactoryBot.create(:garden, description: nil) result = helper.display_garden_description(garden) - expect(result).to eq "no description provided." + expect(result).to eq 'no description provided.' end - it "is less than 130 characters long" do + it 'is less than 130 characters long' do garden = FactoryBot.create(:garden, description: 'a' * 20) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 20 end - it "is 130 characters long" do + it 'is 130 characters long' do garden = FactoryBot.create(:garden, description: 'a' * 130) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 130 end - it "is more than 130 characters long" do + it 'is more than 130 characters long' do garden = FactoryBot.create(:garden, description: 'a' * 140) result = helper.display_garden_description(garden) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", garden_path(garden)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', garden_path(garden)) end end - describe "garden plantings" do - it "is missing" do + describe 'garden plantings' do + it 'is missing' do result = helper.display_garden_plantings(nil) - expect(result).to eq "None" + expect(result).to eq 'None' end - it "has 1 planting" do + it 'has 1 planting' do crop = FactoryBot.create(:crop) plantings = [FactoryBot.create(:planting, quantity: 10, crop: crop)] result = helper.display_garden_plantings(plantings) output = '
    • ' - output += "10 " + link_to(crop.name, crop) + output += '10 ' + link_to(crop.name, crop) output += ", planted on #{plantings.first.planted_at}" - output += "
    " + output += '
' expect(result).to eq output end - it "has 2 plantings" do + it 'has 2 plantings' do plantings = [] crop1 = FactoryBot.create(:crop) @@ -61,17 +61,17 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += "10 " + link_to(crop1.name, crop1) + output += '10 ' + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += "
  • " - output += "
  • " - output += "10 " + link_to(crop2.name, crop2) + output += '
  • ' + output += '
  • ' + output += '10 ' + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += "
" + output += '' expect(result).to eq output end - it "has 3 plantings" do + it 'has 3 plantings' do plantings = [] crop1 = FactoryBot.create(:crop) @@ -86,13 +86,13 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += "10 " + link_to(crop1.name, crop1) + output += '10 ' + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += "
  • " - output += "
  • " - output += "10 " + link_to(crop2.name, crop2) + output += '
  • ' + output += '
  • ' + output += '10 ' + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += "
" + output += '' expect(result).to eq output end end diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index 1ba63810d..a234bc260 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe HarvestsHelper do - describe "display_quantity" do - it "blank" do + describe 'display_quantity' do + it 'blank' do harvest = FactoryBot.create(:harvest, quantity: nil, weight_quantity: nil) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index a00dabff3..8281b3712 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' describe NotificationsHelper do - describe "reply_link" do + describe 'reply_link' do let(:member) { FactoryBot.create(:member) } - it "replies to PMs with PMs" do + it 'replies to PMs with PMs' do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil link.should eq reply_notification_url(notification) end - it "replies to post comments with post comments" do + it 'replies to post comments with post comments' do notification = FactoryBot.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index 3af084d5a..acde7469f 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,64 +1,64 @@ require 'rails_helper' describe PlantingsHelper do - describe "display_planting" do + describe 'display_planting' do let!(:member) { FactoryBot.build(:member, login_name: 'crop_lady') } - it "does not have a quantity nor a planted from value provided" do + it 'does not have a quantity nor a planted from value provided' do planting = FactoryBot.build(:planting, quantity: nil, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady." + expect(result).to eq 'crop_lady.' end - it "does not have a quantity provided" do + it 'does not have a quantity provided' do planting = FactoryBot.build(:planting, quantity: nil, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady planted seeds." + expect(result).to eq 'crop_lady planted seeds.' end - context "when quantity is greater than 1" do - it "does not have a planted from value provided" do + context 'when quantity is greater than 1' do + it 'does not have a planted from value provided' do planting = FactoryBot.build(:planting, quantity: 10, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady planted 10 units." + expect(result).to eq 'crop_lady planted 10 units.' end - it "does have a planted from value provided" do + it 'does have a planted from value provided' do planting = FactoryBot.build(:planting, quantity: 5, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady planted 5 seeds." + expect(result).to eq 'crop_lady planted 5 seeds.' end end - context "when quantity is 1" do - it "does not have a planted from value provided" do + context 'when quantity is 1' do + it 'does not have a planted from value provided' do planting = FactoryBot.build(:planting, quantity: 1, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady planted 1 unit." + expect(result).to eq 'crop_lady planted 1 unit.' end - it "does have a planted from value provided" do + it 'does have a planted from value provided' do planting = FactoryBot.build(:planting, quantity: 1, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady planted 1 seed." + expect(result).to eq 'crop_lady planted 1 seed.' end end end diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 3d559058e..837e1368a 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,33 +1,33 @@ require 'rails_helper' describe SeedsHelper do - describe "seed description" do - it "is missing" do + describe 'seed description' do + it 'is missing' do seed = FactoryBot.create(:seed, description: nil) result = helper.display_seed_description(seed) - expect(result).to eq "no description provided." + expect(result).to eq 'no description provided.' end - it "is less than 130 characters long" do + it 'is less than 130 characters long' do seed = FactoryBot.create(:seed, description: 'a' * 20) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 20 end - it "is 130 characters long" do + it 'is 130 characters long' do seed = FactoryBot.create(:seed, description: 'a' * 130) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 130 end - it "is more than 130 characters long" do + it 'is more than 130 characters long' do seed = FactoryBot.create(:seed, description: 'a' * 140) result = helper.display_seed_description(seed) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', seed_path(seed)) end end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index 1710428a4..a6f7958b1 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -17,8 +17,8 @@ describe 'Growstuff::OauthSignupAction' do 'image' => 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, 'credentials' => { - 'token' => "token", - 'secret' => "donttell" + 'token' => 'token', + 'secret' => 'donttell' }) end diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 415751293..4677f596c 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -10,8 +10,8 @@ describe 'Haml::Filters::Escaped_Markdown' do end it 'converts Markdown to escaped HTML' do - rendered = Haml::Filters::EscapedMarkdown.render("**foo**") - rendered.should == "<p><strong>foo</strong></p>" + rendered = Haml::Filters::EscapedMarkdown.render('**foo**') + rendered.should == '<p><strong>foo</strong></p>' end it 'converts quick crop links' do diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 03ad3b0e1..6c92c5e6d 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -35,17 +35,17 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent crops" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_link("not a crop")) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('not a crop')) expect(rendered).to match(/not a crop/) end it "doesn't convert escaped crop links" do @crop = FactoryBot.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_link(@crop.name)) expect(rendered).to match(/\[#{@crop.name}\]\(crop\)/) end - it "handles multiple crop links" do + it 'handles multiple crop links' do tomato = FactoryBot.create(:tomato) maize = FactoryBot.create(:maize) string = "#{input_link(tomato)} #{input_link(maize)}" @@ -53,24 +53,24 @@ describe 'Haml::Filters::Growstuff_Markdown' do expect(rendered).to match(/#{output_link(tomato)} #{output_link(maize)}/) end - it "converts normal markdown" do - string = "**foo**" + it 'converts normal markdown' do + string = '**foo**' rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/foo<\/strong>/) end - it "finds crops case insensitively" do + it 'finds crops case insensitively' do @crop = FactoryBot.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end - it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do + it 'fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)' do tomato = FactoryBot.create(:tomato) - string = "[test](http://example.com) [tomato](crop)" + string = '[test](http://example.com) [tomato](crop)' rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/#{output_link(tomato)}/) - expect(rendered).to match "test" + expect(rendered).to match 'test' end it 'converts quick member links' do @@ -80,13 +80,13 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent members" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member")) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link('not a member')) expect(rendered).to include('not a member') end it "doesn't convert escaped members" do @member = FactoryBot.create(:member) - rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name)) + rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_member_link(@member.login_name)) expect(rendered).to match(/\[#{@member.login_name}\]\(member\)/) end @@ -97,7 +97,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert invalid @ members" do - rendered = Haml::Filters::GrowstuffMarkdown.render("@notamember") + rendered = Haml::Filters::GrowstuffMarkdown.render('@notamember') expect(rendered).to include('@notamember') end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index e50682700..344b26e7f 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ -require "rails_helper" +require 'rails_helper' describe Notifier do - describe "notifications" do + describe 'notifications' do let(:notification) { FactoryBot.create(:notification) } let(:mail) { Notifier.notify(notification) } @@ -18,12 +18,12 @@ describe Notifier do end end - describe "planting reminders" do + describe 'planting reminders' do let(:member) { FactoryBot.create(:member) } let(:mail) { Notifier.planting_reminder(member) } it 'sets the subject correctly' do - mail.subject.should == "What have you planted lately?" + mail.subject.should == 'What have you planted lately?' end it 'comes from noreply@growstuff.org' do @@ -43,7 +43,7 @@ describe Notifier do end end - describe "new crop request" do + describe 'new crop request' do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop_request) } let(:mail) { Notifier.new_crop_request(member, crop) } @@ -65,13 +65,13 @@ describe Notifier do end end - describe "crop approved" do + describe 'crop approved' do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:crop) } let(:mail) { Notifier.crop_request_approved(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq "Magic bean has been approved" + expect(mail.subject).to eq 'Magic bean has been approved' end it 'comes from noreply@growstuff.org' do @@ -93,13 +93,13 @@ describe Notifier do end end - describe "crop rejected" do + describe 'crop rejected' do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:rejected_crop) } let(:mail) { Notifier.crop_request_rejected(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq "Fail bean has been rejected" + expect(mail.subject).to eq 'Fail bean has been rejected' end it 'comes from noreply@growstuff.org' do @@ -115,7 +115,7 @@ describe Notifier do end it 'includes the reason for rejection' do - expect(mail.body.encoded).to match "Totally fake" + expect(mail.body.encoded).to match 'Totally fake' end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index ef746c8bc..d69b0ba57 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -5,7 +5,7 @@ describe Ability do let(:member) { FactoryBot.create(:member) } let(:ability) { Ability.new(member) } - context "notifications" do + context 'notifications' do it 'member can view their own notifications' do notification = FactoryBot.create(:notification, recipient: member) ability.should be_able_to(:read, notification) @@ -22,7 +22,7 @@ describe Ability do recipient: member, sender: member)) end - it "member can send messages to someone else" do + it 'member can send messages to someone else' do ability.should be_able_to(:create, FactoryBot.create(:notification, recipient: FactoryBot.create(:member), @@ -30,51 +30,51 @@ describe Ability do end end - context "crop wrangling" do + context 'crop wrangling' do let(:crop) { FactoryBot.create(:crop) } - context "standard member" do + context 'standard member' do it "can't manage crops" do ability.should_not be_able_to(:update, crop) ability.should_not be_able_to(:destroy, crop) end - it "can request crops" do + it 'can request crops' do ability.should be_able_to(:create, Crop) end - it "can read crops" do + it 'can read crops' do ability.should be_able_to(:read, crop) end end - context "crop wrangler" do + context 'crop wrangler' do let(:role) { FactoryBot.create(:crop_wrangler) } before(:each) do member.roles << role end - it "has crop_wrangler role" do + it 'has crop_wrangler role' do member.role?(:crop_wrangler).should be true end - it "can create crops" do + it 'can create crops' do ability.should be_able_to(:create, Crop) end - it "can update crops" do + it 'can update crops' do ability.should be_able_to(:update, crop) end - it "can destroy crops" do + it 'can destroy crops' do ability.should be_able_to(:destroy, crop) end end end - context "products" do + context 'products' do let(:product) { FactoryBot.create(:product) } - context "standard member" do + context 'standard member' do it "can't read or manage products" do ability.should_not be_able_to(:read, product) ability.should_not be_able_to(:create, Product) @@ -83,33 +83,33 @@ describe Ability do end end - context "admin" do + context 'admin' do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it "has admin role" do + it 'has admin role' do member.role?(:admin).should be true end - it "can read products" do + it 'can read products' do ability.should be_able_to(:read, product) end - it "can create products" do + it 'can create products' do ability.should be_able_to(:create, Product) end - it "can update products" do + it 'can update products' do ability.should be_able_to(:update, product) end - it "can destroy products" do + it 'can destroy products' do ability.should be_able_to(:destroy, product) end end end - context "orders" do + context 'orders' do let(:order) { FactoryBot.create(:order, member: member) } let(:strangers_order) do FactoryBot.create(:order, @@ -129,8 +129,8 @@ describe Ability do order: completed_order) end - context "standard member" do - it "can read their own orders" do + context 'standard member' do + it 'can read their own orders' do ability.should be_able_to(:read, order) ability.should be_able_to(:read, completed_order) end @@ -139,11 +139,11 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order) end - it "can create a new order" do + it 'can create a new order' do ability.should be_able_to(:create, Order) end - it "can complete their own current order" do + it 'can complete their own current order' do ability.should be_able_to(:complete, order) end @@ -155,7 +155,7 @@ describe Ability do ability.should_not be_able_to(:complete, completed_order) end - it "can delete a current order" do + it 'can delete a current order' do ability.should be_able_to(:destroy, order) end @@ -176,7 +176,7 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order_item) end - it "can create a new order item" do + it 'can create a new order item' do ability.should be_able_to(:create, OrderItem) end @@ -205,30 +205,30 @@ describe Ability do end end - context "admin" do + context 'admin' do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it "has admin role" do + it 'has admin role' do member.role?(:admin).should be true end - it "can read orders" do + it 'can read orders' do ability.should be_able_to(:read, order) end - it "cannot create orders" do + it 'cannot create orders' do ability.should_not be_able_to(:create, order) end - it "cannot complete orders" do + it 'cannot complete orders' do ability.should_not be_able_to(:complete, order) end - it "cannot delete orders" do + it 'cannot delete orders' do ability.should_not be_able_to(:destroy, order) end end @@ -255,10 +255,10 @@ describe Ability do member.roles << role end - it "can read account details" do + it 'can read account details' do ability.should be_able_to(:read, account) end - it "can manage account details" do + it 'can manage account details' do ability.should be_able_to(:create, Account) ability.should be_able_to(:update, account) ability.should be_able_to(:destroy, account) @@ -270,7 +270,7 @@ describe Ability do let(:plant_part) { FactoryBot.create(:plant_part) } context 'ordinary member' do - it "can read plant parts" do + it 'can read plant parts' do ability.should be_able_to(:read, plant_part) end it "can't manage plant parts" do @@ -287,15 +287,15 @@ describe Ability do member.roles << role end - it "can read plant_part details" do + it 'can read plant_part details' do ability.should be_able_to(:read, plant_part) end - it "can manage plant_part details" do + it 'can manage plant_part details' do ability.should be_able_to(:create, PlantPart) ability.should be_able_to(:update, plant_part) end - it "can delete an unused plant part" do + it 'can delete an unused plant part' do ability.should be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 15eb68084..915750eaa 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Account do let(:member) { FactoryBot.create(:member) } - it "auto-creates an account detail record when a member is created" do + it 'auto-creates an account detail record when a member is created' do member.account.should be_an_instance_of Account end @@ -17,7 +17,7 @@ describe Account do member.account.paid_until_string.should eq nil member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq "forever" + member.account.paid_until_string.should eq 'forever' member.account.account_type = FactoryBot.create(:paid_account_type) @time = Time.zone.now diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index f358a9fca..64e483446 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,7 +10,7 @@ describe AlternateName do it 'should be possible to add multiple alternate names to a crop' do crop = an.crop an2 = AlternateName.create( - name: "really alternative tomato", + name: 'really alternative tomato', crop_id: crop.id, creator_id: an.creator.id ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index bc90ee8ba..593d0da1b 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' describe Comment do - context "basic" do + context 'basic' do let(:comment) { FactoryBot.create(:comment) } - it "belongs to a post" do + it 'belongs to a post' do comment.post.should be_an_instance_of Post end - it "belongs to an author" do + it 'belongs to an author' do comment.author.should be_an_instance_of Member end end - context "notifications" do + context 'notifications' do let(:comment) { FactoryBot.create(:comment) } - it "sends a notification when a comment is posted" do + it 'sends a notification when a comment is posted' do expect do FactoryBot.create(:comment) end.to change(Notification, :count).by(1) end - it "sets the notification fields" do + it 'sets the notification fields' do @c = FactoryBot.create(:comment) @n = Notification.first @n.sender.should eq @c.author @@ -41,7 +41,7 @@ describe Comment do end end - context "ordering" do + context 'ordering' do before(:each) do @m = FactoryBot.create(:member) @p = FactoryBot.create(:post, author: @m) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 3f49a249d..254573e80 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -11,8 +11,8 @@ describe Crop do it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') - @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") - @crop2.slug.should eq("tomato") + @crop2.en_wikipedia_url.should eq('http://en.wikipedia.org/wiki/Tomato') + @crop2.slug.should eq('tomato') end it 'should stringify as the system name' do @@ -54,7 +54,7 @@ describe Crop do FactoryBot.create_list(:planting, 3, crop: tomato) end - it "sorts by most plantings" do + it 'sorts by most plantings' do Crop.popular.first.should eq maize FactoryBot.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato @@ -77,7 +77,7 @@ describe Crop do @crop.plantings.size.should eq 1 end - context "wikipedia url" do + context 'wikipedia url' do subject { FactoryBot.build(:tomato, en_wikipedia_url: wikipedia_url) } context 'not a url' do @@ -116,7 +116,7 @@ describe Crop do it { expect(subject).not_to be_valid } end - context "with script tags in url" do + context 'with script tags in url' do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } it { expect(subject).not_to be_valid } @@ -331,13 +331,13 @@ describe Crop do let(:pp1) { FactoryBot.create(:plant_part) } let(:pp2) { FactoryBot.create(:plant_part) } - context "harvests" do + context 'harvests' do let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } - it "has harvests" do + it 'has harvests' do expect(crop.harvests).to eq [harvest] end end @@ -350,21 +350,21 @@ describe Crop do @maize.plant_parts.should eq [@pp1] end - context "search", :elasticsearch do + context 'search', :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } before { sync_elasticsearch([mushroom]) } - it "finds exact matches" do + it 'finds exact matches' do Crop.search('mushroom').should eq [mushroom] end - it "finds approximate matches" do + it 'finds approximate matches' do Crop.search('mush').should eq [mushroom] end it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end - it "searches case insensitively" do + it 'searches case insensitively' do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do @@ -379,141 +379,141 @@ describe Crop do end end - context "csv loading" do + context 'csv loading' do before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) end - context "scientific names" do - it "adds a scientific name to a crop that has none" do - row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar"] + context 'scientific names' do + it 'adds a scientific name to a crop that has none' do + row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar'] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 - expect(tomato.default_scientific_name).to eq "Foo bar" + expect(tomato.default_scientific_name).to eq 'Foo bar' end - it "picks up scientific name from parent crop if available" do + it 'picks up scientific name from parent crop if available' do parent = CsvImporter.new.import_crop( - ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] + ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] ) tomato = CsvImporter.new.import_crop( - ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent"] + ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent'] ) expect(tomato.parent).to eq parent - expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" - expect(tomato.default_scientific_name).to eq "Parentis cropis" + expect(tomato.parent.default_scientific_name).to eq 'Parentis cropis' + expect(tomato.default_scientific_name).to eq 'Parentis cropis' end it "doesn't add a duplicate scientific name" do - row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar, Foo bar"] + row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar, Foo bar'] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 end it "doesn't add a duplicate scientific name from parent" do CsvImporter.new.import_crop( - ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] + ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] ) tomato = CsvImporter.new.import_crop( - ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent", "Parentis cropis"] + ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent', 'Parentis cropis'] ) expect(tomato.scientific_names.size).to eq 1 end - it "loads a crop with multiple scientific names" do - row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo,Bar"] + it 'loads a crop with multiple scientific names' do + row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo,Bar'] tomato = CsvImporter.new.import_crop(row) - expect(tomato.scientific_names[0].name).to eq "Foo" - expect(tomato.scientific_names[1].name).to eq "Bar" + expect(tomato.scientific_names[0].name).to eq 'Foo' + expect(tomato.scientific_names[1].name).to eq 'Bar' end - it "loads multiple scientific names with variant spacing" do - row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Baz, Quux"] + it 'loads multiple scientific names with variant spacing' do + row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Baz, Quux'] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 2 - expect(tomato.scientific_names[0].name).to eq "Baz" - expect(tomato.scientific_names[1].name).to eq "Quux" + expect(tomato.scientific_names[0].name).to eq 'Baz' + expect(tomato.scientific_names[1].name).to eq 'Quux' end end # scientific names - context "alternate names" do - it "loads an alternate name" do - row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo"] + context 'alternate names' do + it 'loads an alternate name' do + row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo'] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 - expect(tomato.alternate_names.last.name).to eq "Foo" + expect(tomato.alternate_names.last.name).to eq 'Foo' end - it "adds multiple alternate names" do - row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo, Bar"] + it 'adds multiple alternate names' do + row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo, Bar'] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 2 - expect(tomato.alternate_names[0].name).to eq "Foo" - expect(tomato.alternate_names[1].name).to eq "Bar" + expect(tomato.alternate_names[0].name).to eq 'Foo' + expect(tomato.alternate_names[1].name).to eq 'Bar' end - it "adds multiple alt names with variant spacing" do - row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo,Bar,Baz, Quux"] + it 'adds multiple alt names with variant spacing' do + row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo,Bar,Baz, Quux'] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 4 - expect(tomato.alternate_names[0].name).to eq "Foo" - expect(tomato.alternate_names[1].name).to eq "Bar" - expect(tomato.alternate_names[2].name).to eq "Baz" - expect(tomato.alternate_names[3].name).to eq "Quux" + expect(tomato.alternate_names[0].name).to eq 'Foo' + expect(tomato.alternate_names[1].name).to eq 'Bar' + expect(tomato.alternate_names[2].name).to eq 'Baz' + expect(tomato.alternate_names[3].name).to eq 'Quux' end - it "Adds a duplicate alternate name for second crop" do - row = ["tomato", "http://en.wikipedia.org/wiki/tomato", "", "", "Foo"] + it 'Adds a duplicate alternate name for second crop' do + row = ['tomato', 'http://en.wikipedia.org/wiki/tomato', '', '', 'Foo'] tomato = CsvImporter.new.import_crop(row) - row = ["tomoto", "http://en.wikipedia.org/wiki/tomoto", "", "", "Foo"] + row = ['tomoto', 'http://en.wikipedia.org/wiki/tomoto', '', '', 'Foo'] tomoto = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 expect(tomoto.alternate_names.size).to eq 1 end end # alternate names - it "loads the simplest possible crop" do - tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato"] + it 'loads the simplest possible crop' do + tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato'] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq "tomato" + expect(tomato.name).to eq 'tomato' expect(tomato.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(tomato.creator).to eq @cropbot end - it "loads a crop with a scientific name" do - tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato", "", "Solanum lycopersicum"] + it 'loads a crop with a scientific name' do + tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato', '', 'Solanum lycopersicum'] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq "tomato" + expect(tomato.name).to eq 'tomato' expect(tomato.scientific_names.size).to eq 1 - expect(tomato.scientific_names.last.name).to eq "Solanum lycopersicum" + expect(tomato.scientific_names.last.name).to eq 'Solanum lycopersicum' end - it "loads a crop with an alternate name" do + it 'loads a crop with an alternate name' do crop = CsvImporter.new.import_crop( - ["tomato", "http://en.wikipedia.org/wiki/Tomato", nil, nil, "Foo"] + ['tomato', 'http://en.wikipedia.org/wiki/Tomato', nil, nil, 'Foo'] ) - expect(crop.name).to eq "tomato" + expect(crop.name).to eq 'tomato' expect(crop.alternate_names.size).to eq 1 - expect(crop.alternate_names.last.name).to eq "Foo" + expect(crop.alternate_names.last.name).to eq 'Foo' end - it "loads a crop with a parent" do + it 'loads a crop with a parent' do parent = FactoryBot.create(:crop, name: 'parent') crop = CsvImporter.new.import_crop( - ["tomato", "http://en.wikipedia.org/wiki/Tomato", "parent"] + ['tomato', 'http://en.wikipedia.org/wiki/Tomato', 'parent'] ) expect(crop.parent).to eq parent end - it "loads a crop with a missing parent" do - tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" + it 'loads a crop with a missing parent' do + tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,parent' CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) @@ -524,40 +524,40 @@ describe Crop do end it "doesn't add unnecessary duplicate crops" do - tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum" + tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum' CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) end loaded = Crop.last - expect(loaded.name).to eq "tomato" + expect(loaded.name).to eq 'tomato' expect(loaded.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(loaded.creator).to eq @cropbot end end - context "crop-post association" do + context 'crop-post association' do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } - let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } + let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } - describe "destroying a crop" do + describe 'destroying a crop' do before do tomato.destroy end - it "should delete the association between post and the crop(tomato)" do + it 'should delete the association between post and the crop(tomato)' do expect(Post.find(post.id).crops).to eq [maize] end - it "should not delete the posts" do + it 'should not delete the posts' do expect(Post.find(post.id)).not_to eq nil end end end - context "crop rejections" do + context 'crop rejections' do let!(:rejected_reason) do FactoryBot.create(:crop, name: 'tomato', approval_status: 'rejected', @@ -570,13 +570,13 @@ describe Crop do rejection_notes: 'blah blah blah') end - describe "rejecting a crop" do - it "should give reason if a default option" do - expect(rejected_reason.rejection_explanation).to eq "not edible" + describe 'rejecting a crop' do + it 'should give reason if a default option' do + expect(rejected_reason.rejection_explanation).to eq 'not edible' end - it "should show rejection notes if reason was other" do - expect(rejected_other.rejection_explanation).to eq "blah blah blah" + it 'should show rejection notes if reason was other' do + expect(rejected_other.rejection_explanation).to eq 'blah blah blah' end end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index bd61fe2ee..139695a2f 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -6,34 +6,34 @@ describe Follow do @member2 = FactoryBot.create(:member) end - it "sends a notification when a follow is created" do + it 'sends a notification when a follow is created' do expect do Follow.create(follower_id: @member1.id, followed_id: @member2.id) end.to change(Notification, :count).by(1) end - it "does not delete any members when follow is deleted" do + it 'does not delete any members when follow is deleted' do expect do follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy end.not_to change(Member, :count) end - context "when follow is created" do + context 'when follow is created' do before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end - it "should not duplicate follows" do + it 'should not duplicate follows' do expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid end - it "should list users in following/follower collections when follow is created" do + it 'should list users in following/follower collections when follow is created' do expect(@member1.followed).to include(@member2) expect(@member2.followers).to include(@member1) end - it "should no longer list users in following/follower collections when follow is deleted" do + it 'should no longer list users in following/follower collections when follow is deleted' do @follow.destroy expect(@member1.followed).not_to include(@member2) expect(@member2.followers).not_to include(@member1) diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index 310c36842..c0d4d47f5 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe Forum do let(:forum) { FactoryBot.create(:forum) } - it "belongs to an owner" do + it 'belongs to an owner' do forum.owner.should be_an_instance_of Member end - it "stringifies nicely" do + it 'stringifies nicely' do forum.to_s.should eq forum.name end @@ -15,7 +15,7 @@ describe Forum do forum.slug.should eq 'permaculture' end - it "has many posts" do + it 'has many posts' do @post1 = FactoryBot.create(:forum_post, forum: forum) @post2 = FactoryBot.create(:forum_post, forum: forum) forum.posts.size.should == 2 diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index f8e5a3311..ec7d5fae2 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -4,12 +4,12 @@ describe Garden do let(:owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: owner) } - it "should have a slug" do + it 'should have a slug' do garden.slug.should match(/member\d+-springfield-community-garden/) end - it "should have a description" do - garden.description.should == "This is a **totally** cool garden" + it 'should have a description' do + garden.description.should == 'This is a **totally** cool garden' end it "doesn't allow a nil name" do @@ -18,27 +18,27 @@ describe Garden do end it "doesn't allow a blank name" do - garden = FactoryBot.build(:garden, name: "") + garden = FactoryBot.build(:garden, name: '') garden.should_not be_valid end - it "allows numbers" do - garden = FactoryBot.build(:garden, name: "100 vines of 2 kamo-kamo") + it 'allows numbers' do + garden = FactoryBot.build(:garden, name: '100 vines of 2 kamo-kamo') garden.should_not be_valid end - it "allows brackets" do - garden = FactoryBot.build(:garden, name: "Garden (second)") + it 'allows brackets' do + garden = FactoryBot.build(:garden, name: 'Garden (second)') garden.should be_valid end - it "allows macrons" do - garden = FactoryBot.build(:garden, name: "Kūmara and pūha patch") + it 'allows macrons' do + garden = FactoryBot.build(:garden, name: 'Kūmara and pūha patch') garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryBot.build(:garden, name: " ") + garden = FactoryBot.build(:garden, name: ' ') garden.should_not be_valid end @@ -47,15 +47,15 @@ describe Garden do garden.should_not be_valid end - it "should have an owner" do + it 'should have an owner' do garden.owner.should be_an_instance_of Member end - it "should stringify as its name" do + it 'should stringify as its name' do garden.to_s.should == garden.name end - context "featured plantings" do + context 'featured plantings' do let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } let(:chard) { FactoryBot.create(:chard) } @@ -63,14 +63,14 @@ describe Garden do let(:pear) { FactoryBot.create(:pear) } let(:walnut) { FactoryBot.create(:walnut) } - it "should fetch < 4 featured plantings if insufficient exist" do + it 'should fetch < 4 featured plantings if insufficient exist' do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end - it "should fetch most recent 4 featured plantings" do + it 'should fetch most recent 4 featured plantings' do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -80,7 +80,7 @@ describe Garden do garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end - it "should skip repeated plantings" do + it 'should skip repeated plantings' do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -93,7 +93,7 @@ describe Garden do end end - it "destroys plantings when deleted" do + it 'destroys plantings when deleted' do garden = FactoryBot.create(:garden, owner: owner) @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @@ -135,7 +135,7 @@ describe Garden do end it "doesn't allow non-numeric quantities" do - garden = FactoryBot.build(:garden, area: "99a") + garden = FactoryBot.build(:garden, area: '99a') garden.should_not be_valid end end @@ -151,7 +151,7 @@ describe Garden do it 'should refuse invalid unit values' do garden = FactoryBot.build(:garden, area_unit: 'not valid') garden.should_not be_valid - garden.errors[:area_unit].should include("not valid is not a valid area unit") + garden.errors[:area_unit].should include('not valid is not a valid area unit') end it 'sets area unit to blank if area is blank' do @@ -175,7 +175,7 @@ describe Garden do end end - it "marks plantings as finished when garden is inactive" do + it 'marks plantings as finished when garden is inactive' do garden = FactoryBot.create(:garden) p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index 1944c6365..da6f06aa8 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe Harvest do - it "has an owner" do + it 'has an owner' do harvest = FactoryBot.create(:harvest) harvest.owner.should be_an_instance_of Member end - it "has a crop" do + it 'has a crop' do harvest = FactoryBot.create(:harvest) harvest.crop.should be_an_instance_of Crop end @@ -38,7 +38,7 @@ describe Harvest do end it "doesn't allow non-numeric quantities" do - @harvest = FactoryBot.build(:harvest, quantity: "99a") + @harvest = FactoryBot.build(:harvest, quantity: '99a') @harvest.should_not be_valid end end @@ -55,7 +55,7 @@ describe Harvest do it 'should refuse invalid unit values' do @harvest = FactoryBot.build(:harvest, unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:unit].should include("not valid is not a valid unit") + @harvest.errors[:unit].should include('not valid is not a valid unit') end it 'sets unit to blank if quantity is blank' do @@ -92,7 +92,7 @@ describe Harvest do end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryBot.build(:harvest, weight_quantity: "99a") + @harvest = FactoryBot.build(:harvest, weight_quantity: '99a') @harvest.should_not be_valid end end @@ -108,7 +108,7 @@ describe Harvest do it 'should refuse invalid weight unit values' do @harvest = FactoryBot.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:weight_unit].should include("not valid is not a valid unit") + @harvest.errors[:weight_unit].should include('not valid is not a valid unit') end it 'sets weight_unit to blank if quantity is blank' do @@ -118,21 +118,21 @@ describe Harvest do end end - context "standardized weights" do + context 'standardized weights' do it 'converts from pounds' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "lb") + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'lb') @harvest.should be_valid @harvest.reload.si_weight.should eq 0.907 end it 'converts from ounces' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: "oz") + @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: 'oz') @harvest.should be_valid @harvest.reload.si_weight.should eq 0.454 end it 'leaves kg alone' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "kg") + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'kg') @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -146,79 +146,79 @@ describe Harvest do end end - context "stringification" do - let(:crop) { FactoryBot.create(:crop, name: "apricot") } + context 'stringification' do + let(:crop) { FactoryBot.create(:crop, name: 'apricot') } - it "apricots" do + it 'apricots' do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "apricots" + @h.to_s.should eq 'apricots' end - it "1 individual apricot" do + it '1 individual apricot' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "1 individual apricot" + @h.to_s.should eq '1 individual apricot' end - it "10 individual apricots" do + it '10 individual apricots' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "10 individual apricots" + @h.to_s.should eq '10 individual apricots' end - it "1 bushel of apricots" do + it '1 bushel of apricots' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "1 bushel of apricots" + @h.to_s.should eq '1 bushel of apricots' end - it "1.5 bushels of apricots" do + it '1.5 bushels of apricots' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1.5, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "1.5 bushels of apricots" + @h.to_s.should eq '1.5 bushels of apricots' end - it "10 bushels of apricots" do + it '10 bushels of apricots' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq "10 bushels of apricots" + @h.to_s.should eq '10 bushels of apricots' end - it "apricots weighing 1.2 kg" do + it 'apricots weighing 1.2 kg' do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: 1.2, weight_unit: 'kg') - @h.to_s.should eq "apricots weighing 1.2 kg" + @h.to_s.should eq 'apricots weighing 1.2 kg' end - it "10 bushels of apricots weighing 100 kg" do + it '10 bushels of apricots weighing 100 kg' do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: 100, weight_unit: 'kg') - @h.to_s.should eq "10 bushels of apricots weighing 100 kg" + @h.to_s.should eq '10 bushels of apricots weighing 100 kg' end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index cf7b81486..7bdee1fee 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -28,7 +28,7 @@ describe 'member' do member.account.should be_an_instance_of Account end - it "should have a default-type account by default" do + it 'should have a default-type account by default' do member.account.account_type.name.should eq Growstuff::Application.config.default_account_type member.paid?.should be(false) end @@ -48,7 +48,7 @@ describe 'member' do end it 'should be able to fetch gardens' do - member.gardens.first.name.should eq "Garden" + member.gardens.first.name.should eq 'Garden' end it 'has many plantings' do @@ -56,19 +56,19 @@ describe 'member' do member.plantings.size.should eq 1 end - it "has many comments" do + it 'has many comments' do FactoryBot.create(:comment, author: member) FactoryBot.create(:comment, author: member) member.comments.size.should == 2 end - it "has many forums" do + it 'has many forums' do FactoryBot.create(:forum, owner: member) FactoryBot.create(:forum, owner: member) member.forums.size.should == 2 end - it "has many likes" do + it 'has many likes' do @post1 = FactoryBot.create(:post, author: member) @post2 = FactoryBot.create(:post, author: member) @like1 = FactoryBot.create(:like, member: member, likeable: @post1) @@ -118,24 +118,24 @@ describe 'member' do end context 'same :login_name' do - it "should not allow two members with the same login_name" do - FactoryBot.create(:member, login_name: "bob") - member = FactoryBot.build(:member, login_name: "bob") + it 'should not allow two members with the same login_name' do + FactoryBot.create(:member, login_name: 'bob') + member = FactoryBot.build(:member, login_name: 'bob') member.should_not be_valid - member.errors[:login_name].should include("has already been taken") + member.errors[:login_name].should include('has already been taken') end - it "tests uniqueness case-insensitively" do - FactoryBot.create(:member, login_name: "bob") - member = FactoryBot.build(:member, login_name: "BoB") + it 'tests uniqueness case-insensitively' do + FactoryBot.create(:member, login_name: 'bob') + member = FactoryBot.build(:member, login_name: 'BoB') member.should_not be_valid - member.errors[:login_name].should include("has already been taken") + member.errors[:login_name].should include('has already been taken') end end context 'case sensitivity' do it 'preserves case of login name' do - FactoryBot.create(:member, login_name: "BOB") + FactoryBot.create(:member, login_name: 'BOB') Member.find('bob').login_name.should eq 'BOB' end end @@ -144,40 +144,40 @@ describe 'member' do it "doesn't allow short names" do member = FactoryBot.build(:invalid_member_shortname) member.should_not be_valid - member.errors[:login_name].should include("should be between 2 and 25 characters long") + member.errors[:login_name].should include('should be between 2 and 25 characters long') end it "doesn't allow really long names" do member = FactoryBot.build(:invalid_member_longname) member.should_not be_valid - member.errors[:login_name].should include("should be between 2 and 25 characters long") + member.errors[:login_name].should include('should be between 2 and 25 characters long') end it "doesn't allow spaces in names" do member = FactoryBot.build(:invalid_member_spaces) member.should_not be_valid - member.errors[:login_name].should include("may only include letters, numbers, or underscores") + member.errors[:login_name].should include('may only include letters, numbers, or underscores') end it "doesn't allow other chars in names" do member = FactoryBot.build(:invalid_member_badchars) member.should_not be_valid - member.errors[:login_name].should include("may only include letters, numbers, or underscores") + member.errors[:login_name].should include('may only include letters, numbers, or underscores') end it "doesn't allow reserved names" do member = FactoryBot.build(:invalid_member_badname) member.should_not be_valid - member.errors[:login_name].should include("name is reserved") + member.errors[:login_name].should include('name is reserved') end end context 'valid login names' do - it "allows plain alphanumeric chars in names" do + it 'allows plain alphanumeric chars in names' do member = FactoryBot.build(:valid_member_alphanumeric) member.should be_valid end - it "allows uppercase chars in names" do + it 'allows uppercase chars in names' do member = FactoryBot.build(:valid_member_uppercase) member.should be_valid end - it "allows underscores in names" do + it 'allows underscores in names' do member = FactoryBot.build(:valid_member_underscore) member.should be_valid end @@ -203,7 +203,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - role = FactoryBot.create(:role, name: "a b c") + role = FactoryBot.create(:role, name: 'a b c') member.roles << role member.role?(:a_b_c).should eq true end @@ -310,17 +310,17 @@ describe 'member' do end end - context "paid accounts" do + context 'paid accounts' do let(:member) { FactoryBot.create(:member) } - it "recognises a permanent paid account" do + it 'recognises a permanent paid account' do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: true) member.account.account_type = account_type member.paid?.should be(true) end - it "recognises a current paid account" do + it 'recognises a current paid account' do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -328,7 +328,7 @@ describe 'member' do member.paid?.should be(true) end - it "recognises an expired paid account" do + it 'recognises an expired paid account' do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -336,14 +336,14 @@ describe 'member' do member.paid?.should be(false) end - it "recognises a free account" do + it 'recognises a free account' do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type member.paid?.should be(false) end - it "recognises a free account even with paid_until set" do + it 'recognises a free account even with paid_until set' do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type @@ -352,19 +352,19 @@ describe 'member' do end end - context "update account" do + context 'update account' do let(:product) do FactoryBot.create(:product, paid_months: 3) end let(:member) { FactoryBot.create(:member) } - it "sets account_type" do + it 'sets account_type' do member.update_account_after_purchase(product) member.account.account_type.should eq product.account_type end - it "sets paid_until" do + it 'sets paid_until' do member.account.paid_until = nil # blank for now, as if never paid before member.update_account_after_purchase(product) @@ -417,7 +417,7 @@ describe 'member' do context 'subscriptions' do let(:member) { FactoryBot.create(:member) } - let(:gb) { instance_double("Gibbon::API.new") } + let(:gb) { instance_double('Gibbon::API.new') } it 'subscribes to the newsletter' do expect(gb).to receive_message_chain('lists.subscribe') @@ -444,12 +444,12 @@ describe 'member' do it { expect(Member.interesting).not_to include(member) } it { expect(Member.has_plantings).not_to include(member) } end - it "unsubscribes from mailing list" do + it 'unsubscribes from mailing list' do expect(member).to receive(:newsletter_unsubscribe).and_return(true) member.destroy end - context "deleted admin member" do + context 'deleted admin member' do let(:member) { FactoryBot.create(:admin_member) } before { member.destroy } @@ -457,7 +457,7 @@ describe 'member' do context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } - it "leaves crops behind, reassigned to cropbot" do + it 'leaves crops behind, reassigned to cropbot' do expect(Crop.all).to include(crop) end end @@ -465,7 +465,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } - it "leaves forums behind, reassigned to ex_admin" do + it 'leaves forums behind, reassigned to ex_admin' do expect(forum.owner).to eq(member) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 4f04573d5..96d390215 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -3,19 +3,19 @@ require 'rails_helper' describe Notification do let(:notification) { FactoryBot.create(:notification) } - it "belongs to a post" do + it 'belongs to a post' do notification.post.should be_an_instance_of Post end - it "belongs to a recipient" do + it 'belongs to a recipient' do notification.recipient.should be_an_instance_of Member end - it "belongs to a sender" do + it 'belongs to a sender' do notification.sender.should be_an_instance_of Member end - it "has a scope for unread" do + it 'has a scope for unread' do Notification.unread.should eq [notification] @n2 = FactoryBot.create(:notification, read: true) Notification.unread.should eq [notification] @@ -24,13 +24,13 @@ describe Notification do Notification.unread.should include notification end - it "counts unread" do + it 'counts unread' do @who = notification.recipient @n2 = FactoryBot.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end - it "sends email if asked" do + it 'sends email if asked' do @notification2 = FactoryBot.create(:notification) @notification2.send_email ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] @@ -42,18 +42,18 @@ describe Notification do ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email] end - it "sends email on creation" do + it 'sends email on creation' do @notification2 = FactoryBot.create(:notification) ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] end - it "replaces missing subjects with (no subject)" do + it 'replaces missing subjects with (no subject)' do notification = FactoryBot.create(:notification, subject: nil) - notification.subject.should == "(no subject)" + notification.subject.should == '(no subject)' end - it "replaces whitespace-only subjects with (no subject)" do - notification = FactoryBot.create(:notification, subject: " ") - notification.subject.should == "(no subject)" + it 'replaces whitespace-only subjects with (no subject)' do + notification = FactoryBot.create(:notification, subject: ' ') + notification.subject.should == '(no subject)' end end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb index 7c2de24c6..1d9835d7d 100644 --- a/spec/models/order_item_spec.rb +++ b/spec/models/order_item_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe OrderItem do let(:order_item) { FactoryBot.create(:order_item) } - it "has an order and a product" do + it 'has an order and a product' do order_item.order.should be_an_instance_of Order order_item.product.should be_an_instance_of Product end - it "validates price > product.min_price" do + it 'validates price > product.min_price' do @product = FactoryBot.create(:product) order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) order_item.should_not be_valid diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 9abb381ba..87ae130a9 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -16,7 +16,7 @@ describe Order do @order2 = Order.create!(member_id: @member2.id) end - it "only returns orders belonging to member" do + it 'only returns orders belonging to member' do Order.by_member(@member1).should eq [@order1] end end @@ -43,7 +43,7 @@ describe Order do @member.account.paid_until.should_not be_nil end - it "totals the amount due" do + it 'totals the amount due' do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -56,7 +56,7 @@ describe Order do @order.total.should eq 1111 end - it "gives the correct total for quantities more than 1" do + it 'gives the correct total for quantities more than 1' do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -69,7 +69,7 @@ describe Order do @order.total.should eq 2222 end - it "formats order items for activemerchant" do + it 'formats order items for activemerchant' do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -87,18 +87,18 @@ describe Order do }] end - context "referral codes" do - it "has a referral code" do + context 'referral codes' do + it 'has a referral code' do referred_order = FactoryBot.create(:referred_order) referred_order.referral_code.should_not be nil end - it "validates referral codes" do + it 'validates referral codes' do referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') referred_order.should_not be_valid end - it "cleans up messy referral codes" do + it 'cleans up messy referral codes' do referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') referred_order.referral_code.should eq 'CAMPAIGN1' end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 5f07a3e29..4400f7d2f 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -9,7 +9,7 @@ describe Photo do let(:harvest) { FactoryBot.create(:harvest) } let(:garden) { FactoryBot.create(:garden) } - context "adds photos" do + context 'adds photos' do it 'to a planting' do planting.photos << photo expect(planting.photos.size).to eq 1 @@ -29,7 +29,7 @@ describe Photo do end end - context "removing photos" do + context 'removing photos' do it 'from a planting' do planting.photos << photo photo.destroy @@ -48,7 +48,7 @@ describe Photo do expect(garden.photos.size).to eq 0 end - it "automatically if unused" do + it 'automatically if unused' do photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 60a95c245..266b75ed7 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -162,11 +162,11 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it "generates a location" do + it 'generates a location' do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end - it "should have a slug" do + it 'should have a slug' do planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/) end @@ -176,15 +176,15 @@ describe Planting do end describe '#planted?' do - it "should be false for future plantings" do + it 'should be false for future plantings' do planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1 expect(planting.planted?).to eq(false) end - it "should be false for never planted" do + it 'should be false for never planted' do planting = FactoryBot.create :planting, planted_at: nil expect(planting.planted?).to eq(false) end - it "should be true for past plantings" do + it 'should be true for past plantings' do planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1 expect(planting.planted?).to eq(true) end @@ -224,7 +224,7 @@ describe Planting do @planting.should_not be_valid end - it "allows blank quantities" do + it 'allows blank quantities' do @planting = FactoryBot.build(:planting, quantity: nil) @planting.should be_valid @planting = FactoryBot.build(:planting, quantity: '') @@ -249,7 +249,7 @@ describe Planting do it 'should refuse invalid sunniness values' do @planting = FactoryBot.build(:planting, sunniness: 'not valid') @planting.should_not be_valid - @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") + @planting.errors[:sunniness].should include('not valid is not a valid sunniness value') end end @@ -271,7 +271,7 @@ describe Planting do it 'should refuse invalid planted_from values' do @planting = FactoryBot.build(:planting, planted_from: 'not valid') @planting.should_not be_valid - @planting.errors[:planted_from].should include("not valid is not a valid planting method") + @planting.errors[:planted_from].should include('not valid is not a valid planting method') end end @@ -336,7 +336,7 @@ describe Planting do end end - context "default arguments" do + context 'default arguments' do it 'ignores plantings without photos' do # first, an interesting planting @planting = FactoryBot.create(:planting) @@ -370,8 +370,8 @@ describe Planting do end end - context "with howmany argument" do - it "only returns the number asked for" do + context 'with howmany argument' do + it 'only returns the number asked for' do @plantings = FactoryBot.create_list(:planting, 10) @plantings.each do |p| p.photos << FactoryBot.create(:photo, owner: planting.owner) @@ -381,7 +381,7 @@ describe Planting do end end # interesting plantings - context "finished" do + context 'finished' do it 'has finished fields' do @planting = FactoryBot.create(:finished_planting) @planting.finished.should be true @@ -402,7 +402,7 @@ describe Planting do Planting.current.should_not include @f end - context "finished date validation" do + context 'finished date validation' do it 'requires finished date after planting date' do @f = FactoryBot.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 98880ce2b..4eb8d6ad6 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,33 +3,33 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } - it_behaves_like "it is likeable" + it_behaves_like 'it is likeable' - it "should have a slug" do + it 'should have a slug' do post = FactoryBot.create(:post, author: member) time = post.created_at - datestr = time.strftime("%Y%m%d") + datestr = time.strftime('%Y%m%d') # 2 digit day and month, full-length years # Counting digits using Math.log is not precise enough! datestr.size.should eq(4 + time.year.to_s.size) post.slug.should eq("#{member.login_name}-#{datestr}-a-post") end - it "has many comments" do + it 'has many comments' do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comments.size.should == 2 end - it "supports counting comments" do + it 'supports counting comments' do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comment_count.should == 2 end - it "destroys comments when deleted" do + it 'destroys comments when deleted' do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) @@ -39,7 +39,7 @@ describe Post do Comment.count.should eq(all - 2) end - it "belongs to a forum" do + it 'belongs to a forum' do post = FactoryBot.create(:forum_post) post.forum.should be_an_instance_of Forum end @@ -50,40 +50,40 @@ describe Post do end it "doesn't allow a blank subject" do - post = FactoryBot.build(:post, subject: "") + post = FactoryBot.build(:post, subject: '') post.should_not be_valid end it "doesn't allow a subject with only spaces" do - post = FactoryBot.build(:post, subject: " ") + post = FactoryBot.build(:post, subject: ' ') post.should_not be_valid end - context "recent activity" do + context 'recent activity' do before do Time.stub(now: Time.now) end let!(:post) { FactoryBot.create(:post, created_at: 1.day.ago) } - it "sets recent activity to post time" do + it 'sets recent activity to post time' do post.recent_activity.to_i.should eq post.created_at.to_i end - it "sets recent activity to comment time" do + it 'sets recent activity to comment time' do comment = FactoryBot.create(:comment, post: post, created_at: 1.hour.ago) post.recent_activity.to_i.should eq comment.created_at.to_i end - it "shiny new post is recently active" do + it 'shiny new post is recently active' do # create a shiny new post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq post2 Post.recently_active.second.should eq post end - it "new comment on old post is recently active" do + it 'new comment on old post is recently active' do # now comment on an older post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) FactoryBot.create(:comment, post: post, created_at: 1.second.ago) @@ -92,22 +92,22 @@ describe Post do end end - context "notifications" do + context 'notifications' do let(:member2) { FactoryBot.create(:member) } - it "sends a notification when a member is mentioned using @-syntax" do + it 'sends a notification when a member is mentioned using @-syntax' do expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2}") end.to change(Notification, :count).by(1) end - it "sends a notification when a member is mentioned using [](member) syntax" do + it 'sends a notification when a member is mentioned using [](member) syntax' do expect do FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)") end.to change(Notification, :count).by(1) end - it "sets the notification field" do + it 'sets the notification field' do p = FactoryBot.create(:post, author: member, body: "Hey @#{member2}") n = Notification.first n.sender.should eq member @@ -116,7 +116,7 @@ describe Post do n.body.should eq p.body end - it "sends notifications to all members mentioned" do + it 'sends notifications to all members mentioned' do member3 = FactoryBot.create(:member) expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}") @@ -130,23 +130,23 @@ describe Post do end end - context "crop-post association" do + context 'crop-post association' do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:chard) { FactoryBot.create(:chard) } - let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } + let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } - it "should be generated" do + it 'should be generated' do expect(tomato.posts).to eq [post] expect(maize.posts).to eq [post] end - it "should not duplicate" do + it 'should not duplicate' do expect(post.crops) =~ [tomato, maize] end - it "should be updated when post was modified" do - post.update_attributes(body: "[chard](crop)") + it 'should be updated when post was modified' do + post.update_attributes(body: '[chard](crop)') expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] @@ -154,17 +154,17 @@ describe Post do expect(maize.posts).to eq [] end - describe "destroying the post" do + describe 'destroying the post' do before do post.destroy end - it "should delete the association" do + it 'should delete the association' do expect(Crop.find(tomato.id).posts).to eq [] expect(Crop.find(maize.id).posts).to eq [] end - it "should not delete the crops" do + it 'should not delete the crops' do expect(Crop.find(tomato.id)).not_to eq nil expect(Crop.find(maize.id)).not_to eq nil end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index 2cc684667..1ff0ba516 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Product do - it "stringifies using the name" do + it 'stringifies using the name' do @product = FactoryBot.create(:product) @product.to_s.should eq @product.name end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index e45d0e240..020e37741 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -7,7 +7,7 @@ describe Seed do seed.save.should be(true) end - it "should have a slug" do + it 'should have a slug' do seed.save seed.slug.should match(/member\d+-magic-bean/) end @@ -28,7 +28,7 @@ describe Seed do @seed.should_not be_valid end - it "allows blank quantities" do + it 'allows blank quantities' do @seed = FactoryBot.build(:seed, quantity: nil) @seed.should be_valid @seed = FactoryBot.build(:seed, quantity: '') @@ -48,8 +48,8 @@ describe Seed do @seed = FactoryBot.build(:seed, tradable_to: 'not valid') @seed.should_not be_valid @seed.errors[:tradable_to].should include( - "You may only trade seed nowhere, locally, "\ - "nationally, or internationally" + 'You may only trade seed nowhere, locally, '\ + 'nationally, or internationally' ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index e28dd6e24..dfced9e4b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' +ENV['RAILS_ENV'] ||= 'test' require 'simplecov' require 'coveralls' @@ -17,7 +17,7 @@ SimpleCov.start :rails do end require 'spec_helper' -require File.expand_path("../../config/environment", __FILE__) +require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! Rails.application.eager_load! @@ -58,8 +58,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } +Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } +Dir[Rails.root.join('spec/features/shared_examples/**/*.rb')].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 6a392eb74..936d1a7a6 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -5,53 +5,53 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do - { "id" => crop.id.to_s, - "type" => "crops", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "plantings" => plantings_as_json_api, - "parent" => parent_as_json_api, - "photos" => photos_as_json_api, - "harvests" => harvests_as_json_api + { 'id' => crop.id.to_s, + 'type' => 'crops', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'plantings' => plantings_as_json_api, + 'parent' => parent_as_json_api, + 'photos' => photos_as_json_api, + 'harvests' => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } let(:harvests_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/harvests", - "related" => "#{resource_url}/harvests" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/harvests", + 'related' => "#{resource_url}/harvests" } } end let(:parent_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/parent", - "related" => "#{resource_url}/parent" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/parent", + 'related' => "#{resource_url}/parent" } } end let(:plantings_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/plantings", - "related" => "#{resource_url}/plantings" } } + 'related' => "#{resource_url}/plantings" } } end let(:photos_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/photos", - "related" => "#{resource_url}/photos" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/photos", + 'related' => "#{resource_url}/photos" } } end let(:attributes) do { - "name" => crop.name, - "en-wikipedia-url" => crop.en_wikipedia_url, - "perennial" => false, - "median-lifespan" => nil, - "median-days-to-first-harvest" => nil, - "median-days-to-last-harvest" => nil + 'name' => crop.name, + 'en-wikipedia-url' => crop.en_wikipedia_url, + 'perennial' => false, + 'median-lifespan' => nil, + 'median-days-to-first-harvest' => nil, + 'median-days-to-last-harvest' => nil } end @@ -63,25 +63,25 @@ RSpec.describe 'Plantings', type: :request do describe '#show' do before { get "/api/v1/crops/#{crop.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } + it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include('parent' => parent_as_json_api) } it { expect(subject['data']).to eq(crop_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#update' do before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#delete' do before { delete "/api/v1/crops/#{crop.id}", {}, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index d6005e286..234606bcd 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -5,36 +5,36 @@ RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do - { "id" => garden.id.to_s, - "type" => "gardens", - "links" => { "self" => resource_url }, - "attributes" => { "name" => garden.name }, - "relationships" => + { 'id' => garden.id.to_s, + 'type' => 'gardens', + 'links' => { 'self' => resource_url }, + 'attributes' => { 'name' => garden.name }, + 'relationships' => { - "owner" => owner_as_json_api, - "plantings" => plantings_as_json_api, - "photos" => photos_as_json_api + 'owner' => owner_as_json_api, + 'plantings' => plantings_as_json_api, + 'photos' => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } let(:plantings_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/plantings", - "related" => "#{resource_url}/plantings" } } + 'related' => "#{resource_url}/plantings" } } end let(:owner_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/owner", - "related" => "#{resource_url}/owner" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/owner", + 'related' => "#{resource_url}/owner" } } end let(:photos_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/photos", - "related" => "#{resource_url}/photos" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/photos", + 'related' => "#{resource_url}/photos" } } end scenario '#index' do @@ -49,16 +49,16 @@ RSpec.describe 'Gardens', type: :request do scenario '#create' do post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end scenario '#update' do post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end scenario '#delete' do delete "/api/v1/gardens/#{garden.id}", {}, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index af2d4201e..b685b2990 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Harvests', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do - { "id" => harvest.id.to_s, - "type" => "harvests", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "crop" => crop_as_json_api, - "planting" => planting_as_json_api, - "owner" => owner_as_json_api, - "photos" => photos_as_json_api + { 'id' => harvest.id.to_s, + 'type' => 'harvests', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'crop' => crop_as_json_api, + 'planting' => planting_as_json_api, + 'owner' => owner_as_json_api, + 'photos' => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } let(:crop_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/crop", - "related" => "#{resource_url}/crop" } } + 'related' => "#{resource_url}/crop" } } end let(:owner_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/owner", - "related" => "#{resource_url}/owner" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/owner", + 'related' => "#{resource_url}/owner" } } end let(:planting_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/planting", - "related" => "#{resource_url}/planting" } } + 'related' => "#{resource_url}/planting" } } end let(:photos_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/photos", - "related" => "#{resource_url}/photos" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/photos", + 'related' => "#{resource_url}/photos" } } end let(:attributes) do { - "harvested-at" => "2015-09-17", - "description" => harvest.description, - "unit" => harvest.unit, - "weight-quantity" => harvest.weight_quantity.to_s, - "weight-unit" => harvest.weight_unit, - "si-weight" => harvest.si_weight + 'harvested-at' => '2015-09-17', + 'description' => harvest.description, + 'unit' => harvest.unit, + 'weight-quantity' => harvest.weight_quantity.to_s, + 'weight-unit' => harvest.weight_unit, + 'si-weight' => harvest.si_weight } end @@ -64,25 +64,25 @@ RSpec.describe 'Harvests', type: :request do describe '#show' do before { get "/api/v1/harvests/#{harvest.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } - it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } - it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include('planting' => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#update' do before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#delete' do before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 6067e59b6..2e9977132 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Members', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do - { "id" => member.id.to_s, - "type" => "members", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "gardens" => gardens_as_json_api, - "harvests" => harvests_as_json_api, - "photos" => photos_as_json_api, - "plantings" => plantings_as_json_api, - "seeds" => seeds_as_json_api + { 'id' => member.id.to_s, + 'type' => 'members', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'gardens' => gardens_as_json_api, + 'harvests' => harvests_as_json_api, + 'photos' => photos_as_json_api, + 'plantings' => plantings_as_json_api, + 'seeds' => seeds_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } let(:harvests_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/harvests", - "related" => "#{resource_url}/harvests" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/harvests", + 'related' => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/photos", - "related" => "#{resource_url}/photos" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/photos", + 'related' => "#{resource_url}/photos" } } end let(:seeds_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/seeds", - "related" => "#{resource_url}/seeds" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/seeds", + 'related' => "#{resource_url}/seeds" } } end let(:plantings_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/plantings", - "related" => "#{resource_url}/plantings" } } + 'related' => "#{resource_url}/plantings" } } end let(:gardens_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/gardens", - "related" => "#{resource_url}/gardens" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/gardens", + 'related' => "#{resource_url}/gardens" } } end let(:attributes) do { - "login-name" => member.login_name + 'login-name' => member.login_name } end @@ -63,26 +63,26 @@ RSpec.describe 'Members', type: :request do describe '#show' do before { get "/api/v1/members/#{member.id}", {}, headers } - it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } - it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } - it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include('gardens' => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include('seeds' => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } it { expect(subject['data']).to eq(member_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#update' do before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#delete' do before { delete "/api/v1/members/#{member.id}", {}, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index e9e584a60..6f5c1434b 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -5,52 +5,52 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do - { "id" => photo.id.to_s, - "type" => "photos", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "owner" => owner_as_json_api, - "plantings" => plantings_as_json_api, - "harvests" => harvests_as_json_api, - "gardens" => gardens_as_json_api + { 'id' => photo.id.to_s, + 'type' => 'photos', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'owner' => owner_as_json_api, + 'plantings' => plantings_as_json_api, + 'harvests' => harvests_as_json_api, + 'gardens' => gardens_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } let(:owner_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/owner", - "related" => "#{resource_url}/owner" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/owner", + 'related' => "#{resource_url}/owner" } } end let(:harvests_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/harvests", - "related" => "#{resource_url}/harvests" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/harvests", + 'related' => "#{resource_url}/harvests" } } end let(:gardens_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/gardens", - "related" => "#{resource_url}/gardens" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/gardens", + 'related' => "#{resource_url}/gardens" } } end let(:plantings_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/plantings", - "related" => "#{resource_url}/plantings" } } + 'related' => "#{resource_url}/plantings" } } end let(:attributes) do { - "thumbnail-url" => photo.thumbnail_url, - "fullsize-url" => photo.fullsize_url, - "link-url" => photo.link_url, - "license-name" => photo.license_name, - "title" => photo.title + 'thumbnail-url' => photo.thumbnail_url, + 'fullsize-url' => photo.fullsize_url, + 'link-url' => photo.link_url, + 'license-name' => photo.license_name, + 'title' => photo.title } end @@ -62,24 +62,24 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/photos/#{photo.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } it { expect(subject['data']).to eq(photo_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#update' do before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#delete' do before { delete "/api/v1/photos/#{photo.id}", {}, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 4e96cefb4..02a7be3f4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -5,65 +5,65 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do - { "id" => planting.id.to_s, - "type" => "plantings", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "garden" => garden_as_json_api, - "crop" => crop_as_json_api, - "owner" => owner_as_json_api, - "photos" => photos_as_json_api, - "harvests" => harvests_as_json_api + { 'id' => planting.id.to_s, + 'type' => 'plantings', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'garden' => garden_as_json_api, + 'crop' => crop_as_json_api, + 'owner' => owner_as_json_api, + 'photos' => photos_as_json_api, + 'harvests' => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } let(:harvests_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/harvests", - "related" => "#{resource_url}/harvests" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/harvests", + 'related' => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/photos", - "related" => "#{resource_url}/photos" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/photos", + 'related' => "#{resource_url}/photos" } } end let(:owner_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/owner", - "related" => "#{resource_url}/owner" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/owner", + 'related' => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { "links" => - { "self" => + { 'links' => + { 'self' => "#{resource_url}/relationships/crop", - "related" => "#{resource_url}/crop" } } + 'related' => "#{resource_url}/crop" } } end let(:garden_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/garden", - "related" => "#{resource_url}/garden" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/garden", + 'related' => "#{resource_url}/garden" } } end let(:attributes) do { - "planted-at" => "2014-07-30", - "finished-at" => nil, - "finished" => false, - "quantity" => 33, - "description" => planting.description, - "sunniness" => nil, - "planted-from" => nil, - "expected-lifespan" => nil, - "finish-predicted-at" => nil, - "percentage-grown" => nil, - "first-harvest-date" => nil, - "last-harvest-date" => nil + 'planted-at' => '2014-07-30', + 'finished-at' => nil, + 'finished' => false, + 'quantity' => 33, + 'description' => planting.description, + 'sunniness' => nil, + 'planted-from' => nil, + 'expected-lifespan' => nil, + 'finish-predicted-at' => nil, + 'percentage-grown' => nil, + 'first-harvest-date' => nil, + 'last-harvest-date' => nil } end @@ -74,26 +74,26 @@ RSpec.describe 'Plantings', type: :request do scenario '#show' do get "/api/v1/plantings/#{planting.id}", {}, headers - expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) - expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) - expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) - expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) - expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) + expect(subject['data']['relationships']).to include('garden' => garden_as_json_api) + expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) + expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) + expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) + expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end scenario '#create' do post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end scenario '#update' do post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end scenario '#delete' do delete "/api/v1/plantings/#{planting.id}", {}, headers - expect(response.code).to eq "404" + expect(response.code).to eq '404' end end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index f518e91de..733ab7e22 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -5,41 +5,41 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do - { "id" => seed.id.to_s, - "type" => "seeds", - "links" => { "self" => resource_url }, - "attributes" => attributes, - "relationships" => { - "owner" => owner_as_json_api, - "crop" => crop_as_json_api + { 'id' => seed.id.to_s, + 'type' => 'seeds', + 'links' => { 'self' => resource_url }, + 'attributes' => attributes, + 'relationships' => { + 'owner' => owner_as_json_api, + 'crop' => crop_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } let(:owner_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/owner", - "related" => "#{resource_url}/owner" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/owner", + 'related' => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { "links" => - { "self" => "#{resource_url}/relationships/crop", - "related" => "#{resource_url}/crop" } } + { 'links' => + { 'self' => "#{resource_url}/relationships/crop", + 'related' => "#{resource_url}/crop" } } end let(:attributes) do { - "description" => seed.description, - "quantity" => seed.quantity, - "plant-before" => "2013-07-15", - "tradable-to" => seed.tradable_to, - "days-until-maturity-min" => seed.days_until_maturity_min, - "days-until-maturity-max" => seed.days_until_maturity_max, - "organic" => seed.organic, - "gmo" => seed.gmo, - "heirloom" => seed.heirloom + 'description' => seed.description, + 'quantity' => seed.quantity, + 'plant-before' => '2013-07-15', + 'tradable-to' => seed.tradable_to, + 'days-until-maturity-min' => seed.days_until_maturity_min, + 'days-until-maturity-max' => seed.days_until_maturity_max, + 'organic' => seed.organic, + 'gmo' => seed.gmo, + 'heirloom' => seed.heirloom } end @@ -51,23 +51,23 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/seeds/#{seed.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } - it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } it { expect(subject['data']).to eq(seed_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#update' do before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end describe '#delete' do before { delete "/api/v1/seeds/#{seed.id}", {}, headers } - it { expect(response.code).to eq "404" } + it { expect(response.code).to eq '404' } end end diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 6cc612f44..45b7754b9 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "Authentications" do - describe "GET /authentications" do +describe 'Authentications' do + describe 'GET /authentications' do end end diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb index c9b2ba9dc..6e5544657 100644 --- a/spec/requests/comments_spec.rb +++ b/spec/requests/comments_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Comments" do - describe "GET /comments" do - it "works! (now write some real specs)" do +describe 'Comments' do + describe 'GET /comments' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get comments_path response.status.should be(200) diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index ff7cb283d..34a86ea66 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Forums" do - describe "GET /forums" do - it "works! (now write some real specs)" do +describe 'Forums' do + describe 'GET /forums' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get forums_path response.status.should be(200) diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 91a8dc8b7..74a9931fb 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Gardens" do - describe "GET /gardens" do - it "works! (now write some real specs)" do +describe 'Gardens' do + describe 'GET /gardens' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get gardens_path response.status.should be(200) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index f3774b3c0..17785af18 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Harvests" do - describe "GET /harvests" do - it "works! (now write some real specs)" do +describe 'Harvests' do + describe 'GET /harvests' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path response.status.should be(200) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index 85afbdd9f..b5879f678 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Notifications" do - describe "GET /notifications" do - it "works! (now write some real specs)" do +describe 'Notifications' do + describe 'GET /notifications' do + it 'works! (now write some real specs)' do get notifications_path # can't see notifications because not logged in # therefore redirect to homepage diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index b937ded3d..a3d39871c 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Photos" do - describe "GET /photos" do - it "works! (now write some real specs)" do +describe 'Photos' do + describe 'GET /photos' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get photos_path response.status.should be(200) diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index 1fc2150b2..c44e42599 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "PlantParts" do - describe "GET /plant_parts" do - it "works! (now write some real specs)" do +describe 'PlantParts' do + describe 'GET /plant_parts' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plant_parts_path response.status.should be(200) diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index cb66922e0..e156f9589 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Plantings" do - describe "GET /plantings" do - it "works! (now write some real specs)" do +describe 'Plantings' do + describe 'GET /plantings' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plantings_path response.status.should be(200) diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index 3bb479aa8..a2e316c38 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Posts" do - describe "GET /posts" do - it "works! (now write some real specs)" do +describe 'Posts' do + describe 'GET /posts' do + it 'works! (now write some real specs)' do get posts_path response.status.should be(200) end diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 922f6f270..02785b4ad 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "ScientificNames" do - describe "GET /scientific_names" do - it "works! (now write some real specs)" do +describe 'ScientificNames' do + describe 'GET /scientific_names' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get scientific_names_path response.status.should be(200) diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 8bc5aeccf..08d3c0f18 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "Seeds" do - describe "GET /seeds" do - it "works! (now write some real specs)" do +describe 'Seeds' do + describe 'GET /seeds' do + it 'works! (now write some real specs)' do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get seeds_path response.status.should be(200) diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb index 8402dd727..53ed9b4a3 100644 --- a/spec/routing/account_types_routing_spec.rb +++ b/spec/routing/account_types_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe AccountTypesController do - describe "routing" do - it "routes to #index" do - get("/account_types").should route_to("account_types#index") + describe 'routing' do + it 'routes to #index' do + get('/account_types').should route_to('account_types#index') end - it "routes to #new" do - get("/account_types/new").should route_to("account_types#new") + it 'routes to #new' do + get('/account_types/new').should route_to('account_types#new') end - it "routes to #show" do - get("/account_types/1").should route_to("account_types#show", id: "1") + it 'routes to #show' do + get('/account_types/1').should route_to('account_types#show', id: '1') end - it "routes to #edit" do - get("/account_types/1/edit").should route_to("account_types#edit", id: "1") + it 'routes to #edit' do + get('/account_types/1/edit').should route_to('account_types#edit', id: '1') end - it "routes to #create" do - post("/account_types").should route_to("account_types#create") + it 'routes to #create' do + post('/account_types').should route_to('account_types#create') end - it "routes to #update" do - put("/account_types/1").should route_to("account_types#update", id: "1") + it 'routes to #update' do + put('/account_types/1').should route_to('account_types#update', id: '1') end - it "routes to #destroy" do - delete("/account_types/1").should route_to("account_types#destroy", id: "1") + it 'routes to #destroy' do + delete('/account_types/1').should route_to('account_types#destroy', id: '1') end end end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 0601b9924..39d814011 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,13 +1,13 @@ -require "rails_helper" +require 'rails_helper' describe AuthenticationsController do - describe "routing" do - it "routes to #create" do - post("/authentications").should route_to("authentications#create") + describe 'routing' do + it 'routes to #create' do + post('/authentications').should route_to('authentications#create') end - it "routes to #destroy" do - delete("/authentications/1").should route_to("authentications#destroy", id: "1") + it 'routes to #destroy' do + delete('/authentications/1').should route_to('authentications#destroy', id: '1') end end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 5390ab066..8f9363dcc 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe CommentsController do - describe "routing" do - it "routes to #index" do - get("/comments").should route_to("comments#index") + describe 'routing' do + it 'routes to #index' do + get('/comments').should route_to('comments#index') end - it "routes to #new" do - get("/comments/new").should route_to("comments#new") + it 'routes to #new' do + get('/comments/new').should route_to('comments#new') end - it "routes to #show" do - get("/comments/1").should route_to("comments#show", id: "1") + it 'routes to #show' do + get('/comments/1').should route_to('comments#show', id: '1') end - it "routes to #edit" do - get("/comments/1/edit").should route_to("comments#edit", id: "1") + it 'routes to #edit' do + get('/comments/1/edit').should route_to('comments#edit', id: '1') end - it "routes to #create" do - post("/comments").should route_to("comments#create") + it 'routes to #create' do + post('/comments').should route_to('comments#create') end - it "routes to #update" do - put("/comments/1").should route_to("comments#update", id: "1") + it 'routes to #update' do + put('/comments/1').should route_to('comments#update', id: '1') end - it "routes to #destroy" do - delete("/comments/1").should route_to("comments#destroy", id: "1") + it 'routes to #destroy' do + delete('/comments/1').should route_to('comments#destroy', id: '1') end end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 97c1a874c..644bad3d6 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe CropsController do - describe "routing" do - it "routes to #index" do - get("/crops").should route_to("crops#index") + describe 'routing' do + it 'routes to #index' do + get('/crops').should route_to('crops#index') end - it "routes to #new" do - get("/crops/new").should route_to("crops#new") + it 'routes to #new' do + get('/crops/new').should route_to('crops#new') end - it "routes to #show" do - get("/crops/1").should route_to("crops#show", id: "1") + it 'routes to #show' do + get('/crops/1').should route_to('crops#show', id: '1') end - it "routes to #edit" do - get("/crops/1/edit").should route_to("crops#edit", id: "1") + it 'routes to #edit' do + get('/crops/1/edit').should route_to('crops#edit', id: '1') end - it "routes to #create" do - post("/crops").should route_to("crops#create") + it 'routes to #create' do + post('/crops').should route_to('crops#create') end - it "routes to #update" do - put("/crops/1").should route_to("crops#update", id: "1") + it 'routes to #update' do + put('/crops/1').should route_to('crops#update', id: '1') end - it "routes to #destroy" do - delete("/crops/1").should route_to("crops#destroy", id: "1") + it 'routes to #destroy' do + delete('/crops/1').should route_to('crops#destroy', id: '1') end end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index ddb01e00c..06aaa6b76 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,13 +1,13 @@ -require "spec_helper" +require 'spec_helper' describe FollowsController do - describe "routing" do - it "routes to #create" do - post("/follows").should route_to("follows#create") + describe 'routing' do + it 'routes to #create' do + post('/follows').should route_to('follows#create') end - it "routes to #destroy" do - delete("/follows/1").should route_to("follows#destroy", id: "1") + it 'routes to #destroy' do + delete('/follows/1').should route_to('follows#destroy', id: '1') end end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index 9ce6f427b..ca229917f 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe ForumsController do - describe "routing" do - it "routes to #index" do - get("/forums").should route_to("forums#index") + describe 'routing' do + it 'routes to #index' do + get('/forums').should route_to('forums#index') end - it "routes to #new" do - get("/forums/new").should route_to("forums#new") + it 'routes to #new' do + get('/forums/new').should route_to('forums#new') end - it "routes to #show" do - get("/forums/1").should route_to("forums#show", id: "1") + it 'routes to #show' do + get('/forums/1').should route_to('forums#show', id: '1') end - it "routes to #edit" do - get("/forums/1/edit").should route_to("forums#edit", id: "1") + it 'routes to #edit' do + get('/forums/1/edit').should route_to('forums#edit', id: '1') end - it "routes to #create" do - post("/forums").should route_to("forums#create") + it 'routes to #create' do + post('/forums').should route_to('forums#create') end - it "routes to #update" do - put("/forums/1").should route_to("forums#update", id: "1") + it 'routes to #update' do + put('/forums/1').should route_to('forums#update', id: '1') end - it "routes to #destroy" do - delete("/forums/1").should route_to("forums#destroy", id: "1") + it 'routes to #destroy' do + delete('/forums/1').should route_to('forums#destroy', id: '1') end end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 6888f099f..8ec871b3b 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe GardensController do - describe "routing" do - it "routes to #index" do - get("/gardens").should route_to("gardens#index") + describe 'routing' do + it 'routes to #index' do + get('/gardens').should route_to('gardens#index') end - it "routes to #new" do - get("/gardens/new").should route_to("gardens#new") + it 'routes to #new' do + get('/gardens/new').should route_to('gardens#new') end - it "routes to #show" do - get("/gardens/1").should route_to("gardens#show", id: "1") + it 'routes to #show' do + get('/gardens/1').should route_to('gardens#show', id: '1') end - it "routes to #edit" do - get("/gardens/1/edit").should route_to("gardens#edit", id: "1") + it 'routes to #edit' do + get('/gardens/1/edit').should route_to('gardens#edit', id: '1') end - it "routes to #create" do - post("/gardens").should route_to("gardens#create") + it 'routes to #create' do + post('/gardens').should route_to('gardens#create') end - it "routes to #update" do - put("/gardens/1").should route_to("gardens#update", id: "1") + it 'routes to #update' do + put('/gardens/1').should route_to('gardens#update', id: '1') end - it "routes to #destroy" do - delete("/gardens/1").should route_to("gardens#destroy", id: "1") + it 'routes to #destroy' do + delete('/gardens/1').should route_to('gardens#destroy', id: '1') end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index c6890df15..41ad0c187 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe HarvestsController do - describe "routing" do - it "routes to #index" do - get("/harvests").should route_to("harvests#index") + describe 'routing' do + it 'routes to #index' do + get('/harvests').should route_to('harvests#index') end - it "routes to #new" do - get("/harvests/new").should route_to("harvests#new") + it 'routes to #new' do + get('/harvests/new').should route_to('harvests#new') end - it "routes to #show" do - get("/harvests/1").should route_to("harvests#show", id: "1") + it 'routes to #show' do + get('/harvests/1').should route_to('harvests#show', id: '1') end - it "routes to #edit" do - get("/harvests/1/edit").should route_to("harvests#edit", id: "1") + it 'routes to #edit' do + get('/harvests/1/edit').should route_to('harvests#edit', id: '1') end - it "routes to #create" do - post("/harvests").should route_to("harvests#create") + it 'routes to #create' do + post('/harvests').should route_to('harvests#create') end - it "routes to #update" do - put("/harvests/1").should route_to("harvests#update", id: "1") + it 'routes to #update' do + put('/harvests/1').should route_to('harvests#update', id: '1') end - it "routes to #destroy" do - delete("/harvests/1").should route_to("harvests#destroy", id: "1") + it 'routes to #destroy' do + delete('/harvests/1').should route_to('harvests#destroy', id: '1') end end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index bb7335e1b..8b0628575 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe NotificationsController do - describe "routing" do - it "routes to #index" do - get("/notifications").should route_to("notifications#index") + describe 'routing' do + it 'routes to #index' do + get('/notifications').should route_to('notifications#index') end - it "routes to #new" do - get("/notifications/new").should route_to("notifications#new") + it 'routes to #new' do + get('/notifications/new').should route_to('notifications#new') end - it "routes to #show" do - get("/notifications/1").should route_to("notifications#show", id: "1") + it 'routes to #show' do + get('/notifications/1').should route_to('notifications#show', id: '1') end - it "routes to #edit" do - get("/notifications/1/edit").should route_to("notifications#edit", id: "1") + it 'routes to #edit' do + get('/notifications/1/edit').should route_to('notifications#edit', id: '1') end - it "routes to #create" do - post("/notifications").should route_to("notifications#create") + it 'routes to #create' do + post('/notifications').should route_to('notifications#create') end - it "routes to #update" do - put("/notifications/1").should route_to("notifications#update", id: "1") + it 'routes to #update' do + put('/notifications/1').should route_to('notifications#update', id: '1') end - it "routes to #destroy" do - delete("/notifications/1").should route_to("notifications#destroy", id: "1") + it 'routes to #destroy' do + delete('/notifications/1').should route_to('notifications#destroy', id: '1') end end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb index 7487cb9f5..095842d7f 100644 --- a/spec/routing/order_items_routing_spec.rb +++ b/spec/routing/order_items_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe OrderItemsController do - describe "routing" do - it "routes to #index" do - get("/order_items").should route_to("order_items#index") + describe 'routing' do + it 'routes to #index' do + get('/order_items').should route_to('order_items#index') end - it "routes to #new" do - get("/order_items/new").should route_to("order_items#new") + it 'routes to #new' do + get('/order_items/new').should route_to('order_items#new') end - it "routes to #show" do - get("/order_items/1").should route_to("order_items#show", id: "1") + it 'routes to #show' do + get('/order_items/1').should route_to('order_items#show', id: '1') end - it "routes to #edit" do - get("/order_items/1/edit").should route_to("order_items#edit", id: "1") + it 'routes to #edit' do + get('/order_items/1/edit').should route_to('order_items#edit', id: '1') end - it "routes to #create" do - post("/order_items").should route_to("order_items#create") + it 'routes to #create' do + post('/order_items').should route_to('order_items#create') end - it "routes to #update" do - put("/order_items/1").should route_to("order_items#update", id: "1") + it 'routes to #update' do + put('/order_items/1').should route_to('order_items#update', id: '1') end - it "routes to #destroy" do - delete("/order_items/1").should route_to("order_items#destroy", id: "1") + it 'routes to #destroy' do + delete('/order_items/1').should route_to('order_items#destroy', id: '1') end end end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb index 38184ef33..4c7d925c5 100644 --- a/spec/routing/orders_routing_spec.rb +++ b/spec/routing/orders_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe OrdersController do - describe "routing" do - it "routes to #index" do - get("/orders").should route_to("orders#index") + describe 'routing' do + it 'routes to #index' do + get('/orders').should route_to('orders#index') end - it "routes to #new" do - get("/orders/new").should route_to("orders#new") + it 'routes to #new' do + get('/orders/new').should route_to('orders#new') end - it "routes to #show" do - get("/orders/1").should route_to("orders#show", id: "1") + it 'routes to #show' do + get('/orders/1').should route_to('orders#show', id: '1') end - it "routes to #edit" do - get("/orders/1/edit").should route_to("orders#edit", id: "1") + it 'routes to #edit' do + get('/orders/1/edit').should route_to('orders#edit', id: '1') end - it "routes to #create" do - post("/orders").should route_to("orders#create") + it 'routes to #create' do + post('/orders').should route_to('orders#create') end - it "routes to #update" do - put("/orders/1").should route_to("orders#update", id: "1") + it 'routes to #update' do + put('/orders/1').should route_to('orders#update', id: '1') end - it "routes to #destroy" do - delete("/orders/1").should route_to("orders#destroy", id: "1") + it 'routes to #destroy' do + delete('/orders/1').should route_to('orders#destroy', id: '1') end end end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index a645d0a60..1337de4b2 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe PhotosController do - describe "routing" do - it "routes to #index" do - get("/photos").should route_to("photos#index") + describe 'routing' do + it 'routes to #index' do + get('/photos').should route_to('photos#index') end - it "routes to #new" do - get("/photos/new").should route_to("photos#new") + it 'routes to #new' do + get('/photos/new').should route_to('photos#new') end - it "routes to #show" do - get("/photos/1").should route_to("photos#show", id: "1") + it 'routes to #show' do + get('/photos/1').should route_to('photos#show', id: '1') end - it "routes to #edit" do - get("/photos/1/edit").should route_to("photos#edit", id: "1") + it 'routes to #edit' do + get('/photos/1/edit').should route_to('photos#edit', id: '1') end - it "routes to #create" do - post("/photos").should route_to("photos#create") + it 'routes to #create' do + post('/photos').should route_to('photos#create') end - it "routes to #update" do - put("/photos/1").should route_to("photos#update", id: "1") + it 'routes to #update' do + put('/photos/1').should route_to('photos#update', id: '1') end - it "routes to #destroy" do - delete("/photos/1").should route_to("photos#destroy", id: "1") + it 'routes to #destroy' do + delete('/photos/1').should route_to('photos#destroy', id: '1') end end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 966047f3f..2a00948bc 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe PlantPartsController do - describe "routing" do - it "routes to #index" do - get("/plant_parts").should route_to("plant_parts#index") + describe 'routing' do + it 'routes to #index' do + get('/plant_parts').should route_to('plant_parts#index') end - it "routes to #new" do - get("/plant_parts/new").should route_to("plant_parts#new") + it 'routes to #new' do + get('/plant_parts/new').should route_to('plant_parts#new') end - it "routes to #show" do - get("/plant_parts/1").should route_to("plant_parts#show", id: "1") + it 'routes to #show' do + get('/plant_parts/1').should route_to('plant_parts#show', id: '1') end - it "routes to #edit" do - get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") + it 'routes to #edit' do + get('/plant_parts/1/edit').should route_to('plant_parts#edit', id: '1') end - it "routes to #create" do - post("/plant_parts").should route_to("plant_parts#create") + it 'routes to #create' do + post('/plant_parts').should route_to('plant_parts#create') end - it "routes to #update" do - put("/plant_parts/1").should route_to("plant_parts#update", id: "1") + it 'routes to #update' do + put('/plant_parts/1').should route_to('plant_parts#update', id: '1') end - it "routes to #destroy" do - delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") + it 'routes to #destroy' do + delete('/plant_parts/1').should route_to('plant_parts#destroy', id: '1') end end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 473fe827e..4098d7703 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe PlantingsController do - describe "routing" do - it "routes to #index" do - get("/plantings").should route_to("plantings#index") + describe 'routing' do + it 'routes to #index' do + get('/plantings').should route_to('plantings#index') end - it "routes to #new" do - get("/plantings/new").should route_to("plantings#new") + it 'routes to #new' do + get('/plantings/new').should route_to('plantings#new') end - it "routes to #show" do - get("/plantings/1").should route_to("plantings#show", id: "1") + it 'routes to #show' do + get('/plantings/1').should route_to('plantings#show', id: '1') end - it "routes to #edit" do - get("/plantings/1/edit").should route_to("plantings#edit", id: "1") + it 'routes to #edit' do + get('/plantings/1/edit').should route_to('plantings#edit', id: '1') end - it "routes to #create" do - post("/plantings").should route_to("plantings#create") + it 'routes to #create' do + post('/plantings').should route_to('plantings#create') end - it "routes to #update" do - put("/plantings/1").should route_to("plantings#update", id: "1") + it 'routes to #update' do + put('/plantings/1').should route_to('plantings#update', id: '1') end - it "routes to #destroy" do - delete("/plantings/1").should route_to("plantings#destroy", id: "1") + it 'routes to #destroy' do + delete('/plantings/1').should route_to('plantings#destroy', id: '1') end end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb index 15166a805..c19642a21 100644 --- a/spec/routing/products_routing_spec.rb +++ b/spec/routing/products_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe ProductsController do - describe "routing" do - it "routes to #index" do - get("/products").should route_to("products#index") + describe 'routing' do + it 'routes to #index' do + get('/products').should route_to('products#index') end - it "routes to #new" do - get("/products/new").should route_to("products#new") + it 'routes to #new' do + get('/products/new').should route_to('products#new') end - it "routes to #show" do - get("/products/1").should route_to("products#show", id: "1") + it 'routes to #show' do + get('/products/1').should route_to('products#show', id: '1') end - it "routes to #edit" do - get("/products/1/edit").should route_to("products#edit", id: "1") + it 'routes to #edit' do + get('/products/1/edit').should route_to('products#edit', id: '1') end - it "routes to #create" do - post("/products").should route_to("products#create") + it 'routes to #create' do + post('/products').should route_to('products#create') end - it "routes to #update" do - put("/products/1").should route_to("products#update", id: "1") + it 'routes to #update' do + put('/products/1').should route_to('products#update', id: '1') end - it "routes to #destroy" do - delete("/products/1").should route_to("products#destroy", id: "1") + it 'routes to #destroy' do + delete('/products/1').should route_to('products#destroy', id: '1') end end end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 7b6469efb..589c40dd8 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe RolesController do - describe "routing" do - it "routes to #index" do - get("/roles").should route_to("roles#index") + describe 'routing' do + it 'routes to #index' do + get('/roles').should route_to('roles#index') end - it "routes to #new" do - get("/roles/new").should route_to("roles#new") + it 'routes to #new' do + get('/roles/new').should route_to('roles#new') end - it "routes to #show" do - get("/roles/1").should route_to("roles#show", id: "1") + it 'routes to #show' do + get('/roles/1').should route_to('roles#show', id: '1') end - it "routes to #edit" do - get("/roles/1/edit").should route_to("roles#edit", id: "1") + it 'routes to #edit' do + get('/roles/1/edit').should route_to('roles#edit', id: '1') end - it "routes to #create" do - post("/roles").should route_to("roles#create") + it 'routes to #create' do + post('/roles').should route_to('roles#create') end - it "routes to #update" do - put("/roles/1").should route_to("roles#update", id: "1") + it 'routes to #update' do + put('/roles/1').should route_to('roles#update', id: '1') end - it "routes to #destroy" do - delete("/roles/1").should route_to("roles#destroy", id: "1") + it 'routes to #destroy' do + delete('/roles/1').should route_to('roles#destroy', id: '1') end end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 7bbbfa764..5020404ea 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe ScientificNamesController do - describe "routing" do - it "routes to #index" do - get("/scientific_names").should route_to("scientific_names#index") + describe 'routing' do + it 'routes to #index' do + get('/scientific_names').should route_to('scientific_names#index') end - it "routes to #new" do - get("/scientific_names/new").should route_to("scientific_names#new") + it 'routes to #new' do + get('/scientific_names/new').should route_to('scientific_names#new') end - it "routes to #show" do - get("/scientific_names/1").should route_to("scientific_names#show", id: "1") + it 'routes to #show' do + get('/scientific_names/1').should route_to('scientific_names#show', id: '1') end - it "routes to #edit" do - get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") + it 'routes to #edit' do + get('/scientific_names/1/edit').should route_to('scientific_names#edit', id: '1') end - it "routes to #create" do - post("/scientific_names").should route_to("scientific_names#create") + it 'routes to #create' do + post('/scientific_names').should route_to('scientific_names#create') end - it "routes to #update" do - put("/scientific_names/1").should route_to("scientific_names#update", id: "1") + it 'routes to #update' do + put('/scientific_names/1').should route_to('scientific_names#update', id: '1') end - it "routes to #destroy" do - delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") + it 'routes to #destroy' do + delete('/scientific_names/1').should route_to('scientific_names#destroy', id: '1') end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 74f4aff64..ad8615cc4 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe SeedsController do - describe "routing" do - it "routes to #index" do - get("/seeds").should route_to("seeds#index") + describe 'routing' do + it 'routes to #index' do + get('/seeds').should route_to('seeds#index') end - it "routes to #new" do - get("/seeds/new").should route_to("seeds#new") + it 'routes to #new' do + get('/seeds/new').should route_to('seeds#new') end - it "routes to #show" do - get("/seeds/1").should route_to("seeds#show", id: "1") + it 'routes to #show' do + get('/seeds/1').should route_to('seeds#show', id: '1') end - it "routes to #edit" do - get("/seeds/1/edit").should route_to("seeds#edit", id: "1") + it 'routes to #edit' do + get('/seeds/1/edit').should route_to('seeds#edit', id: '1') end - it "routes to #create" do - post("/seeds").should route_to("seeds#create") + it 'routes to #create' do + post('/seeds').should route_to('seeds#create') end - it "routes to #update" do - put("/seeds/1").should route_to("seeds#update", id: "1") + it 'routes to #update' do + put('/seeds/1').should route_to('seeds#update', id: '1') end - it "routes to #destroy" do - delete("/seeds/1").should route_to("seeds#destroy", id: "1") + it 'routes to #destroy' do + delete('/seeds/1').should route_to('seeds#destroy', id: '1') end end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 966647515..1b3c8ea59 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,33 +1,33 @@ -require "rails_helper" +require 'rails_helper' describe PostsController do - describe "routing" do - it "routes to #index" do - get("/posts").should route_to("posts#index") + describe 'routing' do + it 'routes to #index' do + get('/posts').should route_to('posts#index') end - it "routes to #new" do - get("/posts/new").should route_to("posts#new") + it 'routes to #new' do + get('/posts/new').should route_to('posts#new') end - it "routes to #show" do - get("/posts/1").should route_to("posts#show", id: "1") + it 'routes to #show' do + get('/posts/1').should route_to('posts#show', id: '1') end - it "routes to #edit" do - get("/posts/1/edit").should route_to("posts#edit", id: "1") + it 'routes to #edit' do + get('/posts/1/edit').should route_to('posts#edit', id: '1') end - it "routes to #create" do - post("/posts").should route_to("posts#create") + it 'routes to #create' do + post('/posts').should route_to('posts#create') end - it "routes to #update" do - put("/posts/1").should route_to("posts#update", id: "1") + it 'routes to #update' do + put('/posts/1').should route_to('posts#update', id: '1') end - it "routes to #destroy" do - delete("/posts/1").should route_to("posts#destroy", id: "1") + it 'routes to #destroy' do + delete('/posts/1').should route_to('posts#destroy', id: '1') end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9a0b542df..300bca74d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,5 +87,5 @@ RSpec.configure do |config| Kernel.srand config.seed # Remember which tests failed, so you can run rspec with the `--only-failures` flag. - config.example_status_persistence_file_path = "tmp/examples.txt" + config.example_status_persistence_file_path = 'tmp/examples.txt' end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index 354c64069..b8236e95f 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,7 +3,7 @@ module ControllerMacros def login_member(member_factory = :member) let(:member) { FactoryBot.create(member_factory || :member) } before(:each) do - @request.env["devise.mapping"] = Devise.mappings[:member] + @request.env['devise.mapping'] = Devise.mappings[:member] sign_in member end end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index aaa4fd689..5b73b5b0c 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,6 +1,6 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) - return unless ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + return unless ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end @@ -10,6 +10,6 @@ RSpec.configure do |config| config.include ElasticsearchHelpers config.before(:all, elasticsearch: true) do - Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' end end diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index e1a590b30..fb24eaa02 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,4 +1,4 @@ -shared_examples "it is likeable" do +shared_examples 'it is likeable' do before(:each) do # Possibly a horrible hack. # Will fail if factory name does not match the model name.. @@ -9,7 +9,7 @@ shared_examples "it is likeable" do @like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable) end - it "has many likes" do + it 'has many likes' do expect(@likeable.likes.length).to eq 2 end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index 1bd22be03..e8f934358 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe "account_types/edit" do +describe 'account_types/edit' do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: "MyString", + name: 'MyString', is_paid: false, is_permanent_paid: false)) end - it "renders the edit account_type form" do + it 'renders the edit account_type form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path(@account_type), method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" + assert_select 'form', action: account_types_path(@account_type), method: 'post' do + assert_select 'input#account_type_name', name: 'account_type[name]' + assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' + assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' end end end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index 56020fc35..94f19d072 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe "account_types/index" do +describe 'account_types/index' do before(:each) do @type = FactoryBot.create(:account_type) assign(:account_types, [@type, @type]) end - it "renders a list of account_types" do + it 'renders a list of account_types' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @type.name.to_s, count: 2 + assert_select 'tr>td', text: @type.name.to_s, count: 2 end end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index 027a1b7c1..db7cec061 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe "account_types/new" do +describe 'account_types/new' do before(:each) do assign(:account_type, stub_model(AccountType, - name: "MyString", + name: 'MyString', is_paid: false, is_permanent_paid: false).as_new_record) end - it "renders new account_type form" do + it 'renders new account_type form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path, method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" + assert_select 'form', action: account_types_path, method: 'post' do + assert_select 'input#account_type_name', name: 'account_type[name]' + assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' + assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' end end end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index a31d4bc33..6bb888f1a 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe "account_types/show" do +describe 'account_types/show' do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: "Name", + name: 'Name', is_paid: false, is_permanent_paid: false)) end - it "renders attributes in

" do + it 'renders attributes in

' do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index bc5c3b5a3..d77edd8c8 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe "accounts/edit" do +describe 'accounts/edit' do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it "renders the edit account form" do + it 'renders the edit account form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path(@account), method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" + assert_select 'form', action: accounts_path(@account), method: 'post' do + assert_select 'input#account_member_id', name: 'account[member_id]' + assert_select 'input#account_account_type', name: 'account[account_type]' end end end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 4ec76151e..7e54347fb 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe "accounts/index" do +describe 'accounts/index' do before(:each) do @member = FactoryBot.create(:member) @account = @member.account assign(:accounts, [@account, @account]) end - it "renders a list of accounts" do + it 'renders a list of accounts' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @account.member_id.to_s, count: 2 + assert_select 'tr>td', text: @account.member_id.to_s, count: 2 end end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 77f6ff20f..5bc6ba812 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe "accounts/new" do +describe 'accounts/new' do before(:each) do @member = FactoryBot.create(:member) assign(:account, @member.account) end - it "renders new account form" do + it 'renders new account form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path, method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" + assert_select 'form', action: accounts_path, method: 'post' do + assert_select 'input#account_member_id', name: 'account[member_id]' + assert_select 'input#account_account_type', name: 'account[account_type]' end end end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb index d96fbbd96..b852b12d1 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe "accounts/show" do +describe 'accounts/show' do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it "renders attributes in

" do + it 'renders attributes in

' do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @account.member_id.to_s diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index beb0eacbd..442a0c36c 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/index.html.haml', type: "view" do +describe 'admin/index.html.haml', type: 'view' do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,14 +8,14 @@ describe 'admin/index.html.haml', type: "view" do render end - it "includes links to manage various things" do - assert_select "a", href: account_types_path - assert_select "a", href: products_path - assert_select "a", href: roles_path - assert_select "a", href: forums_path + it 'includes links to manage various things' do + assert_select 'a', href: account_types_path + assert_select 'a', href: products_path + assert_select 'a', href: roles_path + assert_select 'a', href: forums_path end - it "has a link to newsletter subscribers" do - rendered.should have_content "Newsletter subscribers" + it 'has a link to newsletter subscribers' do + rendered.should have_content 'Newsletter subscribers' end end diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 384833034..8faca4e18 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/newsletter.html.haml', type: "view" do +describe 'admin/newsletter.html.haml', type: 'view' do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -10,7 +10,7 @@ describe 'admin/newsletter.html.haml', type: "view" do render end - it "lists newsletter subscribers by email" do + it 'lists newsletter subscribers by email' do rendered.should have_content @subscriber.email end end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index 8d80dc3ef..905b6a3ff 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/orders/index.html.haml', type: "view" do +describe 'admin/orders/index.html.haml', type: 'view' do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,13 +8,13 @@ describe 'admin/orders/index.html.haml', type: "view" do render end - it "includes a search form for orders" do - assert_select "form" - assert_select "input#search_text" - assert_select "select#search_by" + it 'includes a search form for orders' do + assert_select 'form' + assert_select 'input#search_text' + assert_select 'select#search_by' end - it "lets you search by referral code" do - assert_select "option[value=referral_code]", text: "Referral code" + it 'lets you search by referral code' do + assert_select 'option[value=referral_code]', text: 'Referral code' end end diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index 2ef7d480f..41a46858d 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe "comments/edit" do +describe 'comments/edit' do before(:each) do controller.stub(:current_user) { nil } assign(:comment, FactoryBot.create(:comment)) end - it "renders the edit comment form" do + it 'renders the edit comment form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: comments_path(@comment), method: "post" do - assert_select "textarea#comment_body", name: "comment[body]" + assert_select 'form', action: comments_path(@comment), method: 'post' do + assert_select 'textarea#comment_body', name: 'comment[body]' end end end diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 91ed15a88..3677782e2 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "comments/index" do +describe 'comments/index' do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -16,13 +16,13 @@ describe "comments/index" do render end - it "renders a list of comments" do + it 'renders a list of comments' do render rendered.should have_content 'OMG LOL' rendered.should have_content 'ROFL' end - it "contains an RSS feed link" do - assert_select "a", href: comments_path(format: 'rss') + it 'contains an RSS feed link' do + assert_select 'a', href: comments_path(format: 'rss') end end diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index 672658bac..6d0db9169 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -13,7 +13,7 @@ describe 'comments/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content "Recent comments on all posts" + rendered.should have_content 'Recent comments on all posts' end it 'shows item title' do @@ -26,6 +26,6 @@ describe 'comments/index.rss.haml' do end it 'shows content of comments' do - rendered.should have_content "OMG LOL" + rendered.should have_content 'OMG LOL' end end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index e0533ea5b..e5bdcfb39 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "comments/new" do +describe 'comments/new' do before(:each) do controller.stub(:current_user) { nil } @post = FactoryBot.create(:post) @@ -10,21 +10,21 @@ describe "comments/new" do render end - it "shows the text of the post under discussion" do + it 'shows the text of the post under discussion' do rendered.should have_content @post.body end - it "shows previous comments" do + it 'shows previous comments' do rendered.should have_content @comment.body end - it "shows the correct comment count" do - rendered.should have_content "1 comment" + it 'shows the correct comment count' do + rendered.should have_content '1 comment' end - it "renders new comment form" do - assert_select "form", action: comments_path, method: "post" do - assert_select "textarea#comment_body", name: "comment[body]" + it 'renders new comment form' do + assert_select 'form', action: comments_path, method: 'post' do + assert_select 'textarea#comment_body', name: 'comment[body]' end end diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index 6315b4f69..91e045359 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe "comments/show" do +describe 'comments/show' do before(:each) do controller.stub(:current_user) { nil } @comment = assign(:comment, FactoryBot.create(:comment)) render end - it "renders the comment" do + it 'renders the comment' do rendered.should have_content @comment.author.login_name rendered.should have_content @comment.body end diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index c378c296c..deb541bb4 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/_grown_for" do +describe 'crops/_grown_for' do let(:crop) { FactoryBot.create(:crop) } let(:plant_path) { FactoryBot.create(:plant_part) } let!(:harvest) do @@ -12,6 +12,6 @@ describe "crops/_grown_for" do it 'shows plant parts' do render partial: 'crops/grown_for', locals: { crop: crop } rendered.should have_content plant_path.name - assert_select "a", href: plant_part_path(plant_path) + assert_select 'a', href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 12064a1b8..4cb5aa0a2 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,62 +1,62 @@ require 'rails_helper' -describe "crops/_planting_advice" do +describe 'crops/_planting_advice' do subject { rendered } let(:planting) { FactoryBot.create(:planting) } - shared_examples "render planting_advice" do + shared_examples 'render planting_advice' do before { render 'crops/planting_advice', crop: planting.crop } end - describe "sunniness" do - context "with no sunniness set" do - include_examples "render planting_advice" + describe 'sunniness' do + context 'with no sunniness set' do + include_examples 'render planting_advice' it "doesn't show sunniness" do - is_expected.to have_content "Plant in: not known." + is_expected.to have_content 'Plant in: not known.' end end - context "with sunniness frequencies" do + context 'with sunniness frequencies' do before { FactoryBot.create(:sunny_planting, crop: planting.crop) } - include_examples "render planting_advice" - it { is_expected.to have_content "Plant in:" } - it { is_expected.to have_content "sun (1)" } + include_examples 'render planting_advice' + it { is_expected.to have_content 'Plant in:' } + it { is_expected.to have_content 'sun (1)' } end - context "with multiple sunniness frequencies" do + context 'with multiple sunniness frequencies' do before do FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) FactoryBot.create(:shady_planting, crop: planting.crop) end - include_examples "render planting_advice" - it { is_expected.to have_content "Plant in:" } - it { is_expected.to have_content "sun (2), shade (1)" } + include_examples 'render planting_advice' + it { is_expected.to have_content 'Plant in:' } + it { is_expected.to have_content 'sun (2), shade (1)' } end end - describe "planted from" do - context "when none are set" do - include_examples "render planting_advice" + describe 'planted from' do + context 'when none are set' do + include_examples 'render planting_advice' it "doesn't show planted_from " do - is_expected.to have_content "Plant from: not known." + is_expected.to have_content 'Plant from: not known.' end end - context "with planted_from frequencies" do + context 'with planted_from frequencies' do before { FactoryBot.create(:seed_planting, crop: planting.crop) } - include_examples "render planting_advice" - it { is_expected.to have_content "Plant from:" } - it { is_expected.to have_content "seed (1)" } + include_examples 'render planting_advice' + it { is_expected.to have_content 'Plant from:' } + it { is_expected.to have_content 'seed (1)' } end - context "with multiple planted_from frequencies" do + context 'with multiple planted_from frequencies' do before do FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) FactoryBot.create(:cutting_planting, crop: planting.crop) end - include_examples "render planting_advice" - it { is_expected.to have_content "Plant from:" } - it { is_expected.to have_content "seed (2), cutting (1)" } + include_examples 'render planting_advice' + it { is_expected.to have_content 'Plant from:' } + it { is_expected.to have_content 'seed (2), cutting (1)' } end end end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index dde4a893f..e5f1f92ac 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/_popover" do +describe 'crops/_popover' do before(:each) do @tomato = FactoryBot.create(:tomato) @sn = FactoryBot.create(:solanum_lycopersicum, crop: @tomato) diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index 19fac21af..eeadf603d 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/edit" do +describe 'crops/edit' do before(:each) do controller.stub(:current_user) do FactoryBot.create(:crop_wrangling_member) @@ -13,7 +13,7 @@ describe "crops/edit" do render end - it "shows the creator" do + it 'shows the creator' do rendered.should have_content "Added by #{@crop.creator} less than a minute ago." end end diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index 833bb2b98..0740142bb 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/hierarchy" do +describe 'crops/hierarchy' do before(:each) do controller.stub(:current_user) { nil } @tomato = FactoryBot.create(:tomato) @@ -9,7 +9,7 @@ describe "crops/hierarchy" do render end - it "shows crop hierarchy" do - assert_select "ul>li>ul>li", text: @roma.name + it 'shows crop hierarchy' do + assert_select 'ul>li>ul>li', text: @roma.name end end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 9f2985035..ef7081444 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/index" do +describe 'crops/index' do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -15,20 +15,20 @@ describe "crops/index" do assign(:crops, crops) end - it "shows photos where available" do + it 'shows photos where available' do @planting = FactoryBot.create(:planting, crop: @tomato) @photo = FactoryBot.create(:photo) @planting.photos << @photo render - assert_select "img", src: @photo.thumbnail_url + assert_select 'img', src: @photo.thumbnail_url end - it "linkifies crop images" do + it 'linkifies crop images' do render - assert_select "img", src: :tomato + assert_select 'img', src: :tomato end - context "logged in and crop wrangler" do + context 'logged in and crop wrangler' do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member @@ -36,18 +36,18 @@ describe "crops/index" do render end - it "shows a new crop link" do - rendered.should have_content "New Crop" + it 'shows a new crop link' do + rendered.should have_content 'New Crop' end end - context "downloads" do - it "offers data downloads" do + context 'downloads' do + it 'offers data downloads' do render - rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", href: crops_path(format: 'csv') - assert_select "a", href: crops_path(format: 'json') - assert_select "a", href: crops_path(format: 'rss') + rendered.should have_content 'The data on this page is available in the following formats:' + assert_select 'a', href: crops_path(format: 'csv') + assert_select 'a', href: crops_path(format: 'json') + assert_select 'a', href: crops_path(format: 'rss') end end end diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index 72a8bbdff..cb218b9cd 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -11,7 +11,7 @@ describe 'crops/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content "Recently added crops" + rendered.should have_content 'Recently added crops' end it 'shows names of crops' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index 5ce7eefdc..229474cac 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/new" do +describe 'crops/new' do before(:each) do @crop = FactoryBot.create(:maize) 3.times do @@ -13,7 +13,7 @@ describe "crops/new" do render end - it "shows a link to crop wrangling guidelines" do - assert_select "a[href^='http://wiki.growstuff.org']", "crop wrangling guide" + it 'shows a link to crop wrangling guidelines' do + assert_select "a[href^='http://wiki.growstuff.org']", 'crop wrangling guide' end end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index 085060570..d97eab036 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "crops/wrangle" do +describe 'crops/wrangle' do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) controller.stub(:current_user) { @member } @@ -18,18 +18,18 @@ describe "crops/wrangle" do it 'contains handy links for wranglers' do render - rendered.should have_content "Crop wrangler guidelines" - rendered.should have_content "mailing list" + rendered.should have_content 'Crop wrangler guidelines' + rendered.should have_content 'mailing list' end it 'has a link to add a crop' do render - assert_select "a", href: new_crop_path + assert_select 'a', href: new_crop_path end - it "renders a list of crops" do + it 'renders a list of crops' do render - assert_select "a", text: @maize.name - assert_select "a", text: @tomato.name + assert_select 'a', text: @maize.name + assert_select 'a', text: @tomato.name end end diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb index 720822083..3dd70cd20 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,13 +1,13 @@ -describe 'devise/confirmations/new.html.haml', type: "view" do +describe 'devise/confirmations/new.html.haml', type: 'view' do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return("member") + @view.stub(:resource_name).and_return('member') @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render end it 'should contain a login field' do - rendered.should have_content "Enter either your login name or your email address" + rendered.should have_content 'Enter either your login name or your email address' end end diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index d2cce98c4..b2dcf645a 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do - context "logged in" do +describe 'devise/mailer/confirmation_instructions.html.haml', type: 'view' do + context 'logged in' do before(:each) do @resource = FactoryBot.create(:member) render diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index fc2ad1bbe..d64dbc30d 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do - context "logged in" do +describe 'devise/mailer/reset_password_instructions.html.haml', type: 'view' do + context 'logged in' do before(:each) do @resource = mock_model(Member) - @resource.stub(:email).and_return("example@example.com") - @resource.stub(:reset_password_token).and_return("joe") + @resource.stub(:email).and_return('example@example.com') + @resource.stub(:reset_password_token).and_return('joe') render end diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index 633545cf3..bafbb484c 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do - context "logged in" do +describe 'devise/mailer/unlock_instructions.html.haml', type: 'view' do + context 'logged in' do before(:each) do @resource = FactoryBot.create(:member) render end it "should explain what's happened" do - rendered.should have_content "account has been locked" + rendered.should have_content 'account has been locked' end - it "should have an unlock link" do - rendered.should have_content "Unlock my account" + it 'should have an unlock link' do + rendered.should have_content 'Unlock my account' end end end diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 3d9dae906..52999595f 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'devise/registrations/edit.html.haml', type: "view" do - context "logged in" do +describe 'devise/registrations/edit.html.haml', type: 'view' do + context 'logged in' do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) controller.stub(:current_member) { @member } @view.stub(:resource).and_return(@member) - @view.stub(:resource_name).and_return("member") + @view.stub(:resource_name).and_return('member') @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) end @@ -23,11 +23,11 @@ describe 'devise/registrations/edit.html.haml', type: "view" do end it 'has a checkbox for email notifications' do - assert_select "input[id=member_send_notification_email][type=checkbox]" + assert_select 'input[id=member_send_notification_email][type=checkbox]' end it 'has a checkbox for newsletter subscription' do - assert_select "input[id=member_newsletter][type=checkbox]" + assert_select 'input[id=member_newsletter][type=checkbox]' end end @@ -37,23 +37,23 @@ describe 'devise/registrations/edit.html.haml', type: "view" do end it 'shows show_email checkbox' do - assert_select "input[id=member_show_email][type=checkbox]" + assert_select 'input[id=member_show_email][type=checkbox]' end - it "contains a gravatar icon" do - assert_select "img", src: /gravatar\.com\/avatar/ + it 'contains a gravatar icon' do + assert_select 'img', src: /gravatar\.com\/avatar/ end it 'contains a link to gravatar.com' do - assert_select "a", href: /gravatar\.com/ + assert_select 'a', href: /gravatar\.com/ end it 'shows bio field' do - assert_select "textarea[id=member_bio]" + assert_select 'textarea[id=member_bio]' end it 'shows location field' do - assert_select "input[id=member_location][type=text]" + assert_select 'input[id=member_location][type=text]' end end @@ -61,7 +61,7 @@ describe 'devise/registrations/edit.html.haml', type: "view" do context 'not connected to twitter' do it 'has a link to connect' do render - assert_select "a", "Connect to Twitter" + assert_select 'a', 'Connect to Twitter' end end context 'connected to twitter' do @@ -70,18 +70,18 @@ describe 'devise/registrations/edit.html.haml', type: "view" do render end it 'has a link to twitter profile' do - assert_select "a", href: "http://twitter.com/#{@twitter_auth.name}" + assert_select 'a', href: "http://twitter.com/#{@twitter_auth.name}" end it 'has a link to disconnect' do render - assert_select "a", href: @twitter_auth, text: "Disconnect" + assert_select 'a', href: @twitter_auth, text: 'Disconnect' end end context 'not connected to flickr' do it 'has a link to connect' do render - assert_select "a", "Connect to Flickr" + assert_select 'a', 'Connect to Flickr' end end context 'connected to flickr' do @@ -90,11 +90,11 @@ describe 'devise/registrations/edit.html.haml', type: "view" do render end it 'has a link to flickr photostream' do - assert_select "a", href: "http://flickr.com/photos/#{@flickr_auth.uid}" + assert_select 'a', href: "http://flickr.com/photos/#{@flickr_auth.uid}" end it 'has a link to disconnect' do render - assert_select "a", href: @flickr_auth, text: "Disconnect" + assert_select 'a', href: @flickr_auth, text: 'Disconnect' end end end diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 48805b806..3424fbef9 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/registrations/new.html.haml', type: "view" do - context "logged in" do +describe 'devise/registrations/new.html.haml', type: 'view' do + context 'logged in' do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return("member") + @view.stub(:resource_name).and_return('member') @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render @@ -15,7 +15,7 @@ describe 'devise/registrations/new.html.haml', type: "view" do end it 'has a checkbox for newsletter subscription' do - assert_select "input[id=member_newsletter][type=checkbox]" + assert_select 'input[id=member_newsletter][type=checkbox]' end end end diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index dfe91af2a..9d83e51b3 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/sessions/new.html.haml', type: "view" do - context "logged in" do +describe 'devise/sessions/new.html.haml', type: 'view' do + context 'logged in' do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return("member") + @view.stub(:resource_name).and_return('member') @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index 39147113f..63f2fd52d 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,6 +1,6 @@ -describe 'devise/shared/_links.haml', type: "view" do +describe 'devise/shared/_links.haml', type: 'view' do def devise_mapping(register, recover, confirm, lock, oauth) - dm = double("mappings") + dm = double('mappings') dm.stub(registerable?: register) dm.stub(recoverable?: recover) dm.stub(confirmable?: confirm) @@ -10,15 +10,15 @@ describe 'devise/shared/_links.haml', type: "view" do end it 'should have a sign-in link if not in sessions' do - @view.stub(:controller_name).and_return("anything but sessions") - @view.stub(:resource_name).and_return("member") + @view.stub(:controller_name).and_return('anything but sessions') + @view.stub(:resource_name).and_return('member') @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end it "shouldn't have a sign-in link if in sessions" do - @view.stub(:controller_name).and_return("sessions") - @view.stub(:resource_name).and_return("member") + @view.stub(:controller_name).and_return('sessions') + @view.stub(:resource_name).and_return('member') @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 60d056d72..5fd755cce 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/unlocks/new.html.haml', type: "view" do - context "logged in" do +describe 'devise/unlocks/new.html.haml', type: 'view' do + context 'logged in' do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return("member") + @view.stub(:resource_name).and_return('member') @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 44151170a..152a34418 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe "forums/edit" do +describe 'forums/edit' do before(:each) do @forum = assign(:forum, stub_model(Forum, - name: "MyString", - description: "MyText", + name: 'MyString', + description: 'MyText', owner_id: 1)) end - it "renders the edit forum form" do + it 'renders the edit forum form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: forums_path(@forum), method: "post" do - assert_select "input#forum_name", name: "forum[name]" - assert_select "textarea#forum_description", name: "forum[description]" - assert_select "select#forum_owner_id", name: "forum[owner_id]" + assert_select 'form', action: forums_path(@forum), method: 'post' do + assert_select 'input#forum_name', name: 'forum[name]' + assert_select 'textarea#forum_description', name: 'forum[description]' + assert_select 'select#forum_owner_id', name: 'forum[owner_id]' end end end diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 02b265e85..279a365fc 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "forums/index" do +describe 'forums/index' do before(:each) do @admin = FactoryBot.create(:admin_member) controller.stub(:current_user) { @admin } @@ -9,31 +9,31 @@ describe "forums/index" do assign(:forums, [@forum1, @forum2]) end - it "renders a list of forums" do + it 'renders a list of forums' do render - assert_select "h2", text: @forum1.name, count: 2 + assert_select 'h2', text: @forum1.name, count: 2 end it "doesn't display posts for empty forums" do render - assert_select "table", false + assert_select 'table', false end - context "posts" do + context 'posts' do before(:each) do @post = FactoryBot.create(:forum_post, forum: @forum1) @comment = FactoryBot.create(:comment, post: @post) render end - it "displays posts" do - assert_select "table" + it 'displays posts' do + assert_select 'table' rendered.should have_content @post.subject rendered.should have_content Time.zone.today.to_s(:short) end - it "displays comment count" do - assert_select "td", text: "1" + it 'displays comment count' do + assert_select 'td', text: '1' end end end diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 72cd7ae45..58278ee18 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe "forums/new" do +describe 'forums/new' do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) render end - it "renders new forum form" do - assert_select "form", action: forums_path, method: "post" do - assert_select "input#forum_name", name: "forum[name]" - assert_select "textarea#forum_description", name: "forum[description]" - assert_select "select#forum_owner_id", name: "forum[owner_id]" + it 'renders new forum form' do + assert_select 'form', action: forums_path, method: 'post' do + assert_select 'input#forum_name', name: 'forum[name]' + assert_select 'textarea#forum_description', name: 'forum[description]' + assert_select 'select#forum_owner_id', name: 'forum[owner_id]' end end end diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 08892df58..6e67b8c59 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -describe "forums/show" do +describe 'forums/show' do before(:each) do controller.stub(:current_user) { nil } @forum = assign(:forum, FactoryBot.create(:forum)) end - it "renders attributes" do + it 'renders attributes' do render - rendered.should have_content "Everything about permaculture" + rendered.should have_content 'Everything about permaculture' rendered.should have_content @forum.owner.to_s end - it "parses markdown description into html" do + it 'parses markdown description into html' do render - assert_select "em", "Everything" + assert_select 'em', 'Everything' end it 'links to new post with the forum id' do @@ -24,13 +24,13 @@ describe "forums/show" do it 'has no posts' do render - rendered.should have_content "No posts yet." + rendered.should have_content 'No posts yet.' end it 'shows posts' do @post = FactoryBot.create(:post, forum: @forum) render - assert_select "table" + assert_select 'table' rendered.should have_content @post.subject rendered.should have_content @post.author.to_s end diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index 1326f1544..c725af57e 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe "gardens/edit" do - context "logged in" do +describe 'gardens/edit' do + context 'logged in' do before(:each) do @owner = FactoryBot.create(:member) sign_in @owner @@ -10,17 +10,17 @@ describe "gardens/edit" do render end - it "renders the edit garden form" do + it 'renders the edit garden form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: gardens_path(@garden), method: "post" do - assert_select "input#garden_name", name: "garden[name]" - assert_select "textarea#garden_description", name: "garden[description]" - assert_select "input#garden_location", name: "garden[location]" - assert_select "input#garden_area", name: "garden[area]" - assert_select "select#garden_area_unit", name: "garden[area_unit]" - assert_select "input#garden_active", name: "garden[active]" + assert_select 'form', action: gardens_path(@garden), method: 'post' do + assert_select 'input#garden_name', name: 'garden[name]' + assert_select 'textarea#garden_description', name: 'garden[description]' + assert_select 'input#garden_location', name: 'garden[location]' + assert_select 'input#garden_area', name: 'garden[area]' + assert_select 'select#garden_area_unit', name: 'garden[area_unit]' + assert_select 'input#garden_active', name: 'garden[active]' end end end diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 7346997dc..39b659b7e 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "gardens/new" do +describe 'gardens/new' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -10,14 +10,14 @@ describe "gardens/new" do render end - it "renders new garden form" do - assert_select "form", action: gardens_path, method: "post" do - assert_select "input#garden_name", name: "garden[name]" - assert_select "textarea#garden_description", name: "garden[description]" - assert_select "input#garden_location", name: "garden[location]" - assert_select "input#garden_area", name: "garden[area]" - assert_select "select#garden_area_unit", name: "garden[area_unit]" - assert_select "input#garden_active", name: "garden[active]" + it 'renders new garden form' do + assert_select 'form', action: gardens_path, method: 'post' do + assert_select 'input#garden_name', name: 'garden[name]' + assert_select 'textarea#garden_description', name: 'garden[description]' + assert_select 'input#garden_location', name: 'garden[location]' + assert_select 'input#garden_area', name: 'garden[area]' + assert_select 'select#garden_area_unit', name: 'garden[area_unit]' + assert_select 'input#garden_active', name: 'garden[active]' end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 7130e2e4f..fa03c5856 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "gardens/show" do +describe 'gardens/show' do before(:each) do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @@ -21,11 +21,11 @@ describe "gardens/show" do end it 'should show the description' do - rendered.should have_content "totally cool garden" + rendered.should have_content 'totally cool garden' end it 'renders markdown in the description' do - assert_select "strong", "totally" + assert_select 'strong', 'totally' end it 'should show plantings on the garden page' do @@ -33,7 +33,7 @@ describe "gardens/show" do end it "doesn't show the note about random plantings" do - rendered.should_not have_content "Note: these are a random selection" + rendered.should_not have_content 'Note: these are a random selection' end context 'signed in' do @@ -47,14 +47,14 @@ describe "gardens/show" do end it "shows a 'plant something' button" do - rendered.should have_content "Plant something" + rendered.should have_content 'Plant something' end it "shows an 'add photo' button" do - rendered.should have_content "Add photo" + rendered.should have_content 'Add photo' end - it "links to the right crop in the planting link" do + it 'links to the right crop in the planting link' do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 1193b4284..6d4c55b7e 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe "harvests/edit" do +describe 'harvests/edit' do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it "renders new harvest form" do - assert_select "form", action: harvests_path, method: "post" do - assert_select "input#crop", class: "ui-autocomplete-input" - assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" - assert_select "input#harvest_quantity", name: "harvest[quantity]" - assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" - assert_select "select#harvest_unit", name: "harvest[unit]" - assert_select "select#harvest_weight_unit", name: "harvest[unit]" - assert_select "textarea#harvest_description", name: "harvest[description]" + it 'renders new harvest form' do + assert_select 'form', action: harvests_path, method: 'post' do + assert_select 'input#crop', class: 'ui-autocomplete-input' + assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' + assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' + assert_select 'input#harvest_quantity', name: 'harvest[quantity]' + assert_select 'input#harvest_weight_quantity', name: 'harvest[quantity]' + assert_select 'select#harvest_unit', name: 'harvest[unit]' + assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' + assert_select 'textarea#harvest_description', name: 'harvest[description]' end end end diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index fe205cda6..62ef81d15 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "harvests/index" do +describe 'harvests/index' do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @@ -25,11 +25,11 @@ describe "harvests/index" do render end - it "provides data links" do + it 'provides data links' do render - rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", href: harvests_path(format: 'csv') - assert_select "a", href: harvests_path(format: 'json') + rendered.should have_content 'The data on this page is available in the following formats:' + assert_select 'a', href: harvests_path(format: 'csv') + assert_select 'a', href: harvests_path(format: 'json') end it "displays member's name in title" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index d79055a38..4e6050625 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe "harvests/new" do +describe 'harvests/new' do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it "renders new harvest form" do - assert_select "form", action: harvests_path, method: "post" do - assert_select "input#crop", class: "ui-autocomplete-input" - assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + it 'renders new harvest form' do + assert_select 'form', action: harvests_path, method: 'post' do + assert_select 'input#crop', class: 'ui-autocomplete-input' + assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' + assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' # some browsers interpret without a step as "integer" - assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" - assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" - assert_select "select#harvest_unit", name: "harvest[unit]" - assert_select "select#harvest_weight_unit", name: "harvest[unit]" - assert_select "textarea#harvest_description", name: "harvest[description]" + assert_select 'input#harvest_quantity[step=any]', name: 'harvest[quantity]' + assert_select 'input#harvest_weight_quantity[step=any]', name: 'harvest[quantity]' + assert_select 'select#harvest_unit', name: 'harvest[unit]' + assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' + assert_select 'textarea#harvest_description', name: 'harvest[description]' end end end diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 4aec453ff..a182b5269 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "harvests/show" do +describe 'harvests/show' do subject { render } let!(:harvest) { FactoryBot.create(:harvest) } @@ -11,7 +11,7 @@ describe "harvests/show" do render end - describe "renders attributes" do + describe 'renders attributes' do it { is_expected.to have_content harvest.crop.name } it { is_expected.to have_content harvest.harvested_at.to_s } it { is_expected.to have_content harvest.plant_part.to_s } diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 47244a445..5e661b19d 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_blurb.html.haml', type: "view" do +describe 'home/_blurb.html.haml', type: 'view' do context 'signed out' do before :each do controller.stub(:current_user) { nil } @@ -12,13 +12,13 @@ describe 'home/_blurb.html.haml', type: "view" do end it 'has signup section' do - assert_select "div.signup" - assert_select "a", href: new_member_registration_path + assert_select 'div.signup' + assert_select 'a', href: new_member_registration_path end it 'has a link to sign in' do - rendered.should have_content "Or sign in if you already have an account" - assert_select "a", href: new_member_session_path + rendered.should have_content 'Or sign in if you already have an account' + assert_select 'a', href: new_member_session_path end end end diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index 3ed655438..37dcbd05b 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_crops.html.haml', type: "view" do +describe 'home/_crops.html.haml', type: 'view' do let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } let(:planting) { crop.plantings.first } diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 76aa434b6..3d75ea692 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_members.html.haml', type: "view" do +describe 'home/_members.html.haml', type: 'view' do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago @@ -11,7 +11,7 @@ describe 'home/_members.html.haml', type: "view" do end it 'Has a heading' do - rendered.should have_content "Some of our members" + rendered.should have_content 'Some of our members' end it 'Shows members' do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 7b8d6156c..a551e97f8 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', type: "view" do +describe 'home/_seeds.html.haml', type: 'view' do before(:each) do @owner = FactoryBot.create(:london_member) @seed = FactoryBot.create(:tradable_seed, owner: @owner) diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index a9979190c..dc5a0e8a5 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'home/_stats.html.haml', type: "view" do +describe 'home/_stats.html.haml', type: 'view' do it 'has activity stats' do render - rendered.should have_content "So far, 0 members have planted 0 crops" + rendered.should have_content 'So far, 0 members have planted 0 crops' end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5e11882fd..5eeae7ff4 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/index.html.haml', type: "view" do +describe 'home/index.html.haml', type: 'view' do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 5060fc30d..60f27ca80 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'layouts/_header.html.haml', type: "view" do - context "when not logged in" do +describe 'layouts/_header.html.haml', type: 'view' do + context 'when not logged in' do before(:each) do controller.stub(:current_user) { nil } render end it 'shows the brand logo in the navbar' do - assert_select("a.navbar-brand img[src]", href: root_path) + assert_select('a.navbar-brand img[src]', href: root_path) end it 'should have signup/signin links' do @@ -17,19 +17,19 @@ describe 'layouts/_header.html.haml', type: "view" do end it 'has a Crops link' do - rendered.should have_content "Crops" + rendered.should have_content 'Crops' end it 'has a Seeds link' do - rendered.should have_content "Seeds" + rendered.should have_content 'Seeds' end it 'has a Places link' do - rendered.should have_content "Community Map" + rendered.should have_content 'Community Map' end it 'has a Community section' do - rendered.should have_content "Community" + rendered.should have_content 'Community' end it 'links to members' do @@ -46,11 +46,11 @@ describe 'layouts/_header.html.haml', type: "view" do it 'has a crop search' do assert_select("form[action='#{crops_search_path}']") - assert_select("input#term") + assert_select('input#term') end end - context "logged in" do + context 'logged in' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -58,21 +58,21 @@ describe 'layouts/_header.html.haml', type: "view" do render end - context "login name" do + context 'login name' do it 'should have member login name' do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", "Gardens") + assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", 'Gardens') end it "should show link to member's plantings" do - assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", "Plantings") + assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", 'Plantings') end it "should show link to member's seeds" do - assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", "Seeds") + assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", 'Seeds') end it "should show link to member's posts" do - assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", "Posts") + assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", 'Posts') end end diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 151c6fe19..42d4704ad 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/_meta.html.haml', type: "view" do +describe 'layouts/_meta.html.haml', type: 'view' do before(:each) do render end @@ -21,6 +21,6 @@ describe 'layouts/_meta.html.haml', type: "view" do end it 'should have a title' do - assert_select "head>title" + assert_select 'head>title' end end diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index f094ae2c2..265a0b572 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/application.html.haml', type: "view" do +describe 'layouts/application.html.haml', type: 'view' do before(:each) do controller.stub(:current_user) { nil } end @@ -8,7 +8,7 @@ describe 'layouts/application.html.haml', type: "view" do it 'includes the analytics code' do Growstuff::Application.config.analytics_code = '' render - assert_select "script", text: 'alert("foo!")' + assert_select 'script', text: 'alert("foo!")' rendered.should_not have_content 'script' end end diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index 50d7b675f..d15d69538 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe "members/_location" do - context "member with location" do +describe 'members/_location' do + context 'member with location' do let(:member) { FactoryBot.create(:london_member) } before(:each) { render partial: 'members/location', locals: { member: member } } @@ -10,23 +10,23 @@ describe "members/_location" do expect(rendered).to have_content member.location end - it "links to the places page" do - assert_select "a", href: place_path(member.location) + it 'links to the places page' do + assert_select 'a', href: place_path(member.location) end end - context "member with no location" do + context 'member with no location' do before(:each) do member = FactoryBot.create(:member) render partial: 'members/location', locals: { member: member } end it 'shows unknown location' do - expect(rendered).to have_content "unknown location" + expect(rendered).to have_content 'unknown location' end it "doesn't link anywhere" do - assert_select "a", false + assert_select 'a', false end end end diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 87dd3a285..24308bd0e 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "members/index" do +describe 'members/index' do let(:member) { FactoryBot.create(:london_member) } before(:each) do @@ -15,8 +15,8 @@ describe "members/index" do render end - it "contains two gravatar icons" do - assert_select "img", src: /gravatar\.com\/avatar/, count: 2 + it 'contains two gravatar icons' do + assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 end it 'contains member locations' do diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index 23366a9a8..79ea04078 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/show.rss.haml', type: "view" do +describe 'members/show.rss.haml', type: 'view' do before(:each) do @member = assign(:member, FactoryBot.create(:member)) @post1 = FactoryBot.create(:post, id: 1, author: @member) @@ -16,13 +16,13 @@ describe 'members/show.rss.haml', type: "view" do end it 'shows content of posts' do - is_expected.to have_content "This is some text." + is_expected.to have_content 'This is some text.' end it 'renders post bodies to HTML and XML-escapes them' do # The variable "rendered" has been entity-replaced and tag-stripped # The literal string output contains "<strong>" etc. - is_expected.to have_content "strong" + is_expected.to have_content 'strong' end it 'gives the author in the item title' do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 2c8195069..76d96f3eb 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe "notifications/index" do +describe 'notifications/index' do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } end - context "ordinary notifications" do + context 'ordinary notifications' do before(:each) do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member) @@ -14,34 +14,34 @@ describe "notifications/index" do render end - it "renders a list of notifications" do - assert_select "table" - assert_select "tr>td", text: @notification.sender.to_s, count: 2 - assert_select "tr>td", text: @notification.subject, count: 2 + it 'renders a list of notifications' do + assert_select 'table' + assert_select 'tr>td', text: @notification.sender.to_s, count: 2 + assert_select 'tr>td', text: @notification.subject, count: 2 end it "links to sender's profile" do - assert_select "a", href: member_path(@notification.sender) + assert_select 'a', href: member_path(@notification.sender) end end - context "no subject" do - it "shows (no subject)" do + context 'no subject' do + it 'shows (no subject)' do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member, subject: nil) assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content "(no subject)" + rendered.should have_content '(no subject)' end end - context "whitespace-only subject" do - it "shows (no subject)" do + context 'whitespace-only subject' do + it 'shows (no subject)' do @notification = FactoryBot.create(:notification, - sender: @member, recipient: @member, subject: " ") + sender: @member, recipient: @member, subject: ' ') assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content "(no subject)" + rendered.should have_content '(no subject)' end end end diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index a7f030f47..091e13cc1 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "notifications/new" do +describe 'notifications/new' do before(:each) do @recipient = FactoryBot.create(:member) @sender = FactoryBot.create(:member) @@ -9,38 +9,38 @@ describe "notifications/new" do controller.stub(:current_user) { @sender } end - it "renders new message form" do + it 'renders new message form' do render - assert_select "form", action: notifications_path, method: "notification" do - assert_select "input#notification_subject", name: "notification[subject]" - assert_select "textarea#notification_body", name: "notification[body]" + assert_select 'form', action: notifications_path, method: 'notification' do + assert_select 'input#notification_subject', name: 'notification[subject]' + assert_select 'textarea#notification_body', name: 'notification[body]' end end - it "tells you who the recipient is" do + it 'tells you who the recipient is' do render rendered.should have_content @recipient.login_name end - it "puts the recipient in a hidden field" do + it 'puts the recipient in a hidden field' do render - assert_select "input#notification_recipient_id[type=hidden]", name: "notification[recipient_id]" + assert_select 'input#notification_recipient_id[type=hidden]', name: 'notification[recipient_id]' end - it "fills in the subject if provided" do + it 'fills in the subject if provided' do assign(:subject, 'Foo') render - assert_select "input#notification_subject", value: "Foo" + assert_select 'input#notification_subject', value: 'Foo' end - it "leaves the subject empty if not provided" do + it 'leaves the subject empty if not provided' do render - assert_select "input#notification_subject", value: "" + assert_select 'input#notification_subject', value: '' end - it "Tells you to write your message here" do + it 'Tells you to write your message here' do render - rendered.should have_content "Type your message here" + rendered.should have_content 'Type your message here' end it 'shows markdown help' do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 14db0448c..1376f7c18 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "notifications/show" do +describe 'notifications/show' do before(:each) do @member = FactoryBot.create(:member) @notification = FactoryBot.create(:notification, recipient: @member) @@ -10,16 +10,16 @@ describe "notifications/show" do render end - it "renders attributes" do + it 'renders attributes' do rendered.should have_content @notification.sender.to_s rendered.should have_content @notification.body.to_s end - it "includes a delete button" do - assert_select "a", "Delete" + it 'includes a delete button' do + assert_select 'a', 'Delete' end - it "includes a reply button" do - assert_select "a", { href: @reply_link }, "Reply" + it 'includes a reply button' do + assert_select 'a', { href: @reply_link }, 'Reply' end end diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 913ea10d2..2979e6985 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'notifier/notify.html.haml', type: "view" do +describe 'notifier/notify.html.haml', type: 'view' do before(:each) do @notification = FactoryBot.create(:notification) - @reply_link = "http://example.com" - @signed_message = "EncryptedMessage" + @reply_link = 'http://example.com' + @signed_message = 'EncryptedMessage' assign(:reply_link, @reply_link) render end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index c95f204e2..9660b44fb 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "orders/index" do +describe 'orders/index' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,15 +9,15 @@ describe "orders/index" do assign(:orders, [@order1, @order2]) end - it "shows your current account status" do + it 'shows your current account status' do render - rendered.should have_content "Your current account status" + rendered.should have_content 'Your current account status' end - it "renders a list of orders" do + it 'renders a list of orders' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td a/@href", text: "/orders/#{@order1.id}" - assert_select "tr>td a/@href", text: "/orders/#{@order2.id}" + assert_select 'tr>td a/@href', text: "/orders/#{@order1.id}" + assert_select 'tr>td a/@href', text: "/orders/#{@order2.id}" end end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index a9f662de9..233616b9e 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe "orders/show" do +describe 'orders/show' do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } end - context "current order" do + context 'current order' do before(:each) do @order = assign(:order, FactoryBot.create(:order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -17,38 +17,38 @@ describe "orders/show" do render end - it "displays order number" do - rendered.should have_content "Order number" + it 'displays order number' do + rendered.should have_content 'Order number' end - it "shows order items in a table" do - assert_select "table>tr>th", text: "Product" + it 'shows order items in a table' do + assert_select 'table>tr>th', text: 'Product' end - it "shows the total" do - rendered.should have_content "Total:" - assert_select "strong", /198.00/ + it 'shows the total' do + rendered.should have_content 'Total:' + assert_select 'strong', /198.00/ end - it "shows a foreign exchange link for the total" do + it 'shows a foreign exchange link for the total' do currency = Growstuff::Application.config.currency assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") end - it "asks for a referral code" do + it 'asks for a referral code' do assert_select "input[id='referral_code']" end - it "shows a checkout button" do + it 'shows a checkout button' do assert_select "input[value='Checkout with PayPal']" end - it "shows a delete order button" do - assert_select "a", text: "Delete this order" + it 'shows a delete order button' do + assert_select 'a', text: 'Delete this order' end end - context "completed order" do + context 'completed order' do before(:each) do @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -59,11 +59,11 @@ describe "orders/show" do end it "doesn't show a checkout button" do - assert_select "a", text: "Checkout", count: 0 + assert_select 'a', text: 'Checkout', count: 0 end it "doesn't show delete order button" do - assert_select "a", text: "Delete this order", count: 0 + assert_select 'a', text: 'Delete this order', count: 0 end end end diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index a52b51a79..7376ad759 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe "photos/edit" do +describe 'photos/edit' do before(:each) do @photo = assign(:photo, stub_model(Photo, owner_id: 1, flickr_photo_id: 1, - thumbnail_url: "MyString", - fullsize_url: "MyString")) + thumbnail_url: 'MyString', + fullsize_url: 'MyString')) end end diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index b603de1e6..b99eb8309 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "photos/index" do +describe 'photos/index' do before(:each) do page = 1 per_page = 2 @@ -14,9 +14,9 @@ describe "photos/index" do assign(:photos, photos) end - it "renders a gallery of photos" do + it 'renders a gallery of photos' do render - assert_select ".thumbnail", count: 2 - assert_select "img", count: 2 + assert_select '.thumbnail', count: 2 + assert_select 'img', count: 2 end end diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index e4f24f9e4..3ae91e1a3 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "photos/new" do +describe 'photos/new' do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -14,27 +14,27 @@ describe "photos/new" do assign(:flickr_auth, FactoryBot.create(:flickr_authentication, member: @member)) end - context "user has no photosets" do + context 'user has no photosets' do it "doesn't show a dropdown with sets from Flickr" do render - assert_select "select#set", false + assert_select 'select#set', false end end - context "user has photosets" do + context 'user has photosets' do before(:each) do - assign(:sets, "foo" => "bar") # Hash of names => IDs + assign(:sets, 'foo' => 'bar') # Hash of names => IDs end - it "shows a dropdown with sets from Flickr" do + it 'shows a dropdown with sets from Flickr' do render - assert_select "select#set" + assert_select 'select#set' end - it "shows the current photoset" do - assign(:current_set, "bar") # the ID of the set + it 'shows the current photoset' do + assign(:current_set, 'bar') # the ID of the set render - assert_select "h2", "foo" # the name of the set + assert_select 'h2', 'foo' # the name of the set end end end diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index cecb0008b..ce60a0b47 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "photos/show" do +describe 'photos/show' do let(:photo) { FactoryBot.create :photo, owner: member } before { @photo = photo } @@ -11,70 +11,70 @@ describe "photos/show" do let(:seed) { FactoryBot.create :seed, owner: member } let(:garden) { FactoryBot.create :garden, owner: member } - shared_examples "photo data renders" do - it "shows the image" do + shared_examples 'photo data renders' do + it 'shows the image' do assert_select "img[src='#{@photo.fullsize_url}']" end it "links to the owner's profile" do - assert_select "a", href: @photo.owner + assert_select 'a', href: @photo.owner end - it "shows a link to the original image" do - assert_select "a", href: @photo.link_url, text: "View on Flickr" + it 'shows a link to the original image' do + assert_select 'a', href: @photo.link_url, text: 'View on Flickr' end - it "links to harvest" do - assert_select "a", href: harvest_path(harvest) + it 'links to harvest' do + assert_select 'a', href: harvest_path(harvest) end - it "links to planting" do - assert_select "a", href: planting_path(planting) + it 'links to planting' do + assert_select 'a', href: planting_path(planting) end - it "links to garden" do - assert_select "a", href: garden_path(garden) + it 'links to garden' do + assert_select 'a', href: garden_path(garden) end - it "links to seeds" do - assert_select "a", href: seed_path(seed) + it 'links to seeds' do + assert_select 'a', href: seed_path(seed) end end - shared_examples "No links to change data" do - it "does not have a delete button" do + shared_examples 'No links to change data' do + it 'does not have a delete button' do assert_select "a[href='#{photo_path(@photo)}']", false end end - context "signed in as owner" do + context 'signed in as owner' do before(:each) do controller.stub(:current_user) { member } render end - include_examples "photo data renders" + include_examples 'photo data renders' - it "has a delete button" do + it 'has a delete button' do assert_select "a[href='#{photo_path(@photo)}']" end end - context "signed in as another member" do + context 'signed in as another member' do before(:each) do controller.stub(:current_user) { FactoryBot.create :member } render end - include_examples "photo data renders" - include_examples "No links to change data" + include_examples 'photo data renders' + include_examples 'No links to change data' end - context "not signed in" do + context 'not signed in' do before(:each) do controller.stub(:current_user) { nil } render end - include_examples "photo data renders" - include_examples "No links to change data" + include_examples 'photo data renders' + include_examples 'No links to change data' end - context "CC-licensed photo" do + context 'CC-licensed photo' do before(:each) do controller.stub(:current_user) { nil } # @photo = assign(:photo, FactoryBot.create(:photo, owner: @member)) @@ -84,13 +84,13 @@ describe "photos/show" do @photo.gardens << garden render end - it "links to the CC license" do - assert_select "a", href: @photo.license_url, + it 'links to the CC license' do + assert_select 'a', href: @photo.license_url, text: @photo.license_name end end - context "unlicensed photo" do + context 'unlicensed photo' do before(:each) do controller.stub(:current_user) { nil } @photo = assign(:photo, FactoryBot.create(:unlicensed_photo)) @@ -98,7 +98,7 @@ describe "photos/show" do end it "contains the phrase 'All rights reserved'" do - rendered.should have_content "All rights reserved" + rendered.should have_content 'All rights reserved' end end end diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index 7082290c8..62022a303 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe "places/_map_attribution.html.haml", type: :view do +describe 'places/_map_attribution.html.haml', type: :view do before(:each) do render end - it "links to OpenStreetMap" do - assert_select "a", href: "http://openstreetmap.org", - text: "OpenStreetMap" + it 'links to OpenStreetMap' do + assert_select 'a', href: 'http://openstreetmap.org', + text: 'OpenStreetMap' end - it "links to the ODbL" do - assert_select "a", href: "http://www.openstreetmap.org/copyright", - text: "ODbL" + it 'links to the ODbL' do + assert_select 'a', href: 'http://www.openstreetmap.org/copyright', + text: 'ODbL' end - it "links to CloudMade" do - assert_select "a", href: "http://cloudmade.com", text: "CloudMade" + it 'links to CloudMade' do + assert_select 'a', href: 'http://cloudmade.com', text: 'CloudMade' end end diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index f3a3661ae..3639719d2 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe "places/index" do +describe 'places/index' do before(:each) do render end - it "shows a map" do - assert_select "div#placesmap" + it 'shows a map' do + assert_select 'div#placesmap' end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 635d06ab9..463134684 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "places/show" do +describe 'places/show' do before(:each) do @member = FactoryBot.create(:london_member) @nearby_members = [FactoryBot.create(:member)] @@ -10,15 +10,15 @@ describe "places/show" do render end - it "shows the selected place" do + it 'shows the selected place' do view.content_for(:title).should match @place end - it "shows the selected place in the textbox" do - assert_select "#new_place", value: @place + it 'shows the selected place in the textbox' do + assert_select '#new_place', value: @place end - it "shows the names of nearby members" do + it 'shows the names of nearby members' do @nearby_members.each do |m| rendered.should have_content m.login_name end diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index 683dd6ab0..33dab3bc8 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe "plant_parts/edit" do +describe 'plant_parts/edit' do before(:each) do @plant_part = assign(:plant_part, stub_model(PlantPart, - name: "MyString")) + name: 'MyString')) end - it "renders the edit plant_part form" do + it 'renders the edit plant_part form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: plant_parts_path(@plant_part), method: "post" do - assert_select "input#plant_part_name", name: "plant_part[name]" + assert_select 'form', action: plant_parts_path(@plant_part), method: 'post' do + assert_select 'input#plant_part_name', name: 'plant_part[name]' end end end diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index 65ecf2d63..ff1955637 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe "plant_parts/index" do +describe 'plant_parts/index' do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) assign(:plant_parts, [@pp]) end - it "renders a list of plant_parts" do + it 'renders a list of plant_parts' do render rendered.should have_content @pp.name - assert_select "a", href: plant_part_path(@pp) + assert_select 'a', href: plant_part_path(@pp) end end diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index b1b3f12ae..476987a98 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe "plant_parts/new" do +describe 'plant_parts/new' do before(:each) do assign(:plant_part, stub_model(PlantPart, - name: "MyString").as_new_record) + name: 'MyString').as_new_record) end - it "renders new plant_part form" do + it 'renders new plant_part form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: plant_parts_path, method: "post" do - assert_select "input#plant_part_name", name: "plant_part[name]" + assert_select 'form', action: plant_parts_path, method: 'post' do + assert_select 'input#plant_part_name', name: 'plant_part[name]' end end end diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index b367a723b..a725121fa 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plant_parts/show" do +describe 'plant_parts/show' do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) @@ -8,11 +8,11 @@ describe "plant_parts/show" do assign(:plant_part, @pp) end - it "renders a list of crops harvested for this part" do + it 'renders a list of crops harvested for this part' do render @pp.crops.each do |c| rendered.should have_content c.name - assert_select "a", href: crop_path(c) + assert_select 'a', href: crop_path(c) end end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 6371311ae..36e4aaeab 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plantings/_form" do +describe 'plantings/_form' do before(:each) do @member = FactoryBot.create(:member) @garden = FactoryBot.create(:garden, owner: @member) @@ -18,7 +18,7 @@ describe "plantings/_form" do render end - it "has a free-form text field containing the planting date in ISO format" do + it 'has a free-form text field containing the planting date in ISO format' do assert_select "input#planting_planted_at[type='text'][value='2013-03-01']" end end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index b83af0028..1de078e4a 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plantings/edit" do +describe 'plantings/edit' do before(:each) do @member = FactoryBot.create(:member, login_name: 'right', @@ -19,32 +19,32 @@ describe "plantings/edit" do FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end - context "logged in" do + context 'logged in' do before(:each) do sign_in @member controller.stub(:current_user) { @member } render end - it "renders the edit planting form" do - assert_select "form", action: plantings_path(@planting), method: "post" do - assert_select "input#planting_quantity", name: "planting[quantity]" - assert_select "textarea#planting_description", name: "planting[description]" - assert_select "select#planting_sunniness", name: "planting[sunniness]" - assert_select "select#planting_planted_from", name: "planting[planted_from]" + it 'renders the edit planting form' do + assert_select 'form', action: plantings_path(@planting), method: 'post' do + assert_select 'input#planting_quantity', name: 'planting[quantity]' + assert_select 'textarea#planting_description', name: 'planting[description]' + assert_select 'select#planting_sunniness', name: 'planting[sunniness]' + assert_select 'select#planting_planted_from', name: 'planting[planted_from]' end end it 'includes helpful links for crops and gardens' do - assert_select "a[href='#{new_garden_path}']", text: "Add a garden." + assert_select "a[href='#{new_garden_path}']", text: 'Add a garden.' end - it "chooses the right crop" do - assert_select "input#crop[value=?]", "tomato" + it 'chooses the right crop' do + assert_select 'input#crop[value=?]', 'tomato' end - it "chooses the right garden" do - assert_select "select#planting_garden_id", + it 'chooses the right garden' do + assert_select 'select#planting_garden_id', html: /option selected value="#{@garden.id}"/ end end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index a3a713100..eed256f87 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plantings/index" do +describe 'plantings/index' do let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -36,27 +36,27 @@ describe "plantings/index" do render end - it "renders a list of plantings" do + it 'renders a list of plantings' do rendered.should have_content tomato.name rendered.should have_content maize.name rendered.should have_content member.login_name rendered.should have_content garden.name end - it "displays planting time" do + it 'displays planting time' do rendered.should have_content 'January 13, 2013' end - it "displays finished time" do + it 'displays finished time' do rendered.should have_content 'January 20, 2013' end - it "provides data links" do + it 'provides data links' do render - rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", href: plantings_path(format: 'csv') - assert_select "a", href: plantings_path(format: 'json') - assert_select "a", href: plantings_path(format: 'rss') + rendered.should have_content 'The data on this page is available in the following formats:' + assert_select 'a', href: plantings_path(format: 'csv') + assert_select 'a', href: plantings_path(format: 'json') + assert_select 'a', href: plantings_path(format: 'rss') end it "displays member's name in title" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index c4a394561..bed19f685 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -15,7 +15,7 @@ describe 'plantings/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content "Recent plantings from all members" + rendered.should have_content 'Recent plantings from all members' end it 'item title shows owner and location' do @@ -23,7 +23,7 @@ describe 'plantings/index.rss.haml' do end it 'shows formatted content of posts' do - rendered.should have_content "This is a really good plant." + rendered.should have_content 'This is a really good plant.' end it 'shows sunniness' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 6667a05ee..46971c706 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plantings/new" do +describe 'plantings/new' do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -17,7 +17,7 @@ describe "plantings/new" do owner: @member)) end - context "logged in" do + context 'logged in' do before(:each) do sign_in @member assign(:planting, Planting.new) @@ -26,24 +26,24 @@ describe "plantings/new" do render end - it "renders new planting form" do - assert_select "form", action: plantings_path, method: "post" do - assert_select "select#planting_garden_id", name: "planting[garden_id]" - assert_select "input#crop", class: "ui-autocomplete-input" - assert_select "input#planting_crop_id", name: "planting[crop_id]" - assert_select "input#planting_quantity", name: "planting[quantity]" - assert_select "textarea#planting_description", name: "planting[description]" - assert_select "select#planting_sunniness", name: "planting[sunniness]" - assert_select "select#planting_planted_from", name: "planting[planted_from]" + it 'renders new planting form' do + assert_select 'form', action: plantings_path, method: 'post' do + assert_select 'select#planting_garden_id', name: 'planting[garden_id]' + assert_select 'input#crop', class: 'ui-autocomplete-input' + assert_select 'input#planting_crop_id', name: 'planting[crop_id]' + assert_select 'input#planting_quantity', name: 'planting[quantity]' + assert_select 'textarea#planting_description', name: 'planting[description]' + assert_select 'select#planting_sunniness', name: 'planting[sunniness]' + assert_select 'select#planting_planted_from', name: 'planting[planted_from]' end end it 'includes helpful links for crops and gardens' do - assert_select "a", href: new_garden_path, text: "Add a garden." + assert_select 'a', href: new_garden_path, text: 'Add a garden.' end - it "selects a garden given in a param" do - assert_select "select#planting_garden_id", + it 'selects a garden given in a param' do + assert_select 'select#planting_garden_id', html: /option selected value="#{@garden_z.id}"/ end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 899724ac7..748ceee3d 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "plantings/show" do +describe 'plantings/show' do let(:crop) { FactoryBot.create(:tomato) } let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -19,7 +19,7 @@ describe "plantings/show" do context 'sunniness' do let(:planting) { FactoryBot.create(:sunny_planting) } - it "shows the sunniness" do + it 'shows the sunniness' do render rendered.should have_content 'Sun or shade?' rendered.should have_content 'sun' @@ -29,7 +29,7 @@ describe "plantings/show" do context 'planted from' do let(:planting) { FactoryBot.create(:cutting_planting) } - it "shows planted_from" do + it 'shows planted_from' do render rendered.should have_content 'Planted from:' rendered.should have_content 'cutting' @@ -43,41 +43,41 @@ describe "plantings/show" do end end - it "shows photos" do + it 'shows photos' do photo = FactoryBot.create(:photo, owner: member) planting.photos << photo render assert_select "img[src='#{photo.thumbnail_url}']" end - it "shows a link to add photos" do + it 'shows a link to add photos' do render - rendered.should have_content "Add photo" + rendered.should have_content 'Add photo' end - context "no location set" do + context 'no location set' do before(:each) do render end - it "renders the quantity planted" do + it 'renders the quantity planted' do rendered.should match(/3/) end - it "renders the description" do + it 'renders the description' do rendered.should match(/This is a/) end - it "renders markdown in the description" do - assert_select "em", "really" + it 'renders markdown in the description' do + assert_select 'em', 'really' end it "doesn't contain a () if no location is set" do - rendered.should_not have_content "()" + rendered.should_not have_content '()' end end - context "location set" do + context 'location set' do before(:each) do planting.owner.update(location: 'Greenwich, UK') render diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index a153995c5..9217d6729 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe "posts/_single" do +describe 'posts/_single' do def render_post - render partial: "single", locals: { post: @post } + render partial: 'single', locals: { post: @post } end before(:each) do @@ -15,16 +15,16 @@ describe "posts/_single" do render_post end - it "contains a permanent link to post" do - assert_select "a[href='#{post_path @post}']", "Permalink" + it 'contains a permanent link to post' do + assert_select "a[href='#{post_path @post}']", 'Permalink' end it "doesn't contain a link to new comment" do - assert_select("a", { href: new_comment_path(post_id: @post.id) }, false) + assert_select('a', { href: new_comment_path(post_id: @post.id) }, false) end end - context "when logged in" do + context 'when logged in' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -32,16 +32,16 @@ describe "posts/_single" do render_post end - it "contains link to new comment" do - assert_select("a", { href: new_comment_path(post_id: @post.id) }, "Reply") + it 'contains link to new comment' do + assert_select('a', { href: new_comment_path(post_id: @post.id) }, 'Reply') end - it "does not contain an edit link" do + it 'does not contain an edit link' do assert_select "a[href='#{edit_post_path(@post)}']", false end end - context "when logged in as post author" do + context 'when logged in as post author' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -50,88 +50,88 @@ describe "posts/_single" do render_post end - it "contains an edit link" do - assert_select "a[href='#{edit_post_path(@post)}']", "Edit" + it 'contains an edit link' do + assert_select "a[href='#{edit_post_path(@post)}']", 'Edit' end end - context "when there are no comments" do + context 'when there are no comments' do before(:each) do render_post end - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "0 comments" + it 'renders the number of comments' do + assert_select "a[href='#{post_path(@post)}\#comments']", '0 comments' end end - context "when there is 1 comment" do + context 'when there is 1 comment' do before(:each) do @comment = FactoryBot.create(:comment, post: @post) render_post end - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "1 comment" + it 'renders the number of comments' do + assert_select "a[href='#{post_path(@post)}\#comments']", '1 comment' end end - context "when there are 2 comments" do + context 'when there are 2 comments' do before(:each) do @comment = FactoryBot.create(:comment, post: @post) @comment2 = FactoryBot.create(:comment, post: @post) render_post end - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "2 comments" + it 'renders the number of comments' do + assert_select "a[href='#{post_path(@post)}\#comments']", '2 comments' end end - context "when comments should be hidden" do + context 'when comments should be hidden' do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @comment = FactoryBot.create(:comment, post: @post) - render partial: "single", locals: { + render partial: 'single', locals: { post: @post, hide_comments: true } end - it "renders no value of comments" do - rendered.should_not have_content "1 comment" + it 'renders no value of comments' do + rendered.should_not have_content '1 comment' end - it "does not contain link to post" do + it 'does not contain link to post' do assert_select "a[href='#{post_path @post}']", false end - it "does not contain link to new comment" do + it 'does not contain link to new comment' do assert_select "a[href='#{new_comment_path(post_id: @post.id)}']", false end end - context "when post has been edited" do + context 'when post has been edited' do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @post = FactoryBot.create(:post, author: @member) - @post.update(body: "I am updated") + @post.update(body: 'I am updated') render_post end - it "shows edited at" do - rendered.should have_content "edited at" + it 'shows edited at' do + rendered.should have_content 'edited at' end - it "shows the updated time" do + it 'shows the updated time' do rendered.should have_content @post.updated_at end end - context "when comment has been edited" do + context 'when comment has been edited' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -139,19 +139,19 @@ describe "posts/_single" do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(body: "I've been updated") - render partial: "comments/single", locals: { comment: @comment } + render partial: 'comments/single', locals: { comment: @comment } end - it "shows edited at time" do - rendered.should have_content "edited at" + it 'shows edited at time' do + rendered.should have_content 'edited at' end - it "shows updated time" do + it 'shows updated time' do rendered.should have_content @comment.updated_at end end - context "when post has not been edited" do + context 'when post has not been edited' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -161,12 +161,12 @@ describe "posts/_single" do render_post end - it "does not show edited at" do + it 'does not show edited at' do rendered.should_not have_content "edited at #{@post.updated_at}" end end - context "when comment has not been edited" do + context 'when comment has not been edited' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -174,10 +174,10 @@ describe "posts/_single" do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(updated_at: @comment.created_at) - render partial: "comments/single", locals: { comment: @comment } + render partial: 'comments/single', locals: { comment: @comment } end - it "does not show edited at" do + it 'does not show edited at' do rendered.should_not have_content "edited at #{@comment.updated_at}" end end diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 48d64a267..6867185c3 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,34 +1,34 @@ require 'rails_helper' -describe "posts/edit" do +describe 'posts/edit' do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @post = assign(:post, FactoryBot.create(:post, author: @author)) end - context "logged in" do + context 'logged in' do before(:each) do sign_in @author render end - it "renders the edit post form" do - assert_select "form", action: posts_path(@post), method: "post" do - assert_select "input#post_subject", name: "post[subject]" - assert_select "textarea#post_body", name: "post[body]" + it 'renders the edit post form' do + assert_select 'form', action: posts_path(@post), method: 'post' do + assert_select 'input#post_subject', name: 'post[subject]' + assert_select 'textarea#post_body', name: 'post[body]' end end it 'no hidden forum field' do - assert_select "input#post_forum_id[type=hidden]", false + assert_select 'input#post_forum_id[type=hidden]', false end it 'no forum mentioned' do - rendered.should_not have_content "This post will be posted in the forum" + rendered.should_not have_content 'This post will be posted in the forum' end - context "forum specified" do + context 'forum specified' do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index eeebac8b6..ca924a855 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "posts/index" do +describe 'posts/index' do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @@ -17,19 +17,19 @@ describe "posts/index" do render end - it "renders a list of posts" do - assert_select "div.post", count: 2 - assert_select "h3", text: "A Post".to_s, count: 2 - assert_select "div.post-body", - text: "This is some text.".to_s, count: 2 + it 'renders a list of posts' do + assert_select 'div.post', count: 2 + assert_select 'h3', text: 'A Post'.to_s, count: 2 + assert_select 'div.post-body', + text: 'This is some text.'.to_s, count: 2 end - it "contains two gravatar icons" do - assert_select "img", src: /gravatar\.com\/avatar/, count: 2 + it 'contains two gravatar icons' do + assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 end - it "contains RSS feed links for posts and comments" do - assert_select "a", href: posts_path(format: 'rss') - assert_select "a", href: comments_path(format: 'rss') + it 'contains RSS feed links for posts and comments' do + assert_select 'a', href: posts_path(format: 'rss') + assert_select 'a', href: comments_path(format: 'rss') end end diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 3d4ec11f2..23fd0a4b8 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index.rss.haml', type: "view" do +describe 'posts/index.rss.haml', type: 'view' do before(:each) do controller.stub(:current_user) { nil } author = FactoryBot.create(:member) @@ -11,11 +11,11 @@ describe 'posts/index.rss.haml', type: "view" do end it 'shows RSS feed title' do - rendered.should have_content "Recent posts from all members" + rendered.should have_content 'Recent posts from all members' end it 'shows content of posts' do - rendered.should have_content "This is some text." + rendered.should have_content 'This is some text.' end it 'gives the author in the item title' do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index fa344e55b..37e251bea 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "posts/new" do +describe 'posts/new' do before(:each) do @author = FactoryBot.create(:member) assign(:post, FactoryBot.create(:post, author: @author)) @@ -9,22 +9,22 @@ describe "posts/new" do controller.stub(:current_user) { @author } end - it "renders new post form" do + it 'renders new post form' do render - assert_select "form", action: posts_path, method: "post" do - assert_select "input#post_subject", name: "post[subject]" - assert_select "textarea#post_body", name: "post[body]" + assert_select 'form', action: posts_path, method: 'post' do + assert_select 'input#post_subject', name: 'post[subject]' + assert_select 'textarea#post_body', name: 'post[body]' end end it 'no hidden forum field' do render - assert_select "input#post_forum_id[type=hidden]", false + assert_select 'input#post_forum_id[type=hidden]', false end it 'no forum mentioned' do render - rendered.should_not have_content "This post will be posted in the forum" + rendered.should_not have_content 'This post will be posted in the forum' end it "asks what's going on in your garden" do @@ -32,7 +32,7 @@ describe "posts/new" do rendered.should have_content "What's going on in your food garden?" end - context "forum specified" do + context 'forum specified' do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, forum: @forum)) diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index ba6921e4e..e29fb3f1b 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "posts/show" do +describe 'posts/show' do subject { rendered } let(:author) { FactoryBot.create(:member) } @@ -11,7 +11,7 @@ describe "posts/show" do describe 'render post' do before { render } - describe "basic post" do + describe 'basic post' do let(:post) { FactoryBot.create(:post, author: author) } # show the name of the member who posted the post @@ -23,17 +23,17 @@ describe "posts/show" do it { is_expected.not_to have_text('An Update') } end - describe "should parse markdown into html" do + describe 'should parse markdown into html' do let(:post) { FactoryBot.create(:markdown_post, author: author) } - it { assert_select "strong", "strong" } + it { assert_select 'strong', 'strong' } end describe "shouldn't let html through in body" do let(:post) { FactoryBot.create(:post, author: author, body: 'EVIL') } it { is_expected.to have_content('EVIL') } - it { is_expected.not_to have_link("http://evil.com") } + it { is_expected.not_to have_link('http://evil.com') } end describe 'script tag in post body' do let(:post) { FactoryBot.create(:post, author: author, body: "") } @@ -53,7 +53,7 @@ describe "posts/show" do end end - context "when there is one comment" do + context 'when there is one comment' do let(:post) { FactoryBot.create(:html_post, author: author) } let!(:comment) { FactoryBot.create(:comment, post: post) } @@ -63,10 +63,10 @@ describe "posts/show" do end it 'shows comment count only 1' do - assert_select "div.post_comments", false + assert_select 'div.post_comments', false end - it "shows comments" do + it 'shows comments' do is_expected.to have_content comment.body end @@ -75,36 +75,36 @@ describe "posts/show" do end end - context "when there is more than one comment" do + context 'when there is more than one comment' do let(:post) { FactoryBot.create(:html_post, author: author) } before(:each) do - @comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!", + @comment1 = FactoryBot.create(:comment, post: post, body: 'F1rst!!!', created_at: Date.new(2010, 5, 17)) - @comment3 = FactoryBot.create(:comment, post: post, body: "Th1rd!!!", + @comment3 = FactoryBot.create(:comment, post: post, body: 'Th1rd!!!', created_at: Date.new(2012, 5, 17)) - @comment4 = FactoryBot.create(:comment, post: post, body: "F0urth!!!") - @comment2 = FactoryBot.create(:comment, post: post, body: "S3c0nd!!1!", + @comment4 = FactoryBot.create(:comment, post: post, body: 'F0urth!!!') + @comment2 = FactoryBot.create(:comment, post: post, body: 'S3c0nd!!1!', created_at: Date.new(2011, 5, 17)) @comments = post.comments render end - it "shows the oldest comments first" do + it 'shows the oldest comments first' do is_expected.to have_content(/#{@comment1.body}.*#{@comment2.body}.*#{@comment3.body}.*#{@comment4.body}/m) end end - context "forum post" do + context 'forum post' do let(:post) { FactoryBot.create(:forum_post, author: author) } before { render } - it "shows forum name" do + it 'shows forum name' do is_expected.to have_content "in #{post.forum.name}" end end - context "signed in" do + context 'signed in' do let(:post) { FactoryBot.create(:post, author: author) } before(:each) do @@ -114,7 +114,7 @@ describe "posts/show" do end it 'shows a comment button' do - is_expected.to have_link "Comment", href: new_comment_path(post_id: post.id) + is_expected.to have_link 'Comment', href: new_comment_path(post_id: post.id) end end end diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index c22c4196f..f952c6e70 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -25,6 +25,6 @@ describe 'posts/show.rss.haml' do end it 'shows content of comments' do - rendered.should have_content "OMG LOL" + rendered.should have_content 'OMG LOL' end end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index 3d60c9e95..568445d72 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe "products/edit" do +describe 'products/edit' do before(:each) do @product = assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99")) + name: 'MyString', + description: 'MyString', + min_price: '9.99')) end - it "renders the edit product form" do + it 'renders the edit product form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path(@product), method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" + assert_select 'form', action: products_path(@product), method: 'post' do + assert_select 'input#product_name', name: 'product[name]' + assert_select 'textarea#product_description', name: 'product[description]' + assert_select 'input#product_min_price', name: 'product[min_price]' + assert_select 'input#product_recommended_price', name: 'product[recommended_price]' end end end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index 90e08e2a3..c92e2dc02 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe "products/index" do +describe 'products/index' do before(:each) do @product = FactoryBot.create(:product) assign(:products, [@product, @product]) end - it "renders a list of products" do + it 'renders a list of products' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @product.name, count: 2 - assert_select "tr>td", text: @product.description, count: 2 - assert_select "tr>td", text: @product.min_price.to_s, count: 2 + assert_select 'tr>td', text: @product.name, count: 2 + assert_select 'tr>td', text: @product.description, count: 2 + assert_select 'tr>td', text: @product.min_price.to_s, count: 2 end end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index 336c6bac1..f4b596eaf 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -1,24 +1,24 @@ require 'rails_helper' -describe "products/new" do +describe 'products/new' do before(:each) do assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99").as_new_record) + name: 'MyString', + description: 'MyString', + min_price: '9.99').as_new_record) end - it "renders new product form" do + it 'renders new product form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path, method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" - assert_select "select#product_account_type_id", name: "product[account_type_id]" - assert_select "input#product_paid_months", name: "product[paid_months]" + assert_select 'form', action: products_path, method: 'post' do + assert_select 'input#product_name', name: 'product[name]' + assert_select 'textarea#product_description', name: 'product[description]' + assert_select 'input#product_min_price', name: 'product[min_price]' + assert_select 'input#product_recommended_price', name: 'product[recommended_price]' + assert_select 'select#product_account_type_id', name: 'product[account_type_id]' + assert_select 'input#product_paid_months', name: 'product[paid_months]' end end end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb index 315d9caae..243eae01b 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe "products/show" do +describe 'products/show' do before(:each) do @product = assign(:product, FactoryBot.create(:product)) end - it "renders attributes in

" do + it 'renders attributes in

' do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @product.name diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index a86f67ceb..28a5283f2 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe "roles/edit" do +describe 'roles/edit' do before(:each) do @role = assign(:role, stub_model(Role, - name: "MyString", - description: "MyText")) + name: 'MyString', + description: 'MyText')) end - it "renders the edit role form" do + it 'renders the edit role form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: roles_path(@role), method: "post" do - assert_select "input#role_name", name: "role[name]" - assert_select "textarea#role_description", name: "role[description]" + assert_select 'form', action: roles_path(@role), method: 'post' do + assert_select 'input#role_name', name: 'role[name]' + assert_select 'textarea#role_description', name: 'role[description]' end end end diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index e4b28e9ba..232b750df 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe "roles/index" do +describe 'roles/index' do before(:each) do controller.stub(:current_user) { nil } assign(:roles, [ stub_model(Role, - name: "Name", - description: "MyText"), + name: 'Name', + description: 'MyText'), stub_model(Role, - name: "Name", - description: "MyText") + name: 'Name', + description: 'MyText') ]) end - it "renders a list of roles" do + it 'renders a list of roles' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: "Name".to_s, count: 2 - assert_select "tr>td", text: "MyText".to_s, count: 2 + assert_select 'tr>td', text: 'Name'.to_s, count: 2 + assert_select 'tr>td', text: 'MyText'.to_s, count: 2 end end diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index 1cdce8c41..d11424840 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe "roles/new" do +describe 'roles/new' do before(:each) do assign(:role, stub_model(Role, - name: "MyString", - description: "MyText").as_new_record) + name: 'MyString', + description: 'MyText').as_new_record) end - it "renders new role form" do + it 'renders new role form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: roles_path, method: "post" do - assert_select "input#role_name", name: "role[name]" - assert_select "textarea#role_description", name: "role[description]" + assert_select 'form', action: roles_path, method: 'post' do + assert_select 'input#role_name', name: 'role[name]' + assert_select 'textarea#role_description', name: 'role[description]' end end end diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 56f1cc4fb..2d3ea832f 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe "roles/show" do +describe 'roles/show' do before(:each) do @role = assign(:role, stub_model(Role, - name: "Name", - description: "MyText")) + name: 'Name', + description: 'MyText')) end - it "renders attributes in

" do + it 'renders attributes in

' do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index ecaa2056f..081e5a548 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe "scientific_names/edit" do - context "logged in" do +describe 'scientific_names/edit' do + context 'logged in' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -11,14 +11,14 @@ describe "scientific_names/edit" do render end - it "shows the creator" do + it 'shows the creator' do rendered.should have_content "Added by #{@scientific_name.creator} less than a minute ago." end - it "renders the edit scientific_name form" do - assert_select "form", action: scientific_names_path(@scientific_name), method: "post" do - assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" - assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" + it 'renders the edit scientific_name form' do + assert_select 'form', action: scientific_names_path(@scientific_name), method: 'post' do + assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' + assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' end end end diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 4d63ac9e1..682b7078d 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "scientific_names/index" do +describe 'scientific_names/index' do before(:each) do controller.stub(:current_user) { nil } assign(:scientific_names, [ @@ -9,29 +9,29 @@ describe "scientific_names/index" do ]) end - it "renders a list of scientific_names" do + it 'renders a list of scientific_names' do render - assert_select "tr>td", text: "Zea mays".to_s - assert_select "tr>td", text: "Solanum lycopersicum".to_s + assert_select 'tr>td', text: 'Zea mays'.to_s + assert_select 'tr>td', text: 'Solanum lycopersicum'.to_s end it "doesn't show edit/destroy links" do render - rendered.should_not have_content "Edit" - rendered.should_not have_content "Delete" + rendered.should_not have_content 'Edit' + rendered.should_not have_content 'Delete' end - context "logged in and crop wrangler" do + context 'logged in and crop wrangler' do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member controller.stub(:current_user) { @member } end - it "shows edit/destroy links" do + it 'shows edit/destroy links' do render - rendered.should have_content "Edit" - rendered.should have_content "Delete" + rendered.should have_content 'Edit' + rendered.should have_content 'Delete' end end end diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index 0cf5a4205..a7ad30252 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe "scientific_names/new" do +describe 'scientific_names/new' do before(:each) do assign(:scientific_name, FactoryBot.create(:zea_mays)) end - context "logged in" do + context 'logged in' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -13,12 +13,12 @@ describe "scientific_names/new" do render end - it "renders new scientific_name form" do + it 'renders new scientific_name form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: scientific_names_path, method: "post" do - assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" - assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" + assert_select 'form', action: scientific_names_path, method: 'post' do + assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' + assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' end end end diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index b728df2b3..85d3be9ba 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe "scientific_names/show" do +describe 'scientific_names/show' do before(:each) do controller.stub(:current_user) { nil } @scientific_name = assign(:scientific_name, FactoryBot.create(:zea_mays)) end - it "renders attributes in

" do + it 'renders attributes in

' do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Zea mays/) diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index f450d7065..14e604816 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "seeds/edit" do +describe 'seeds/edit' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -8,23 +8,23 @@ describe "seeds/edit" do @seed = FactoryBot.create(:seed, owner: @member) end - it "renders the edit seed form" do + it 'renders the edit seed form' do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: seeds_path(@seed), method: "post" do - assert_select "input#crop", class: "ui-autocomplete-input" - assert_select "input#seed_crop_id", name: "seed[crop_id]" - assert_select "textarea#seed_description", name: "seed[description]" - assert_select "input#seed_quantity", name: "seed[quantity]" - assert_select "select#seed_tradable_to", name: "seed[tradable_to]" + assert_select 'form', action: seeds_path(@seed), method: 'post' do + assert_select 'input#crop', class: 'ui-autocomplete-input' + assert_select 'input#seed_crop_id', name: 'seed[crop_id]' + assert_select 'textarea#seed_description', name: 'seed[description]' + assert_select 'input#seed_quantity', name: 'seed[quantity]' + assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' end end it "doesn't revert tradable_to to nowhere" do @seed = FactoryBot.create(:tradable_seed, owner: @member) - @seed.tradable_to.should_not eq "nowhere" + @seed.tradable_to.should_not eq 'nowhere' render - assert_select "option[selected=selected]", text: @seed.tradable_to + assert_select 'option[selected=selected]', text: @seed.tradable_to end end diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 4df8e526c..bfb6e27c4 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -14,7 +14,7 @@ describe 'seeds/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content "Recent seeds from all members" + rendered.should have_content 'Recent seeds from all members' end it 'has a useful item title' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index 5c5cf3ae4..0270d831c 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "seeds/new" do +describe 'seeds/new' do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,21 +9,21 @@ describe "seeds/new" do assign(:seed, @seed1) end - it "renders new seed form" do + it 'renders new seed form' do render - assert_select "form", action: seeds_path, method: "post" do - assert_select "input#crop", class: "ui-autocomplete-input" - assert_select "input#seed_crop_id", name: "seed[crop_id]" - assert_select "textarea#seed_description", name: "seed[description]" - assert_select "input#seed_quantity", name: "seed[quantity]" - assert_select "select#seed_tradable_to", name: "seed[tradable_to]" + assert_select 'form', action: seeds_path, method: 'post' do + assert_select 'input#crop', class: 'ui-autocomplete-input' + assert_select 'input#seed_crop_id', name: 'seed[crop_id]' + assert_select 'textarea#seed_description', name: 'seed[description]' + assert_select 'input#seed_quantity', name: 'seed[quantity]' + assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' end end it 'reminds you to set your location' do render rendered.should have_content "Don't forget to set your location." - assert_select "a", text: "set your location" + assert_select 'a', text: 'set your location' end context 'member has location' do @@ -43,7 +43,7 @@ describe "seeds/new" do it 'links to change location' do render - assert_select "a", text: "Change your location." + assert_select 'a', text: 'Change your location.' end end end diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index fd2848f97..854b87e2c 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe "seeds/show" do +describe 'seeds/show' do before(:each) do controller.stub(:current_user) { nil } @seed = FactoryBot.create(:seed) @@ -8,12 +8,12 @@ describe "seeds/show" do assign(:photos, @seed.photos.paginate(page: 1)) end - it "renders attributes in

" do + it 'renders attributes in

' do render rendered.should have_content @seed.crop.name end - context "tradable" do + context 'tradable' do before(:each) do @owner = FactoryBot.create(:london_member) assign(:seed, FactoryBot.create(:tradable_seed, @@ -24,12 +24,12 @@ describe "seeds/show" do controller.stub(:current_user) { @member } end - it "shows tradable attributes" do + it 'shows tradable attributes' do render - rendered.should have_content "Will trade: locally" + rendered.should have_content 'Will trade: locally' end - it "shows location of seed owner" do + it 'shows location of seed owner' do render rendered.should have_content @owner.location assert_select 'a', href: place_path(@owner.location) @@ -45,18 +45,18 @@ describe "seeds/show" do it 'says "from unspecified location"' do render - rendered.should have_content "(from unspecified location)" + rendered.should have_content '(from unspecified location)' end - it "links to profile to set location" do + it 'links to profile to set location' do render - assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: "Set Location" + assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: 'Set Location' end end - it "shows button to send message" do + it 'shows button to send message' do render - rendered.should have_content "Request seeds" + rendered.should have_content 'Request seeds' end end end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index 754f05c09..a23320f44 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'shop/index.html.haml', type: "view" do +describe 'shop/index.html.haml', type: 'view' do before(:each) do @product1 = FactoryBot.create(:product) @product2 = FactoryBot.create(:product_with_recommended_price) @@ -8,7 +8,7 @@ describe 'shop/index.html.haml', type: "view" do assign(:order_item, OrderItem.new) end - context "signed in" do + context 'signed in' do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -16,7 +16,7 @@ describe 'shop/index.html.haml', type: "view" do end it 'shows products' do - assert_select("h2", text: @product1.name) + assert_select('h2', text: @product1.name) end it 'shows prices in configured currency' do @@ -38,15 +38,15 @@ describe 'shop/index.html.haml', type: "view" do end it 'displays the order form' do - assert_select "form", count: 2 + assert_select 'form', count: 2 end it 'renders markdown in product descriptions' do - assert_select "em", text: 'hurrah', count: 2 + assert_select 'em', text: 'hurrah', count: 2 end end - context "is paid" do + context 'is paid' do before(:each) do @member = FactoryBot.create(:member) @member.account.account_type = FactoryBot.create(:paid_account_type) @@ -54,29 +54,29 @@ describe 'shop/index.html.haml', type: "view" do controller.stub(:current_member) { @member } end - it "recognises the paid member" do + it 'recognises the paid member' do @member.paid?.should be(true) end - it "tells you you have a paid membership" do + it 'tells you you have a paid membership' do render - rendered.should have_content "You currently have a paid" + rendered.should have_content 'You currently have a paid' end it "doesn't show shop" do render - assert_select "form", false + assert_select 'form', false end end - context "signed out" do + context 'signed out' do before(:each) do controller.stub(:current_user) { nil } render end - it "tells you to sign up/sign in" do - rendered.should have_content "sign in or sign up" + it 'tells you to sign up/sign in' do + rendered.should have_content 'sign in or sign up' end end end From f8127eeec3cf1e10b934cc64a95cacf5d5a5e30d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 9 Feb 2018 07:44:48 +1300 Subject: [PATCH 082/101] Revert "Auto corrected by following Style/StringLiterals" This reverts commit ab56a3c6b32f0cabe9ea116f317e4727631adc81. --- Gemfile | 14 +- Guardfile | 6 +- app/controllers/alternate_names_controller.rb | 4 +- app/controllers/application_controller.rb | 14 +- app/controllers/authentications_controller.rb | 4 +- app/controllers/charts/crops_controller.rb | 2 +- app/controllers/crops_controller.rb | 16 +- app/controllers/follows_controller.rb | 2 +- app/controllers/likes_controller.rb | 2 +- app/controllers/members_controller.rb | 4 +- app/controllers/notifications_controller.rb | 4 +- .../omniauth_callbacks_controller.rb | 8 +- app/controllers/order_items_controller.rb | 2 +- app/controllers/orders_controller.rb | 4 +- app/controllers/pages_controller.rb | 2 +- .../photo_associations_controller.rb | 2 +- app/controllers/photos_controller.rb | 6 +- app/controllers/registrations_controller.rb | 6 +- app/controllers/sessions_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +- app/helpers/crops_helper.rb | 2 +- app/helpers/gardens_helper.rb | 10 +- app/helpers/harvests_helper.rb | 2 +- app/helpers/plantings_helper.rb | 8 +- app/helpers/seeds_helper.rb | 4 +- app/mailers/notifier.rb | 8 +- app/models/ability.rb | 2 +- app/models/account.rb | 2 +- app/models/alternate_name.rb | 2 +- app/models/comment.rb | 2 +- app/models/crop.rb | 48 +-- app/models/csv_importer.rb | 2 +- app/models/follow.rb | 4 +- app/models/forum.rb | 2 +- app/models/garden.rb | 10 +- app/models/harvest.rb | 48 +-- app/models/member.rb | 20 +- app/models/notification.rb | 2 +- app/models/order.rb | 12 +- app/models/order_item.rb | 2 +- app/models/planting.rb | 14 +- app/models/scientific_name.rb | 2 +- app/models/seed.rb | 14 +- app/services/crop_search_service.rb | 16 +- config.rb | 10 +- config/application.rb | 8 +- config/environments/test.rb | 20 +- config/initializers/devise.rb | 2 +- config/initializers/geocoder.rb | 4 +- config/initializers/time_formats.rb | 8 +- config/routes.rb | 10 +- config/setup_load_paths.rb | 2 +- .../20120903092956_devise_create_users.rb | 4 +- ...0201053200_add_approval_status_to_crops.rb | 2 +- .../20171105011017_set_prediction_data.rb | 4 +- .../20171129041341_create_photographings.rb | 8 +- db/seeds.rb | 52 +-- lib/actions/oauth_signup_action.rb | 2 +- lib/tasks/growstuff.rake | 108 +++--- lib/tasks/hooks.rake | 2 +- lib/tasks/i18n.rake | 4 +- lib/tasks/testing.rake | 4 +- script/heroku_maintenance.rb | 4 +- spec/controllers/accounts_controller_spec.rb | 2 +- .../admin/orders_controller_spec.rb | 6 +- spec/controllers/admin_controller_spec.rb | 4 +- .../charts/gardens_controller_spec.rb | 4 +- spec/controllers/comments_controller_spec.rb | 50 +-- spec/controllers/crops_controller_spec.rb | 24 +- spec/controllers/forums_controller_spec.rb | 6 +- spec/controllers/gardens_controller_spec.rb | 4 +- spec/controllers/harvests_controller_spec.rb | 84 ++--- spec/controllers/home_controller_spec.rb | 2 +- spec/controllers/likes_controller_spec.rb | 18 +- spec/controllers/member_controller_spec.rb | 24 +- .../notifications_controller_spec.rb | 36 +- .../order_items_controller_spec.rb | 8 +- spec/controllers/orders_controller_spec.rb | 14 +- .../photo_associations_controller_spec.rb | 6 +- spec/controllers/photos_controller_spec.rb | 88 ++--- spec/controllers/places_controller_spec.rb | 14 +- spec/controllers/plantings_controller_spec.rb | 14 +- spec/controllers/posts_controller_spec.rb | 22 +- spec/controllers/products_controller_spec.rb | 2 +- .../registrations_controller_spec.rb | 8 +- spec/controllers/roles_controller_spec.rb | 6 +- .../scientific_names_controller_spec.rb | 4 +- spec/controllers/seeds_controller_spec.rb | 4 +- spec/controllers/shop_controller_spec.rb | 8 +- spec/factories/account_types.rb | 8 +- spec/factories/alternate_names.rb | 4 +- spec/factories/crop.rb | 46 +-- spec/factories/forums.rb | 4 +- spec/factories/garden.rb | 6 +- spec/factories/harvests.rb | 12 +- spec/factories/like.rb | 2 +- spec/factories/member.rb | 2 +- spec/factories/notifications.rb | 4 +- spec/factories/order_items.rb | 2 +- spec/factories/photos.rb | 8 +- spec/factories/plant_parts.rb | 2 +- spec/factories/planting.rb | 2 +- spec/factories/post.rb | 6 +- spec/factories/products.rb | 8 +- spec/factories/roles.rb | 10 +- spec/factories/scientific_name.rb | 6 +- spec/factories/seeds.rb | 8 +- spec/features/admin/account_types_spec.rb | 20 +- spec/features/admin/forums_spec.rb | 26 +- spec/features/admin/products_spec.rb | 12 +- spec/features/cms_spec.rb | 8 +- .../comments/commenting_a_comment_spec.rb | 22 +- spec/features/crops/alternate_name_spec.rb | 48 +-- spec/features/crops/browse_crops_spec.rb | 12 +- spec/features/crops/creating_a_crop_spec.rb | 40 +-- spec/features/crops/crop_detail_page_spec.rb | 100 +++--- spec/features/crops/crop_photos_spec.rb | 24 +- spec/features/crops/crop_search_spec.rb | 20 +- spec/features/crops/crop_wranglers_spec.rb | 32 +- .../crops/crop_wrangling_button_spec.rb | 14 +- spec/features/crops/inflections_spec.rb | 28 +- spec/features/crops/request_new_crop_spec.rb | 40 +-- spec/features/crops/requested_crops_spec.rb | 6 +- spec/features/following_spec.rb | 40 +-- spec/features/footer_spec.rb | 4 +- spec/features/gardens/adding_gardens_spec.rb | 32 +- spec/features/gardens/gardens_index_spec.rb | 28 +- spec/features/gardens_spec.rb | 82 ++--- .../features/harvests/browse_harvests_spec.rb | 8 +- .../harvests/harvesting_a_crop_spec.rb | 84 ++--- spec/features/locale_spec.rb | 8 +- spec/features/member_profile_spec.rb | 108 +++--- spec/features/members/deletion_spec.rb | 72 ++-- spec/features/members_list_spec.rb | 28 +- spec/features/notifications_spec.rb | 18 +- spec/features/photos/new_photo_spec.rb | 26 +- spec/features/photos/show_photo_spec.rb | 20 +- .../features/places/searching_a_place_spec.rb | 44 +-- spec/features/planting_reminder_spec.rb | 34 +- .../plantings/planting_a_crop_spec.rb | 328 +++++++++--------- spec/features/posts/posting_a_post_spec.rb | 24 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/features/scientific_name_spec.rb | 48 +-- spec/features/seeds/adding_seeds_spec.rb | 64 ++-- spec/features/seeds/misc_seeds_spec.rb | 32 +- spec/features/seeds/seed_photos.rb | 10 +- spec/features/shared_examples/append_date.rb | 18 +- spec/features/shared_examples/crop_suggest.rb | 50 +-- spec/features/signin_spec.rb | 26 +- spec/features/signout_spec.rb | 18 +- spec/features/signup_spec.rb | 12 +- spec/features/unsubscribing_spec.rb | 12 +- spec/helpers/application_helper_spec.rb | 6 +- spec/helpers/crops_helper_spec.rb | 12 +- spec/helpers/gardens_helper_spec.rb | 50 +-- spec/helpers/harvests_helper_spec.rb | 4 +- spec/helpers/notifications_helper_spec.rb | 6 +- spec/helpers/plantings_helper_spec.rb | 30 +- spec/helpers/seeds_helper_spec.rb | 14 +- spec/lib/actions/oauth_signup_action_spec.rb | 4 +- .../lib/haml/filters/escaped_markdown_spec.rb | 4 +- .../haml/filters/growstuff_markdown_spec.rb | 24 +- spec/mailers/notifier_spec.rb | 20 +- spec/models/ability_spec.rb | 76 ++-- spec/models/account_spec.rb | 4 +- spec/models/alternate_name_spec.rb | 2 +- spec/models/comment_spec.rb | 14 +- spec/models/crop_spec.rb | 154 ++++---- spec/models/follow_spec.rb | 12 +- spec/models/forum_spec.rb | 6 +- spec/models/garden_spec.rb | 42 +-- spec/models/harvest_spec.rb | 56 +-- spec/models/member_spec.rb | 74 ++-- spec/models/notification_spec.rb | 24 +- spec/models/order_item_spec.rb | 4 +- spec/models/order_spec.rb | 16 +- spec/models/photo_spec.rb | 6 +- spec/models/planting_spec.rb | 26 +- spec/models/post_spec.rb | 56 +-- spec/models/product_spec.rb | 2 +- spec/models/seed_spec.rb | 8 +- spec/rails_helper.rb | 8 +- spec/requests/api/v1/crop_request_spec.rb | 68 ++-- spec/requests/api/v1/gardens_request_spec.rb | 40 +-- spec/requests/api/v1/harvest_request_spec.rb | 68 ++-- spec/requests/api/v1/member_request_spec.rb | 68 ++-- spec/requests/api/v1/photos_request_spec.rb | 64 ++-- .../requests/api/v1/plantings_request_spec.rb | 90 ++--- spec/requests/api/v1/seeds_request_spec.rb | 54 +-- spec/requests/authentications_spec.rb | 4 +- spec/requests/comments_spec.rb | 6 +- spec/requests/forums_spec.rb | 6 +- spec/requests/gardens_spec.rb | 6 +- spec/requests/harvests_spec.rb | 6 +- spec/requests/notifications_spec.rb | 6 +- spec/requests/photos_spec.rb | 6 +- spec/requests/plant_parts_spec.rb | 6 +- spec/requests/plantings_spec.rb | 6 +- spec/requests/post_spec.rb | 6 +- spec/requests/scientific_names_spec.rb | 6 +- spec/requests/seeds_spec.rb | 6 +- spec/routing/account_types_routing_spec.rb | 32 +- spec/routing/authentications_routing_spec.rb | 12 +- spec/routing/comments_routing_spec.rb | 32 +- spec/routing/crops_routing_spec.rb | 32 +- spec/routing/follows_routing_spec.rb | 12 +- spec/routing/forums_routing_spec.rb | 32 +- spec/routing/gardens_routing_spec.rb | 32 +- spec/routing/harvests_routing_spec.rb | 32 +- spec/routing/notifications_routing_spec.rb | 32 +- spec/routing/order_items_routing_spec.rb | 32 +- spec/routing/orders_routing_spec.rb | 32 +- spec/routing/photos_routing_spec.rb | 32 +- spec/routing/plant_parts_routing_spec.rb | 32 +- spec/routing/plantings_routing_spec.rb | 32 +- spec/routing/products_routing_spec.rb | 32 +- spec/routing/roles_routing_spec.rb | 32 +- spec/routing/scientific_names_routing_spec.rb | 32 +- spec/routing/seeds_routing_spec.rb | 32 +- spec/routing/updates_routing_spec.rb | 32 +- spec/spec_helper.rb | 2 +- spec/support/controller_macros.rb | 2 +- spec/support/elasticsearch_helpers.rb | 4 +- spec/support/is_likeable.rb | 4 +- .../account_types/edit.html.haml_spec.rb | 14 +- .../account_types/index.html.haml_spec.rb | 6 +- .../views/account_types/new.html.haml_spec.rb | 14 +- .../account_types/show.html.haml_spec.rb | 6 +- spec/views/accounts/edit.html.haml_spec.rb | 10 +- spec/views/accounts/index.html.haml_spec.rb | 6 +- spec/views/accounts/new.html.haml_spec.rb | 10 +- spec/views/accounts/show.html.haml_spec.rb | 4 +- spec/views/admin/index_spec.rb | 16 +- spec/views/admin/newsletter_spec.rb | 4 +- spec/views/admin/orders/index_spec.rb | 14 +- spec/views/comments/edit.html.haml_spec.rb | 8 +- spec/views/comments/index.html.haml_spec.rb | 8 +- spec/views/comments/index.rss.haml_spec.rb | 4 +- spec/views/comments/new.html.haml_spec.rb | 16 +- spec/views/comments/show.html.haml_spec.rb | 4 +- spec/views/crops/_grown_for.html.haml_spec.rb | 4 +- .../crops/_planting_advice.html.haml_spec.rb | 52 +-- spec/views/crops/_popover.html.haml_spec.rb | 2 +- spec/views/crops/edit.html.haml_spec.rb | 4 +- spec/views/crops/hierarchy.html.haml_spec.rb | 6 +- spec/views/crops/index.html.haml_spec.rb | 28 +- spec/views/crops/index.rss.haml_spec.rb | 2 +- spec/views/crops/new.html.haml_spec.rb | 6 +- spec/views/crops/wrangle.html.haml_spec.rb | 14 +- spec/views/devise/confirmations/new_spec.rb | 6 +- .../mailer/confirmation_instructions_spec.rb | 4 +- .../reset_password_instructions_spec.rb | 8 +- .../devise/mailer/unlock_instructions_spec.rb | 10 +- spec/views/devise/registrations/edit_spec.rb | 34 +- spec/views/devise/registrations/new_spec.rb | 8 +- spec/views/devise/sessions/new_spec.rb | 6 +- spec/views/devise/shared/_links_spec.rb | 12 +- spec/views/devise/unlocks/new_spec.rb | 6 +- spec/views/forums/edit.html.haml_spec.rb | 16 +- spec/views/forums/index.html.haml_spec.rb | 18 +- spec/views/forums/new.html.haml_spec.rb | 12 +- spec/views/forums/show.html.haml_spec.rb | 14 +- spec/views/gardens/edit.html.haml_spec.rb | 20 +- spec/views/gardens/new.html.haml_spec.rb | 18 +- spec/views/gardens/show.html.haml_spec.rb | 14 +- spec/views/harvests/edit.html.haml_spec.rb | 22 +- spec/views/harvests/index.html.haml_spec.rb | 10 +- spec/views/harvests/new.html.haml_spec.rb | 22 +- spec/views/harvests/show.html.haml_spec.rb | 4 +- spec/views/home/_blurb.html.haml_spec.rb | 10 +- spec/views/home/_crops.html.haml_spec.rb | 2 +- spec/views/home/_members.html.haml_spec.rb | 4 +- spec/views/home/_seeds.html.haml_spec.rb | 2 +- spec/views/home/_stats.html.haml_spec.rb | 4 +- spec/views/home/index_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 28 +- spec/views/layouts/_meta_spec.rb | 4 +- spec/views/layouts/application_spec.rb | 4 +- .../views/members/_location.html.haml_spec.rb | 14 +- spec/views/members/index.html.haml_spec.rb | 6 +- spec/views/members/show.rss.haml_spec.rb | 6 +- .../notifications/index.html.haml_spec.rb | 28 +- .../views/notifications/new.html.haml_spec.rb | 28 +- .../notifications/show.html.haml_spec.rb | 12 +- spec/views/notifier/notify.html.haml_spec.rb | 6 +- spec/views/orders/index.html.haml_spec.rb | 12 +- spec/views/orders/show.html.haml_spec.rb | 34 +- spec/views/photos/edit.html.haml_spec.rb | 6 +- spec/views/photos/index.html.haml_spec.rb | 8 +- spec/views/photos/new.html.haml_spec.rb | 20 +- spec/views/photos/show.html.haml_spec.rb | 60 ++-- .../places/_map_attribution.html.haml_spec.rb | 18 +- spec/views/places/index.html.haml_spec.rb | 6 +- spec/views/places/show.html.haml_spec.rb | 10 +- spec/views/plant_parts/edit.html.haml_spec.rb | 10 +- .../views/plant_parts/index.html.haml_spec.rb | 6 +- spec/views/plant_parts/new.html.haml_spec.rb | 10 +- spec/views/plant_parts/show.html.haml_spec.rb | 6 +- spec/views/plantings/_form.html.haml_spec.rb | 4 +- spec/views/plantings/edit.html.haml_spec.rb | 26 +- spec/views/plantings/index.html.haml_spec.rb | 18 +- spec/views/plantings/index.rss.haml_spec.rb | 4 +- spec/views/plantings/new.html.haml_spec.rb | 28 +- spec/views/plantings/show.html.haml_spec.rb | 26 +- spec/views/posts/_single.html.haml_spec.rb | 84 ++--- spec/views/posts/edit.html.haml_spec.rb | 18 +- spec/views/posts/index.html.haml_spec.rb | 22 +- spec/views/posts/index.rss.haml_spec.rb | 6 +- spec/views/posts/new.html.haml_spec.rb | 16 +- spec/views/posts/show.html.haml_spec.rb | 36 +- spec/views/posts/show.rss.haml_spec.rb | 2 +- spec/views/products/edit.html.haml_spec.rb | 20 +- spec/views/products/index.html.haml_spec.rb | 10 +- spec/views/products/new.html.haml_spec.rb | 24 +- spec/views/products/show.html.haml_spec.rb | 4 +- spec/views/roles/edit.html.haml_spec.rb | 14 +- spec/views/roles/index.html.haml_spec.rb | 16 +- spec/views/roles/new.html.haml_spec.rb | 14 +- spec/views/roles/show.html.haml_spec.rb | 8 +- .../scientific_names/edit.html.haml_spec.rb | 14 +- .../scientific_names/index.html.haml_spec.rb | 20 +- .../scientific_names/new.html.haml_spec.rb | 12 +- .../scientific_names/show.html.haml_spec.rb | 4 +- spec/views/seeds/edit.html.haml_spec.rb | 20 +- spec/views/seeds/index.rss.haml_spec.rb | 2 +- spec/views/seeds/new.html.haml_spec.rb | 20 +- spec/views/seeds/show.html.haml_spec.rb | 22 +- spec/views/shop/index_spec.rb | 26 +- 330 files changed, 3121 insertions(+), 3121 deletions(-) diff --git a/Gemfile b/Gemfile index 4e6dc5797..488a3b9ab 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' -gem 'chartkick' +gem "chartkick" # client for Elasticsearch. Elasticsearch is a flexible # and powerful, distributed, real-time search and analytics engine. @@ -87,15 +87,15 @@ gem 'chartkick' # Project does not use semver, so we want to be in sync with the version of # elasticsearch we use # See https://github.com/elastic/elasticsearch-ruby#compatibility -gem 'elasticsearch-api', '~> 2.0.0' -gem 'elasticsearch-model' -gem 'elasticsearch-rails' -gem 'hashie', '>= 3.5.3' +gem "elasticsearch-api", "~> 2.0.0" +gem "elasticsearch-model" +gem "elasticsearch-rails" +gem "hashie", ">= 3.5.3" gem 'rake', '>= 10.0.0' # locale based flash notices for controllers -gem 'responders' +gem "responders" # allows soft delete. Used for members. gem 'acts_as_paranoid', '~> 0.5.0' @@ -125,7 +125,7 @@ group :development do end group :development, :test do - gem 'active_merchant-paypal-bogus-gateway' + gem "active_merchant-paypal-bogus-gateway" gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Guardfile b/Guardfile index dabd4b9d5..4b5f3ccb5 100644 --- a/Guardfile +++ b/Guardfile @@ -3,11 +3,11 @@ guard :rspec, failed_mode: :keep do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } + watch('spec/spec_helper.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } - watch('config/routes.rb') { 'spec/routing' } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } end diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index e06a07b5a..0f1471a8c 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -30,7 +30,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.save redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.' else - render action: 'new' + render action: "new" end end @@ -40,7 +40,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.update(alternate_name_params) redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.' else - render action: 'edit' + render action: "edit" end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b5a0bf32..3e6221d06 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,12 +7,12 @@ class ApplicationController < ActionController::Base before_action :set_locale def store_location - unless request.path.in?(['/members/sign_in', - '/members/sign_up', - '/members/password/new', - '/members/password/edit', - '/members/confirmation', - '/members/sign_out']) || request.xhr? + unless request.path.in?(["/members/sign_in", + "/members/sign_up", + "/members/password/new", + "/members/password/edit", + "/members/confirmation", + "/members/sign_out"]) || request.xhr? store_location_for(:member, request.fullpath) end end @@ -77,6 +77,6 @@ class ApplicationController < ActionController::Base end def expire_homepage - expire_fragment('homepage_stats') + expire_fragment("homepage_stats") end end diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 7c603eb6a..fc18ff4d7 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -22,9 +22,9 @@ class AuthenticationsController < ApplicationController name: name ) - flash[:notice] = 'Authentication successful.' + flash[:notice] = "Authentication successful." else - flash[:notice] = 'Authentication failed.' + flash[:notice] = "Authentication failed." end redirect_to request.env['omniauth.origin'] || edit_member_registration_path end diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 17c774c14..b5fe3d4a7 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -14,7 +14,7 @@ module Charts @crop = Crop.find(params[:crop_id]) render json: Harvest.joins(:plant_part) .where(crop: @crop) - .group('plant_parts.name').count(:id) + .group("plant_parts.name").count(:id) end private diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index e6ff7c7e0..361e28031 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -23,9 +23,9 @@ class CropsController < ApplicationController def wrangle @approval_status = params[:approval_status] @crops = case @approval_status - when 'pending' + when "pending" Crop.pending_approval - when 'rejected' + when "rejected" Crop.rejected else Crop.recent @@ -78,7 +78,7 @@ class CropsController < ApplicationController @crop.creator = current_member else @crop.requester = current_member - @crop.approval_status = 'pending' + @crop.approval_status = "pending" end notify_wranglers if Crop.transaction { @crop.save && save_crop_names } @@ -89,13 +89,13 @@ class CropsController < ApplicationController def update previous_status = @crop.approval_status - @crop.creator = current_member if previous_status == 'pending' + @crop.creator = current_member if previous_status == "pending" if @crop.update(crop_params) recreate_names('alt_name', 'alternate') recreate_names('sci_name', 'scientific') - notifier.deliver_now! if previous_status == 'pending' + notifier.deliver_now! if previous_status == "pending" end respond_with @crop @@ -110,9 +110,9 @@ class CropsController < ApplicationController def notifier case @crop.approval_status - when 'approved' + when "approved" Notifier.crop_request_approved(@crop.requester, @crop) - when 'rejected' + when "rejected" Notifier.crop_request_rejected(@crop.requester, @crop) end end @@ -185,7 +185,7 @@ class CropsController < ApplicationController def crops q = Crop.approved.includes(:scientific_names, plantings: :photos) q = q.popular unless @sort == 'alpha' - q.order('LOWER(crops.name)').includes(:photos).paginate(page: params[:page]) + q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page]) end def requested_crops diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 80341035f..2c4b2daab 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -11,7 +11,7 @@ class FollowsController < ApplicationController flash[:notice] = "Followed #{@follow.followed.login_name}" redirect_to :back else - flash[:error] = 'Already following or error while following.' + flash[:error] = "Already following or error while following." redirect_to :back end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index d5a8506d7..5f7c5dac9 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -26,7 +26,7 @@ class LikesController < ApplicationController { id: like.likeable.id, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, 'like'), + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), url: like_path(like, format: :json) } end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index e435ef08a..c346eb8e3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -49,8 +49,8 @@ class MembersController < ApplicationController end EMAIL_TYPE_STRING = { - send_notification_email: 'direct message notifications', - send_planting_reminder: 'planting reminders' + send_notification_email: "direct message notifications", + send_planting_reminder: "planting reminders" }.freeze def unsubscribe diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 61dbea6dd..7c3c1f322 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -21,7 +21,7 @@ class NotificationsController < ApplicationController def new @notification = Notification.new @recipient = Member.find_by(id: params[:recipient_id]) - @subject = params[:subject] || '' + @subject = params[:subject] || "" end # GET /notifications/1/reply @@ -53,7 +53,7 @@ class NotificationsController < ApplicationController if @notification.save redirect_to notifications_path, notice: 'Message was successfully sent.' else - render action: 'new' + render action: "new" end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index c70da1443..3d642cd3d 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -12,8 +12,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def failure - flash[:alert] = 'Authentication failed.' - redirect_to request.env['omniauth.origin'] || '/' + flash[:alert] = "Authentication failed." + redirect_to request.env['omniauth.origin'] || "/" end private @@ -30,9 +30,9 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) if action.member_created? - raise 'Invalid provider' unless %w(facebook twitter flickr).index(auth['provider'].to_s) + raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s) - session["devise.#{auth['provider']}_data"] = request.env['omniauth.auth'] + session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] sign_in member redirect_to finish_signup_url(member) else diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 9c3e79dae..326cff21f 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -24,7 +24,7 @@ class OrderItemsController < ApplicationController def errors if @order_item.errors.empty? - 'There was a problem with your order.' + "There was a problem with your order." else @order_item.errors.full_messages.to_sentence end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 0929d3948..3bc9fe45c 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -42,7 +42,7 @@ class OrdersController < ApplicationController ) format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } else - format.html { render action: 'show' } + format.html { render action: "show" } end end end @@ -60,7 +60,7 @@ class OrdersController < ApplicationController @order.completed_at = Time.zone.now @order.record_paypal_details(params[:token]) else - flash[:alert] = 'Could not complete your order. Please notify support.' + flash[:alert] = "Could not complete your order. Please notify support." end else flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ec270b2a6..9ffb98af8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def letsencrypt # use your code here, not mine - render text: 'y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU' + render text: "y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" end end diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 35ef97632..126aaf9b3 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -3,7 +3,7 @@ class PhotoAssociationsController < ApplicationController respond_to :json, :html def destroy - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class @photo = Photo.find_by!(id: params[:photo_id], owner: current_member) @item = Photographing.item(item_id, item_class) @item.photos.delete(@photo) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 3757894a8..57b10e5d8 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -75,10 +75,10 @@ class PhotosController < ApplicationController # Item with photos attached def item_to_link_to - raise 'No item id provided' if item_id.nil? - raise 'No item type provided' if item_type.nil? + raise "No item id provided" if item_id.nil? + raise "No item type provided" if item_type.nil? item_class = item_type.capitalize - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class item_class.constantize.find_by!(id: params[:id], owner_id: current_member.id) end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index a83d6b466..72e92b9fd 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,7 +5,7 @@ class RegistrationsController < Devise::RegistrationsController @twitter_auth = current_member.auth('twitter') @flickr_auth = current_member.auth('flickr') @facebook_auth = current_member.auth('facebook') - render 'edit' + render "edit" end # we need this subclassed method so that Devise doesn't force people to @@ -32,7 +32,7 @@ class RegistrationsController < Devise::RegistrationsController sign_in @member, bypass: true redirect_to edit_member_registration_path else - render 'edit' + render "edit" end end @@ -40,7 +40,7 @@ class RegistrationsController < Devise::RegistrationsController if @member.destroy_with_password(params.require(:member)[:current_password]) redirect_to root_path else - render 'edit' + render "edit" end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ee1fddc3c..6106e0c75 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ class SessionsController < Devise::SessionsController def create super do |_resource| if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) - flash[:alert] = 'There are crops waiting to be wrangled.' + flash[:alert] = "There are crops waiting to be wrangled." end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6076d98ef..639d27686 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper currency = Growstuff::Application.config.currency link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" - link_to '(convert)', link, target: '_blank', rel: 'noopener noreferrer' + link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer" end def build_alert_classes(alert_type = :info) @@ -37,7 +37,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier = 'all') + def cache_key_for(klass, identifier = "all") count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" @@ -102,7 +102,7 @@ module ApplicationHelper elsif planting t(".title.planting_#{type}", planting: planting.to_s) else - t('.title.default') + t(".title.default") end end diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index c96ff8fa1..b99d687aa 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -13,7 +13,7 @@ module CropsHelper if total_quantity != 0 "You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop." else - 'You have an unknown quantity of seeds of this crop.' + "You have an unknown quantity of seeds of this crop." end end diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index cfbf90024..a72505558 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,10 +1,10 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - 'no description provided.' + "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') do - link_to 'Read more', garden_path(garden) + link_to "Read more", garden_path(garden) end end end @@ -19,12 +19,12 @@ module GardensHelper def display_garden_plantings(plantings) if plantings.blank? - 'None' + "None" else output = '

    ' plantings.each do |planting| - output += '
  • ' - output += planting.quantity.nil? ? '0 ' : "#{planting.quantity} " + output += "
  • " + output += planting.quantity.nil? ? "0 " : "#{planting.quantity} " output += link_to planting.crop.name, planting.crop output += ", planted on #{planting.planted_at}
  • " end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 6d9430b74..14277817b 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -28,7 +28,7 @@ module HarvestsHelper end def display_harvest_description(harvest) - return 'No description provided.' if harvest.description.nil? + return "No description provided." if harvest.description.nil? harvest.description end end diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index 3e093d1e9..f71dc8158 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -3,18 +3,18 @@ module PlantingsHelper if planting.finished_at.present? planting.finished_at elsif planting.finished - 'Yes (no date specified)' + "Yes (no date specified)" else - '(no date specified)' + "(no date specified)" end end def display_planted_from(planting) - planting.planted_from.present? ? planting.planted_from : 'not specified' + planting.planted_from.present? ? planting.planted_from : "not specified" end def display_planting_quantity(planting) - planting.quantity.present? ? planting.quantity : 'not specified' + planting.quantity.present? ? planting.quantity : "not specified" end def display_planting(planting) diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb index 7a7948dec..f0bc76dd9 100644 --- a/app/helpers/seeds_helper.rb +++ b/app/helpers/seeds_helper.rb @@ -1,9 +1,9 @@ module SeedsHelper def display_seed_description(seed) if seed.description.nil? - 'no description provided.' + "no description provided." else - truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to 'Read more', seed_path(seed) } + truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) } end end end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index f191263bc..6c479f51f 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,11 +1,11 @@ class Notifier < ActionMailer::Base include NotificationsHelper - default from: 'Growstuff ' + default from: "Growstuff " def verifier unless ENV['RAILS_SECRET_TOKEN'] - raise 'RAILS_SECRET_TOKEN environment variable'\ - 'not set - have you created config/application.yml?' + raise "RAILS_SECRET_TOKEN environment variable"\ + "not set - have you created config/application.yml?" end ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN']) @@ -33,7 +33,7 @@ class Notifier < ActionMailer::Base message = { member_id: @member.id, type: :send_planting_reminder } @signed_message = verifier.generate(message) - mail(to: @member.email, subject: 'What have you planted lately?') if @member.send_planting_reminder + mail(to: @member.email, subject: "What have you planted lately?") if @member.send_planting_reminder end def new_crop_request(member, request) diff --git a/app/models/ability.rb b/app/models/ability.rb index e0e99dc30..283bf45cc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -36,7 +36,7 @@ class Ability # nobody should be able to view unapproved crops unless they # are wranglers or admins cannot :read, Crop - can :read, Crop, approval_status: 'approved' + can :read, Crop, approval_status: "approved" # scientific names should only be viewable if associated crop is approved cannot :read, ScientificName can :read, ScientificName do |sn| diff --git a/app/models/account.rb b/app/models/account.rb index cfd4b2979..646e9db78 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -15,7 +15,7 @@ class Account < ActiveRecord::Base def paid_until_string if account_type.is_permanent_paid - 'forever' + "forever" elsif account_type.is_paid paid_until.to_s end diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb index 1e989cbca..aa960e1f4 100644 --- a/app/models/alternate_name.rb +++ b/app/models/alternate_name.rb @@ -1,5 +1,5 @@ class AlternateName < ActiveRecord::Base - after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } + after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/comment.rb b/app/models/comment.rb index 0f11bfb6f..7098e0b46 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ class Comment < ActiveRecord::Base belongs_to :author, class_name: 'Member' belongs_to :post - scope :post_order, -> { reorder('created_at ASC') } # for display on post page + scope :post_order, -> { reorder("created_at ASC") } # for display on post page after_create do recipient = post.author.id diff --git a/app/models/crop.rb b/app/models/crop.rb index 4466e31e7..15787f6f1 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -15,7 +15,7 @@ class Crop < ActiveRecord::Base has_many :photos, through: :plantings has_many :seeds has_many :harvests - has_many :plant_parts, -> { uniq.reorder('plant_parts.name') }, through: :harvests + has_many :plant_parts, -> { uniq.reorder("plant_parts.name") }, through: :harvests belongs_to :creator, class_name: 'Member' belongs_to :requester, class_name: 'Member' belongs_to :parent, class_name: 'Crop' @@ -26,12 +26,12 @@ class Crop < ActiveRecord::Base ## Scopes scope :recent, -> { approved.order(created_at: :desc) } scope :toplevel, -> { approved.where(parent_id: nil) } - scope :popular, -> { approved.reorder('plantings_count desc, lower(name) asc') } + scope :popular, -> { approved.reorder("plantings_count desc, lower(name) asc") } # ok on sqlite and psql, but not on mysql scope :randomized, -> { approved.reorder('random()') } - scope :pending_approval, -> { where(approval_status: 'pending') } - scope :approved, -> { where(approval_status: 'approved') } - scope :rejected, -> { where(approval_status: 'rejected') } + scope :pending_approval, -> { where(approval_status: "pending") } + scope :approved, -> { where(approval_status: "approved") } + scope :rejected, -> { where(approval_status: "rejected") } scope :interesting, -> { approved.has_photos.randomized } scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } @@ -53,17 +53,17 @@ class Crop < ActiveRecord::Base #################################### # Elastic search configuration - if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" include Elasticsearch::Model include Elasticsearch::Model::Callbacks # In order to avoid clashing between different environments, # use Rails.env as a part of index name (eg. development_growstuff) - index_name [Rails.env, 'growstuff'].join('_') + index_name [Rails.env, "growstuff"].join('_') settings index: { number_of_shards: 1 }, analysis: { tokenizer: { gs_edgeNGram_tokenizer: { - type: 'edgeNGram', # edgeNGram: NGram match from the start of a token + type: "edgeNGram", # edgeNGram: NGram match from the start of a token min_gram: 3, max_gram: 10, # token_chars: Elasticsearch will split on characters @@ -73,8 +73,8 @@ class Crop < ActiveRecord::Base }, analyzer: { gs_edgeNGram_analyzer: { - tokenizer: 'gs_edgeNGram_tokenizer', - filter: ['lowercase'] + tokenizer: "gs_edgeNGram_tokenizer", + filter: ["lowercase"] } } } do @@ -104,7 +104,7 @@ class Crop < ActiveRecord::Base # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) - __elasticsearch__.index_document if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" end # End Elasticsearch section @@ -148,10 +148,10 @@ class Crop < ActiveRecord::Base # value: count of how many times it's been used by harvests def popular_plant_parts PlantPart.joins(:harvests) - .where('crop_id = ?', id) - .order('count_harvests_id DESC') - .group('plant_parts.id', 'plant_parts.name') - .count('harvests.id') + .where("crop_id = ?", id) + .order("count_harvests_id DESC") + .group("plant_parts.id", "plant_parts.name") + .count("harvests.id") end def annual? @@ -167,15 +167,15 @@ class Crop < ActiveRecord::Base end def pending? - approval_status == 'pending' + approval_status == "pending" end def approved? - approval_status == 'approved' + approval_status == "approved" end def rejected? - approval_status == 'rejected' + approval_status == "rejected" end def approval_statuses @@ -183,11 +183,11 @@ class Crop < ActiveRecord::Base end def reasons_for_rejection - ['already in database', 'not edible', 'not enough information', 'other'] + ["already in database", "not edible", "not enough information", "other"] end def rejection_explanation - return rejection_notes if reason_for_rejection == 'other' + return rejection_notes if reason_for_rejection == "other" reason_for_rejection end @@ -212,7 +212,7 @@ class Crop < ActiveRecord::Base end def self.case_insensitive_name(name) - where(['lower(crops.name) = :value', { value: name.downcase }]) + where(["lower(crops.name) = :value", { value: name.downcase }]) end private @@ -235,11 +235,11 @@ class Crop < ActiveRecord::Base def must_be_rejected_if_rejected_reasons_present return if rejected? return unless reason_for_rejection.present? || rejection_notes.present? - errors.add(:approval_status, 'must be rejected if a reason for rejection is present') + errors.add(:approval_status, "must be rejected if a reason for rejection is present") end def must_have_meaningful_reason_for_rejection - return unless reason_for_rejection == 'other' && rejection_notes.blank? - errors.add(:rejection_notes, 'must be added if the reason for rejection is "other"') + return unless reason_for_rejection == "other" && rejection_notes.blank? + errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") end end diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index 477ac1a37..2f646b6ab 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -65,6 +65,6 @@ class CsvImporter @cropbot ||= Member.find_by!(login_name: 'cropbot') @cropbot rescue StandardError - raise 'cropbot account not found: run rake db:seed' + raise "cropbot account not found: run rake db:seed" end end diff --git a/app/models/follow.rb b/app/models/follow.rb index b00a50138..557887cb6 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,6 +1,6 @@ class Follow < ActiveRecord::Base - belongs_to :follower, class_name: 'Member' - belongs_to :followed, class_name: 'Member' + belongs_to :follower, class_name: "Member" + belongs_to :followed, class_name: "Member" validates :follower_id, uniqueness: { scope: :followed_id } after_create do diff --git a/app/models/forum.rb b/app/models/forum.rb index 47fea88cc..7cbc0d43d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -4,7 +4,7 @@ class Forum < ActiveRecord::Base friendly_id :name, use: %i(slugged finders) has_many :posts - belongs_to :owner, class_name: 'Member' + belongs_to :owner, class_name: "Member" def to_s name diff --git a/app/models/garden.rb b/app/models/garden.rb index 3f7defffa..0c3378b00 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -35,13 +35,13 @@ class Garden < ActiveRecord::Base allow_nil: true AREA_UNITS_VALUES = { - 'square metres' => 'square metre', - 'square feet' => 'square foot', - 'hectares' => 'hectare', - 'acres' => 'acre' + "square metres" => "square metre", + "square feet" => "square foot", + "hectares" => "hectare", + "acres" => "acre" }.freeze validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values, - message: '%s is not a valid area unit' }, + message: "%s is not a valid area unit" }, allow_nil: true, allow_blank: true diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 9d73ab100..6bb9aa048 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -7,22 +7,22 @@ class Harvest < ActiveRecord::Base # Constants UNITS_VALUES = { - 'individual' => 'individual', - 'bunches' => 'bunch', - 'sprigs' => 'sprig', - 'handfuls' => 'handful', - 'litres' => 'litre', - 'pints' => 'pint', - 'quarts' => 'quart', - 'buckets' => 'bucket', - 'baskets' => 'basket', - 'bushels' => 'bushel' + "individual" => "individual", + "bunches" => "bunch", + "sprigs" => "sprig", + "handfuls" => "handful", + "litres" => "litre", + "pints" => "pint", + "quarts" => "quart", + "buckets" => "bucket", + "baskets" => "basket", + "bushels" => "bushel" }.freeze WEIGHT_UNITS_VALUES = { - 'kg' => 'kg', - 'lb' => 'lb', - 'oz' => 'oz' + "kg" => "kg", + "lb" => "lb", + "oz" => "oz" }.freeze ## @@ -44,18 +44,18 @@ class Harvest < ActiveRecord::Base ## ## Validations validates :crop, approved: true - validates :crop, presence: { message: 'must be present and exist in our database' } - validates :plant_part, presence: { message: 'must be present and exist in our database' } + validates :crop, presence: { message: "must be present and exist in our database" } + validates :plant_part, presence: { message: "must be present and exist in our database" } validates :harvested_at, presence: true validates :quantity, allow_nil: true, numericality: { only_integer: false, greater_than_or_equal_to: 0 } validates :unit, allow_nil: true, allow_blank: true, inclusion: { - in: UNITS_VALUES.values, message: '%s is not a valid unit' + in: UNITS_VALUES.values, message: "%s is not a valid unit" } validates :weight_quantity, allow_nil: true, numericality: { only_integer: false } validates :weight_unit, allow_nil: true, allow_blank: true, inclusion: { - in: WEIGHT_UNITS_VALUES.values, message: '%s is not a valid unit' + in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting validate :owner_must_match_planting @@ -71,7 +71,7 @@ class Harvest < ActiveRecord::Base def set_si_weight return if weight_unit.nil? weight_string = "#{weight_quantity} #{weight_unit}" - self.si_weight = Unit.new(weight_string).convert_to('kg').to_s('%0.3f').delete(' kg').to_f + self.si_weight = Unit.new(weight_string).convert_to("kg").to_s("%0.3f").delete(" kg").to_f end def cleanup_quantities @@ -94,11 +94,11 @@ class Harvest < ActiveRecord::Base def quantity_to_human return number_to_human(quantity.to_s, strip_insignificant_zeros: true) if quantity - '' + "" end def unit_to_human - return '' unless quantity + return "" unless quantity if unit == 'individual' 'individual' elsif quantity == 1 @@ -109,7 +109,7 @@ class Harvest < ActiveRecord::Base end def weight_to_human - return '' unless weight_quantity + return "" unless weight_quantity "weighing #{number_to_human(weight_quantity, strip_insignificant_zeros: true)} #{weight_unit}" end @@ -131,17 +131,17 @@ class Harvest < ActiveRecord::Base def crop_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:planting, 'must be the same crop') unless crop == planting.crop + errors.add(:planting, "must be the same crop") unless crop == planting.crop end def owner_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:owner, 'of harvest must be the same as planting') unless owner == planting.owner + errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner end def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? - errors.add(:planting, 'cannot be harvested before planting') unless harvested_at > planting.planted_at + errors.add(:planting, "cannot be harvested before planting") unless harvested_at > planting.planted_at end end diff --git a/app/models/member.rb b/app/models/member.rb index 07840383a..9828a005c 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -25,8 +25,8 @@ class Member < ActiveRecord::Base has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy - has_many :follows, class_name: 'Follow', foreign_key: 'follower_id', dependent: :destroy - has_many :inverse_follows, class_name: 'Follow', foreign_key: 'followed_id', dependent: :destroy + has_many :follows, class_name: "Follow", foreign_key: "follower_id", dependent: :destroy + has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id", dependent: :destroy has_many :followed, through: :follows has_many :followers, through: :inverse_follows, source: :follower @@ -38,7 +38,7 @@ class Member < ActiveRecord::Base scope :recently_joined, -> { reorder(confirmed_at: :desc) } scope :wants_newsletter, -> { where(newsletter: true) } scope :interesting, -> { confirmed.located.recently_signed_in.has_plantings } - scope :has_plantings, -> { joins(:plantings).group('members.id') } + scope :has_plantings, -> { joins(:plantings).group("members.id") } # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, @@ -60,13 +60,13 @@ class Member < ActiveRecord::Base validates :tos_agreement, acceptance: { allow_nil: true, accept: true } validates :login_name, length: { - minimum: 2, maximum: 25, message: 'should be between 2 and 25 characters long' + minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long" }, exclusion: { - in: %w(growstuff admin moderator staff nearby), message: 'name is reserved' + in: %w(growstuff admin moderator staff nearby), message: "name is reserved" }, format: { - with: /\A\w+\z/, message: 'may only include letters, numbers, or underscores' + with: /\A\w+\z/, message: "may only include letters, numbers, or underscores" }, uniqueness: { case_sensitive: false @@ -82,7 +82,7 @@ class Member < ActiveRecord::Base # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations - after_create { |member| Garden.create(name: 'Garden', owner_id: member.id) } + after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address @@ -98,7 +98,7 @@ class Member < ActiveRecord::Base end def role?(role_sym) - roles.any? { |r| r.name.gsub(/\s+/, '_').underscore.to_sym == role_sym } + roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end def current_order @@ -179,11 +179,11 @@ class Member < ActiveRecord::Base end def self.login_name_or_email(login) - where(['lower(login_name) = :value OR lower(email) = :value', { value: login.downcase }]) + where(["lower(login_name) = :value OR lower(email) = :value", { value: login.downcase }]) end def self.case_insensitive_login_name(login) - where(['lower(login_name) = :value', { value: login.downcase }]) + where(["lower(login_name) = :value", { value: login.downcase }]) end def self.nearest_to(place) diff --git a/app/models/notification.rb b/app/models/notification.rb index 071dcc2b0..1b09b1e5e 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -16,7 +16,7 @@ class Notification < ActiveRecord::Base end def replace_blank_subject - self.subject = '(no subject)' if subject.nil? || subject =~ /^\s*$/ + self.subject = "(no subject)" if subject.nil? || subject =~ /^\s*$/ end def send_email diff --git a/app/models/order.rb b/app/models/order.rb index 1356df8be..53a309c35 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -8,7 +8,7 @@ class Order < ActiveRecord::Base # Validations validates :referral_code, format: { with: /\A[a-zA-Z0-9 ]*\z/, - message: 'may only include letters and numbers' + message: "may only include letters and numbers" } # @@ -68,19 +68,19 @@ class Order < ActiveRecord::Base def self.search(args = {}) if args[:for] case args[:by] - when 'member' + when "member" member = Member.with_deleted.find_by(login_name: args[:for]) return member.orders if member - when 'order_id' + when "order_id" order = Order.find_by(id: args[:for]) return [order] if order - when 'paypal_token' + when "paypal_token" order = Order.find_by(paypal_express_token: args[:for]) return [order] if order - when 'paypal_payer_id' + when "paypal_payer_id" order = Order.find_by(paypal_express_payer_id: args[:for]) return [order] if order - when 'referral_code' + when "referral_code" # coerce to uppercase return Order.where(referral_code: args[:for].upcase) end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index b693c2cd3..380fbff58 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -3,7 +3,7 @@ class OrderItem < ActiveRecord::Base belongs_to :product validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: 'may only have one item.' } + validates :order_id, uniqueness: { message: "may only have one item." } def price_must_be_greater_than_minimum @product = Product.find(product_id) diff --git a/app/models/planting.rb b/app/models/planting.rb index 165dcfcd3..6fd4aec17 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -30,7 +30,7 @@ class Planting < ActiveRecord::Base scope :one_per_owner, lambda { joins("JOIN members m ON (m.id=plantings.owner_id) LEFT OUTER JOIN plantings p2 - ON (m.id=p2.owner_id AND plantings.id < p2.id)").where('p2 IS NULL') + ON (m.id=p2.owner_id AND plantings.id < p2.id)").where("p2 IS NULL") } ## @@ -41,17 +41,17 @@ class Planting < ActiveRecord::Base ## ## Validations validates :garden, presence: true - validates :crop, presence: true, approved: { message: 'must be present and exist in our database' } + validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validate :finished_must_be_after_planted validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :sunniness, allow_nil: true, allow_blank: true, inclusion: { - in: SUNNINESS_VALUES, message: '%s is not a valid sunniness value' + in: SUNNINESS_VALUES, message: "%s is not a valid sunniness value" } validates :planted_from, allow_nil: true, allow_blank: true, inclusion: { - in: PLANTED_FROM_VALUES, message: '%s is not a valid planting method' + in: PLANTED_FROM_VALUES, message: "%s is not a valid planting method" } def planting_slug @@ -64,7 +64,7 @@ class Planting < ActiveRecord::Base # location = garden owner + garden name, i.e. "Skud's backyard" def location - I18n.t('gardens.location', garden: garden.name, owner: garden.owner.login_name) + I18n.t("gardens.location", garden: garden.name, owner: garden.owner.login_name) end # stringify as "beet in Skud's backyard" or similar @@ -134,10 +134,10 @@ class Planting < ActiveRecord::Base # check that any finished_at date occurs after planted_at def finished_must_be_after_planted return unless planted_at && finished_at # only check if we have both - errors.add(:finished_at, 'must be after the planting date') unless planted_at < finished_at + errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at end def owner_must_match_garden_owner - errors.add(:owner, 'must be the same as garden') unless owner == garden.owner + errors.add(:owner, "must be the same as garden") unless owner == garden.owner end end diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb index b25b06a76..bca467b5b 100644 --- a/app/models/scientific_name.rb +++ b/app/models/scientific_name.rb @@ -1,5 +1,5 @@ class ScientificName < ActiveRecord::Base - after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } + after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/seed.rb b/app/models/seed.rb index 525bbf105..7abae922c 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -16,7 +16,7 @@ class Seed < ActiveRecord::Base # # Validations validates :crop, approved: true - validates :crop, presence: { message: 'must be present and exist in our database' } + validates :crop, presence: { message: "must be present and exist in our database" } validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :days_until_maturity_min, allow_nil: true, @@ -24,17 +24,17 @@ class Seed < ActiveRecord::Base validates :days_until_maturity_max, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :tradable_to, allow_nil: false, allow_blank: false, - inclusion: { in: TRADABLE_TO_VALUES, message: 'You may only trade seed nowhere, '\ - 'locally, nationally, or internationally' } + inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\ + "locally, nationally, or internationally" } validates :organic, allow_nil: false, allow_blank: false, - inclusion: { in: ORGANIC_VALUES, message: 'You must say whether the seeds '\ + inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\ "are organic or not, or that you don't know" } validates :gmo, allow_nil: false, allow_blank: false, - inclusion: { in: GMO_VALUES, message: 'You must say whether the seeds are '\ + inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\ "genetically modified or not, or that you don't know" } validates :heirloom, allow_nil: false, allow_blank: false, - inclusion: { in: HEIRLOOM_VALUES, message: 'You must say whether the seeds'\ - 'are heirloom, hybrid, or unknown' } + inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ + "are heirloom, hybrid, or unknown" } # # Delegations diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 82d6933fb..af6085737 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -1,21 +1,21 @@ class CropSearchService # Crop.search(string) def self.search(query) - if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' - search_str = query.nil? ? '' : query.downcase + if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + search_str = query.nil? ? "" : query.downcase response = Crop.__elasticsearch__.search( # Finds documents which match any field, but uses the _score from # the best field insead of adding up _score from each field. query: { multi_match: { query: search_str.to_s, - analyzer: 'standard', - fields: ['name', - 'scientific_names.scientific_name', - 'alternate_names.name'] + analyzer: "standard", + fields: ["name", + "scientific_names.scientific_name", + "alternate_names.name"] } }, filter: { - term: { approval_status: 'approved' } + term: { approval_status: "approved" } }, size: 50 ) @@ -26,7 +26,7 @@ class CropSearchService # collection, so it matches what we get from elasticsearch and we can # manipulate it in the same ways (eg. deleting elements without deleting # the whole record from the db) - matches = Crop.approved.where('name ILIKE ?', "%#{query}%").to_a + matches = Crop.approved.where("name ILIKE ?", "%#{query}%").to_a # we want to make sure that exact matches come first, even if not # using elasticsearch (eg. in development) diff --git a/config.rb b/config.rb index 89ca5df52..f816551c1 100644 --- a/config.rb +++ b/config.rb @@ -1,11 +1,11 @@ # Require any additional compass plugins here. # rubocop:disable Lint/UselessAssignment # Set this to the root of your project when deployed: -http_path = '/' -css_dir = 'app/assets/stylesheets' -sass_dir = 'app/assets/stylesheets' -javascripts_dir = 'app/assets/javascripts' -images_dir = 'app/assets/images' +http_path = "/" +css_dir = "app/assets/stylesheets" +sass_dir = "app/assets/stylesheets" +javascripts_dir = "app/assets/javascripts" +images_dir = "app/assets/images" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed diff --git a/config/application.rb b/config/application.rb index 36ccf09e5..5280dce7e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -42,10 +42,10 @@ module Growstuff config.i18n.fallbacks = [:en] # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = 'utf-8' + config.encoding = "utf-8" # Configure a default account type - config.default_account_type = 'Free' + config.default_account_type = "Free" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] @@ -84,9 +84,9 @@ module Growstuff # Growstuff-specific configuration variables config.currency = 'AUD' - config.bot_email = 'noreply@growstuff.org' + config.bot_email = "noreply@growstuff.org" config.user_agent = 'Growstuff' - config.user_agent_email = 'info@growstuff.org' + config.user_agent_email = "info@growstuff.org" Gibbon::API.api_key = ENV['GROWSTUFF_MAILCHIMP_APIKEY'] || 'notarealkey' # API key can't be blank or tests fail diff --git a/config/environments/test.rb b/config/environments/test.rb index b3f6b46d5..bf4135f64 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -20,7 +20,7 @@ Growstuff::Application.configure do # Configure static asset server for tests with Cache-Control for performance config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching config.consider_all_requests_local = true @@ -53,7 +53,7 @@ Growstuff::Application.configure do end config.after_initialize do - require 'active_merchant/ext/paypal_bogus_gateway' + require "active_merchant/ext/paypal_bogus_gateway" ActiveMerchant::Billing::Base.mode = :test ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new @@ -63,7 +63,7 @@ end Geocoder.configure(lookup: :test) Geocoder::Lookup::Test.add_stub( - 'Amundsen-Scott Base, Antarctica', [ + "Amundsen-Scott Base, Antarctica", [ { 'latitude' => -90.0, 'longitude' => 0.0 @@ -72,7 +72,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Philippines', [ + "Philippines", [ { 'latitude' => 12.7503486, 'longitude' => 122.7312101, @@ -86,7 +86,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Greenwich, UK', [ + "Greenwich, UK", [ { 'latitude' => 51.483061, 'longitude' => -0.004151 @@ -95,7 +95,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Edinburgh', [ + "Edinburgh", [ { 'latitude' => 55.953252, 'longitude' => -3.188267 @@ -104,7 +104,7 @@ Geocoder::Lookup::Test.add_stub( ) # Unknown location -Geocoder::Lookup::Test.add_stub('Tatooine', []) +Geocoder::Lookup::Test.add_stub("Tatooine", []) Capybara.configure do |config| config.always_include_port = true @@ -115,12 +115,12 @@ OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(provider: 'facebook', uid: '123545', info: { - name: 'John Testerson', + name: "John Testerson", nickname: 'JohnnyT', email: 'example.oauth.facebook@example.com', image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, credentials: { - token: 'token', - secret: 'donttell' + token: "token", + secret: "donttell" }) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 40f94b72a..ec28eb983 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -5,7 +5,7 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = 'Growstuff ' + config.mailer_sender = "Growstuff " config.secret_key = ENV['RAILS_SECRET_TOKEN'] diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index a16483e35..afe41f574 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -4,9 +4,9 @@ Geocoder.configure( units: :km, timeout: 10, http_headers: { - 'User-Agent' => + "User-Agent" => "#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}", - 'From' => Growstuff::Application.config.user_agent_email + "From" => Growstuff::Application.config.user_agent_email } ) # This configuration takes precedence over environment/test.rb diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index f6f268bc8..3f3adf454 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1,9 +1,9 @@ Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' -Date::DATE_FORMATS[:default] = '%B %d, %Y' +Date::DATE_FORMATS[:default] = "%B %d, %Y" -Time::DATE_FORMATS[:date] = '%B %d, %Y' -Date::DATE_FORMATS[:date] = '%B %d, %Y' +Time::DATE_FORMATS[:date] = "%B %d, %Y" +Date::DATE_FORMATS[:date] = "%B %d, %Y" -Date::DATE_FORMATS[:ymd] = '%Y-%m-%d' +Date::DATE_FORMATS[:ymd] = "%Y-%m-%d" Time::DATE_FORMATS[:datetime] = '%B %d, %Y at %H:%M' diff --git a/config/routes.rb b/config/routes.rb index f4a22a2c6..f1588fa17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,10 @@ Growstuff::Application.routes.draw do resources :plant_parts devise_for :members, controllers: { - registrations: 'registrations', - passwords: 'passwords', - sessions: 'sessions', - omniauth_callbacks: 'omniauth_callbacks' + registrations: "registrations", + passwords: "passwords", + sessions: "sessions", + omniauth_callbacks: "omniauth_callbacks" } devise_scope :member do get '/members/unsubscribe/:message' => 'members#unsubscribe', as: 'unsubscribe_member' @@ -85,7 +85,7 @@ Growstuff::Application.routes.draw do resources :likes, only: %i(create destroy) - get 'home/index' + get "home/index" root to: 'home#index' get 'auth/:provider/callback' => 'authentications#create' diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index 4f891ff40..c1a0f95fd 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -4,7 +4,7 @@ if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') RVM.use_from_path! File.dirname(File.dirname(__FILE__)) rescue LoadError # RVM is unavailable at this point. - raise 'RVM ruby lib is currently unavailable.' + raise "RVM ruby lib is currently unavailable." end end diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb index 4eac342d8..cf02cbe2a 100644 --- a/db/migrate/20120903092956_devise_create_users.rb +++ b/db/migrate/20120903092956_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable - t.string :email, null: false, default: '' - t.string :encrypted_password, null: false, default: '' + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb index b338f43ef..07b1e0879 100644 --- a/db/migrate/20150201053200_add_approval_status_to_crops.rb +++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb @@ -1,5 +1,5 @@ class AddApprovalStatusToCrops < ActiveRecord::Migration def change - add_column :crops, :approval_status, :string, default: 'approved' + add_column :crops, :approval_status, :string, default: "approved" end end diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb index dce1225aa..149001927 100644 --- a/db/migrate/20171105011017_set_prediction_data.rb +++ b/db/migrate/20171105011017_set_prediction_data.rb @@ -1,8 +1,8 @@ class SetPredictionData < ActiveRecord::Migration def up - say 'Updating all plantings time to first harvest' + say "Updating all plantings time to first harvest" Planting.all.each(&:update_harvest_days) - say 'Updating crop median time to first harvest, and lifespan' + say "Updating crop median time to first harvest, and lifespan" Crop.all.each do |crop| crop.update_lifespan_medians crop.update_harvest_medians diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb index ed099382c..8054ba9cd 100644 --- a/db/migrate/20171129041341_create_photographings.rb +++ b/db/migrate/20171129041341_create_photographings.rb @@ -18,19 +18,19 @@ class CreatePhotographings < ActiveRecord::Migration end def migrate_data - say 'migrating garden photos' + say "migrating garden photos" GardensPhoto.all.each do |g| Photographing.create! photo_id: g.photo_id, photographable_id: g.garden_id, photographable_type: 'Garden' end - say 'migrating planting photos' + say "migrating planting photos" PhotosPlanting.all.each do |p| Photographing.create! photo_id: p.photo_id, photographable_id: p.planting_id, photographable_type: 'Planting' end - say 'migrating harvest photos' + say "migrating harvest photos" HarvestsPhoto.all.each do |h| Photographing.create! photo_id: h.photo_id, photographable_id: h.harvest_id, photographable_type: 'Harvest' end - say 'migrating seed photos' + say "migrating seed photos" PhotosSeed.all.each do |s| Photographing.create! photo_id: s.photo_id, photographable_id: s.seed_id, photographable_type: 'Seed' end diff --git a/db/seeds.rb b/db/seeds.rb index 637467ee3..be885a352 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -23,7 +23,7 @@ def load_data end end - puts 'Done!' + puts "Done!" end def load_crops @@ -34,39 +34,39 @@ def load_crops CsvImporter.new.import_crop(row) end end - puts 'Finished loading crops' + puts "Finished loading crops" end def load_roles - puts 'Creating admin role...' + puts "Creating admin role..." @admin = Role.create(name: 'Admin') - puts 'Creating crop wrangler role...' + puts "Creating crop wrangler role..." @wrangler = Role.create(name: 'Crop Wrangler') end def load_basic_account_types puts "Adding 'free' and 'staff' account types..." AccountType.create!( - name: 'Free', + name: "Free", is_paid: false, is_permanent_paid: false ) AccountType.create!( - name: 'Staff', + name: "Staff", is_paid: true, is_permanent_paid: true ) end def load_test_users # rubocop:disable Metrics/AbcSize - puts 'Loading test users...' + puts "Loading test users..." # Open suburb csv source_path = Rails.root.join('db', 'seeds') begin suburb_file = File.open("#{source_path}/suburbs.csv") rescue StandardError - puts 'Warning: unable to open suburbs.csv' + puts "Warning: unable to open suburbs.csv" end # rake parameter (eg. 'rake db:seed member_size=10') @@ -105,15 +105,15 @@ def load_test_users # rubocop:disable Metrics/AbcSize ) end - puts 'Finished loading test users' + puts "Finished loading test users" end def load_admin_users - puts 'Adding admin and crop wrangler members...' + puts "Adding admin and crop wrangler members..." @admin_user = Member.new( - login_name: 'admin1', - email: 'admin1@example.com', - password: 'password1', + login_name: "admin1", + email: "admin1@example.com", + password: "password1", tos_agreement: true ) @admin_user.skip_confirmation! @@ -121,9 +121,9 @@ def load_admin_users @admin_user.save! @wrangler_user = Member.new( - login_name: 'wrangler1', - email: 'wrangler1@example.com', - password: 'password1', + login_name: "wrangler1", + email: "wrangler1@example.com", + password: "password1", tos_agreement: true ) @wrangler_user.skip_confirmation! @@ -133,7 +133,7 @@ end def create_cropbot @cropbot_user = Member.new( - login_name: 'cropbot', + login_name: "cropbot", email: Growstuff::Application.config.bot_email, password: SecureRandom.urlsafe_base64(64), tos_agreement: true @@ -141,43 +141,43 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: 'Staff') + @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") @cropbot_user.account.save end def load_paid_account_types puts "Adding 'paid' and 'seed' account types..." @paid_account = AccountType.create!( - name: 'Paid', + name: "Paid", is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.create!( - name: 'Seed', + name: "Seed", is_paid: true, is_permanent_paid: true ) end def load_products - puts 'Adding products...' + puts "Adding products..." Product.create!( - name: 'Annual subscription', - description: 'Paid account, 1 year', + name: "Annual subscription", + description: "Paid account, 1 year", min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.create!( - name: 'Seed account', - description: 'Paid account, in perpetuity', + name: "Seed account", + description: "Paid account, in perpetuity", min_price: 15_000, account_type_id: @seed_account.id ) end def load_plant_parts - puts 'Loading plant parts...' + puts "Loading plant parts..." plant_parts = [ 'fruit', 'flower', diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index f3b22c24b..de274dc35 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -14,7 +14,7 @@ class Growstuff::OauthSignupAction m.password = Devise.friendly_token[0, 20] # First, try the nickname or friendly generate from the email - m.login_name = auth.info.nickname || auth.info.email.split('@').first.gsub(/[^A-Za-z]+/, '_').underscore + m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore # Do we have a collision with an existing account? Generate a 20 character long random name # so the user can update it later diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 8b3c670ff..03b2e3d0e 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -1,12 +1,12 @@ namespace :growstuff do - desc 'Add an admin user, by name' + desc "Add an admin user, by name" # usage: rake growstuff:admin_user name=skud task admin_user: :environment do add_role_to_member! ENV['name'], 'admin' end - desc 'Add a crop wrangler user, by name' + desc "Add a crop wrangler user, by name" # usage: rake growstuff:cropwrangler_user name=skud task cropwrangler_user: :environment do @@ -15,7 +15,7 @@ namespace :growstuff do def add_role_to_member!(login_name, role_name) unless login_name && role_name - raise 'Usage: rake growstuff:[rolename] name=[username] '\ + raise "Usage: rake growstuff:[rolename] name=[username] "\ "\n (login name is case-sensitive)\n" end member = Member.find_by!(login_name: login_name) @@ -23,23 +23,23 @@ namespace :growstuff do member.roles << role end - desc 'Upload crops from a CSV file' + desc "Upload crops from a CSV file" # usage: rake growstuff:import_crops file=filename.csv task import_crops: :environment do require 'csv' - @file = ENV['file'] or raise 'Usage: rake growstuff:import_crops file=file.csv' + @file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv" puts "Loading crops from #{@file}..." CSV.foreach(@file) do |row| CsvImporter.new.import_crop(row) end Rails.cache.delete('full_crop_hierarchy') - puts 'Finished loading crops' + puts "Finished loading crops" end - desc 'Send planting reminder email' + desc "Send planting reminder email" # usage: rake growstuff:send_planting_reminder task send_planting_reminder: :environment do @@ -58,7 +58,7 @@ namespace :growstuff do end end - desc 'Depopulate Null Island' + desc "Depopulate Null Island" # this fixes up anyone who has erroneously wound up with a 0,0 lat/long task depopulate_null_island: :environment do Member.find_each do |m| @@ -69,9 +69,9 @@ namespace :growstuff do end end - desc 'One-off tasks needed at various times and kept for posterity' + desc "One-off tasks needed at various times and kept for posterity" namespace :oneoff do - desc 'May 2013: replace any empty notification subjects with (no subject)' + desc "May 2013: replace any empty notification subjects with (no subject)" task empty_subjects: :environment do # this is inefficient as it checks every Notification, but the # site is small and there aren't many of them, so it shouldn't matter @@ -82,81 +82,81 @@ namespace :growstuff do end end - desc 'May 2013: replace any empty garden names with Garden' + desc "May 2013: replace any empty garden names with Garden" task empty_garden_names: :environment do # this is inefficient as it checks every Garden, but the # site is small and there aren't many of them, so it shouldn't matter # for this one-off script. Garden.all.each do |g| if g.name.nil? or g.name =~ /^\s*$/ - g.name = 'Garden' + g.name = "Garden" g.save end end end - desc 'June 2013: create account types and products.' + desc "June 2013: create account types and products." task setup_shop: :environment do - puts 'Adding account types...' + puts "Adding account types..." AccountType.find_or_create_by( - name: 'Free', + name: "Free", is_paid: false, is_permanent_paid: false ) @paid_account = AccountType.find_or_create_by( - name: 'Paid', + name: "Paid", is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.find_or_create_by( - name: 'Seed', + name: "Seed", is_paid: true, is_permanent_paid: true ) @staff_account = AccountType.find_or_create_by( - name: 'Staff', + name: "Staff", is_paid: true, is_permanent_paid: true ) - puts 'Adding products...' + puts "Adding products..." Product.find_or_create_by( - name: 'Annual subscription', - description: 'An annual subscription gives you access '\ - 'to paid account features for one year. Does not auto-renew.', + name: "Annual subscription", + description: "An annual subscription gives you access "\ + "to paid account features for one year. Does not auto-renew.", min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.find_or_create_by( - name: 'Seed account', - description: 'A seed account helps Growstuff grow in its '\ - 'early days. It gives you all the features of '\ - 'a paid account, in perpetuity. This account '\ - 'type never expires.', + name: "Seed account", + description: "A seed account helps Growstuff grow in its "\ + "early days. It gives you all the features of "\ + "a paid account, in perpetuity. This account "\ + "type never expires.", min_price: 15_000, account_type_id: @seed_account.id ) - puts 'Giving each member an account record...' + puts "Giving each member an account record..." Member.all.each do |m| Account.create(member_id: m.id) unless m.account end - puts 'Making Skud a staff account...' + puts "Making Skud a staff account..." @skud = Member.find_by(login_name: 'Skud') if @skud @skud.account.account_type = @staff_account @skud.account.save end - puts 'Done setting up shop.' + puts "Done setting up shop." end - desc 'June 2013: replace nil account_types with free accounts' + desc "June 2013: replace nil account_types with free accounts" task nil_account_type: :environment do - free = AccountType.find_by(name: 'Free') - raise 'Free account type not found: run rake growstuff:oneoff:setup_shop'\ + free = AccountType.find_by(name: "Free") + raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ unless free Account.all.each do |a| unless a.account_type @@ -166,7 +166,7 @@ namespace :growstuff do end end - desc 'July 2013: replace nil seed.tradable_to with nowhere' + desc "July 2013: replace nil seed.tradable_to with nowhere" task tradable_to_nowhere: :environment do Seed.all.each do |s| unless s.tradable_to @@ -176,18 +176,18 @@ namespace :growstuff do end end - desc 'August 2013: set up plantings_count cache on crop' + desc "August 2013: set up plantings_count cache on crop" task reset_crop_plantings_count: :environment do Crop.find_each do |c| Crop.reset_counters c.id, :plantings end end - desc 'August 2013: set default creator on existing crops' + desc "August 2013: set default creator on existing crops" task set_default_crop_creator: :environment do - cropbot = Member.find_by(login_name: 'cropbot') - raise 'cropbot not found: create cropbot member on site or run rake db:seed' unless cropbot - cropbot.account.account_type = AccountType.find_by(name: 'Staff') # set this just because it's nice + cropbot = Member.find_by(login_name: "cropbot") + raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot + cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice cropbot.account.save Crop.find_each do |crop| unless crop.creator @@ -203,7 +203,7 @@ namespace :growstuff do end end - desc 'August 2013: set planting owner' + desc "August 2013: set planting owner" task set_planting_owner: :environment do Planting.find_each do |p| p.owner = p.garden.owner @@ -211,14 +211,14 @@ namespace :growstuff do end end - desc 'August 2013: initialize member planting counter' + desc "August 2013: initialize member planting counter" task initialize_member_planting_count: :environment do Member.find_each do |m| Member.reset_counters m.id, :plantings end end - desc 'October 2013: set garden locations to member locations' + desc "October 2013: set garden locations to member locations" task initialize_garden_locations: :environment do Member.located.find_each do |m| m.gardens.each do |g| @@ -231,7 +231,7 @@ namespace :growstuff do end end - desc 'October 2013: import initial plant parts' + desc "October 2013: import initial plant parts" task import_plant_parts: :environment do plant_parts = [ 'fruit', @@ -252,7 +252,7 @@ namespace :growstuff do end end - desc 'July 2014: set planting_count to 0 by default, not nil' + desc "July 2014: set planting_count to 0 by default, not nil" task zero_plantings_count: :environment do Crop.find_each do |c| if c.plantings_count.nil? @@ -262,32 +262,32 @@ namespace :growstuff do end end - desc 'August 2014: fix ping to pint in database' + desc "August 2014: fix ping to pint in database" task ping_to_pint: :environment do Harvest.find_each do |h| - if h.unit == 'ping' - h.unit = 'pint' + if h.unit == "ping" + h.unit = "pint" h.save end end end - desc 'October 2014: remove unused photos' + desc "October 2014: remove unused photos" task remove_unused_photos: :environment do Photo.find_each(&:destroy_if_unused) end - desc 'October 2014: generate crops_posts records for existing posts' + desc "October 2014: generate crops_posts records for existing posts" task generate_crops_posts_records: :environment do Post.find_each(&:save) end - desc 'October 2014: add alternate names for crops' + desc "October 2014: add alternate names for crops" task add_alternate_names: :environment do require 'csv' - file = 'db/seeds/alternate_names_201410.csv' + file = "db/seeds/alternate_names_201410.csv" puts "Loading alternate names from #{file}..." - cropbot = Member.find_by(login_name: 'cropbot') + cropbot = Member.find_by(login_name: "cropbot") CSV.foreach(file) do |row| _crop_id, crop_name, alternate_names = row next if alternate_names.blank? @@ -305,7 +305,7 @@ namespace :growstuff do end end - desc 'January 2015: fill in si_weight column' + desc "January 2015: fill in si_weight column" task populate_si_weight: :environment do Harvest.find_each do |h| h.set_si_weight @@ -313,7 +313,7 @@ namespace :growstuff do end end - desc 'January 2015: build Elasticsearch index' + desc "January 2015: build Elasticsearch index" task elasticsearch_create_index: :environment do Crop.__elasticsearch__.create_index! force: true Crop.import diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake index 07113f935..7543404b2 100644 --- a/lib/tasks/hooks.rake +++ b/lib/tasks/hooks.rake @@ -1,4 +1,4 @@ -desc 'Install git hooks' +desc "Install git hooks" task :hooks do FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', force: true diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index 4ed2ae2ee..04fa8001b 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -1,10 +1,10 @@ namespace :i18n do - desc 'sort all i18n locale keys' + desc "sort all i18n locale keys" task :normalize do `i18n-tasks normalize` end - desc 'translate haml strings into i18 en locale using haml-i18n-extractor' + desc "translate haml strings into i18 en locale using haml-i18n-extractor" task :extractor, [:haml_path] do |_t, args| require 'haml-i18n-extractor' haml_path = args[:haml_path] diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 7ab937e27..1120f6ca9 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -10,13 +10,13 @@ begin rescue LoadError end -desc 'Run static code-quality checks' +desc "Run static code-quality checks" task :static do system('script/check_static') end namespace :spec do - desc 'Run only unit tests' + desc "Run only unit tests" task unit: ['jasmine:ci'] do suites = %w(controllers helpers lib mailers models requests routing views) system('rspec', *suites.collect { |s| "spec/#{s}" }) diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb index 375d03117..d2a20d67a 100755 --- a/script/heroku_maintenance.rb +++ b/script/heroku_maintenance.rb @@ -13,9 +13,9 @@ else end case ARGV[0] -when 'on' +when "on" maintenance_state = true -when 'off' +when "off" maintenance_state = false else abort "usage: #{$PROGRAM_NAME} (on|off)" diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index a63890bf3..2b4222f1d 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -4,7 +4,7 @@ describe AccountsController do login_member(:admin_member) def valid_attributes - { 'paid_until' => Time.now } + { "paid_until" => Time.now } end def create_account diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index 0a23dd88a..fb475b34c 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' describe Admin::OrdersController do login_member(:admin_member) - describe 'GET search' do - it 'assigns @orders' do + describe "GET search" do + it "assigns @orders" do order = FactoryBot.create(:order) get :search, search_by: 'order_id', search_text: order.id assigns(:orders).should eq([order]) end - it 'sets an error message if nothing found' do + it "sets an error message if nothing found" do get :search, search_by: 'order_id', search_text: 'foo' flash[:alert].should have_text "Couldn't find order with" end diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index e123b2b02..9f134bbab 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe AdminController do login_member(:admin_member) - describe 'GET admin/newsletter' do + describe "GET admin/newsletter" do it 'fetches the admin newsletter page' do get :newsletter response.should be_success - response.should render_template('admin/newsletter') + response.should render_template("admin/newsletter") end it 'assigns @members' do diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index 288e652b3..daa50a811 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -5,13 +5,13 @@ describe Charts::GardensController do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context 'when not signed in' do + context "when not signed in" do describe 'GET timeline' do before { get :timeline, garden_id: garden.to_param } it { expect(response).to be_success } end end - context 'when signed in' do + context "when signed in" do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index c705917ce..2d265de5f 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -11,106 +11,106 @@ describe CommentsController do def valid_attributes @post = FactoryBot.create(:post) - { post_id: @post.id, body: 'some text' } + { post_id: @post.id, body: "some text" } end - describe 'GET RSS feed' do + describe "GET RSS feed" do let!(:first_comment) { FactoryBot.create :comment, created_at: 10.days.ago } let!(:last_comment) { FactoryBot.create :comment, created_at: 4.minutes.ago } - describe 'returns an RSS feed' do - before { get :index, format: 'rss' } + describe "returns an RSS feed" do + before { get :index, format: "rss" } it { is_expected.to be_success } - it { is_expected.to render_template('comments/index') } - it { expect(response.content_type).to eq('application/rss+xml') } + it { is_expected.to render_template("comments/index") } + it { expect(response.content_type).to eq("application/rss+xml") } it { expect(assigns(:comments)).to eq([last_comment, first_comment]) } end end - describe 'GET new' do + describe "GET new" do let(:post) { FactoryBot.create(:post) } - describe 'with valid params' do + describe "with valid params" do before { get :new, post_id: post.id } - it 'picks up post from params' do + it "picks up post from params" do assigns(:post).should eq(post) end let(:old_comment) { FactoryBot.create(:comment, post: post) } - it 'assigns the old comments as @comments' do + it "assigns the old comments as @comments" do assigns(:comments).should eq [old_comment] end end - it 'dies if no post specified' do + it "dies if no post specified" do get :new expect(response).not_to be_success end end - describe 'GET edit' do + describe "GET edit" do let(:post) { FactoryBot.create(:post) } before { get :edit, id: comment.to_param } - describe 'my comment' do + describe "my comment" do let!(:comment) { FactoryBot.create :comment, author: member, post: post } let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) } - it 'assigns previous comments as @comments' do + it "assigns previous comments as @comments" do expect(assigns(:comments)).to eq([comment, old_comment]) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment, post: post } it { expect(response).not_to be_success } end end - describe 'PUT update' do + describe "PUT update" do before { put :update, id: comment.to_param, comment: valid_attributes } - describe 'my comment' do + describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } it "redirects to the comment's post" do expect(response).to redirect_to(comment.post) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } end - describe 'attempting to change post_id' do + describe "attempting to change post_id" do let(:post) { FactoryBot.create :post, subject: 'our post' } let(:other_post) { FactoryBot.create :post, subject: 'the other post' } - let(:valid_attributes) { { post_id: other_post.id, body: 'kōrero' } } + let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } } let(:comment) { FactoryBot.create :comment, author: member, post: post } - it 'does not change post_id' do + it "does not change post_id" do comment.reload expect(comment.post_id).to eq(post.id) end end end - describe 'DELETE destroy' do + describe "DELETE destroy" do before { delete :destroy, id: comment.to_param } - describe 'my comment' do + describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } - it 'redirects to the post the comment was on' do + it "redirects to the post the comment was on" do expect(response).to redirect_to(comment.post) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index ab6aaced4..5b682f6c2 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -5,7 +5,7 @@ describe CropsController do def valid_attributes { - name: 'Tomato', + name: "Tomato", en_wikipedia_url: 'http://en.wikipedia.org/wiki/Tomato', approval_status: 'approved' } @@ -13,37 +13,37 @@ describe CropsController do subject { response } - describe 'GET crop wrangler homepage' do + describe "GET crop wrangler homepage" do describe 'fetches the crop wrangler homepage' do before { get :wrangle } it { is_expected.to be_success } - it { is_expected.to render_template('crops/wrangle') } + it { is_expected.to render_template("crops/wrangle") } it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) } end end - describe 'GET crop hierarchy ' do + describe "GET crop hierarchy " do describe 'fetches the crop hierarchy page' do before { get :hierarchy } it { is_expected.to be_success } - it { is_expected.to render_template('crops/hierarchy') } + it { is_expected.to render_template("crops/hierarchy") } end end - describe 'GET crop search' do + describe "GET crop search" do describe 'fetches the crop search page' do before { get :search } it { is_expected.to be_success } - it { is_expected.to render_template('crops/search') } + it { is_expected.to render_template("crops/search") } end end - describe 'GET RSS feed' do - describe 'returns an RSS feed' do - before { get :index, format: 'rss' } + describe "GET RSS feed" do + describe "returns an RSS feed" do + before { get :index, format: "rss" } it { is_expected.to be_success } - it { is_expected.to render_template('crops/index') } - it { expect(response.content_type).to eq('application/rss+xml') } + it { is_expected.to render_template("crops/index") } + it { expect(response.content_type).to eq("application/rss+xml") } end end end diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index 995c4aabd..5c59473cb 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -5,9 +5,9 @@ describe ForumsController do def valid_attributes { - 'name' => 'MyString', - 'description' => 'Something', - 'owner_id' => 1 + "name" => "MyString", + "description" => "Something", + "owner_id" => 1 } end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 4d4c77d8e..2e31f2d78 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -5,7 +5,7 @@ RSpec.describe GardensController, type: :controller do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context 'when not signed in' do + context "when not signed in" do describe 'GET new' do before { get :new, id: garden.to_param } it { expect(response).to redirect_to(new_member_session_path) } @@ -37,7 +37,7 @@ RSpec.describe GardensController, type: :controller do end end end - context 'when signed in' do + context "when signed in" do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 1dbdfe431..705f954b5 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -12,7 +12,7 @@ describe HarvestsController do } end - describe 'GET index' do + describe "GET index" do let(:member1) { FactoryBot.create(:member) } let(:member2) { FactoryBot.create(:member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -20,7 +20,7 @@ describe HarvestsController do let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } - describe 'assigns all harvests as @harvests' do + describe "assigns all harvests as @harvests" do before { get :index, {} } it { assigns(:harvests).should =~ [harvest1, harvest2] } end @@ -31,68 +31,68 @@ describe HarvestsController do it { expect(assigns(:harvests)).to eq [harvest1] } end - describe 'picks up crop from params and shows the harvests for the crop only' do + describe "picks up crop from params and shows the harvests for the crop only" do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:harvests)).to eq [harvest2] } end - describe 'generates a csv' do - before { get :index, format: 'csv' } + describe "generates a csv" do + before { get :index, format: "csv" } it { expect(response.status).to eq 200 } end end - describe 'GET show' do + describe "GET show" do let(:harvest) { Harvest.create! valid_attributes } - describe 'assigns the requested harvest as @harvest' do + describe "assigns the requested harvest as @harvest" do before { get :show, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe 'GET new' do + describe "GET new" do before { get :new, {} } - describe 'assigns a new harvest as @harvest' do + describe "assigns a new harvest as @harvest" do it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - describe 'sets the date of the harvest to today' do + describe "sets the date of the harvest to today" do it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end - describe 'GET edit' do + describe "GET edit" do let(:harvest) { Harvest.create! valid_attributes } - describe 'assigns the requested harvest as @harvest' do + describe "assigns the requested harvest as @harvest" do before { get :edit, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe 'POST create' do - describe 'with valid params' do - it 'creates a new Harvest' do + describe "POST create" do + describe "with valid params" do + it "creates a new Harvest" do expect do post :create, harvest: valid_attributes end.to change(Harvest, :count).by(1) end - it 'assigns a newly created harvest as @harvest' do + it "assigns a newly created harvest as @harvest" do post :create, harvest: valid_attributes assigns(:harvest).should be_a(Harvest) assigns(:harvest).should be_persisted end - it 'redirects to the created harvest' do + it "redirects to the created harvest" do post :create, harvest: valid_attributes response.should redirect_to(Harvest.last) end - describe 'links to planting' do + describe "links to planting" do let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } @@ -100,26 +100,26 @@ describe HarvestsController do end end - describe 'with invalid params' do - it 'assigns a newly created but unsaved harvest as @harvest' do + describe "with invalid params" do + it "assigns a newly created but unsaved harvest as @harvest" do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - post :create, harvest: { 'crop_id' => 'invalid value' } + post :create, harvest: { "crop_id" => "invalid value" } assigns(:harvest).should be_a_new(Harvest) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted - post :create, harvest: { 'crop_id' => 'invalid value' } - response.should render_template('new') + post :create, harvest: { "crop_id" => "invalid value" } + response.should render_template("new") end end - describe 'not my planting' do + describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe 'does not save planting_id' do + describe "does not save planting_id" do before do allow(Harvest).to receive(:new).and_return(harvest) post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -129,52 +129,52 @@ describe HarvestsController do end end - describe 'PUT update' do - describe 'with valid params' do - it 'updates the requested harvest' do + describe "PUT update" do + describe "with valid params" do + it "updates the requested harvest" do harvest = Harvest.create! valid_attributes # Assuming there are no other harvests in the database, this # specifies that the Harvest created on the previous line # receives the :update message with whatever params are # submitted in the request. - Harvest.any_instance.should_receive(:update).with('crop_id' => '1', "owner_id": member.id) - put :update, id: harvest.to_param, harvest: { 'crop_id' => '1' } + Harvest.any_instance.should_receive(:update).with("crop_id" => "1", "owner_id": member.id) + put :update, id: harvest.to_param, harvest: { "crop_id" => "1" } end - it 'assigns the requested harvest as @harvest' do + it "assigns the requested harvest as @harvest" do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes assigns(:harvest).should eq(harvest) end - it 'redirects to the harvest' do + it "redirects to the harvest" do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes response.should redirect_to(harvest) end end - describe 'with invalid params' do - it 'assigns the harvest as @harvest' do + describe "with invalid params" do + it "assigns the harvest as @harvest" do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } + put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } assigns(:harvest).should eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes - put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } - response.should render_template('edit') + put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } + response.should render_template("edit") end end - describe 'not my planting' do + describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe 'does not save planting_id' do + describe "does not save planting_id" do before do put :update, id: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -184,15 +184,15 @@ describe HarvestsController do end end - describe 'DELETE destroy' do - it 'destroys the requested harvest' do + describe "DELETE destroy" do + it "destroys the requested harvest" do harvest = Harvest.create! valid_attributes expect do delete :destroy, id: harvest.to_param end.to change(Harvest, :count).by(-1) end - it 'redirects to the harvests list' do + it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes delete :destroy, id: harvest.to_param response.should redirect_to(harvests_url) diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 44615dbd2..cb12b2bb4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' describe HomeController do - describe 'GET index' do + describe "GET index" do end end diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 6ed93b136..a80fc0d56 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -8,36 +8,36 @@ describe LikesController do before { sign_in member } - describe 'POST create' do - it { expect(response.content_type).to eq 'application/json' } + describe "POST create" do + it { expect(response.content_type).to eq "application/json" } before { post :create, post_id: blogpost.id, format: :json } it { expect(Like.last.likeable_id).to eq(blogpost.id) } it { expect(Like.last.likeable_type).to eq('Post') } - it { JSON.parse(response.body)['description'] == '1 like' } + it { JSON.parse(response.body)["description"] == "1 like" } describe "Liking someone else's post" do it { expect(response.code).to eq('201') } end - describe 'Liking your own post' do + describe "Liking your own post" do let(:blogpost) { FactoryBot.create(:post, author: member) } end end - describe 'DELETE destroy' do + describe "DELETE destroy" do before { delete :destroy, id: like.id, format: :json } - it { expect(response.content_type).to eq 'application/json' } + it { expect(response.content_type).to eq "application/json" } - describe 'un-liking something i liked before' do + describe "un-liking something i liked before" do it { expect(response.code).to eq('200') } - it { JSON.parse(response.body)['description'] == '0 likes' } + it { JSON.parse(response.body)["description"] == "0 likes" } end describe "Deleting someone else's like" do let(:like) { FactoryBot.create :like } it { expect(response.code).to eq('403') } - it { JSON.parse(response.body)['error'] == 'Unable to like' } + it { JSON.parse(response.body)["error"] == "Unable to like" } end end end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 9be56ccfd..14ba85e08 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -8,22 +8,22 @@ describe MembersController do @flickr_auth = FactoryBot.create(:flickr_authentication, member: @member) end - describe 'GET index' do - it 'assigns only confirmed members as @members' do + describe "GET index" do + it "assigns only confirmed members as @members" do get :index, {} assigns(:members).should eq([@member]) end end - describe 'GET JSON index' do - it 'provides JSON for members' do + describe "GET JSON index" do + it "provides JSON for members" do get :index, format: 'json' response.should be_success end end - describe 'GET show' do - it 'provides JSON for member profile' do + describe "GET show" do + it "provides JSON for member profile" do get :show, id: @member.id, format: 'json' response.should be_success end @@ -33,12 +33,12 @@ describe MembersController do assigns(:posts).should eq(@posts) end - it 'assigns @twitter_auth' do + it "assigns @twitter_auth" do get :show, id: @member.id assigns(:twitter_auth).should eq(@twitter_auth) end - it 'assigns @flickr_auth' do + it "assigns @flickr_auth" do get :show, id: @member.id assigns(:flickr_auth).should eq(@flickr_auth) end @@ -54,11 +54,11 @@ describe MembersController do end describe "GET member's RSS feed" do - it 'returns an RSS feed' do - get :show, id: @member.to_param, format: 'rss' + it "returns an RSS feed" do + get :show, id: @member.to_param, format: "rss" response.should be_success - response.should render_template('members/show') - response.content_type.should eq('application/rss+xml') + response.should render_template("members/show") + response.content_type.should eq("application/rss+xml") end end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 8340ac4fb..fd6f40aa1 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -5,9 +5,9 @@ describe NotificationsController do def valid_attributes { - 'recipient_id' => subject.current_member.id, - 'sender_id' => FactoryBot.create(:member).id, - 'subject' => 'test' + "recipient_id" => subject.current_member.id, + "sender_id" => FactoryBot.create(:member).id, + "subject" => 'test' } end @@ -18,9 +18,9 @@ describe NotificationsController do # attributes. def valid_attributes_for_sender { - 'sender_id' => subject.current_member.id, - 'recipient_id' => FactoryBot.create(:member).id, - 'subject' => 'test' + "sender_id" => subject.current_member.id, + "recipient_id" => FactoryBot.create(:member).id, + "subject" => 'test' } end @@ -28,22 +28,22 @@ describe NotificationsController do {} end - describe 'GET index' do - it 'assigns all notifications as @notifications' do + describe "GET index" do + it "assigns all notifications as @notifications" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :index, {} assigns(:notifications).should eq([notification]) end end - describe 'GET show' do - it 'assigns the requested notification as @notification' do + describe "GET show" do + it "assigns the requested notification as @notification" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param assigns(:notification).should eq(notification) end - it 'assigns the reply link for a post comment' do + it "assigns the reply link for a post comment" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param @@ -53,7 +53,7 @@ describe NotificationsController do ) end - it 'marks notifications as read' do + it "marks notifications as read" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -62,8 +62,8 @@ describe NotificationsController do end end - describe 'GET reply' do - it 'marks notifications as read' do + describe "GET reply" do + it "marks notifications as read" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :reply, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -72,16 +72,16 @@ describe NotificationsController do end end - describe 'GET new' do - it 'assigns a recipient' do + describe "GET new" do + it "assigns a recipient" do @recipient = FactoryBot.create(:member) get :new, recipient_id: @recipient.id assigns(:recipient).should be_an_instance_of(Member) end end - describe 'POST create' do - describe 'with valid params' do + describe "POST create" do + describe "with valid params" do it "redirects to the recipient's profile" do @recipient = FactoryBot.create(:member) post :create, notification: { recipient_id: @recipient.id, subject: 'foo' } diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 08203c852..4de8eb98d 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -16,8 +16,8 @@ describe OrderItemsController do context 'signed in' do before { sign_in member } - describe 'POST create' do - describe 'redirects to order' do + describe "POST create" do + describe "redirects to order" do before do post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } end @@ -36,8 +36,8 @@ describe OrderItemsController do end end - describe 'with non-int price' do - it 'converts 3.33 to 333 cents' do + describe "with non-int price" do + it "converts 3.33 to 333 cents" do order = FactoryBot.create(:order, member: member) product = FactoryBot.create(:product, min_price: 1) expect do diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index ef792ab69..3c6631d8c 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -4,14 +4,14 @@ describe OrdersController do login_member(:admin_member) def valid_attributes - { 'member_id' => 1 } + { "member_id" => 1 } end def valid_session {} end - describe 'GET checkout' do + describe "GET checkout" do it 'sets the referral_code' do member = FactoryBot.create(:member) sign_in member @@ -21,7 +21,7 @@ describe OrdersController do order.referral_code.should eq 'FOOBAR' end - it 'redirects to Paypal' do + it "redirects to Paypal" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -31,8 +31,8 @@ describe OrdersController do end end - describe 'GET complete' do - it 'assigns the requested order as @order' do + describe "GET complete" do + it "assigns the requested order as @order" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -41,8 +41,8 @@ describe OrdersController do end end - describe 'DELETE destroy' do - it 'redirects to the shop' do + describe "DELETE destroy" do + it "redirects to the shop" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index 30c629576..f021d5aa8 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe PhotoAssociationsController do login_member - describe 'destroy' do + describe "destroy" do let(:valid_params) do { id: harvest.id, @@ -14,11 +14,11 @@ describe PhotoAssociationsController do before { photo.harvests << harvest } - describe 'my harvest my photo' do + describe "my harvest my photo" do let(:harvest) { FactoryBot.create :harvest, owner: member } let(:photo) { FactoryBot.create :photo, owner: member } - it 'removes link' do + it "removes link" do expect { delete :destroy, valid_params }.to change { photo.harvests.count }.by(-1) end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index ce5c71b66..76869ebf3 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -8,13 +8,13 @@ describe PhotosController do def valid_attributes member = FactoryBot.create(:member) { - 'owner_id' => member.id, - 'flickr_photo_id' => 1, - 'title' => 'Photo', - 'license_name' => 'CC-BY', - 'thumbnail_url' => 'http://example.com/thumb.jpg', - 'fullsize_url' => 'http://example.com/full.jpg', - 'link_url' => 'http://example.com' + "owner_id" => member.id, + "flickr_photo_id" => 1, + "title" => "Photo", + "license_name" => "CC-BY", + "thumbnail_url" => 'http://example.com/thumb.jpg', + "fullsize_url" => 'http://example.com/full.jpg', + "link_url" => 'http://example.com' } end @@ -22,7 +22,7 @@ describe PhotosController do {} end - describe 'GET new' do + describe "GET new" do let(:tomato) { FactoryBot.create(:tomato) } let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -33,39 +33,39 @@ describe PhotosController do before(:each) do sign_in member member.stub(:flickr_photos) { [[], 0] } - member.stub(:flickr_sets) { { 'foo' => 'bar' } } + member.stub(:flickr_sets) { { "foo" => "bar" } } controller.stub(:current_member) { member } end - describe 'planting photos' do - before(:each) { get :new, type: 'planting', id: planting.id } + describe "planting photos" do + before(:each) { get :new, type: "planting", id: planting.id } it { assigns(:flickr_auth).should be_an_instance_of(Authentication) } it { assigns(:item).should eq planting } it { expect(flash[:alert]).not_to be_present } it { expect(flash[:alert]).not_to be_present } end - describe 'harvest photos' do - before { get :new, type: 'harvest', id: harvest.id } + describe "harvest photos" do + before { get :new, type: "harvest", id: harvest.id } it { assigns(:item).should eq harvest } it { expect(flash[:alert]).not_to be_present } end - describe 'garden photos' do - before { get :new, type: 'garden', id: garden.id } + describe "garden photos" do + before { get :new, type: "garden", id: garden.id } it { assigns(:item).should eq garden } it { expect(flash[:alert]).not_to be_present } end end - describe 'POST create' do + describe "POST create" do before(:each) do - Photo.any_instance.stub(:flickr_metadata).and_return(title: 'A Heartbreaking work of staggering genius', - license_name: 'CC-BY', - license_url: 'http://example.com/aybpl', - thumbnail_url: 'http://example.com/thumb.jpg', - fullsize_url: 'http://example.com/full.jpg', - link_url: 'http://example.com') + Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", + thumbnail_url: "http://example.com/thumb.jpg", + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com") end let(:member) { FactoryBot.create(:member) } @@ -74,32 +74,32 @@ describe PhotosController do let(:harvest) { FactoryBot.create(:harvest, owner: member) } let(:photo) { FactoryBot.create(:photo, owner: member) } - describe 'with valid params' do + describe "with valid params" do before { controller.stub(:current_member) { member } } - it 'attaches the photo to a planting' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + it "attaches the photo to a planting" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end describe "doesn't attach a photo to a planting twice" do before do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id end it { expect(flash[:alert]).not_to be_present } it { expect(Photo.last.plantings.size).to eq 1 } end - it 'attaches the photo to a harvest' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + it "attaches the photo to a harvest" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end it "doesn't attach a photo to a harvest twice" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.size.should eq 1 end @@ -107,15 +107,15 @@ describe PhotosController do it "doesn't attach photo to a comment" do comment = FactoryBot.create(:comment) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'comment', id: comment.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id end.to raise_error end end - describe 'for the second time' do + describe "for the second time" do let(:planting) { FactoryBot.create :planting, owner: member } - it 'does not add a photo twice' do + it "does not add a photo twice" do expect do post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' end.to change(Photo, :count).by(1) @@ -125,40 +125,40 @@ describe PhotosController do end end - describe 'with matching owners' do + describe "with matching owners" do before { controller.stub(:current_member) { member } } - it 'creates the planting/photo link' do + it "creates the planting/photo link" do planting = FactoryBot.create(:planting, garden: garden, owner: member) photo = FactoryBot.create(:photo, owner: member) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end - it 'creates the harvest/photo link' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + it "creates the harvest/photo link" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end end - describe 'with mismatched owners' do + describe "with mismatched owners" do let(:photo) { FactoryBot.create(:photo) } - it 'does not create the planting/photo link' do + it "does not create the planting/photo link" do # members will be auto-created, and different another_planting = FactoryBot.create(:planting) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: another_planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.plantings.first.should_not eq another_planting end - it 'does not create the harvest/photo link' do + it "does not create the harvest/photo link" do # members will be auto-created, and different another_harvest = FactoryBot.create(:harvest) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: another_harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.harvests.first.should_not eq another_harvest end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 761334e43..8b6cb0a31 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -5,27 +5,27 @@ describe PlacesController do controller.stub(:current_member) { nil } end - describe 'GET show' do + describe "GET show" do before(:each) do @member_london = FactoryBot.create(:london_member) @member_south_pole = FactoryBot.create(:south_pole_member) end - it 'assigns place name' do + it "assigns place name" do get :show, place: @member_london.location assigns(:place).should eq @member_london.location end - it 'assigns nearby members' do + it "assigns nearby members" do get :show, place: @member_london.location assigns(:nearby_members).should eq [@member_london, @member_south_pole] end end - describe 'GET search' do - it 'redirects to the new place' do - get :search, new_place: 'foo' - response.should redirect_to place_path('foo') + describe "GET search" do + it "redirects to the new place" do + get :search, new_place: "foo" + response.should redirect_to place_path("foo") end end end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index bdfdfc2bf..abe5ea626 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -10,7 +10,7 @@ describe PlantingsController do } end - describe 'GET index' do + describe "GET index" do let!(:member1) { FactoryBot.create(:member) } let!(:member2) { FactoryBot.create(:member) } let!(:tomato) { FactoryBot.create(:tomato) } @@ -18,7 +18,7 @@ describe PlantingsController do let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - describe 'assigns all plantings as @plantings' do + describe "assigns all plantings as @plantings" do before { get :index, {} } it { expect(assigns(:plantings)).to match [planting1, planting2] } end @@ -29,15 +29,15 @@ describe PlantingsController do it { expect(assigns(:plantings)).to eq [planting1] } end - describe 'picks up crop from params and shows the plantings for the crop only' do + describe "picks up crop from params and shows the plantings for the crop only" do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:plantings)).to eq [planting2] } end end - describe 'GET new' do - describe 'picks up crop from params' do + describe "GET new" do + describe "picks up crop from params" do let(:crop) { FactoryBot.create(:crop) } before { get :new, crop_id: crop.id } @@ -85,12 +85,12 @@ describe PlantingsController do it { expect(assigns(:garden)).to be_a_new(Garden) } end - describe 'sets the date of the planting to today' do + describe "sets the date of the planting to today" do before { get :new, {} } it { expect(assigns(:planting).planted_at).to eq Time.zone.today } end - describe 'sets the owner automatically' do + describe "sets the owner automatically" do before { post :create, planting: valid_attributes } it { expect(assigns(:planting).owner).to eq subject.current_member } end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 4c2aadf28..cbfe8b46c 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -5,25 +5,25 @@ describe PostsController do def valid_attributes member = FactoryBot.create(:member) - { author_id: member.id, subject: 'blah', body: 'blah blah' } + { author_id: member.id, subject: "blah", body: "blah blah" } end - describe 'GET RSS feed' do - it 'returns an RSS feed' do - get :index, format: 'rss' + describe "GET RSS feed" do + it "returns an RSS feed" do + get :index, format: "rss" response.should be_success - response.should render_template('posts/index') - response.content_type.should eq('application/rss+xml') + response.should render_template("posts/index") + response.content_type.should eq("application/rss+xml") end end - describe 'GET RSS feed for individual post' do - it 'returns an RSS feed' do + describe "GET RSS feed for individual post" do + it "returns an RSS feed" do post = Post.create! valid_attributes - get :show, format: 'rss', id: post.slug + get :show, format: "rss", id: post.slug response.should be_success - response.should render_template('posts/show') - response.content_type.should eq('application/rss+xml') + response.should render_template("posts/show") + response.content_type.should eq("application/rss+xml") end end end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 4e28e70c3..173ef9ba4 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -5,7 +5,7 @@ describe ProductsController do def valid_attributes { - name: 'product name', + name: "product name", description: 'some description', min_price: 9.99 } diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 210357fa8..015bbb705 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -8,19 +8,19 @@ describe RegistrationsController do controller.stub(:devise_mapping).and_return(Devise.mappings[:member]) end - describe 'GET edit' do - it 'assigns the requested member as @member' do + describe "GET edit" do + it "assigns the requested member as @member" do get :edit assigns(:member).should eq(@member) end - it 'picks up the twitter auth' do + it "picks up the twitter auth" do @auth = FactoryBot.create(:authentication, member: @member) get :edit assigns(:twitter_auth).should eq @auth end - it 'picks up the flickr auth' do + it "picks up the flickr auth" do @auth = FactoryBot.create(:flickr_authentication, member: @member) get :edit assigns(:flickr_auth).should eq @auth diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index 8901c8d61..9bf0ea1b5 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -2,13 +2,13 @@ require 'rails_helper' describe RolesController do def valid_attributes - { 'name' => 'MyString' } + { "name" => "MyString" } end login_member(:admin_member) - describe 'GET index' do - it 'assigns all roles as @roles' do + describe "GET index" do + it "assigns all roles as @roles" do role = Role.create! valid_attributes get :index, {} # note that admin role exists because of login_admin_member diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index bd2da752c..412f53224 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -11,8 +11,8 @@ describe ScientificNamesController do { name: 'Solanum lycopersicum', crop_id: @crop.id } end - describe 'GET new' do - it 'assigns crop if specified' do + describe "GET new" do + it "assigns crop if specified" do get :new, crop_id: 1 assigns(:crop).should be_an_instance_of Crop end diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 4c73a1d49..c2fd699eb 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe SeedsController do - describe 'GET index' do - it 'picks up owner from params' do + describe "GET index" do + it "picks up owner from params" do owner = FactoryBot.create(:member) get :index, owner: owner.slug assigns(:owner).should eq(owner) diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 0b5931ec9..2fc6b77f7 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -4,15 +4,15 @@ describe ShopController do let!(:product1) { FactoryBot.create(:product, name: 'aaa') } let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - describe 'GET index' do + describe "GET index" do describe 'not logged in' do before { get :index, {} } - describe 'assigns all products as @products ordered by name' do + describe "assigns all products as @products ordered by name" do it { expect(assigns(:products)).to eq([product1, product2]) } end - describe 'assigns a new @order_item to build forms' do + describe "assigns a new @order_item to build forms" do it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } end @@ -21,7 +21,7 @@ describe ShopController do end end describe 'logged in' do - describe 'assigns @order as current_order if there is one' do + describe "assigns @order as current_order if there is one" do let(:member) { FactoryBot.create(:member) } let!(:order) { FactoryBot.create(:order, member: member) } diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb index ccd8aa0c6..66717492f 100644 --- a/spec/factories/account_types.rb +++ b/spec/factories/account_types.rb @@ -7,25 +7,25 @@ FactoryBot.define do is_permanent_paid false factory :free_account_type do - name 'Free' + name "Free" is_paid false is_permanent_paid false end factory :paid_account_type do - name 'Paid' + name "Paid" is_paid true is_permanent_paid false end factory :permanent_paid_account_type do - name 'Permanent paid' + name "Permanent paid" is_paid true is_permanent_paid true end factory :staff_account_type do - name 'Staff' + name "Staff" is_paid true is_permanent_paid true end diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb index 95db4a7c2..32c609cc3 100644 --- a/spec/factories/alternate_names.rb +++ b/spec/factories/alternate_names.rb @@ -2,13 +2,13 @@ FactoryBot.define do factory :alternate_name do - name 'alternate name' + name "alternate name" crop creator factory :alternate_eggplant do association :crop, factory: :eggplant - name 'aubergine' + name "aubergine" end end end diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index 221023fd2..2a8c6b656 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :crop do - name 'magic bean' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Magic_bean' - approval_status 'approved' + name "magic bean" + en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean" + approval_status "approved" creator factory :annual_crop, parent: :crop do @@ -13,71 +13,71 @@ FactoryBot.define do end factory :tomato do - name 'tomato' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Tomato' + name "tomato" + en_wikipedia_url "http://en.wikipedia.org/wiki/Tomato" end factory :maize do - name 'maize' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Maize' + name "maize" + en_wikipedia_url "http://en.wikipedia.org/wiki/Maize" end factory :chard do - name 'chard' + name "chard" end factory :walnut do - name 'walnut' + name "walnut" end factory :apple do - name 'apple' + name "apple" end factory :pear do - name 'pear' + name "pear" end # for testing varieties factory :roma do - name 'roma tomato' + name "roma tomato" end factory :popcorn do - name 'popcorn' + name "popcorn" end factory :eggplant do - name 'eggplant' + name "eggplant" end # This should have a name that is alphabetically earlier than :uppercase # crop to ensure that the ordering tests work. factory :lowercasecrop do - name 'ffrench bean' + name "ffrench bean" end factory :uppercasecrop do - name 'Swiss chard' + name "Swiss chard" end factory :autoloaded_crop do - creator 'cropbot' + creator "cropbot" end # for testing crop request factory :crop_request do - name 'Ultra berry' - en_wikipedia_url '' - approval_status 'pending' + name "Ultra berry" + en_wikipedia_url "" + approval_status "pending" association :requester, factory: :member request_notes "Please approve this even though it's fake." end factory :rejected_crop do - name 'Fail bean' - approval_status 'rejected' - reason_for_rejection 'Totally fake' + name "Fail bean" + approval_status "rejected" + reason_for_rejection "Totally fake" end end end diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb index 7c3828604..5636981fb 100644 --- a/spec/factories/forums.rb +++ b/spec/factories/forums.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :forum do - name 'Permaculture' - description '*Everything* about permaculture!' + name "Permaculture" + description "*Everything* about permaculture!" owner end end diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb index 3dfa11ac5..1f3d7461d 100644 --- a/spec/factories/garden.rb +++ b/spec/factories/garden.rb @@ -1,12 +1,12 @@ FactoryBot.define do factory :garden do name 'Springfield Community Garden' - description 'This is a **totally** cool garden' + description "This is a **totally** cool garden" owner active true area 23 - area_unit 'acre' - location 'Greenwich, UK' + area_unit "acre" + location "Greenwich, UK" factory :inactive_garden do active false diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index ce41589c1..ae3144a1e 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -7,11 +7,11 @@ FactoryBot.define do planting nil owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at { Time.zone.local(2015, 9, 17) } - quantity '3' - unit 'individual' + quantity "3" + unit "individual" weight_quantity 6 - weight_unit 'kg' - description 'A lovely harvest' + weight_unit "kg" + description "A lovely harvest" factory :harvest_with_planting do planting @@ -19,10 +19,10 @@ FactoryBot.define do end trait :long_description do - description 'This is a very long description that is so very long that it will need to be cut off' + description "This is a very long description that is so very long that it will need to be cut off" end trait :no_description do - description '' + description "" end end diff --git a/spec/factories/like.rb b/spec/factories/like.rb index 43500ddbe..bf19554bb 100644 --- a/spec/factories/like.rb +++ b/spec/factories/like.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :like do member - association :likeable, factory: 'post' + association :likeable, factory: "post" end end diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 2f9373b82..016b12263 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -77,7 +77,7 @@ FactoryBot.define do end factory :invalid_member_spaces do - login_name 'a b' + login_name "a b" end factory :invalid_member_badchars do diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 215fb83ab..b893fcc1b 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -4,8 +4,8 @@ FactoryBot.define do factory :notification, aliases: [:message] do sender recipient - subject 'MyString' - body 'MyText' + subject "MyString" + body "MyText" read false post diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb index b4089f4b1..5dfba00ab 100644 --- a/spec/factories/order_items.rb +++ b/spec/factories/order_items.rb @@ -4,7 +4,7 @@ FactoryBot.define do factory :order_item do order product - price '999' + price "999" quantity 42 end end diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index 305121c30..455d721c7 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -5,15 +5,15 @@ FactoryBot.define do owner flickr_photo_id 1 title { Faker::HarryPotter.quote } - license_name 'CC-BY' - license_url 'http://example.com/license.html' + license_name "CC-BY" + license_url "http://example.com/license.html" thumbnail_url { "http://example.com/#{Faker::File.file_name}.jpg" } fullsize_url { "http://example.com/#{Faker::File.file_name}.jpg" } link_url { Faker::Internet.url } factory :unlicensed_photo do - license_name 'All rights reserved' - license_url '' + license_name "All rights reserved" + license_url "" end end end diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb index ad0576129..695bf7542 100644 --- a/spec/factories/plant_parts.rb +++ b/spec/factories/plant_parts.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :plant_part do - name 'pollen' + name "pollen" end end diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index adba79848..5b7311025 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -5,7 +5,7 @@ FactoryBot.define do crop planted_at { Time.zone.local(2014, 7, 30) } quantity 33 - description 'This is a *really* good plant.' + description "This is a *really* good plant." factory :seed_planting do planted_from 'seed' diff --git a/spec/factories/post.rb b/spec/factories/post.rb index e7e72c0b5..da6390ef8 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -1,13 +1,13 @@ FactoryBot.define do factory :post do - subject 'A Post' - body 'This is some text.' + subject "A Post" + body "This is some text." author created_at { Time.now } # Markdown is allowed in posts factory :markdown_post do - body 'This is some **strong** text.' + body "This is some **strong** text." end # HTML isn't allowed in posts diff --git a/spec/factories/products.rb b/spec/factories/products.rb index ab9d9556b..444c8597d 100644 --- a/spec/factories/products.rb +++ b/spec/factories/products.rb @@ -2,14 +2,14 @@ FactoryBot.define do factory :product do - name 'annual subscription' - description 'paid membership, renewing yearly, *hurrah*' - min_price '999' + name "annual subscription" + description "paid membership, renewing yearly, *hurrah*" + min_price "999" account_type paid_months 12 factory :product_with_recommended_price do - recommended_price '1200' + recommended_price "1200" end end end diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 833191aac..fed5e5e00 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -2,17 +2,17 @@ FactoryBot.define do factory :role do - name 'Moderator' - description 'These people moderate the forums' + name "Moderator" + description "These people moderate the forums" initialize_with { Role.find_or_create_by(name: name) } factory :admin do - name 'admin' + name "admin" end factory :crop_wrangler do - name 'Crop Wrangler' - description 'they wrangle crops' + name "Crop Wrangler" + description "they wrangle crops" end end end diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb index 3032eaa21..aa0911504 100644 --- a/spec/factories/scientific_name.rb +++ b/spec/factories/scientific_name.rb @@ -1,17 +1,17 @@ FactoryBot.define do factory :scientific_name do association :crop, factory: :crop - name 'Beanus Magicus' + name "Beanus Magicus" creator factory :zea_mays do association :crop, factory: :maize - name 'Zea mays' + name "Zea mays" end factory :solanum_lycopersicum do association :crop, factory: :tomato - name 'Solanum lycopersicum' + name "Solanum lycopersicum" end end end diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index 9509750f9..41b3d404f 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -4,9 +4,9 @@ FactoryBot.define do factory :seed do owner crop - description 'MyText' + description "MyText" quantity 1 - plant_before '2013-07-15' + plant_before "2013-07-15" tradable_to 'nowhere' organic 'unknown' gmo 'unknown' @@ -15,11 +15,11 @@ FactoryBot.define do days_until_maturity_max nil factory :tradable_seed do - tradable_to 'locally' + tradable_to "locally" end factory :untradable_seed do - tradable_to 'nowhere' + tradable_to "nowhere" end end end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb index 5dddeeaab..dac241586 100644 --- a/spec/features/admin/account_types_spec.rb +++ b/spec/features/admin/account_types_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'account types', js: true do - context 'admin user' do +feature "account types", js: true do + context "admin user" do let(:member) { create :admin_member } let(:account_type) { create :account_type } @@ -9,28 +9,28 @@ feature 'account types', js: true do login_as member end - scenario 'navigating to account type admin with JavaScript on' do + scenario "navigating to account type admin with JavaScript on" do visit root_path # Extra click for the expandable login menu click_link member.login_name - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path - click_link 'Account types' + click_link "Account types" expect(current_path).to eq account_types_path end - scenario 'navigating to account type admin without JavaScript - Accessility version', js: false do + scenario "navigating to account type admin without JavaScript - Accessility version", js: false do visit root_path # Extra link not needed as menu is already expanded - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path - click_link 'Account types' + click_link "Account types" expect(current_path).to eq account_types_path end - scenario 'adding an account type' do + scenario "adding an account type" do visit account_types_path - click_link 'New Account type' + click_link "New Account type" expect(current_path).to eq new_account_type_path fill_in 'Name', with: 'Guest' click_button 'Save' diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index da6704134..87f44f26d 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'forums', js: true do - context 'as an admin user' do +feature "forums", js: true do + context "as an admin user" do let(:member) { create :admin_member } let(:forum) { create :forum } @@ -9,35 +9,35 @@ feature 'forums', js: true do login_as member end - scenario 'navigating to forum admin without js', js: false do + scenario "navigating to forum admin without js", js: false do visit root_path - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link 'Forums' + click_link "Forums" end expect(current_path).to eq forums_path - expect(page).to have_content 'New forum' + expect(page).to have_content "New forum" end - scenario 'navigating to forum admin with js' do + scenario "navigating to forum admin with js" do visit root_path click_link member.login_name - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link 'Forums' + click_link "Forums" end expect(current_path).to eq forums_path - expect(page).to have_content 'New forum' + expect(page).to have_content "New forum" end - scenario 'adding a forum' do + scenario "adding a forum" do visit forums_path - click_link 'New forum' + click_link "New forum" expect(current_path).to eq new_forum_path fill_in 'Name', with: 'Discussion' - fill_in 'Description', with: 'this is a new forum' + fill_in 'Description', with: "this is a new forum" click_button 'Save' expect(current_path).to eq forum_path(Forum.last) expect(page).to have_content 'Forum was successfully created' diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 918e3fd7c..ca24daf83 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'products' do - context 'admin user' do +feature "products" do + context "admin user" do let(:member) { create :admin_member } let(:product) { create :product } @@ -9,15 +9,15 @@ feature 'products' do login_as member end - scenario 'navigating to product admin' do + scenario "navigating to product admin" do visit admin_path - click_link 'Products' + click_link "Products" expect(current_path).to eq products_path end - scenario 'adding a product' do + scenario "adding a product" do visit products_path - click_link 'New Product' + click_link "New Product" expect(current_path).to eq new_product_path fill_in 'Name', with: 'Special offer' # note that failing to fill in a mandatory field has a messy error. diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index e41d1d25d..176c531a8 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -feature 'cms admin' do +feature "cms admin" do let(:member) { create :member } let(:admin_member) { create :admin_member } scenario "can't view CMS admin if not signed in" do visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content 'Please sign in as an admin user' + expect(page).to have_content "Please sign in as an admin user" end scenario "can't view CMS admin if not an admin member" do @@ -15,10 +15,10 @@ feature 'cms admin' do login_as member visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content 'Please sign in as an admin user' + expect(page).to have_content "Please sign in as an admin user" end - scenario 'admin members can view CMS admin area' do + scenario "admin members can view CMS admin area" do login_as admin_member visit comfy_admin_cms_path expect(current_path).to match(/#{comfy_admin_cms_path}/) # match any CMS admin page diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 604bf311e..75024ffb6 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -9,25 +9,25 @@ feature 'Commenting on a post' do visit new_comment_path post_id: post.id end - scenario 'creating a comment' do - fill_in 'comment_body', with: 'This is a sample test for comment' - click_button 'Post comment' - expect(page).to have_content 'comment was successfully created.' - expect(page).to have_content 'Posted by' + scenario "creating a comment" do + fill_in "comment_body", with: "This is a sample test for comment" + click_button "Post comment" + expect(page).to have_content "comment was successfully created." + expect(page).to have_content "Posted by" end - context 'editing a comment' do + context "editing a comment" do let(:existing_comment) { create :comment, post: post, author: member } background do visit edit_comment_path existing_comment end - scenario 'saving edit' do - fill_in 'comment_body', with: 'Testing edit for comment' - click_button 'Post comment' - expect(page).to have_content 'comment was successfully updated.' - expect(page).to have_content 'edited at' + scenario "saving edit" do + fill_in "comment_body", with: "Testing edit for comment" + click_button "Post comment" + expect(page).to have_content "comment was successfully updated." + expect(page).to have_content "edited at" end end end diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index fe4667cf5..e3b36c4a8 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature 'Alternate names', js: true do +feature "Alternate names", js: true do let!(:alternate_eggplant) { create :alternate_eggplant } let(:crop) { alternate_eggplant.crop } - scenario 'Display alternate names on crop page' do + scenario "Display alternate names on crop page" do visit crop_path(alternate_eggplant.crop) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end - scenario 'Index page for alternate names' do + scenario "Index page for alternate names" do visit alternate_names_path expect(page).to have_content alternate_eggplant.name end - context 'User is a crop wrangler' do + context "User is a crop wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -23,59 +23,59 @@ feature 'Alternate names', js: true do login_as member end - scenario 'Crop wranglers can edit alternate names' do + scenario "Crop wranglers can edit alternate names" do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content 'CROP WRANGLER' + expect(page).to have_content "CROP WRANGLER" expect(page).to have_content alternate_eggplant.name - expect(page).to have_link 'Edit', href: edit_alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on 'Edit' } + expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) + within('.alternate_names') { click_on "Edit" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'alternative aubergine' - click_on 'Save' + fill_in 'Name', with: "alternative aubergine" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'alternative aubergine' + expect(page).to have_content "alternative aubergine" expect(page).to have_content 'Alternate name was successfully updated' end - scenario 'Crop wranglers can delete alternate names' do + scenario "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) - expect(page).to have_link 'Delete', + expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on 'Delete' } + within('.alternate_names') { click_on "Delete" } expect(page.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end - scenario 'Crop wranglers can add alternate names' do + scenario "Crop wranglers can add alternate names" do visit crop_path(crop) - expect(page).to have_link 'Add', + expect(page).to have_link "Add", href: new_alternate_name_path(crop_id: crop.id) - within('.alternate_names') { click_on 'Add' } + within('.alternate_names') { click_on "Add" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'not an aubergine' - click_on 'Save' + fill_in 'Name', with: "not an aubergine" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'not an aubergine' + expect(page).to have_content "not an aubergine" expect(page).to have_content 'Alternate name was successfully created' end - scenario 'The show-alternate-name page works' do + scenario "The show-alternate-name page works" do visit alternate_name_path(alternate_eggplant) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name end - context 'When alternate name is rejected' do + context "When alternate name is rejected" do let(:rejected_crop) { create :rejected_crop } let(:pending_alt_name) { create :alternate_name, crop: rejected_crop } - scenario 'Displays crop rejection message' do + scenario "Displays crop rejection message" do visit alternate_name_path(pending_alt_name) - expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' + expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end end end diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 7f8b87467..72e63c8fd 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'browse crops' do +feature "browse crops" do let(:tomato) { create :tomato } let(:maize) { create :maize } let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } - scenario 'has a form for sorting by' do + scenario "has a form for sorting by" do visit crops_path - expect(page).to have_css 'select#sort' + expect(page).to have_css "select#sort" end - scenario 'shows a list of crops' do + scenario "shows a list of crops" do crop1 = tomato visit crops_path expect(page).to have_content crop1.name end - scenario 'pending crops are not listed' do + scenario "pending crops are not listed" do visit crops_path expect(page).not_to have_content pending_crop.name end - scenario 'rejected crops are not listed' do + scenario "rejected crops are not listed" do visit crops_path expect(page).not_to have_content rejected_crop.name end diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index c5c12617e..2b1300485 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Crop - ' do +feature "Crop - " do let!(:crop_wrangler) { create :crop_wrangling_member } let!(:member) { create :member } @@ -9,27 +9,27 @@ feature 'Crop - ' do visit new_crop_path end - scenario 'creating a crop with multiple scientific and alternate name', :js do - within 'form#new_crop' do - fill_in 'crop_name', with: 'Philippine flower' - fill_in 'en_wikipedia_url', with: 'https://en.wikipedia.org/wiki/Jasminum_sambac' - click_button 'add-sci_name-row' - fill_in 'sci_name[1]', with: 'Jasminum sambac 1' - fill_in 'sci_name[2]', with: 'Jasminum sambac 2' - fill_in 'alt_name[1]', with: 'Sampaguita' - click_button 'add-alt_name-row' - click_button 'add-alt_name-row' - fill_in 'alt_name[2]', with: 'Manol' - click_button 'add-alt_name-row' - fill_in 'alt_name[3]', with: 'Jazmin' - fill_in 'alt_name[4]', with: 'Matsurika' - fill_in 'request_notes', with: 'This is the Philippine national flower.' - click_button 'Save' + scenario "creating a crop with multiple scientific and alternate name", :js do + within "form#new_crop" do + fill_in "crop_name", with: "Philippine flower" + fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac" + click_button "add-sci_name-row" + fill_in "sci_name[1]", with: "Jasminum sambac 1" + fill_in "sci_name[2]", with: "Jasminum sambac 2" + fill_in "alt_name[1]", with: "Sampaguita" + click_button "add-alt_name-row" + click_button "add-alt_name-row" + fill_in "alt_name[2]", with: "Manol" + click_button "add-alt_name-row" + fill_in "alt_name[3]", with: "Jazmin" + fill_in "alt_name[4]", with: "Matsurika" + fill_in "request_notes", with: "This is the Philippine national flower." + click_button "Save" end expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content 'This crop is currently pending approval.' - expect(page).to have_content 'Jasminum sambac 2' - expect(page).to have_content 'Matsurika' + expect(page).to have_content "This crop is currently pending approval." + expect(page).to have_content "Jasminum sambac 2" + expect(page).to have_content "Matsurika" end end diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 8270660e7..b7dca2e8d 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'crop detail page', js: true do +feature "crop detail page", js: true do subject do # Update the medians after all the # data has been loaded @@ -12,22 +12,22 @@ feature 'crop detail page', js: true do end let(:crop) { create :crop } - context 'varieties' do - scenario 'The crop DOES NOT have varieties' do + context "varieties" do + scenario "The crop DOES NOT have varieties" do visit crop_path(crop) - within '.varieties' do + within ".varieties" do expect(page).to have_no_selector('li', text: /tomato/i) expect(page).to have_no_selector('button', text: /Show+/i) end end - scenario 'The crop has one variety' do + scenario "The crop has one variety" do create :crop, name: 'Roma tomato 1', parent: crop subject - within '.varieties' do + within ".varieties" do # It lists all 2 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 2) # It DOES NOT have "Show all/less" toggle link @@ -35,16 +35,16 @@ feature 'crop detail page', js: true do end end - context 'many' do + context "many" do let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop } let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop } let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop } let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop } - scenario 'The crop has 4 varieties' do + scenario "The crop has 4 varieties" do subject - within '.varieties' do + within ".varieties" do # It lists all 5 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 5) # It DOES NOT have "Show all/less" toggle link @@ -52,12 +52,12 @@ feature 'crop detail page', js: true do end end - scenario 'The crop has 5 varieties, including grandchild', js: true do + scenario "The crop has 5 varieties, including grandchild", js: true do create :crop, name: 'Roma tomato child 1', parent: roma4 subject - within '.varieties' do + within ".varieties" do # It lists the first 5 items (note: including the top level item.) # It HAS have "Show all" toggle link but not "Show less" link expect(page).to have_selector('li', text: /tomato/i, count: 5) @@ -93,90 +93,90 @@ feature 'crop detail page', js: true do end end - context 'signed in member' do + context "signed in member" do let(:member) { create :member } background do login_as(member) end - context 'action buttons' do + context "action buttons" do background { subject } - scenario 'has a link to plant the crop' do - expect(page).to have_link 'Plant this', href: new_planting_path(crop_id: crop.id) + scenario "has a link to plant the crop" do + expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) end - scenario 'has a link to harvest the crop' do - expect(page).to have_link 'Harvest this', href: new_harvest_path(crop_id: crop.id) + scenario "has a link to harvest the crop" do + expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) end - scenario 'has a link to add seeds' do - expect(page).to have_link 'Add seeds to stash', href: new_seed_path(crop_id: crop.id) + scenario "has a link to add seeds" do + expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) end end - context 'SEO' do + context "SEO" do background { subject } - scenario 'has seed heading with SEO' do + scenario "has seed heading with SEO" do expect(page).to have_content "Find #{crop.name} seeds" end - scenario 'has harvest heading with SEO' do + scenario "has harvest heading with SEO" do expect(page).to have_content "#{crop.name.capitalize} harvests" end - scenario 'has planting heading with SEO' do + scenario "has planting heading with SEO" do expect(page).to have_content "See who's planted #{crop.name.pluralize}" end - scenario 'has planting advice with SEO' do + scenario "has planting advice with SEO" do expect(page).to have_content "How to grow #{crop.name}" end - scenario 'has a link to Wikipedia with SEO' do + scenario "has a link to Wikipedia with SEO" do expect(page).to have_content "Learn more about #{crop.name}" - expect(page).to have_link 'Wikipedia (English)', href: crop.en_wikipedia_url + expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url end - scenario 'has a link to OpenFarm' do - expect(page).to have_link 'OpenFarm - Growing guide', + scenario "has a link to OpenFarm" do + expect(page).to have_link "OpenFarm - Growing guide", href: "https://openfarm.cc/en/crops/#{URI.escape crop.name}" end - scenario 'has a link to gardenate' do - expect(page).to have_link 'Gardenate - Planting reminders', + scenario "has a link to gardenate" do + expect(page).to have_link "Gardenate - Planting reminders", href: "http://www.gardenate.com/plant/#{URI.escape crop.name}" end end end - context 'seed quantity for a crop' do + context "seed quantity for a crop" do let(:member) { create :member } let(:seed) { create :seed, crop: crop, quantity: 20, owner: member } - scenario 'User not signed in' do + scenario "User not signed in" do visit crop_path(seed.crop) - expect(page).not_to have_content 'You have 20 seeds of this crop' + expect(page).not_to have_content "You have 20 seeds of this crop" expect(page).not_to have_content "You don't have any seeds of this crop" - expect(page).not_to have_link 'View your seeds' + expect(page).not_to have_link "View your seeds" end - scenario 'User signed in' do + scenario "User signed in" do login_as(member) visit crop_path(seed.crop) - expect(page).to have_content 'You have 20 seeds of this crop.' - expect(page).to have_link 'View your seeds' + expect(page).to have_content "You have 20 seeds of this crop." + expect(page).to have_link "View your seeds" end - scenario 'click link to your owned seeds' do + scenario "click link to your owned seeds" do login_as(member) visit crop_path(seed.crop) - click_link 'View your seeds' + click_link "View your seeds" expect(current_path).to eq seeds_by_owner_path(owner: member.slug) end end - shared_examples 'predicts harvest' do + shared_examples "predicts harvest" do describe 'with harvest history data' do before do # 50 days to harvest @@ -190,8 +190,8 @@ feature 'crop detail page', js: true do planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) planting.crop.update_medians end - it 'predicts harvest' do - is_expected.to have_text('First harvest expected 20 days after planting') + it "predicts harvest" do + is_expected.to have_text("First harvest expected 20 days after planting") end end end @@ -210,15 +210,15 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end - it 'predicts lifespan' do - is_expected.to have_text 'Median lifespan' - is_expected.to have_text '99 days' + it "predicts lifespan" do + is_expected.to have_text "Median lifespan" + is_expected.to have_text "99 days" end - it 'describes annual crops' do + it "describes annual crops" do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -232,10 +232,10 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end - it 'describes perennial crops' do + it "describes perennial crops" do is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end end @@ -247,7 +247,7 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end end end diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 0c79d55d8..ccc5288f0 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'crop detail page', js: true do +feature "crop detail page", js: true do subject { page } let(:member) { create :member } @@ -29,29 +29,29 @@ feature 'crop detail page', js: true do visit crop_path(crop) end - shared_examples 'shows photos' do - describe 'show planting photos' do + shared_examples "shows photos" do + describe "show planting photos" do it { is_expected.to have_xpath("//img[contains(@src,'#{photo1.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo2.thumbnail_url}')]") } end - describe 'show harvest photos' do + describe "show harvest photos" do it { is_expected.to have_xpath("//img[contains(@src,'#{photo3.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo4.thumbnail_url}')]") } end - describe 'link to more photos' do - it { is_expected.to have_link 'more photos' } + describe "link to more photos" do + it { is_expected.to have_link "more photos" } end end - context 'when signed in' do + context "when signed in" do background { login_as(create(:member)) } - include_examples 'shows photos' + include_examples "shows photos" end - context 'when signed in as photos owner' do + context "when signed in as photos owner" do background { login_as(member) } - include_examples 'shows photos' + include_examples "shows photos" end - context 'when not signed in ' do - include_examples 'shows photos' + context "when not signed in " do + include_examples "shows photos" end end diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index b10aa043d..f2f86980c 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature 'crop search' do - scenario 'search results show the search term in title' do +feature "crop search" do + scenario "search results show the search term in title" do visit root_path - within 'form#navbar-search' do - fill_in 'term', with: 'tomato' - click_button 'Search' + within "form#navbar-search" do + fill_in "term", with: "tomato" + click_button "Search" end - expect(page).to have_css 'h1', text: 'Crops matching "tomato"' + expect(page).to have_css "h1", text: "Crops matching \"tomato\"" end - scenario 'search page with no search term shows suitable title' do + scenario "search page with no search term shows suitable title" do visit crops_search_path - expect(page).to have_css 'h1', text: 'Crop search' + expect(page).to have_css "h1", text: "Crop search" end - scenario 'search page has a search form on it' do + scenario "search page has a search form on it" do visit crops_search_path - expect(page).to have_css 'form#crop-search' + expect(page).to have_css "form#crop-search" end end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index c5ae2c9a2..eafc7039f 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'crop wranglers', js: true do - context 'signed in wrangler' do +feature "crop wranglers", js: true do + context "signed in wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:wrangler) { crop_wranglers.first } let!(:crops) { create_list :crop, 2 } @@ -10,7 +10,7 @@ feature 'crop wranglers', js: true do background { login_as wrangler } - scenario 'sees crop wranglers listed on the crop wrangler page' do + scenario "sees crop wranglers listed on the crop wrangler page" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -23,7 +23,7 @@ feature 'crop wranglers', js: true do end end - scenario 'can see list of crops with extra detail of who created a crop' do + scenario "can see list of crops with extra detail of who created a crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -32,39 +32,39 @@ feature 'crop wranglers', js: true do end end - scenario 'visiting a crop can see wrangler links' do + scenario "visiting a crop can see wrangler links" do visit crop_path(crops.first) expect(page).to have_content 'You are a CROP WRANGLER' expect(page).to have_link 'Edit crop' expect(page).to have_link 'Delete crop' end - scenario 'can create a new crop' do + scenario "can create a new crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' click_link 'Add Crop' - fill_in 'Name', with: 'aubergine' - fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Maize' - fill_in 'sci_name[1]', with: 'planticus maximus' + fill_in 'Name', with: "aubergine" + fill_in 'en_wikipedia_url', with: "http://en.wikipedia.org/wiki/Maize" + fill_in 'sci_name[1]', with: "planticus maximus" click_on 'Save' expect(page).to have_content 'crop was successfully created.' expect(page).to have_content 'planticus maximus' end - scenario 'View pending crops' do + scenario "View pending crops" do visit crop_path(requested_crop) - expect(page).to have_content 'This crop is currently pending approval.' + expect(page).to have_content "This crop is currently pending approval." expect(page).to have_content "Please approve this even though it's fake." end - scenario 'View rejected crops' do + scenario "View rejected crops" do visit crop_path(rejected_crop) - expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' + expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end end - context 'signed in non-wrangler' do + context "signed in non-wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { create :member } @@ -72,13 +72,13 @@ feature 'crop wranglers', js: true do scenario "can't see wrangling page without js", js: false do visit root_path - expect(page).not_to have_link 'Crop Wrangling' + expect(page).not_to have_link "Crop Wrangling" end scenario "can't see wrangling page with js" do visit root_path click_link member.login_name - expect(page).not_to have_link 'Crop Wrangling' + expect(page).not_to have_link "Crop Wrangling" end end end diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index dd1f439c8..ede88f003 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'crop wrangling button' do +feature "crop wrangling button" do let(:crop_wrangler) { create :crop_wrangling_member } let(:member) { create :member } - context 'crop wrangling button' do + context "crop wrangling button" do background do login_as crop_wrangler visit crops_path end - scenario 'has a link to crop wrangling page' do - expect(page).to have_link 'Wrangle Crops', href: wrangle_crops_path + scenario "has a link to crop wrangling page" do + expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path end end - context 'crop wrangling button' do + context "crop wrangling button" do background do login_as member visit crops_path end - scenario 'has no link to crop wrangling page' do - expect(page).to have_no_link 'Wrangle Crops', href: wrangle_crops_path + scenario "has no link to crop wrangling page" do + expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path end end end diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index 015b19d6d..d08f2490b 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature 'irregular crop inflections' do +feature "irregular crop inflections" do # We're just testing a couple of representative crops to # check that inflection works: you don't need to add # every crop here. - scenario 'crops which are mass nouns' do - expect('kale'.pluralize).to eq 'kale' - expect('broccoli'.pluralize).to eq 'broccoli' - expect('square foot'.pluralize).to eq 'square feet' - expect('squash'.pluralize).to eq 'squash' - expect('bok choy'.pluralize).to eq 'bok choy' - expect('achiote'.pluralize).to eq 'achiote' - expect('alfalfa'.pluralize).to eq 'alfalfa' - expect('allspice'.pluralize).to eq 'allspice' - expect('spinach'.pluralize).to eq 'spinach' - expect('garlic'.pluralize).to eq 'garlic' - expect('licorice'.pluralize).to eq 'licorice' - expect('lillipilli'.pluralize).to eq 'lillipillies' + scenario "crops which are mass nouns" do + expect("kale".pluralize).to eq "kale" + expect("broccoli".pluralize).to eq "broccoli" + expect("square foot".pluralize).to eq "square feet" + expect("squash".pluralize).to eq "squash" + expect("bok choy".pluralize).to eq "bok choy" + expect("achiote".pluralize).to eq "achiote" + expect("alfalfa".pluralize).to eq "alfalfa" + expect("allspice".pluralize).to eq "allspice" + expect("spinach".pluralize).to eq "spinach" + expect("garlic".pluralize).to eq "garlic" + expect("licorice".pluralize).to eq "licorice" + expect("lillipilli".pluralize).to eq "lillipillies" end end diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index 5dc54d8cb..9cccac4f8 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'Requesting a new crop' do - context 'As a regular member' do +feature "Requesting a new crop" do + context "As a regular member" do let(:member) { create :member } let!(:wrangler) { create :crop_wrangling_member } @@ -9,39 +9,39 @@ feature 'Requesting a new crop' do login_as member end - scenario 'Submit request' do + scenario "Submit request" do visit new_crop_path - fill_in 'Name', with: 'Couch potato' - fill_in 'request_notes', with: 'Couch potatoes are real for real.' - click_button 'Save' + fill_in "Name", with: "Couch potato" + fill_in "request_notes", with: "Couch potatoes are real for real." + click_button "Save" expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content 'This crop is currently pending approval.' + expect(page).to have_content "This crop is currently pending approval." end end - context 'As a crop wrangler' do + context "As a crop wrangler" do let(:wrangler) { create :crop_wrangling_member } let!(:crop) { create :crop_request } let!(:already_approved) { create :crop } background { login_as wrangler } - scenario 'Approve a request' do + scenario "Approve a request" do visit edit_crop_path(crop) - select 'approved', from: 'Approval status' - click_button 'Save' - expect(page).to have_content 'En wikipedia url is not a valid English Wikipedia URL' - fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi' - click_button 'Save' - expect(page).to have_content 'crop was successfully updated.' + select "approved", from: "Approval status" + click_button "Save" + expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL" + fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi" + click_button "Save" + expect(page).to have_content "crop was successfully updated." end - scenario 'Rejecting a crop' do + scenario "Rejecting a crop" do visit edit_crop_path(crop) - select 'rejected', from: 'Approval status' - select 'not edible', from: 'Reason for rejection' - click_button 'Save' - expect(page).to have_content 'crop was successfully updated.' + select "rejected", from: "Approval status" + select "not edible", from: "Reason for rejection" + click_button "Save" + expect(page).to have_content "crop was successfully updated." end end end diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index c3329635a..15226efe4 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Crop - ' do +feature "Crop - " do let(:member) { create :member } let!(:requested_crop) { create :crop, requester: member, approval_status: 'pending', name: 'puha for dinner' } @@ -9,7 +9,7 @@ feature 'Crop - ' do visit requested_crops_path end - scenario 'creating a crop with multiple scientific and alternate name', :js do - expect(page).to have_content 'puha for dinner' + scenario "creating a crop with multiple scientific and alternate name", :js do + expect(page).to have_content "puha for dinner" end end diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 5fbeb5296..735883e77 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature 'follows', :js do - context 'when signed out' do +feature "follows", :js do + context "when signed out" do let(:member) { create :member } - scenario 'follow buttons on member profile page' do + scenario "follow buttons on member profile page" do visit member_path(member) - expect(page).not_to have_link 'Follow' - expect(page).not_to have_link 'Unfollow' + expect(page).not_to have_link "Follow" + expect(page).not_to have_link "Unfollow" end end - context 'when signed in' do + context "when signed in" do let(:member) { create :member } let(:other_member) { create :member } @@ -21,45 +21,45 @@ feature 'follows', :js do scenario "your profile doesn't have a follow button" do visit member_path(member) - expect(page).not_to have_link 'Follow' - expect(page).not_to have_link 'Unfollow' + expect(page).not_to have_link "Follow" + expect(page).not_to have_link "Unfollow" end - context 'following another member' do + context "following another member" do background do visit member_path(other_member) end - scenario 'has a follow button' do - expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) + scenario "has a follow button" do + expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) end - scenario 'has correct message and unfollow button' do + scenario "has correct message and unfollow button" do click_link 'Follow' expect(page).to have_content "Followed #{other_member.login_name}" - expect(page).to have_link 'Unfollow', href: follow_path(member.get_follow(other_member)) + expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member)) end - scenario 'has a followed member listed in the following page' do + scenario "has a followed member listed in the following page" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s end - scenario 'does not die when passed an authenticity_token' do - visit member_follows_path member, params: { authenticity_token: 'Ultima ratio regum' } + scenario "does not die when passed an authenticity_token" do + visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" } expect(page.status_code).to equal 200 end - scenario 'has correct message and follow button after unfollow' do + scenario "has correct message and follow button after unfollow" do click_link 'Follow' click_link 'Unfollow' expect(page).to have_content "Unfollowed #{other_member.login_name}" visit member_path(other_member) # unfollowing redirects to root - expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) + expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) end - scenario 'has member in following list' do + scenario "has member in following list" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s @@ -71,7 +71,7 @@ feature 'follows', :js do expect(page).to have_content member.login_name.to_s end - scenario 'removes members from following and followers lists after unfollow' do + scenario "removes members from following and followers lists after unfollow" do click_link 'Follow' click_link 'Unfollow' visit member_follows_path(member) diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index 3023212f7..b7d109773 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'footer', js: true do +feature "footer", js: true do before { visit root_path } - scenario 'footer is on home page' do + scenario "footer is on home page" do expect(page).to have_css 'footer' end diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index 746acc1f0..c3f78dd18 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Gardens', :js do +feature "Gardens", :js do let(:member) { FactoryBot.create :member } background do @@ -9,30 +9,30 @@ feature 'Gardens', :js do visit new_garden_path end - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'Name' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "Name" expect(page).to have_optional 'textarea#garden_description' expect(page).to have_optional 'input#garden_location' expect(page).to have_optional 'input#garden_area' end - scenario 'Create new garden' do - fill_in 'Name', with: 'New garden' - click_button 'Save' - expect(page).to have_content 'Garden was successfully created' - expect(page).to have_content 'New garden' + scenario "Create new garden" do + fill_in "Name", with: "New garden" + click_button "Save" + expect(page).to have_content "Garden was successfully created" + expect(page).to have_content "New garden" end - scenario 'Refuse to create new garden with negative area' do + scenario "Refuse to create new garden with negative area" do visit new_garden_path - fill_in 'Name', with: 'Negative Garden' - fill_in 'Area', with: -5 - click_button 'Save' - expect(page).not_to have_content 'Garden was successfully created' - expect(page).to have_content 'Area must be greater than or equal to 0' + fill_in "Name", with: "Negative Garden" + fill_in "Area", with: -5 + click_button "Save" + expect(page).not_to have_content "Garden was successfully created" + expect(page).to have_content "Area must be greater than or equal to 0" end end diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/gardens_index_spec.rb index 9cd03a930..39161d5c8 100644 --- a/spec/features/gardens/gardens_index_spec.rb +++ b/spec/features/gardens/gardens_index_spec.rb @@ -1,46 +1,46 @@ require 'rails_helper' require 'custom_matchers' -feature 'Gardens#index', :js do - context 'Logged in as member' do +feature "Gardens#index", :js do + context "Logged in as member" do let(:member) { FactoryBot.create :member } background { login_as member } - context 'with 10 gardens' do + context "with 10 gardens" do before do FactoryBot.create_list :garden, 10, owner: member visit gardens_path(member: member) end - it 'displays each of the gardens' do + it "displays each of the gardens" do member.gardens.each do |garden| expect(page).to have_text garden.name end end - it 'links to each garden' do + it "links to each garden" do member.gardens.each do |garden| expect(page).to have_link(garden.name, href: garden_path(garden)) end end end - context 'with inactive gardens' do - let!(:active_garden) { FactoryBot.create :garden, name: 'My active garden', owner: member } - let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: 'retired garden', owner: member } + context "with inactive gardens" do + let!(:active_garden) { FactoryBot.create :garden, name: "My active garden", owner: member } + let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: "retired garden", owner: member } before { visit gardens_path(member: member) } - it 'show active garden' do + it "show active garden" do expect(page).to have_text active_garden.name end - it 'should not show inactive garden' do + it "should not show inactive garden" do expect(page).not_to have_text inactive_garden.name end - it 'links to active garden' do + it "links to active garden" do expect(page).to have_link(active_garden.name, href: garden_path(active_garden)) end - it 'does not link to inactive gardens' do + it "does not link to inactive gardens" do expect(page).not_to have_link(inactive_garden.name, href: garden_path(inactive_garden)) end end @@ -59,10 +59,10 @@ feature 'Gardens#index', :js do before do visit gardens_path(member: member) end - it 'shows planting in garden' do + it "shows planting in garden" do expect(page).to have_link(planting.crop.name, href: planting_path(planting)) end - it 'does not show finished planting' do + it "does not show finished planting" do expect(page).not_to have_text(finished_planting.crop.name) end end diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 613fb688d..0954d35eb 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'Planting a crop', js: true do +feature "Planting a crop", js: true do # name is aaa to ensure it is ordered first let!(:garden) { create :garden, name: 'aaa' } - let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse('2013-3-10') } + let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") } let!(:tomato) { create :tomato } let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } @@ -11,88 +11,88 @@ feature 'Planting a crop', js: true do login_as garden.owner end - scenario 'View gardens' do + scenario "View gardens" do visit gardens_path expect(page).to have_content "Everyone's gardens" - click_link 'My Gardens' + click_link "My Gardens" expect(page).to have_content "#{garden.owner.login_name}'s gardens" click_link "Everyone's gardens" expect(page).to have_content "Everyone's gardens" end - scenario 'Marking a garden as inactive' do + scenario "Marking a garden as inactive" do visit garden_path(garden) - click_link 'Mark as inactive' - expect(page).to have_content 'Garden was successfully updated' - expect(page).to have_content 'This garden is inactive' - expect(page).to have_content 'Mark as active' - expect(page).not_to have_content 'Mark as inactive' + click_link "Mark as inactive" + expect(page).to have_content "Garden was successfully updated" + expect(page).to have_content "This garden is inactive" + expect(page).to have_content "Mark as active" + expect(page).not_to have_content "Mark as inactive" end - scenario 'List only active gardens' do + scenario "List only active gardens" do visit garden_path(garden) - click_link 'Mark as inactive' + click_link "Mark as inactive" visit gardens_path expect(page).not_to have_link garden_path(garden) end - scenario 'Create new garden' do + scenario "Create new garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' - expect(page).to have_content 'Garden was successfully created' - expect(page).to have_content 'New garden' + fill_in "Name", with: "New garden" + click_button "Save" + expect(page).to have_content "Garden was successfully created" + expect(page).to have_content "New garden" end - scenario 'Refuse to create new garden with negative area' do + scenario "Refuse to create new garden with negative area" do visit new_garden_path - fill_in 'Name', with: 'Negative Garden' - fill_in 'Area', with: -5 - click_button 'Save' - expect(page).not_to have_content 'Garden was successfully created' - expect(page).to have_content 'Area must be greater than or equal to 0' + fill_in "Name", with: "Negative Garden" + fill_in "Area", with: -5 + click_button "Save" + expect(page).not_to have_content "Garden was successfully created" + expect(page).to have_content "Area must be greater than or equal to 0" end - context 'Clicking edit from the index page' do + context "Clicking edit from the index page" do background do visit gardens_path end - scenario 'button on index to edit garden' do - first('.garden-info').click_link('edit_garden_link') + scenario "button on index to edit garden" do + first(".garden-info").click_link("edit_garden_link") expect(page).to have_content 'Edit garden' end end - scenario 'Edit garden' do + scenario "Edit garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' + fill_in "Name", with: "New garden" + click_button "Save" click_link 'edit_garden_link' - fill_in 'Name', with: 'Different name' - click_button 'Save' - expect(page).to have_content 'Garden was successfully updated' - expect(page).to have_content 'Different name' + fill_in "Name", with: "Different name" + click_button "Save" + expect(page).to have_content "Garden was successfully updated" + expect(page).to have_content "Different name" end - scenario 'Delete garden' do + scenario "Delete garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' + fill_in "Name", with: "New garden" + click_button "Save" visit garden_path(Garden.last) click_link 'delete_garden_link' - expect(page).to have_content 'Garden was successfully deleted' + expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end - describe 'Making a planting inactive from garden show' do + describe "Making a planting inactive from garden show" do let(:path) { garden_path garden } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end - scenario 'List only active plantings on a garden' do + scenario "List only active plantings on a garden" do visit gardens_path expect(page).not_to have_content finished_planting.crop_name end diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 30339219a..2a8400c2e 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'browse harvests' do +feature "browse harvests" do let!(:member) { create :member } let!(:harvest) { create :harvest, owner: member } @@ -16,11 +16,11 @@ feature 'browse harvests' do end scenario 'read more' do - expect(page).not_to have_link 'Read more' + expect(page).not_to have_link "Read more" end end - feature 'filled in optional fields' do + feature "filled in optional fields" do let!(:harvest) { create :harvest, :long_description } before(:each) do @@ -28,7 +28,7 @@ feature 'browse harvests' do end scenario 'read more' do - expect(page).to have_link 'Read more' + expect(page).to have_link "Read more" end it 'links to #show' do diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 6c2b253c0..84c4b5a7f 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Harvesting a crop', :js, :elasticsearch do +feature "Harvesting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let!(:plant_part) { create :plant_part } @@ -13,44 +13,44 @@ feature 'Harvesting a crop', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'harvest', 'crop' + it_behaves_like "crop suggest", "harvest", "crop" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'What did you harvest?' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "What did you harvest?" expect(page).to have_optional 'input#harvest_quantity' expect(page).to have_optional 'input#harvest_weight_quantity' expect(page).to have_optional 'textarea#harvest_description' end - scenario 'Creating a new harvest', :js do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' + scenario "Creating a new harvest", :js do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" - within 'form#new_harvest' do + within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' - fill_in 'When?', with: '2014-06-15' - fill_in 'How many?', with: 42 - fill_in 'Weighing (in total):', with: 42 - fill_in 'Notes', with: "It's killer." - click_button 'Save' + fill_in "When?", with: "2014-06-15" + fill_in "How many?", with: 42 + fill_in "Weighing (in total):", with: 42 + fill_in "Notes", with: "It's killer." + click_button "Save" end - expect(page).to have_content 'harvest was successfully created.' + expect(page).to have_content "harvest was successfully created." end - context 'Clicking edit from the index page' do + context "Clicking edit from the index page" do let!(:harvest) { create :harvest, crop: maize, owner: member } background do visit harvests_path end - scenario 'button on index to edit harvest' do - click_link 'edit_harvest_glyphicon' + scenario "button on index to edit harvest" do + click_link "edit_harvest_glyphicon" expect(current_path).to eq edit_harvest_path(harvest) expect(page).to have_content 'Editing harvest' end @@ -62,58 +62,58 @@ feature 'Harvesting a crop', :js, :elasticsearch do expect(current_path).to eq member_path member end - scenario 'Harvesting from crop page' do + scenario "Harvesting from crop page" do visit crop_path(maize) - click_link 'Harvest this' - within 'form#new_harvest' do + click_link "Harvest this" + within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'harvest was successfully created.' - expect(page).to have_content 'maize' + expect(page).to have_content "harvest was successfully created." + expect(page).to have_content "maize" end - scenario 'Harvesting from planting page' do + scenario "Harvesting from planting page" do planting = create :planting, crop: maize, owner: member, garden: member.gardens.first visit planting_path(planting) - click_link 'Harvest' + click_link "Harvest" select plant_part.name, from: 'harvest[plant_part_id]' - click_button 'Save' + click_button "Save" - expect(page).to have_content 'harvest was successfully created.' + expect(page).to have_content "harvest was successfully created." expect(page).to have_content planting.garden.name - expect(page).to have_content 'maize' + expect(page).to have_content "maize" end - context 'Editing a harvest' do + context "Editing a harvest" do let(:existing_harvest) { create :harvest, crop: maize, owner: member } let!(:other_plant_part) { create :plant_part, name: 'chocolate' } background do visit harvest_path(existing_harvest) - click_link 'Edit' + click_link "Edit" end - scenario 'Saving without edits' do + scenario "Saving without edits" do # Check that the autosuggest helper properly fills inputs with # existing resource's data - click_button 'Save' - expect(page).to have_content 'harvest was successfully updated.' - expect(page).to have_content 'maize' + click_button "Save" + expect(page).to have_content "harvest was successfully updated." + expect(page).to have_content "maize" end - scenario 'change plant part' do + scenario "change plant part" do select other_plant_part.name, from: 'harvest[plant_part_id]' - click_button 'Save' - expect(page).to have_content 'harvest was successfully updated.' + click_button "Save" + expect(page).to have_content "harvest was successfully updated." expect(page).to have_content other_plant_part.name end end - context 'Viewing a harvest' do + context "Viewing a harvest" do let(:existing_harvest) do create :harvest, crop: maize, owner: member, harvested_at: Time.zone.today @@ -127,10 +127,10 @@ feature 'Harvesting a crop', :js, :elasticsearch do visit harvest_path(existing_harvest) end - scenario 'linking to a planting' do + scenario "linking to a planting" do expect(page).to have_content planting.to_s choose("harvest_planting_id_#{existing_planting.id}") - click_button 'save' + click_button "save" expect(page).to have_link(href: planting_path(existing_planting)) end end diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 5dabbfa5e..01d164f3c 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Changing locales', js: true do +feature "Changing locales", js: true do after { I18n.locale = :en } - scenario 'Locale can be set with a query param' do + scenario "Locale can be set with a query param" do visit root_path - expect(page).to have_content('a community of food gardeners.') + expect(page).to have_content("a community of food gardeners.") visit root_path(locale: 'ja') - expect(page).to have_content('はガーデナーのコミュニティです。') + expect(page).to have_content("はガーデナーのコミュニティです。") end end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index bf54c637f..32b11bda1 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -1,109 +1,109 @@ require 'rails_helper' -feature 'member profile', js: true do - context 'signed out member' do +feature "member profile", js: true do + context "signed out member" do let(:member) { create :member } - scenario 'basic details on member profile page' do + scenario "basic details on member profile page" do visit member_path(member) - expect(page).to have_css('h1', text: member.login_name) + expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content 'Account type: Free account' + expect(page).to have_content "Account type: Free account" expect(page).to have_content "#{member.login_name}'s gardens" - expect(page).to have_link 'More about this garden...', href: garden_path(member.gardens.first) + expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end - scenario 'no bio' do + scenario "no bio" do member.bio = nil member.save visit member_path(member) expect(page).to have_content "hasn't written a bio yet" end - scenario 'gravatar' do + scenario "gravatar" do visit member_path(member) - expect(page).to have_css 'img.avatar' + expect(page).to have_css "img.avatar" end - context 'location' do - scenario 'member has set location' do + context "location" do + scenario "member has set location" do london_member = create :london_member visit member_path(london_member) - expect(page).to have_css('h1>small', text: london_member.location) - expect(page).to have_css('#membermap') + expect(page).to have_css("h1>small", text: london_member.location) + expect(page).to have_css("#membermap") expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}" end - scenario 'member has not set location' do + scenario "member has not set location" do visit member_path(member) - expect(page).not_to have_css('h1>small') - expect(page).not_to have_css('#membermap') - expect(page).not_to have_content 'See other members' + expect(page).not_to have_css("h1>small") + expect(page).not_to have_css("#membermap") + expect(page).not_to have_content "See other members" end end - context 'email privacy' do - scenario 'public email address' do + context "email privacy" do + scenario "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario 'private email address' do + scenario "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end - context 'email privacy' do - scenario 'public email address' do + context "email privacy" do + scenario "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario 'private email address' do + scenario "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end - context 'activity stats' do - scenario 'with no activity' do + context "activity stats" do + scenario "with no activity" do visit member_path(member) - expect(page).to have_content 'Activity' - expect(page).to have_content '0 plantings' - expect(page).to have_content '0 harvests' - expect(page).to have_content '0 seeds' - expect(page).to have_content '0 posts' + expect(page).to have_content "Activity" + expect(page).to have_content "0 plantings" + expect(page).to have_content "0 harvests" + expect(page).to have_content "0 seeds" + expect(page).to have_content "0 posts" end - scenario 'with some activity' do + scenario "with some activity" do create_list :planting, 2, owner: member create_list :harvest, 3, owner: member create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link '2 plantings', href: plantings_by_owner_path(owner: member) - expect(page).to have_link '3 harvests', href: harvests_by_owner_path(owner: member) - expect(page).to have_link '4 seeds', href: seeds_by_owner_path(owner: member) - expect(page).to have_link '5 posts', href: posts_by_author_path(author: member) + expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member) + expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member) + expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member) + expect(page).to have_link "5 posts", href: posts_by_author_path(author: member) end end - scenario 'twitter link' do + scenario "twitter link" do twitter_auth = create :authentication, member: member visit member_path(member) expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}" end - scenario 'flickr link' do + scenario "flickr link" do flickr_auth = create :flickr_authentication, member: member visit member_path(member) expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}" end end - context 'signed in member' do + context "signed in member" do let(:member) { create :member } let(:other_member) { create :member } let(:admin_member) { create :admin_member } @@ -115,35 +115,35 @@ feature 'member profile', js: true do scenario "admin user's page" do visit member_path(admin_member) - expect(page).to have_text 'Admin' + expect(page).to have_text "Admin" end scenario "crop wrangler's page" do visit member_path(crop_wrangler) - expect(page).to have_text 'Crop Wrangler' + expect(page).to have_text "Crop Wrangler" end scenario "ordinary user's page" do visit member_path(other_member) - expect(page).not_to have_text 'Crop Wrangler' - expect(page).not_to have_text 'Admin' + expect(page).not_to have_text "Crop Wrangler" + expect(page).not_to have_text "Admin" end - context 'your own profile page' do + context "your own profile page" do background do visit member_path(member) end - scenario 'has a link to create new garden' do - expect(page).to have_link 'New Garden', href: new_garden_path + scenario "has a link to create new garden" do + expect(page).to have_link "New Garden", href: new_garden_path end - scenario 'has a button to edit profile' do - expect(page).to have_link 'Edit profile', href: edit_member_registration_path + scenario "has a button to edit profile" do + expect(page).to have_link "Edit profile", href: edit_member_registration_path end - scenario 'has a button to upgrade account' do - expect(page).to have_link 'Upgrade account', href: shop_path + scenario "has a button to upgrade account" do + expect(page).to have_link "Upgrade account", href: shop_path end end @@ -152,18 +152,18 @@ feature 'member profile', js: true do visit member_path(other_member) end - scenario 'has a private message button' do - expect(page).to have_link 'Send message', href: new_notification_path(recipient_id: other_member.id) + scenario "has a private message button" do + expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) end end - context 'home page' do + context "home page" do background do visit root_path end - scenario 'does not have a button to edit profile' do - expect(page).not_to have_link 'Edit profile', href: edit_member_registration_path + scenario "does not have a button to edit profile" do + expect(page).not_to have_link "Edit profile", href: edit_member_registration_path end end end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 58041c581..793a6ada5 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'member deletion' do - context 'with activity and followers' do +feature "member deletion" do + context "with activity and followers" do let(:member) { FactoryBot.create(:member) } let(:other_member) { FactoryBot.create(:member) } let(:memberpost) { FactoryBot.create(:post, author: member) } @@ -24,86 +24,86 @@ feature 'member deletion' do logout login_as(member) FactoryBot.create(:comment, author: member, post: othermemberpost) - FactoryBot.create(:comment, author: other_member, post: memberpost, body: 'Fun comment-y thing') + FactoryBot.create(:comment, author: other_member, post: memberpost, body: "Fun comment-y thing") # deletion breaks if no wranglers exist FactoryBot.create(:cropbot) # deletion breaks if ex_member doesn't exist - FactoryBot.create(:member, login_name: 'ex_member') + FactoryBot.create(:member, login_name: "ex_member") end - scenario 'has option to delete on member profile page' do + scenario "has option to delete on member profile page" do visit member_path(member) click_link 'Edit profile' - expect(page).to have_link 'Delete Account' + expect(page).to have_link "Delete Account" end - scenario 'asks for password before deletion' do + scenario "asks for password before deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - click_button 'Delete' + click_button "Delete" expect(page).to have_content "Current password can't be blank" end - scenario 'password must be correct' do + scenario "password must be correct" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'wrongpassword' - click_button 'Delete' - expect(page).to have_content 'Current password is invalid' + fill_in "current_pw_for_delete", with: "wrongpassword" + click_button "Delete" + expect(page).to have_content "Current password is invalid" end - scenario 'deletes and removes bio' do + scenario "deletes and removes bio" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" visit member_path(member) expect(page.status_code).to eq(404) end - context 'deletes and' do + context "deletes and" do background do logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" logout end - scenario 'removes plantings' do + scenario "removes plantings" do visit planting_path(planting) expect(page.status_code).to eq(404) end - scenario 'removes gardens' do + scenario "removes gardens" do visit garden_path(secondgarden) expect(page.status_code).to eq(404) end - scenario 'removes harvests and seeds' do + scenario "removes harvests and seeds" do visit harvest_path(harvest) expect(page.status_code).to eq(404) end - scenario 'removes seeds' do + scenario "removes seeds" do visit seed_path(seed) expect(page.status_code).to eq(404) end - scenario 'removes members from following' do + scenario "removes members from following" do visit member_follows_path(other_member) expect(page).not_to have_content member.login_name.to_s visit member_followers_path(other_member) expect(page).not_to have_content member.login_name.to_s end - scenario 'replaces posts with deletion note' do + scenario "replaces posts with deletion note" do visit post_path(memberpost) expect(page.status_code).to eq(404) end @@ -112,16 +112,16 @@ feature 'member deletion' do visit post_path(othermemberpost) expect(page).not_to have_content member.login_name expect(page).to have_content other_member.login_name - expect(page).to have_content 'Member Deleted' + expect(page).to have_content "Member Deleted" end - scenario 'leaves a record of orders and payments intact' do + scenario "leaves a record of orders and payments intact" do login_as(admin) visit admin_path - fill_in 'search_text', with: member.login_name.to_s - find('#maincontainer').click_button('Search', exact: true) + fill_in "search_text", with: member.login_name.to_s + find("#maincontainer").click_button("Search", exact: true) expect(page).to have_content member.login_name.to_s - expect(page).to have_content 'Found 1 result' + expect(page).to have_content "Found 1 result" logout end @@ -133,7 +133,7 @@ feature 'member deletion' do pending "doesn't show in nearby" - scenario 'can no longer sign in' do + scenario "can no longer sign in" do visit new_member_session_path fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password @@ -143,25 +143,25 @@ feature 'member deletion' do end end - context 'for a crop wrangler' do + context "for a crop wrangler" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:otherwrangler) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop, creator: member) } FactoryBot.create(:cropbot) - let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: 'ex_wrangler') } + let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: "ex_wrangler") } - scenario 'leaves crops behind' do + scenario "leaves crops behind" do login_as(otherwrangler) visit edit_crop_path(crop) expect(page).to have_content member.login_name - expect(page).not_to have_content 'cropbot' + expect(page).not_to have_content "cropbot" logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" login_as(otherwrangler) visit edit_crop_path(crop) expect(page).not_to have_content member.login_name diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 395766fb9..01b6ee8bd 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'members list' do - context 'list all members' do - let!(:member1) { create :member, login_name: 'Archaeopteryx', confirmed_at: Time.zone.parse('2013-02-10') } - let!(:member2) { create :member, login_name: 'Zephyrosaurus', confirmed_at: Time.zone.parse('2014-01-11') } - let!(:member3) { create :member, login_name: 'Testingname', confirmed_at: Time.zone.parse('2014-05-09') } +feature "members list" do + context "list all members" do + let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') } + let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') } + let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') } - scenario 'default alphabetical sort' do + scenario "default alphabetical sort" do visit members_path - expect(page).to have_css '#sort' - expect(page).to have_selector 'form' + expect(page).to have_css "#sort" + expect(page).to have_selector "form" click_button('Show') - all_links = page.all('#maincontainer p.login-name') + all_links = page.all("#maincontainer p.login-name") expect(all_links.first).to have_text member1.login_name expect(all_links.last).to have_text member2.login_name end - scenario 'recently joined sort' do + scenario "recently joined sort" do visit members_path - expect(page).to have_css '#sort' - expect(page).to have_selector 'form' - select('recently', from: 'sort') + expect(page).to have_css "#sort" + expect(page).to have_selector "form" + select("recently", from: 'sort') click_button('Show') - all_links = page.all('#maincontainer p.login-name') + all_links = page.all("#maincontainer p.login-name") expect(all_links.first).to have_text member3.login_name expect(all_links.last).to have_text member1.login_name end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 1c0f31110..aa81403d6 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature 'Notifications', :js do +feature "Notifications", :js do let(:sender) { create :member } let(:recipient) { create :member } - context 'On existing notification' do + context "On existing notification" do let!(:notification) do create :notification, sender: sender, recipient: recipient, - body: 'Notification body', + body: "Notification body", post_id: nil end @@ -18,14 +18,14 @@ feature 'Notifications', :js do visit notification_path(notification) end - scenario 'Replying to the notification' do - click_link 'Reply' - expect(page).to have_content 'Notification body' + scenario "Replying to the notification" do + click_link "Reply" + expect(page).to have_content "Notification body" - fill_in 'notification_body', with: 'Response body' - click_button 'Send' + fill_in 'notification_body', with: "Response body" + click_button "Send" - expect(page).to have_content 'Message was successfully sent' + expect(page).to have_content "Message was successfully sent" end end diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index cc2c16593..1c13b2793 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -1,49 +1,49 @@ require 'rails_helper' -feature 'new photo page' do +feature "new photo page" do let(:photo) { FactoryBot.create :photo } - context 'signed in member' do + context "signed in member" do let(:member) { FactoryBot.create :member } background { login_as member } - context 'viewing a planting' do + context "viewing a planting" do let(:planting) { FactoryBot.create :planting, owner: member } - scenario 'add photo' do + scenario "add photo" do visit planting_path(planting) click_link('Add photo', match: :first) expect(page).to have_text planting.crop.name end end - context 'viewing a harvest' do + context "viewing a harvest" do let(:harvest) { FactoryBot.create :harvest, owner: member } - scenario 'add photo' do + scenario "add photo" do visit harvest_path(harvest) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text harvest.crop.name end end - context 'viewing a garden' do + context "viewing a garden" do let(:garden) { FactoryBot.create :garden, owner: member } - scenario 'add photo' do + scenario "add photo" do visit garden_path(garden) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text garden.name end end - pending 'viewing a seed' do + pending "viewing a seed" do let(:seed) { FactoryBot.create :seed, owner: member } - scenario 'add photo' do + scenario "add photo" do visit seed_path(seed) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text seed.to_s end end diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index 4d96a0193..bac25b370 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature 'show photo page' do +feature "show photo page" do let(:photo) { create :photo } - context 'signed in member' do + context "signed in member" do let(:member) { create :member } background { login_as member } - context 'linked to planting' do + context "linked to planting" do let(:planting) { create :planting } - scenario 'shows linkback to planting' do + scenario "shows linkback to planting" do planting.photos << photo visit photo_path(photo) expect(page).to have_link "#{planting.crop.name} planting in #{planting.garden.name} by #{planting.owner}", @@ -19,30 +19,30 @@ feature 'show photo page' do end end - context 'linked to harvest' do + context "linked to harvest" do let(:harvest) { create :harvest } - scenario 'shows linkback to harvest' do + scenario "shows linkback to harvest" do harvest.photos << photo visit photo_path(photo) expect(page).to have_link "#{harvest.crop.name} harvest by #{harvest.owner}", href: harvest_path(harvest) end end - context 'linked to garden' do + context "linked to garden" do let(:garden) { create :garden } - scenario 'shows linkback to garden' do + scenario "shows linkback to garden" do garden.photos << photo visit photo_path(photo) expect(page).to have_link "garden named \"#{garden.name}\" by #{garden.owner}", href: garden_path(garden) end end - context 'linked to seed' do + context "linked to seed" do let(:seed) { create :seed } - scenario 'shows linkback to seed' do + scenario "shows linkback to seed" do seed.photos << photo visit photo_path(photo) expect(page).to have_link "#{seed.crop.name} seeds belonging to #{seed.owner}", href: seed_path(seed) diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index dd2b47712..edbb06e59 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -1,39 +1,39 @@ -require 'rails_helper' +require "rails_helper" -feature 'User searches' do - let(:member) { create :member, location: 'Philippines' } +feature "User searches" do + let(:member) { create :member, location: "Philippines" } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:seed1) { create :seed, owner: member } - let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') } + let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") } - scenario 'with a valid place' do + scenario "with a valid place" do visit places_path - search_with 'Philippines' - expect(page).to have_content 'community near Philippines' - expect(page).to have_button 'search_button' - expect(page).to have_content 'Nearby members' - expect(page).not_to have_content 'No results found' + search_with "Philippines" + expect(page).to have_content "community near Philippines" + expect(page).to have_button "search_button" + expect(page).to have_content "Nearby members" + expect(page).not_to have_content "No results found" end - scenario 'with a blank search string' do + scenario "with a blank search string" do visit places_path - search_with '' - expect(page).to have_content 'Please enter a valid location' - expect(page).to have_button 'search_button' + search_with "" + expect(page).to have_content "Please enter a valid location" + expect(page).to have_button "search_button" end - describe 'Nearby plantings, seed, and members' do + describe "Nearby plantings, seed, and members" do before do login_as member visit places_path - search_with 'Philippines' + search_with "Philippines" end - it 'should show that there are nearby seeds, plantings, and members' do - expect(page).to have_content 'Nearby members' - expect(page).to have_content 'Seeds available for trade near Philippines' - expect(page).to have_content 'Recent plantings near Philippines' + it "should show that there are nearby seeds, plantings, and members" do + expect(page).to have_content "Nearby members" + expect(page).to have_content "Seeds available for trade near Philippines" + expect(page).to have_content "Recent plantings near Philippines" end it "should go to members' index page" do @@ -55,7 +55,7 @@ feature 'User searches' do private def search_with(search_string) - fill_in 'new_place', with: search_string - click_button 'search_button' + fill_in "new_place", with: search_string + click_button "search_button" end end diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 5a9d954b8..3b407c3df 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature 'Planting reminder email', :js do +feature "Planting reminder email", :js do let(:member) { create :member } let(:mail) { Notifier.planting_reminder(member) } @@ -11,13 +11,13 @@ feature 'Planting reminder email', :js do { host: 'localhost', port: 8080 } end - scenario 'has a greeting' do - expect(mail).to have_content 'Hello' + scenario "has a greeting" do + expect(mail).to have_content "Hello" end - context 'when member has no plantings' do - scenario 'tells you to track your plantings' do - expect(mail).to have_content 'planting your first crop' + context "when member has no plantings" do + scenario "tells you to track your plantings" do + expect(mail).to have_content "planting your first crop" end scenario "doesn't list plantings" do @@ -25,41 +25,41 @@ feature 'Planting reminder email', :js do end end - context 'when member has some plantings' do + context "when member has some plantings" do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the email is generated: otherwise, they won't be present in the email. let!(:p1) { create :planting, garden: member.gardens.first, owner: member } let!(:p2) { create :planting, garden: member.gardens.first, owner: member } - scenario 'lists plantings' do + scenario "lists plantings" do expect(mail).to have_content "most recent plantings you've told us about" expect(mail).to have_link p1.to_s, href: planting_url(p1) expect(mail).to have_link p2.to_s, href: planting_url(p2) - expect(mail).to have_content 'keep your garden records up to date' + expect(mail).to have_content "keep your garden records up to date" end end - context 'when member has no harvests' do - scenario 'tells you to tracking plantings' do - expect(mail).to have_content 'Get started now by tracking your first harvest' + context "when member has no harvests" do + scenario "tells you to tracking plantings" do + expect(mail).to have_content "Get started now by tracking your first harvest" end scenario "doesn't list plantings" do - expect(mail).not_to have_content 'the last few things you harvested were' + expect(mail).not_to have_content "the last few things you harvested were" end end - context 'when member has some harvests' do + context "when member has some harvests" do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the spec is run. let!(:h1) { create :harvest, owner: member } let!(:h2) { create :harvest, owner: member } - scenario 'lists harvests' do - expect(mail).to have_content 'the last few things you harvested were' + scenario "lists harvests" do + expect(mail).to have_content "the last few things you harvested were" expect(mail).to have_link h1.to_s, href: harvest_url(h1) expect(mail).to have_link h2.to_s, href: harvest_url(h2) - expect(mail).to have_content 'Harvested anything else lately?' + expect(mail).to have_content "Harvested anything else lately?" end end end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index ad1cfb5ff..0e26d7078 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,12 +1,12 @@ -require 'rails_helper' +require "rails_helper" require 'custom_matchers' -feature 'Planting a crop', :js, :elasticsearch do +feature "Planting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:planting) do - create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') + create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") end background do @@ -15,15 +15,15 @@ feature 'Planting a crop', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'planting' + it_behaves_like "crop suggest", "planting" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'What did you plant?' - expect(page).to have_selector '.form-group.required', text: 'Where did you plant it?' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "What did you plant?" + expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" expect(page).to have_optional 'input#planting_planted_at' expect(page).to have_optional 'input#planting_quantity' expect(page).to have_optional 'select#planting_planted_from' @@ -32,20 +32,20 @@ feature 'Planting a crop', :js, :elasticsearch do expect(page).to have_optional 'input#planting_finished_at' end - scenario 'Creating a new planting' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2014-06-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + scenario "Creating a new planting" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2014-06-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: Not enough data" end scenario "Clicking link to owner's profile" do @@ -54,230 +54,230 @@ feature 'Planting a crop', :js, :elasticsearch do expect(current_path).to eq member_path(member) end - describe 'Progress bar status on planting creation' do + describe "Progress bar status on planting creation" do before do login_as member visit new_planting_path - @a_past_date = 15.days.ago.strftime('%Y-%m-%d') - @right_now = Time.zone.today.strftime('%Y-%m-%d') - @a_future_date = 1.year.from_now.strftime('%Y-%m-%d') + @a_past_date = 15.days.ago.strftime("%Y-%m-%d") + @right_now = Time.zone.today.strftime("%Y-%m-%d") + @a_future_date = 1.year.from_now.strftime("%Y-%m-%d") end - it 'should show that it is not planted yet' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_future_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + it "should show that it is not planted yet" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_future_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: 0% - not planted yet' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: 0% - not planted yet" end - it 'should show that days before maturity is unknown' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_past_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + it "should show that days before maturity is unknown" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_past_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: Not enough data" end - it 'should show that planting is in progress' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @right_now - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - fill_in 'Finished date', with: @a_future_date - click_button 'Save' + it "should show that planting is in progress" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @right_now + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + fill_in "Finished date", with: @a_future_date + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).not_to have_content 'Progress: 0% - not planted yet' - expect(page).not_to have_content 'Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).not_to have_content "Progress: 0% - not planted yet" + expect(page).not_to have_content "Not enough data" end - it 'should show that planting is 100% complete (no date specified)' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @right_now - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + it "should show that planting is 100% complete (no date specified)" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @right_now + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content '100%' - expect(page).to have_content 'Yes (no date specified)' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "100%" + expect(page).to have_content "Yes (no date specified)" end - it 'should show that planting is 100% complete (date specified)' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_past_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - fill_in 'Finished date', with: @right_now - click_button 'Save' + it "should show that planting is 100% complete (date specified)" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_past_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + fill_in "Finished date", with: @right_now + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content '100%' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "100%" end end - scenario 'Planting from crop page' do + scenario "Planting from crop page" do visit crop_path(maize) - click_link 'Plant this' - within 'form#new_planting' do + click_link "Plant this" + within "form#new_planting" do expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'maize' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "maize" end - scenario 'Editing a planting to add details' do + scenario "Editing a planting to add details" do visit planting_path(planting) - click_link 'Edit' - fill_in 'Tell us more about it', with: 'Some extra notes' - click_button 'Save' - expect(page).to have_content 'planting was successfully updated' + click_link "Edit" + fill_in "Tell us more about it", with: "Some extra notes" + click_button "Save" + expect(page).to have_content "planting was successfully updated" end - scenario 'Editing a planting to fill in the finished date' do + scenario "Editing a planting to fill in the finished date" do visit planting_path(planting) - expect(page).to have_content 'Progress: Not enough data' - click_link 'Edit' - check 'finished' - fill_in 'Finished date', with: '2015-06-25' - click_button 'Save' - expect(page).to have_content 'planting was successfully updated' - expect(page).not_to have_content 'Progress: Not enough data' + expect(page).to have_content "Progress: Not enough data" + click_link "Edit" + check "finished" + fill_in "Finished date", with: "2015-06-25" + click_button "Save" + expect(page).to have_content "planting was successfully updated" + expect(page).not_to have_content "Progress: Not enough data" end - scenario 'Marking a planting as finished' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When?', with: '2014-07-01' - check 'Mark as finished' - fill_in 'Finished date', with: '2014-08-30' + scenario "Marking a planting as finished" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When?", with: "2014-07-01" + check "Mark as finished" + fill_in "Finished date", with: "2014-08-30" # Trigger click instead of using Capybara"s uncheck # because a date selection widget is overlapping # the checkbox preventing interaction. - find('#planting_finished').trigger 'click' + find("#planting_finished").trigger 'click' end # Javascript removes the finished at date when the # planting is marked unfinished. - expect(find('#planting_finished_at').value).to eq('') + expect(find("#planting_finished_at").value).to eq("") - within 'form#new_planting' do - find('#planting_finished').trigger 'click' + within "form#new_planting" do + find("#planting_finished").trigger 'click' end # The finished at date was cached in Javascript in # case the user clicks unfinished accidentally. - expect(find('#planting_finished_at').value).to eq('2014-08-30') + expect(find("#planting_finished_at").value).to eq("2014-08-30") - within 'form#new_planting' do - click_button 'Save' + within "form#new_planting" do + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Finished: August 30, 2014' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Finished: August 30, 2014" # shouldn't be on the page visit plantings_path - expect(page).not_to have_content 'maize' + expect(page).not_to have_content "maize" # show all plantings to see this finished planting visit plantings_path(all: 1) - expect(page).to have_content 'August 30, 2014' + expect(page).to have_content "August 30, 2014" end - scenario 'Marking a planting as finished without a date' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - check 'Mark as finished' - click_button 'Save' + scenario "Marking a planting as finished without a date" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + check "Mark as finished" + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Finished: Yes (no date specified)' - expect(page).to have_content '100%' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Finished: Yes (no date specified)" + expect(page).to have_content "100%" end - describe 'Planting sunniness' do - it 'should show the a sunny image' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2015-10-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'sun', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + describe "Planting sunniness" do + it "should show the a sunny image" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2015-10-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "sun", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end expect(page).to have_css("img[alt='sun']") end - it 'should show a sunniness not specified image' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2015-10-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + it "should show a sunniness not specified image" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2015-10-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end expect(page).to have_css("img[alt='not specified']") end end - describe 'Marking a planting as finished from the show page' do + describe "Marking a planting as finished from the show page" do let(:path) { planting_path(planting) } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end - describe 'Marking a planting as finished from the list page' do + describe "Marking a planting as finished from the list page" do let(:path) { plantings_path } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end end diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index 6e1b7aa55..ac31b6fec 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -8,26 +8,26 @@ feature 'Post a post' do visit new_post_path end - scenario 'creating a post' do - fill_in 'post_subject', with: 'Testing' - fill_in 'post_body', with: 'This is a sample test' - click_button 'Post' - expect(page).to have_content 'Post was successfully created' - expect(page).to have_content 'Posted by' + scenario "creating a post" do + fill_in "post_subject", with: "Testing" + fill_in "post_body", with: "This is a sample test" + click_button "Post" + expect(page).to have_content "Post was successfully created" + expect(page).to have_content "Posted by" end - context 'editing a post' do + context "editing a post" do let(:existing_post) { create :post, author: member } background do visit edit_post_path(existing_post) end - scenario 'saving edit' do - fill_in 'post_subject', with: 'Testing Edit' - click_button 'Post' - expect(page).to have_content 'Post was successfully updated' - expect(page).to have_content 'edited at' + scenario "saving edit" do + fill_in "post_subject", with: "Testing Edit" + click_button "Post" + expect(page).to have_content "Post was successfully updated" + expect(page).to have_content "edited at" end end end diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index a7b15d1a9..59833eff1 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -8,7 +8,7 @@ feature 'Plantings RSS feed' do scenario 'The index title is what we expect' do visit plantings_path(format: 'rss') - expect(page).to have_content 'Recent plantings from '\ + expect(page).to have_content "Recent plantings from "\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 869c00214..445a50cca 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -8,7 +8,7 @@ feature 'Posts RSS feed' do scenario 'The index title is what we expect' do visit posts_path(format: 'rss') - expect(page).to have_content 'Recent posts from '\ + expect(page).to have_content "Recent posts from "\ "#{@author ? @author : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index d4981aea5..888cc42ec 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -8,7 +8,7 @@ feature 'Seeds RSS feed' do scenario 'The index title is what we expect' do visit seeds_path(format: 'rss') - expect(page).to have_content 'Recent seeds from '\ + expect(page).to have_content "Recent seeds from "\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index a232b9d0d..d6daf709b 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature 'Scientific names', js: true do +feature "Scientific names", js: true do let!(:zea_mays) { create :zea_mays } let(:crop) { zea_mays.crop } - scenario 'Display scientific names on crop page' do + scenario "Display scientific names on crop page" do visit crop_path(zea_mays.crop) expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - scenario 'Index page for scientific names' do + scenario "Index page for scientific names" do visit scientific_names_path expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - context 'User is a crop wrangler' do + context "User is a crop wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -24,59 +24,59 @@ feature 'Scientific names', js: true do login_as(member) end - scenario 'Crop wranglers can edit scientific names' do + scenario "Crop wranglers can edit scientific names" do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content 'CROP WRANGLER' + expect(page).to have_content "CROP WRANGLER" expect(page).to have_content zea_mays.name - expect(page).to have_link 'Edit', href: edit_scientific_name_path(zea_mays) - within('.scientific_names') { click_on 'Edit' } + expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays) + within('.scientific_names') { click_on "Edit" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'Zea mirabila' - click_on 'Save' - expect(page).to have_content 'Zea mirabila' + fill_in 'Name', with: "Zea mirabila" + click_on "Save" + expect(page).to have_content "Zea mirabila" expect(page).to have_content 'crop was successfully updated' end - scenario 'Crop wranglers can delete scientific names' do + scenario "Crop wranglers can delete scientific names" do visit crop_path(zea_mays.crop) - expect(page).to have_link 'Delete', + expect(page).to have_link "Delete", href: scientific_name_path(zea_mays) - within('.scientific_names') { click_on 'Delete' } + within('.scientific_names') { click_on "Delete" } expect(page.status_code).to equal 200 expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' end - scenario 'Crop wranglers can add scientific names' do + scenario "Crop wranglers can add scientific names" do visit crop_path(crop) - expect(page).to have_link 'Add', + expect(page).to have_link "Add", href: new_scientific_name_path(crop_id: crop.id) - within('.scientific_names') { click_on 'Add' } + within('.scientific_names') { click_on "Add" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'Zea mirabila' - click_on 'Save' + fill_in 'Name', with: "Zea mirabila" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'Zea mirabila' + expect(page).to have_content "Zea mirabila" expect(page).to have_content 'crop was successfully created.' end - scenario 'The show-scientific-name page works' do + scenario "The show-scientific-name page works" do visit scientific_name_path(zea_mays) expect(page.status_code).to equal 200 expect(page).to have_link zea_mays.crop.name, href: crop_path(zea_mays.crop) end - context 'When scientific name is pending' do + context "When scientific name is pending" do let(:pending_crop) { create :crop_request } let(:pending_sci_name) { create :scientific_name, crop: pending_crop } - scenario 'Displays crop pending message' do + scenario "Displays crop pending message" do visit scientific_name_path(pending_sci_name) - expect(page).to have_content 'This crop is currently pending approval' + expect(page).to have_content "This crop is currently pending approval" end end end diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index d1f6acfac..4c183ae24 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Seeds', :js, :elasticsearch do +feature "Seeds", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } @@ -11,14 +11,14 @@ feature 'Seeds', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'seed', 'crop' + it_behaves_like "crop suggest", "seed", "crop" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'Crop:' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "Crop:" expect(page).to have_optional 'input#seed_quantity' expect(page).to have_optional 'input#seed_plant_before' expect(page).to have_optional 'input#seed_days_until_maturity_min' @@ -30,40 +30,40 @@ feature 'Seeds', :js, :elasticsearch do expect(page).to have_selector '.form-group.required', text: 'Will trade:' end - scenario 'Adding a new seed', js: true do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_seed' do - fill_in 'Quantity:', with: 42 - fill_in 'Plant before:', with: '2014-06-15' - fill_in 'Days until maturity:', with: 999 - fill_in 'to', with: 1999 - select 'certified organic', from: 'Organic?' - select 'non-certified GMO-free', from: 'GMO?' - select 'heirloom', from: 'Heirloom?' - fill_in 'Description', with: "It's killer." - select 'internationally', from: 'Will trade:' - click_button 'Save' + scenario "Adding a new seed", js: true do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_seed" do + fill_in "Quantity:", with: 42 + fill_in "Plant before:", with: "2014-06-15" + fill_in "Days until maturity:", with: 999 + fill_in "to", with: 1999 + select "certified organic", from: "Organic?" + select "non-certified GMO-free", from: "GMO?" + select "heirloom", from: "Heirloom?" + fill_in "Description", with: "It's killer." + select "internationally", from: "Will trade:" + click_button "Save" end - expect(page).to have_content 'Successfully added maize seed to your stash' - expect(page).to have_content 'Quantity: 42' - expect(page).to have_content 'Days until maturity: 999–1999' - expect(page).to have_content 'certified organic' - expect(page).to have_content 'non-certified GMO-free' - expect(page).to have_content 'Heirloom? heirloom' + expect(page).to have_content "Successfully added maize seed to your stash" + expect(page).to have_content "Quantity: 42" + expect(page).to have_content "Days until maturity: 999–1999" + expect(page).to have_content "certified organic" + expect(page).to have_content "non-certified GMO-free" + expect(page).to have_content "Heirloom? heirloom" expect(page).to have_content "It's killer." end - scenario 'Adding a seed from crop page' do + scenario "Adding a seed from crop page" do visit crop_path(maize) - click_link 'Add seeds to stash' - within 'form#new_seed' do + click_link "Add seeds to stash" + within "form#new_seed" do expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'Successfully added maize seed to your stash' - expect(page).to have_content 'maize' + expect(page).to have_content "Successfully added maize seed to your stash" + expect(page).to have_content "maize" end end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 824a2f5c7..1db053a80 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'seeds', js: true do - context 'signed in user' do +feature "seeds", js: true do + context "signed in user" do let(:member) { create :member } let(:crop) { create :crop } @@ -9,17 +9,17 @@ feature 'seeds', js: true do login_as member end - scenario 'button on index to edit seed' do + scenario "button on index to edit seed" do seed = create :seed, owner: member visit seeds_path - click_link 'edit_seed_glyphicon' + click_link "edit_seed_glyphicon" expect(current_path).to eq edit_seed_path(seed) expect(page).to have_content 'Editing seeds' end - scenario 'button on front page to add seeds' do + scenario "button on front page to add seeds" do visit root_path - click_link 'Add seeds' + click_link "Add seeds" expect(current_path).to eq new_seed_path expect(page).to have_content 'Add seeds' end @@ -32,7 +32,7 @@ feature 'seeds', js: true do # actually adding seeds is in spec/features/seeds_new_spec.rb - scenario 'edit seeds' do + scenario "edit seeds" do seed = create :seed, owner: member visit seed_path(seed) click_link 'Edit' @@ -42,35 +42,35 @@ feature 'seeds', js: true do expect(current_path).to eq seed_path(seed) end - scenario 'delete seeds' do + scenario "delete seeds" do seed = create :seed, owner: member visit seed_path(seed) click_link 'Delete' expect(current_path).to eq seeds_path end - scenario 'view seeds with max and min days until maturity' do + scenario "view seeds with max and min days until maturity" do seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 5–7' + expect(page).to have_content "Days until maturity: 5–7" end - scenario 'view seeds with only max days until maturity' do + scenario "view seeds with only max days until maturity" do seed = create :seed, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 7' + expect(page).to have_content "Days until maturity: 7" end - scenario 'view seeds with only min days until maturity' do + scenario "view seeds with only min days until maturity" do seed = create :seed, days_until_maturity_min: 5 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 5' + expect(page).to have_content "Days until maturity: 5" end - scenario 'view seeds with neither max nor min days until maturity' do + scenario "view seeds with neither max nor min days until maturity" do seed = create :seed visit seed_path(seed) - expect(page).to have_content 'Days until maturity: unknown' + expect(page).to have_content "Days until maturity: unknown" end end end diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index d0bd8531b..7e26ece28 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Seeds', :js do +feature "Seeds", :js do subject do login_as member visit seed_path(seed) @@ -26,16 +26,16 @@ feature 'Seeds', :js do before { seed.photos = photos } let!(:photos) { FactoryBot.create_list :photo, 50 } - it 'shows newest photo' do + it "shows newest photo" do is_expected.to have_xpath("//img[contains(@src,'#{photos.last.thumbnail_url}')]") end - it 'links to newest photo' do + it "links to newest photo" do is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photos.last)}')]") end - it 'does not show oldest photo' do + it "does not show oldest photo" do is_expected.not_to have_xpath("//img[contains(@src,'#{photos.first.thumbnail_url}')]") end - it 'does not link to oldest photo' do + it "does not link to oldest photo" do is_expected.not_to have_xpath("//a[contains(@href,'#{photo_path(photos.first)}')]") end end diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index eda8257ba..03e29c5f4 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -1,21 +1,21 @@ -shared_examples 'append date' do - let(:this_month) { Time.zone.today.strftime('%B') } - let(:this_year) { Time.zone.today.strftime('%Y') } +shared_examples "append date" do + let(:this_month) { Time.zone.today.strftime("%B") } + let(:this_year) { Time.zone.today.strftime("%Y") } background { visit path } - scenario 'Selecting a date with datepicker' do + scenario "Selecting a date with datepicker" do click_link link_text - within 'div.datepicker' do + within "div.datepicker" do expect(page).to have_content this_month.to_s - find('.datepicker-days td.day', text: '21').click + find(".datepicker-days td.day", text: "21").click end expect(page).to have_content "Finished: #{this_month} 21, #{this_year}" end - scenario 'Confirming without selecting date' do + scenario "Confirming without selecting date" do click_link link_text - click_link 'Confirm without date' - expect(page).to have_content('Finished: Yes (no date specified) ') + click_link "Confirm without date" + expect(page).to have_content("Finished: Yes (no date specified) ") end end diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 5bd51205d..0d2e688a1 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -1,6 +1,6 @@ require 'rails_helper' -shared_examples 'crop suggest' do |resource| +shared_examples "crop suggest" do |resource| let!(:pea) { create :crop, name: 'pea' } let!(:pear) { create :pear } let!(:tomato) { create :tomato } @@ -8,66 +8,66 @@ shared_examples 'crop suggest' do |resource| background { sync_elasticsearch [pea, pear, maize, tomato] } - scenario 'placeholder text in crop auto suggest field' do + scenario "placeholder text in crop auto suggest field" do expect(page).to have_selector("input[placeholder='e.g. lettuce']") end - scenario 'typing in the crop name displays suggestions' do + scenario "typing in the crop name displays suggestions" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pe' + fill_autocomplete "crop", with: "pe" end - expect(page).not_to have_content('pear') - expect(page).not_to have_content('pea') + expect(page).not_to have_content("pear") + expect(page).not_to have_content("pea") within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pea' + fill_autocomplete "crop", with: "pea" end - expect(page).to have_content('pear') - expect(page).to have_content('pea') + expect(page).to have_content("pear") + expect(page).to have_content("pea") within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pear' + fill_autocomplete "crop", with: "pear" end - expect(page).to have_content('pear') + expect(page).to have_content("pear") end - scenario 'selecting crop from dropdown' do + scenario "selecting crop from dropdown" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pear' + fill_autocomplete "crop", with: "pear" end - select_from_autocomplete('pear') + select_from_autocomplete("pear") expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", visible: false) end - scenario 'Typing and pausing does not affect input' do + scenario "Typing and pausing does not affect input" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pea' + fill_autocomplete "crop", with: "pea" end - expect(page).to have_content('pear') - expect(find_field('crop').value).to eq('pea') + expect(page).to have_content("pear") + expect(find_field("crop").value).to eq("pea") end - scenario 'Searching for a crop casts a wide net on results' do + scenario "Searching for a crop casts a wide net on results" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'tom' + fill_autocomplete "crop", with: "tom" end - expect(page).to have_content('tomato') - expect(page).to have_content('roma tomato') + expect(page).to have_content("tomato") + expect(page).to have_content("roma tomato") end scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'Ryan Gosling' - click_button 'Save' + fill_autocomplete "crop", with: "Ryan Gosling" + click_button "Save" end - expect(page).to have_content('Crop must be present and exist in our database') + expect(page).to have_content("Crop must be present and exist in our database") end end diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index e2817517b..acd9f5295 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'signin', js: true do +feature "signin", js: true do let(:member) { create :member } let(:recipient) { create :member } let(:wrangler) { create :crop_wrangling_member } @@ -12,14 +12,14 @@ feature 'signin', js: true do click_button 'Sign in' end - scenario 'via email address' do + scenario "via email address" do visit crops_path # some random page click_link 'Sign in' login - expect(page).to have_content('Sign out') + expect(page).to have_content("Sign out") end - scenario 'redirect to previous page after signin' do + scenario "redirect to previous page after signin" do visit crops_path # some random page click_link 'Sign in' login @@ -33,12 +33,12 @@ feature 'signin', js: true do expect(current_path).to eq root_path end - scenario 'redirect to signin page for if not authenticated to view notification' do + scenario "redirect to signin page for if not authenticated to view notification" do visit notification_path(notification) expect(current_path).to eq new_member_session_path end - shared_examples 'redirects to what you were trying to do' do + shared_examples "redirects to what you were trying to do" do scenario do visit "/#{model_name}/new" expect(current_path).to eq new_member_session_path @@ -47,33 +47,33 @@ feature 'signin', js: true do end end - describe 'redirects to what you were trying to do' do + describe "redirects to what you were trying to do" do %w(plantings harvests posts photos gardens seeds).each do |m| - it_behaves_like 'redirects to what you were trying to do' do + it_behaves_like "redirects to what you were trying to do" do let(:model_name) { m } end end end - scenario 'after signin, redirect to new notifications page' do + scenario "after signin, redirect to new notifications page" do visit new_notification_path(recipient: recipient) expect(current_path).to eq new_member_session_path login expect(current_path).to eq new_notification_path end - scenario 'after crop wrangler signs in and crops await wrangling, show alert' do + scenario "after crop wrangler signs in and crops await wrangling, show alert" do create :crop_request visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: wrangler.login_name fill_in 'Password', with: wrangler.password click_button 'Sign in' - expect(page).to have_content('There are crops waiting to be wrangled.') + expect(page).to have_content("There are crops waiting to be wrangled.") end - context 'with facebook' do - scenario 'sign in' do + context "with facebook" do + scenario "sign in" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index e97d31db2..35cd8af9b 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'signout' do +feature "signout" do let(:member) { create :member } - scenario 'redirect to previous page after signout' do + scenario "redirect to previous page after signout" do visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: member.login_name @@ -13,8 +13,8 @@ feature 'signout' do expect(current_path).to eq crops_path end - shared_examples 'sign-in redirects' do |path| - scenario 'after signout, redirect to signin page if page needs authentication' do + shared_examples "sign-in redirects" do |path| + scenario "after signout, redirect to signin page if page needs authentication" do visit path expect(current_path).to eq new_member_session_path expect(page).to have_http_status(200) @@ -32,11 +32,11 @@ feature 'signout' do let(:path) {} describe 'after signout, redirect to signin page if page needs authentication' do - include_examples 'sign-in redirects', '/plantings/new' - include_examples 'sign-in redirects', '/harvests/new' - include_examples 'sign-in redirects', '/posts/new' - include_examples 'sign-in redirects', '/gardens/new' - include_examples 'sign-in redirects', '/seeds/new' + include_examples "sign-in redirects", "/plantings/new" + include_examples "sign-in redirects", "/harvests/new" + include_examples "sign-in redirects", "/posts/new" + include_examples "sign-in redirects", "/gardens/new" + include_examples "sign-in redirects", "/seeds/new" end scenario 'photos' do diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 968158879..6afb28119 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'signup', js: true do - scenario 'sign up for new account from top menubar' do +feature "signup", js: true do + scenario "sign up for new account from top menubar" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -13,7 +13,7 @@ feature 'signup', js: true do expect(current_path).to eq root_path end - scenario 'sign up for new account with existing username' do + scenario "sign up for new account with existing username" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -32,7 +32,7 @@ feature 'signup', js: true do click_button 'Sign up' end - scenario 'sign up for new account without accepting TOS' do + scenario "sign up for new account without accepting TOS" do visit root_path first('.signup a').click # click the 'Sign up' button in the middle of the page fill_in 'Login name', with: 'person123' @@ -44,8 +44,8 @@ feature 'signup', js: true do expect(current_path).to eq members_path end - context 'with facebook' do - scenario 'sign up' do + context "with facebook" do + scenario "sign up" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all Member.where(email: 'tdawg@hotmail.com').delete_all diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 96dfa92de..8244d207a 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature 'unsubscribe' do +feature "unsubscribe" do let(:member) { create :member } let(:notification) { create :notification } @@ -9,7 +9,7 @@ feature 'unsubscribe' do clear_emails end - scenario 'from planting reminder mailing list' do + scenario "from planting reminder mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -20,13 +20,13 @@ feature 'unsubscribe' do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from planting reminders' - expect(page).to have_content 'You have been unsubscribed from planting reminders' + expect(page).to have_content "You have been unsubscribed from planting reminders" updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(false) expect(updated_member.send_notification_email).to eq(true) end - scenario 'from inbox notification mailing list' do + scenario "from inbox notification mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -38,13 +38,13 @@ feature 'unsubscribe' do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from direct message notifications' - expect(page).to have_content 'You have been unsubscribed from direct message notifications' + expect(page).to have_content "You have been unsubscribed from direct message notifications" updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(true) expect(updated_member.send_notification_email).to eq(false) end - scenario 'visit unsubscribe page with a non-encrypted parameter' do + scenario "visit unsubscribe page with a non-encrypted parameter" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 64369860f..b3ea0ce52 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe ApplicationHelper do - it 'formats prices' do + it "formats prices" do price_in_dollars(999).should eq '9.99' price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency) end - it 'parses dates' do + it "parses dates" do parse_date(nil).should eq nil parse_date('').should eq nil parse_date('2012-05-12').should eq Date.new(2012, 5, 12) parse_date('may 12th 2012').should eq Date.new(2012, 5, 12) end - it 'shows required field marker help text with proper formatting' do + it "shows required field marker help text with proper formatting" do output = required_field_help_text expect(output).to have_selector '.margin-bottom' expect(output).to have_selector '.red', text: '*' diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb index d47fd90cd..49a570836 100644 --- a/spec/helpers/crops_helper_spec.rb +++ b/spec/helpers/crops_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe CropsHelper do - describe 'display_seed_availability' do + describe "display_seed_availability" do before :each do @member = create :member @crop = create :tomato end - context 'with no seeds' do + context "with no seeds" do it 'should render' do expect(helper.display_seed_availability(@member, @crop)).to eq "You don't have any seeds of this crop." end end - context 'with an unknown quantity of seeds' do + context "with an unknown quantity of seeds" do before do create :seed, crop: @crop, quantity: nil, owner: @member end @@ -21,11 +21,11 @@ describe CropsHelper do it 'should render' do expect( helper.display_seed_availability(@member, @crop) - ).to eq 'You have an unknown quantity of seeds of this crop.' + ).to eq "You have an unknown quantity of seeds of this crop." end end - context 'with an quantity of seeds' do + context "with an quantity of seeds" do before do a_different_crop = create :apple @@ -36,7 +36,7 @@ describe CropsHelper do end it 'should render' do - expect(helper.display_seed_availability(@member, @crop)).to eq 'You have 33 seeds of this crop.' + expect(helper.display_seed_availability(@member, @crop)).to eq "You have 33 seeds of this crop." end end end diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb index bfb9e1bbc..c22b51b79 100644 --- a/spec/helpers/gardens_helper_spec.rb +++ b/spec/helpers/gardens_helper_spec.rb @@ -1,55 +1,55 @@ require 'rails_helper' describe GardensHelper do - describe 'garden description' do - it 'is missing' do + describe "garden description" do + it "is missing" do garden = FactoryBot.create(:garden, description: nil) result = helper.display_garden_description(garden) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 20) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 130) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 140) result = helper.display_garden_description(garden) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', garden_path(garden)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", garden_path(garden)) end end - describe 'garden plantings' do - it 'is missing' do + describe "garden plantings" do + it "is missing" do result = helper.display_garden_plantings(nil) - expect(result).to eq 'None' + expect(result).to eq "None" end - it 'has 1 planting' do + it "has 1 planting" do crop = FactoryBot.create(:crop) plantings = [FactoryBot.create(:planting, quantity: 10, crop: crop)] result = helper.display_garden_plantings(plantings) output = '
    • ' - output += '10 ' + link_to(crop.name, crop) + output += "10 " + link_to(crop.name, crop) output += ", planted on #{plantings.first.planted_at}" - output += '
    ' + output += "
" expect(result).to eq output end - it 'has 2 plantings' do + it "has 2 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -61,17 +61,17 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += '10 ' + link_to(crop1.name, crop1) + output += "10 " + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += '
  • ' - output += '
  • ' - output += '10 ' + link_to(crop2.name, crop2) + output += "
  • " + output += "
  • " + output += "10 " + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += '
' + output += "" expect(result).to eq output end - it 'has 3 plantings' do + it "has 3 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -86,13 +86,13 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += '10 ' + link_to(crop1.name, crop1) + output += "10 " + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += '
  • ' - output += '
  • ' - output += '10 ' + link_to(crop2.name, crop2) + output += "
  • " + output += "
  • " + output += "10 " + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += '
' + output += "" expect(result).to eq output end end diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index a234bc260..1ba63810d 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe HarvestsHelper do - describe 'display_quantity' do - it 'blank' do + describe "display_quantity" do + it "blank" do harvest = FactoryBot.create(:harvest, quantity: nil, weight_quantity: nil) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 8281b3712..a00dabff3 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' describe NotificationsHelper do - describe 'reply_link' do + describe "reply_link" do let(:member) { FactoryBot.create(:member) } - it 'replies to PMs with PMs' do + it "replies to PMs with PMs" do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil link.should eq reply_notification_url(notification) end - it 'replies to post comments with post comments' do + it "replies to post comments with post comments" do notification = FactoryBot.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index acde7469f..3af084d5a 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,64 +1,64 @@ require 'rails_helper' describe PlantingsHelper do - describe 'display_planting' do + describe "display_planting" do let!(:member) { FactoryBot.build(:member, login_name: 'crop_lady') } - it 'does not have a quantity nor a planted from value provided' do + it "does not have a quantity nor a planted from value provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady.' + expect(result).to eq "crop_lady." end - it 'does not have a quantity provided' do + it "does not have a quantity provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted seeds.' + expect(result).to eq "crop_lady planted seeds." end - context 'when quantity is greater than 1' do - it 'does not have a planted from value provided' do + context "when quantity is greater than 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 10, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 10 units.' + expect(result).to eq "crop_lady planted 10 units." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 5, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 5 seeds.' + expect(result).to eq "crop_lady planted 5 seeds." end end - context 'when quantity is 1' do - it 'does not have a planted from value provided' do + context "when quantity is 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 unit.' + expect(result).to eq "crop_lady planted 1 unit." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 seed.' + expect(result).to eq "crop_lady planted 1 seed." end end end diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 837e1368a..3d559058e 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,33 +1,33 @@ require 'rails_helper' describe SeedsHelper do - describe 'seed description' do - it 'is missing' do + describe "seed description" do + it "is missing" do seed = FactoryBot.create(:seed, description: nil) result = helper.display_seed_description(seed) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 20) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 130) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 140) result = helper.display_seed_description(seed) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', seed_path(seed)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed)) end end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index a6f7958b1..1710428a4 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -17,8 +17,8 @@ describe 'Growstuff::OauthSignupAction' do 'image' => 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, 'credentials' => { - 'token' => 'token', - 'secret' => 'donttell' + 'token' => "token", + 'secret' => "donttell" }) end diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 4677f596c..415751293 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -10,8 +10,8 @@ describe 'Haml::Filters::Escaped_Markdown' do end it 'converts Markdown to escaped HTML' do - rendered = Haml::Filters::EscapedMarkdown.render('**foo**') - rendered.should == '<p><strong>foo</strong></p>' + rendered = Haml::Filters::EscapedMarkdown.render("**foo**") + rendered.should == "<p><strong>foo</strong></p>" end it 'converts quick crop links' do diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 6c92c5e6d..03ad3b0e1 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -35,17 +35,17 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent crops" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('not a crop')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_link("not a crop")) expect(rendered).to match(/not a crop/) end it "doesn't convert escaped crop links" do @crop = FactoryBot.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) expect(rendered).to match(/\[#{@crop.name}\]\(crop\)/) end - it 'handles multiple crop links' do + it "handles multiple crop links" do tomato = FactoryBot.create(:tomato) maize = FactoryBot.create(:maize) string = "#{input_link(tomato)} #{input_link(maize)}" @@ -53,24 +53,24 @@ describe 'Haml::Filters::Growstuff_Markdown' do expect(rendered).to match(/#{output_link(tomato)} #{output_link(maize)}/) end - it 'converts normal markdown' do - string = '**foo**' + it "converts normal markdown" do + string = "**foo**" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/foo<\/strong>/) end - it 'finds crops case insensitively' do + it "finds crops case insensitively" do @crop = FactoryBot.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end - it 'fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)' do + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do tomato = FactoryBot.create(:tomato) - string = '[test](http://example.com) [tomato](crop)' + string = "[test](http://example.com) [tomato](crop)" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/#{output_link(tomato)}/) - expect(rendered).to match 'test' + expect(rendered).to match "test" end it 'converts quick member links' do @@ -80,13 +80,13 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent members" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link('not a member')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member")) expect(rendered).to include('not a member') end it "doesn't convert escaped members" do @member = FactoryBot.create(:member) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_member_link(@member.login_name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name)) expect(rendered).to match(/\[#{@member.login_name}\]\(member\)/) end @@ -97,7 +97,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert invalid @ members" do - rendered = Haml::Filters::GrowstuffMarkdown.render('@notamember') + rendered = Haml::Filters::GrowstuffMarkdown.render("@notamember") expect(rendered).to include('@notamember') end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 344b26e7f..e50682700 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" describe Notifier do - describe 'notifications' do + describe "notifications" do let(:notification) { FactoryBot.create(:notification) } let(:mail) { Notifier.notify(notification) } @@ -18,12 +18,12 @@ describe Notifier do end end - describe 'planting reminders' do + describe "planting reminders" do let(:member) { FactoryBot.create(:member) } let(:mail) { Notifier.planting_reminder(member) } it 'sets the subject correctly' do - mail.subject.should == 'What have you planted lately?' + mail.subject.should == "What have you planted lately?" end it 'comes from noreply@growstuff.org' do @@ -43,7 +43,7 @@ describe Notifier do end end - describe 'new crop request' do + describe "new crop request" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop_request) } let(:mail) { Notifier.new_crop_request(member, crop) } @@ -65,13 +65,13 @@ describe Notifier do end end - describe 'crop approved' do + describe "crop approved" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:crop) } let(:mail) { Notifier.crop_request_approved(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Magic bean has been approved' + expect(mail.subject).to eq "Magic bean has been approved" end it 'comes from noreply@growstuff.org' do @@ -93,13 +93,13 @@ describe Notifier do end end - describe 'crop rejected' do + describe "crop rejected" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:rejected_crop) } let(:mail) { Notifier.crop_request_rejected(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Fail bean has been rejected' + expect(mail.subject).to eq "Fail bean has been rejected" end it 'comes from noreply@growstuff.org' do @@ -115,7 +115,7 @@ describe Notifier do end it 'includes the reason for rejection' do - expect(mail.body.encoded).to match 'Totally fake' + expect(mail.body.encoded).to match "Totally fake" end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index d69b0ba57..ef746c8bc 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -5,7 +5,7 @@ describe Ability do let(:member) { FactoryBot.create(:member) } let(:ability) { Ability.new(member) } - context 'notifications' do + context "notifications" do it 'member can view their own notifications' do notification = FactoryBot.create(:notification, recipient: member) ability.should be_able_to(:read, notification) @@ -22,7 +22,7 @@ describe Ability do recipient: member, sender: member)) end - it 'member can send messages to someone else' do + it "member can send messages to someone else" do ability.should be_able_to(:create, FactoryBot.create(:notification, recipient: FactoryBot.create(:member), @@ -30,51 +30,51 @@ describe Ability do end end - context 'crop wrangling' do + context "crop wrangling" do let(:crop) { FactoryBot.create(:crop) } - context 'standard member' do + context "standard member" do it "can't manage crops" do ability.should_not be_able_to(:update, crop) ability.should_not be_able_to(:destroy, crop) end - it 'can request crops' do + it "can request crops" do ability.should be_able_to(:create, Crop) end - it 'can read crops' do + it "can read crops" do ability.should be_able_to(:read, crop) end end - context 'crop wrangler' do + context "crop wrangler" do let(:role) { FactoryBot.create(:crop_wrangler) } before(:each) do member.roles << role end - it 'has crop_wrangler role' do + it "has crop_wrangler role" do member.role?(:crop_wrangler).should be true end - it 'can create crops' do + it "can create crops" do ability.should be_able_to(:create, Crop) end - it 'can update crops' do + it "can update crops" do ability.should be_able_to(:update, crop) end - it 'can destroy crops' do + it "can destroy crops" do ability.should be_able_to(:destroy, crop) end end end - context 'products' do + context "products" do let(:product) { FactoryBot.create(:product) } - context 'standard member' do + context "standard member" do it "can't read or manage products" do ability.should_not be_able_to(:read, product) ability.should_not be_able_to(:create, Product) @@ -83,33 +83,33 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read products' do + it "can read products" do ability.should be_able_to(:read, product) end - it 'can create products' do + it "can create products" do ability.should be_able_to(:create, Product) end - it 'can update products' do + it "can update products" do ability.should be_able_to(:update, product) end - it 'can destroy products' do + it "can destroy products" do ability.should be_able_to(:destroy, product) end end end - context 'orders' do + context "orders" do let(:order) { FactoryBot.create(:order, member: member) } let(:strangers_order) do FactoryBot.create(:order, @@ -129,8 +129,8 @@ describe Ability do order: completed_order) end - context 'standard member' do - it 'can read their own orders' do + context "standard member" do + it "can read their own orders" do ability.should be_able_to(:read, order) ability.should be_able_to(:read, completed_order) end @@ -139,11 +139,11 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order) end - it 'can create a new order' do + it "can create a new order" do ability.should be_able_to(:create, Order) end - it 'can complete their own current order' do + it "can complete their own current order" do ability.should be_able_to(:complete, order) end @@ -155,7 +155,7 @@ describe Ability do ability.should_not be_able_to(:complete, completed_order) end - it 'can delete a current order' do + it "can delete a current order" do ability.should be_able_to(:destroy, order) end @@ -176,7 +176,7 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order_item) end - it 'can create a new order item' do + it "can create a new order item" do ability.should be_able_to(:create, OrderItem) end @@ -205,30 +205,30 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read orders' do + it "can read orders" do ability.should be_able_to(:read, order) end - it 'cannot create orders' do + it "cannot create orders" do ability.should_not be_able_to(:create, order) end - it 'cannot complete orders' do + it "cannot complete orders" do ability.should_not be_able_to(:complete, order) end - it 'cannot delete orders' do + it "cannot delete orders" do ability.should_not be_able_to(:destroy, order) end end @@ -255,10 +255,10 @@ describe Ability do member.roles << role end - it 'can read account details' do + it "can read account details" do ability.should be_able_to(:read, account) end - it 'can manage account details' do + it "can manage account details" do ability.should be_able_to(:create, Account) ability.should be_able_to(:update, account) ability.should be_able_to(:destroy, account) @@ -270,7 +270,7 @@ describe Ability do let(:plant_part) { FactoryBot.create(:plant_part) } context 'ordinary member' do - it 'can read plant parts' do + it "can read plant parts" do ability.should be_able_to(:read, plant_part) end it "can't manage plant parts" do @@ -287,15 +287,15 @@ describe Ability do member.roles << role end - it 'can read plant_part details' do + it "can read plant_part details" do ability.should be_able_to(:read, plant_part) end - it 'can manage plant_part details' do + it "can manage plant_part details" do ability.should be_able_to(:create, PlantPart) ability.should be_able_to(:update, plant_part) end - it 'can delete an unused plant part' do + it "can delete an unused plant part" do ability.should be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 915750eaa..15eb68084 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Account do let(:member) { FactoryBot.create(:member) } - it 'auto-creates an account detail record when a member is created' do + it "auto-creates an account detail record when a member is created" do member.account.should be_an_instance_of Account end @@ -17,7 +17,7 @@ describe Account do member.account.paid_until_string.should eq nil member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq 'forever' + member.account.paid_until_string.should eq "forever" member.account.account_type = FactoryBot.create(:paid_account_type) @time = Time.zone.now diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index 64e483446..f358a9fca 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,7 +10,7 @@ describe AlternateName do it 'should be possible to add multiple alternate names to a crop' do crop = an.crop an2 = AlternateName.create( - name: 'really alternative tomato', + name: "really alternative tomato", crop_id: crop.id, creator_id: an.creator.id ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 593d0da1b..bc90ee8ba 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' describe Comment do - context 'basic' do + context "basic" do let(:comment) { FactoryBot.create(:comment) } - it 'belongs to a post' do + it "belongs to a post" do comment.post.should be_an_instance_of Post end - it 'belongs to an author' do + it "belongs to an author" do comment.author.should be_an_instance_of Member end end - context 'notifications' do + context "notifications" do let(:comment) { FactoryBot.create(:comment) } - it 'sends a notification when a comment is posted' do + it "sends a notification when a comment is posted" do expect do FactoryBot.create(:comment) end.to change(Notification, :count).by(1) end - it 'sets the notification fields' do + it "sets the notification fields" do @c = FactoryBot.create(:comment) @n = Notification.first @n.sender.should eq @c.author @@ -41,7 +41,7 @@ describe Comment do end end - context 'ordering' do + context "ordering" do before(:each) do @m = FactoryBot.create(:member) @p = FactoryBot.create(:post, author: @m) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 254573e80..3f49a249d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -11,8 +11,8 @@ describe Crop do it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') - @crop2.en_wikipedia_url.should eq('http://en.wikipedia.org/wiki/Tomato') - @crop2.slug.should eq('tomato') + @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") + @crop2.slug.should eq("tomato") end it 'should stringify as the system name' do @@ -54,7 +54,7 @@ describe Crop do FactoryBot.create_list(:planting, 3, crop: tomato) end - it 'sorts by most plantings' do + it "sorts by most plantings" do Crop.popular.first.should eq maize FactoryBot.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato @@ -77,7 +77,7 @@ describe Crop do @crop.plantings.size.should eq 1 end - context 'wikipedia url' do + context "wikipedia url" do subject { FactoryBot.build(:tomato, en_wikipedia_url: wikipedia_url) } context 'not a url' do @@ -116,7 +116,7 @@ describe Crop do it { expect(subject).not_to be_valid } end - context 'with script tags in url' do + context "with script tags in url" do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } it { expect(subject).not_to be_valid } @@ -331,13 +331,13 @@ describe Crop do let(:pp1) { FactoryBot.create(:plant_part) } let(:pp2) { FactoryBot.create(:plant_part) } - context 'harvests' do + context "harvests" do let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } - it 'has harvests' do + it "has harvests" do expect(crop.harvests).to eq [harvest] end end @@ -350,21 +350,21 @@ describe Crop do @maize.plant_parts.should eq [@pp1] end - context 'search', :elasticsearch do + context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } before { sync_elasticsearch([mushroom]) } - it 'finds exact matches' do + it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] end - it 'finds approximate matches' do + it "finds approximate matches" do Crop.search('mush').should eq [mushroom] end it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end - it 'searches case insensitively' do + it "searches case insensitively" do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do @@ -379,141 +379,141 @@ describe Crop do end end - context 'csv loading' do + context "csv loading" do before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) end - context 'scientific names' do - it 'adds a scientific name to a crop that has none' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar'] + context "scientific names" do + it "adds a scientific name to a crop that has none" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 - expect(tomato.default_scientific_name).to eq 'Foo bar' + expect(tomato.default_scientific_name).to eq "Foo bar" end - it 'picks up scientific name from parent crop if available' do + it "picks up scientific name from parent crop if available" do parent = CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent"] ) expect(tomato.parent).to eq parent - expect(tomato.parent.default_scientific_name).to eq 'Parentis cropis' - expect(tomato.default_scientific_name).to eq 'Parentis cropis' + expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" + expect(tomato.default_scientific_name).to eq "Parentis cropis" end it "doesn't add a duplicate scientific name" do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar, Foo bar'] + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar, Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 end it "doesn't add a duplicate scientific name from parent" do CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent', 'Parentis cropis'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent", "Parentis cropis"] ) expect(tomato.scientific_names.size).to eq 1 end - it 'loads a crop with multiple scientific names' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo,Bar'] + it "loads a crop with multiple scientific names" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo,Bar"] tomato = CsvImporter.new.import_crop(row) - expect(tomato.scientific_names[0].name).to eq 'Foo' - expect(tomato.scientific_names[1].name).to eq 'Bar' + expect(tomato.scientific_names[0].name).to eq "Foo" + expect(tomato.scientific_names[1].name).to eq "Bar" end - it 'loads multiple scientific names with variant spacing' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Baz, Quux'] + it "loads multiple scientific names with variant spacing" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 2 - expect(tomato.scientific_names[0].name).to eq 'Baz' - expect(tomato.scientific_names[1].name).to eq 'Quux' + expect(tomato.scientific_names[0].name).to eq "Baz" + expect(tomato.scientific_names[1].name).to eq "Quux" end end # scientific names - context 'alternate names' do - it 'loads an alternate name' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo'] + context "alternate names" do + it "loads an alternate name" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 - expect(tomato.alternate_names.last.name).to eq 'Foo' + expect(tomato.alternate_names.last.name).to eq "Foo" end - it 'adds multiple alternate names' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo, Bar'] + it "adds multiple alternate names" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo, Bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 2 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" end - it 'adds multiple alt names with variant spacing' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo,Bar,Baz, Quux'] + it "adds multiple alt names with variant spacing" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo,Bar,Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 4 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' - expect(tomato.alternate_names[2].name).to eq 'Baz' - expect(tomato.alternate_names[3].name).to eq 'Quux' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" + expect(tomato.alternate_names[2].name).to eq "Baz" + expect(tomato.alternate_names[3].name).to eq "Quux" end - it 'Adds a duplicate alternate name for second crop' do - row = ['tomato', 'http://en.wikipedia.org/wiki/tomato', '', '', 'Foo'] + it "Adds a duplicate alternate name for second crop" do + row = ["tomato", "http://en.wikipedia.org/wiki/tomato", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) - row = ['tomoto', 'http://en.wikipedia.org/wiki/tomoto', '', '', 'Foo'] + row = ["tomoto", "http://en.wikipedia.org/wiki/tomoto", "", "", "Foo"] tomoto = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 expect(tomoto.alternate_names.size).to eq 1 end end # alternate names - it 'loads the simplest possible crop' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato'] + it "loads the simplest possible crop" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(tomato.creator).to eq @cropbot end - it 'loads a crop with a scientific name' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato', '', 'Solanum lycopersicum'] + it "loads a crop with a scientific name" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato", "", "Solanum lycopersicum"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.scientific_names.size).to eq 1 - expect(tomato.scientific_names.last.name).to eq 'Solanum lycopersicum' + expect(tomato.scientific_names.last.name).to eq "Solanum lycopersicum" end - it 'loads a crop with an alternate name' do + it "loads a crop with an alternate name" do crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', nil, nil, 'Foo'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", nil, nil, "Foo"] ) - expect(crop.name).to eq 'tomato' + expect(crop.name).to eq "tomato" expect(crop.alternate_names.size).to eq 1 - expect(crop.alternate_names.last.name).to eq 'Foo' + expect(crop.alternate_names.last.name).to eq "Foo" end - it 'loads a crop with a parent' do + it "loads a crop with a parent" do parent = FactoryBot.create(:crop, name: 'parent') crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', 'parent'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", "parent"] ) expect(crop.parent).to eq parent end - it 'loads a crop with a missing parent' do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,parent' + it "loads a crop with a missing parent" do + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) @@ -524,40 +524,40 @@ describe Crop do end it "doesn't add unnecessary duplicate crops" do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum' + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) end loaded = Crop.last - expect(loaded.name).to eq 'tomato' + expect(loaded.name).to eq "tomato" expect(loaded.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(loaded.creator).to eq @cropbot end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - describe 'destroying a crop' do + describe "destroying a crop" do before do tomato.destroy end - it 'should delete the association between post and the crop(tomato)' do + it "should delete the association between post and the crop(tomato)" do expect(Post.find(post.id).crops).to eq [maize] end - it 'should not delete the posts' do + it "should not delete the posts" do expect(Post.find(post.id)).not_to eq nil end end end - context 'crop rejections' do + context "crop rejections" do let!(:rejected_reason) do FactoryBot.create(:crop, name: 'tomato', approval_status: 'rejected', @@ -570,13 +570,13 @@ describe Crop do rejection_notes: 'blah blah blah') end - describe 'rejecting a crop' do - it 'should give reason if a default option' do - expect(rejected_reason.rejection_explanation).to eq 'not edible' + describe "rejecting a crop" do + it "should give reason if a default option" do + expect(rejected_reason.rejection_explanation).to eq "not edible" end - it 'should show rejection notes if reason was other' do - expect(rejected_other.rejection_explanation).to eq 'blah blah blah' + it "should show rejection notes if reason was other" do + expect(rejected_other.rejection_explanation).to eq "blah blah blah" end end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 139695a2f..bd61fe2ee 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -6,34 +6,34 @@ describe Follow do @member2 = FactoryBot.create(:member) end - it 'sends a notification when a follow is created' do + it "sends a notification when a follow is created" do expect do Follow.create(follower_id: @member1.id, followed_id: @member2.id) end.to change(Notification, :count).by(1) end - it 'does not delete any members when follow is deleted' do + it "does not delete any members when follow is deleted" do expect do follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy end.not_to change(Member, :count) end - context 'when follow is created' do + context "when follow is created" do before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end - it 'should not duplicate follows' do + it "should not duplicate follows" do expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid end - it 'should list users in following/follower collections when follow is created' do + it "should list users in following/follower collections when follow is created" do expect(@member1.followed).to include(@member2) expect(@member2.followers).to include(@member1) end - it 'should no longer list users in following/follower collections when follow is deleted' do + it "should no longer list users in following/follower collections when follow is deleted" do @follow.destroy expect(@member1.followed).not_to include(@member2) expect(@member2.followers).not_to include(@member1) diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index c0d4d47f5..310c36842 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe Forum do let(:forum) { FactoryBot.create(:forum) } - it 'belongs to an owner' do + it "belongs to an owner" do forum.owner.should be_an_instance_of Member end - it 'stringifies nicely' do + it "stringifies nicely" do forum.to_s.should eq forum.name end @@ -15,7 +15,7 @@ describe Forum do forum.slug.should eq 'permaculture' end - it 'has many posts' do + it "has many posts" do @post1 = FactoryBot.create(:forum_post, forum: forum) @post2 = FactoryBot.create(:forum_post, forum: forum) forum.posts.size.should == 2 diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index ec7d5fae2..f8e5a3311 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -4,12 +4,12 @@ describe Garden do let(:owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: owner) } - it 'should have a slug' do + it "should have a slug" do garden.slug.should match(/member\d+-springfield-community-garden/) end - it 'should have a description' do - garden.description.should == 'This is a **totally** cool garden' + it "should have a description" do + garden.description.should == "This is a **totally** cool garden" end it "doesn't allow a nil name" do @@ -18,27 +18,27 @@ describe Garden do end it "doesn't allow a blank name" do - garden = FactoryBot.build(:garden, name: '') + garden = FactoryBot.build(:garden, name: "") garden.should_not be_valid end - it 'allows numbers' do - garden = FactoryBot.build(:garden, name: '100 vines of 2 kamo-kamo') + it "allows numbers" do + garden = FactoryBot.build(:garden, name: "100 vines of 2 kamo-kamo") garden.should_not be_valid end - it 'allows brackets' do - garden = FactoryBot.build(:garden, name: 'Garden (second)') + it "allows brackets" do + garden = FactoryBot.build(:garden, name: "Garden (second)") garden.should be_valid end - it 'allows macrons' do - garden = FactoryBot.build(:garden, name: 'Kūmara and pūha patch') + it "allows macrons" do + garden = FactoryBot.build(:garden, name: "Kūmara and pūha patch") garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryBot.build(:garden, name: ' ') + garden = FactoryBot.build(:garden, name: " ") garden.should_not be_valid end @@ -47,15 +47,15 @@ describe Garden do garden.should_not be_valid end - it 'should have an owner' do + it "should have an owner" do garden.owner.should be_an_instance_of Member end - it 'should stringify as its name' do + it "should stringify as its name" do garden.to_s.should == garden.name end - context 'featured plantings' do + context "featured plantings" do let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } let(:chard) { FactoryBot.create(:chard) } @@ -63,14 +63,14 @@ describe Garden do let(:pear) { FactoryBot.create(:pear) } let(:walnut) { FactoryBot.create(:walnut) } - it 'should fetch < 4 featured plantings if insufficient exist' do + it "should fetch < 4 featured plantings if insufficient exist" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end - it 'should fetch most recent 4 featured plantings' do + it "should fetch most recent 4 featured plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -80,7 +80,7 @@ describe Garden do garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end - it 'should skip repeated plantings' do + it "should skip repeated plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -93,7 +93,7 @@ describe Garden do end end - it 'destroys plantings when deleted' do + it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @@ -135,7 +135,7 @@ describe Garden do end it "doesn't allow non-numeric quantities" do - garden = FactoryBot.build(:garden, area: '99a') + garden = FactoryBot.build(:garden, area: "99a") garden.should_not be_valid end end @@ -151,7 +151,7 @@ describe Garden do it 'should refuse invalid unit values' do garden = FactoryBot.build(:garden, area_unit: 'not valid') garden.should_not be_valid - garden.errors[:area_unit].should include('not valid is not a valid area unit') + garden.errors[:area_unit].should include("not valid is not a valid area unit") end it 'sets area unit to blank if area is blank' do @@ -175,7 +175,7 @@ describe Garden do end end - it 'marks plantings as finished when garden is inactive' do + it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index da6f06aa8..1944c6365 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe Harvest do - it 'has an owner' do + it "has an owner" do harvest = FactoryBot.create(:harvest) harvest.owner.should be_an_instance_of Member end - it 'has a crop' do + it "has a crop" do harvest = FactoryBot.create(:harvest) harvest.crop.should be_an_instance_of Crop end @@ -38,7 +38,7 @@ describe Harvest do end it "doesn't allow non-numeric quantities" do - @harvest = FactoryBot.build(:harvest, quantity: '99a') + @harvest = FactoryBot.build(:harvest, quantity: "99a") @harvest.should_not be_valid end end @@ -55,7 +55,7 @@ describe Harvest do it 'should refuse invalid unit values' do @harvest = FactoryBot.build(:harvest, unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:unit].should include('not valid is not a valid unit') + @harvest.errors[:unit].should include("not valid is not a valid unit") end it 'sets unit to blank if quantity is blank' do @@ -92,7 +92,7 @@ describe Harvest do end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryBot.build(:harvest, weight_quantity: '99a') + @harvest = FactoryBot.build(:harvest, weight_quantity: "99a") @harvest.should_not be_valid end end @@ -108,7 +108,7 @@ describe Harvest do it 'should refuse invalid weight unit values' do @harvest = FactoryBot.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:weight_unit].should include('not valid is not a valid unit') + @harvest.errors[:weight_unit].should include("not valid is not a valid unit") end it 'sets weight_unit to blank if quantity is blank' do @@ -118,21 +118,21 @@ describe Harvest do end end - context 'standardized weights' do + context "standardized weights" do it 'converts from pounds' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'lb') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "lb") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.907 end it 'converts from ounces' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: 'oz') + @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: "oz") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.454 end it 'leaves kg alone' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'kg') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "kg") @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -146,79 +146,79 @@ describe Harvest do end end - context 'stringification' do - let(:crop) { FactoryBot.create(:crop, name: 'apricot') } + context "stringification" do + let(:crop) { FactoryBot.create(:crop, name: "apricot") } - it 'apricots' do + it "apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq 'apricots' + @h.to_s.should eq "apricots" end - it '1 individual apricot' do + it "1 individual apricot" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 individual apricot' + @h.to_s.should eq "1 individual apricot" end - it '10 individual apricots' do + it "10 individual apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 individual apricots' + @h.to_s.should eq "10 individual apricots" end - it '1 bushel of apricots' do + it "1 bushel of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 bushel of apricots' + @h.to_s.should eq "1 bushel of apricots" end - it '1.5 bushels of apricots' do + it "1.5 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1.5, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1.5 bushels of apricots' + @h.to_s.should eq "1.5 bushels of apricots" end - it '10 bushels of apricots' do + it "10 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 bushels of apricots' + @h.to_s.should eq "10 bushels of apricots" end - it 'apricots weighing 1.2 kg' do + it "apricots weighing 1.2 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: 1.2, weight_unit: 'kg') - @h.to_s.should eq 'apricots weighing 1.2 kg' + @h.to_s.should eq "apricots weighing 1.2 kg" end - it '10 bushels of apricots weighing 100 kg' do + it "10 bushels of apricots weighing 100 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: 100, weight_unit: 'kg') - @h.to_s.should eq '10 bushels of apricots weighing 100 kg' + @h.to_s.should eq "10 bushels of apricots weighing 100 kg" end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 7bdee1fee..cf7b81486 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -28,7 +28,7 @@ describe 'member' do member.account.should be_an_instance_of Account end - it 'should have a default-type account by default' do + it "should have a default-type account by default" do member.account.account_type.name.should eq Growstuff::Application.config.default_account_type member.paid?.should be(false) end @@ -48,7 +48,7 @@ describe 'member' do end it 'should be able to fetch gardens' do - member.gardens.first.name.should eq 'Garden' + member.gardens.first.name.should eq "Garden" end it 'has many plantings' do @@ -56,19 +56,19 @@ describe 'member' do member.plantings.size.should eq 1 end - it 'has many comments' do + it "has many comments" do FactoryBot.create(:comment, author: member) FactoryBot.create(:comment, author: member) member.comments.size.should == 2 end - it 'has many forums' do + it "has many forums" do FactoryBot.create(:forum, owner: member) FactoryBot.create(:forum, owner: member) member.forums.size.should == 2 end - it 'has many likes' do + it "has many likes" do @post1 = FactoryBot.create(:post, author: member) @post2 = FactoryBot.create(:post, author: member) @like1 = FactoryBot.create(:like, member: member, likeable: @post1) @@ -118,24 +118,24 @@ describe 'member' do end context 'same :login_name' do - it 'should not allow two members with the same login_name' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'bob') + it "should not allow two members with the same login_name" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "bob") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end - it 'tests uniqueness case-insensitively' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'BoB') + it "tests uniqueness case-insensitively" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "BoB") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end end context 'case sensitivity' do it 'preserves case of login name' do - FactoryBot.create(:member, login_name: 'BOB') + FactoryBot.create(:member, login_name: "BOB") Member.find('bob').login_name.should eq 'BOB' end end @@ -144,40 +144,40 @@ describe 'member' do it "doesn't allow short names" do member = FactoryBot.build(:invalid_member_shortname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow really long names" do member = FactoryBot.build(:invalid_member_longname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow spaces in names" do member = FactoryBot.build(:invalid_member_spaces) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow other chars in names" do member = FactoryBot.build(:invalid_member_badchars) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow reserved names" do member = FactoryBot.build(:invalid_member_badname) member.should_not be_valid - member.errors[:login_name].should include('name is reserved') + member.errors[:login_name].should include("name is reserved") end end context 'valid login names' do - it 'allows plain alphanumeric chars in names' do + it "allows plain alphanumeric chars in names" do member = FactoryBot.build(:valid_member_alphanumeric) member.should be_valid end - it 'allows uppercase chars in names' do + it "allows uppercase chars in names" do member = FactoryBot.build(:valid_member_uppercase) member.should be_valid end - it 'allows underscores in names' do + it "allows underscores in names" do member = FactoryBot.build(:valid_member_underscore) member.should be_valid end @@ -203,7 +203,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - role = FactoryBot.create(:role, name: 'a b c') + role = FactoryBot.create(:role, name: "a b c") member.roles << role member.role?(:a_b_c).should eq true end @@ -310,17 +310,17 @@ describe 'member' do end end - context 'paid accounts' do + context "paid accounts" do let(:member) { FactoryBot.create(:member) } - it 'recognises a permanent paid account' do + it "recognises a permanent paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: true) member.account.account_type = account_type member.paid?.should be(true) end - it 'recognises a current paid account' do + it "recognises a current paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -328,7 +328,7 @@ describe 'member' do member.paid?.should be(true) end - it 'recognises an expired paid account' do + it "recognises an expired paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -336,14 +336,14 @@ describe 'member' do member.paid?.should be(false) end - it 'recognises a free account' do + it "recognises a free account" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type member.paid?.should be(false) end - it 'recognises a free account even with paid_until set' do + it "recognises a free account even with paid_until set" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type @@ -352,19 +352,19 @@ describe 'member' do end end - context 'update account' do + context "update account" do let(:product) do FactoryBot.create(:product, paid_months: 3) end let(:member) { FactoryBot.create(:member) } - it 'sets account_type' do + it "sets account_type" do member.update_account_after_purchase(product) member.account.account_type.should eq product.account_type end - it 'sets paid_until' do + it "sets paid_until" do member.account.paid_until = nil # blank for now, as if never paid before member.update_account_after_purchase(product) @@ -417,7 +417,7 @@ describe 'member' do context 'subscriptions' do let(:member) { FactoryBot.create(:member) } - let(:gb) { instance_double('Gibbon::API.new') } + let(:gb) { instance_double("Gibbon::API.new") } it 'subscribes to the newsletter' do expect(gb).to receive_message_chain('lists.subscribe') @@ -444,12 +444,12 @@ describe 'member' do it { expect(Member.interesting).not_to include(member) } it { expect(Member.has_plantings).not_to include(member) } end - it 'unsubscribes from mailing list' do + it "unsubscribes from mailing list" do expect(member).to receive(:newsletter_unsubscribe).and_return(true) member.destroy end - context 'deleted admin member' do + context "deleted admin member" do let(:member) { FactoryBot.create(:admin_member) } before { member.destroy } @@ -457,7 +457,7 @@ describe 'member' do context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } - it 'leaves crops behind, reassigned to cropbot' do + it "leaves crops behind, reassigned to cropbot" do expect(Crop.all).to include(crop) end end @@ -465,7 +465,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } - it 'leaves forums behind, reassigned to ex_admin' do + it "leaves forums behind, reassigned to ex_admin" do expect(forum.owner).to eq(member) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 96d390215..4f04573d5 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -3,19 +3,19 @@ require 'rails_helper' describe Notification do let(:notification) { FactoryBot.create(:notification) } - it 'belongs to a post' do + it "belongs to a post" do notification.post.should be_an_instance_of Post end - it 'belongs to a recipient' do + it "belongs to a recipient" do notification.recipient.should be_an_instance_of Member end - it 'belongs to a sender' do + it "belongs to a sender" do notification.sender.should be_an_instance_of Member end - it 'has a scope for unread' do + it "has a scope for unread" do Notification.unread.should eq [notification] @n2 = FactoryBot.create(:notification, read: true) Notification.unread.should eq [notification] @@ -24,13 +24,13 @@ describe Notification do Notification.unread.should include notification end - it 'counts unread' do + it "counts unread" do @who = notification.recipient @n2 = FactoryBot.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end - it 'sends email if asked' do + it "sends email if asked" do @notification2 = FactoryBot.create(:notification) @notification2.send_email ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] @@ -42,18 +42,18 @@ describe Notification do ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email] end - it 'sends email on creation' do + it "sends email on creation" do @notification2 = FactoryBot.create(:notification) ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] end - it 'replaces missing subjects with (no subject)' do + it "replaces missing subjects with (no subject)" do notification = FactoryBot.create(:notification, subject: nil) - notification.subject.should == '(no subject)' + notification.subject.should == "(no subject)" end - it 'replaces whitespace-only subjects with (no subject)' do - notification = FactoryBot.create(:notification, subject: ' ') - notification.subject.should == '(no subject)' + it "replaces whitespace-only subjects with (no subject)" do + notification = FactoryBot.create(:notification, subject: " ") + notification.subject.should == "(no subject)" end end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb index 1d9835d7d..7c2de24c6 100644 --- a/spec/models/order_item_spec.rb +++ b/spec/models/order_item_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe OrderItem do let(:order_item) { FactoryBot.create(:order_item) } - it 'has an order and a product' do + it "has an order and a product" do order_item.order.should be_an_instance_of Order order_item.product.should be_an_instance_of Product end - it 'validates price > product.min_price' do + it "validates price > product.min_price" do @product = FactoryBot.create(:product) order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) order_item.should_not be_valid diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 87ae130a9..9abb381ba 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -16,7 +16,7 @@ describe Order do @order2 = Order.create!(member_id: @member2.id) end - it 'only returns orders belonging to member' do + it "only returns orders belonging to member" do Order.by_member(@member1).should eq [@order1] end end @@ -43,7 +43,7 @@ describe Order do @member.account.paid_until.should_not be_nil end - it 'totals the amount due' do + it "totals the amount due" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -56,7 +56,7 @@ describe Order do @order.total.should eq 1111 end - it 'gives the correct total for quantities more than 1' do + it "gives the correct total for quantities more than 1" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -69,7 +69,7 @@ describe Order do @order.total.should eq 2222 end - it 'formats order items for activemerchant' do + it "formats order items for activemerchant" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -87,18 +87,18 @@ describe Order do }] end - context 'referral codes' do - it 'has a referral code' do + context "referral codes" do + it "has a referral code" do referred_order = FactoryBot.create(:referred_order) referred_order.referral_code.should_not be nil end - it 'validates referral codes' do + it "validates referral codes" do referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') referred_order.should_not be_valid end - it 'cleans up messy referral codes' do + it "cleans up messy referral codes" do referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') referred_order.referral_code.should eq 'CAMPAIGN1' end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 4400f7d2f..5f07a3e29 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -9,7 +9,7 @@ describe Photo do let(:harvest) { FactoryBot.create(:harvest) } let(:garden) { FactoryBot.create(:garden) } - context 'adds photos' do + context "adds photos" do it 'to a planting' do planting.photos << photo expect(planting.photos.size).to eq 1 @@ -29,7 +29,7 @@ describe Photo do end end - context 'removing photos' do + context "removing photos" do it 'from a planting' do planting.photos << photo photo.destroy @@ -48,7 +48,7 @@ describe Photo do expect(garden.photos.size).to eq 0 end - it 'automatically if unused' do + it "automatically if unused" do photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 266b75ed7..60a95c245 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -162,11 +162,11 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it 'generates a location' do + it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end - it 'should have a slug' do + it "should have a slug" do planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/) end @@ -176,15 +176,15 @@ describe Planting do end describe '#planted?' do - it 'should be false for future plantings' do + it "should be false for future plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1 expect(planting.planted?).to eq(false) end - it 'should be false for never planted' do + it "should be false for never planted" do planting = FactoryBot.create :planting, planted_at: nil expect(planting.planted?).to eq(false) end - it 'should be true for past plantings' do + it "should be true for past plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1 expect(planting.planted?).to eq(true) end @@ -224,7 +224,7 @@ describe Planting do @planting.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @planting = FactoryBot.build(:planting, quantity: nil) @planting.should be_valid @planting = FactoryBot.build(:planting, quantity: '') @@ -249,7 +249,7 @@ describe Planting do it 'should refuse invalid sunniness values' do @planting = FactoryBot.build(:planting, sunniness: 'not valid') @planting.should_not be_valid - @planting.errors[:sunniness].should include('not valid is not a valid sunniness value') + @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") end end @@ -271,7 +271,7 @@ describe Planting do it 'should refuse invalid planted_from values' do @planting = FactoryBot.build(:planting, planted_from: 'not valid') @planting.should_not be_valid - @planting.errors[:planted_from].should include('not valid is not a valid planting method') + @planting.errors[:planted_from].should include("not valid is not a valid planting method") end end @@ -336,7 +336,7 @@ describe Planting do end end - context 'default arguments' do + context "default arguments" do it 'ignores plantings without photos' do # first, an interesting planting @planting = FactoryBot.create(:planting) @@ -370,8 +370,8 @@ describe Planting do end end - context 'with howmany argument' do - it 'only returns the number asked for' do + context "with howmany argument" do + it "only returns the number asked for" do @plantings = FactoryBot.create_list(:planting, 10) @plantings.each do |p| p.photos << FactoryBot.create(:photo, owner: planting.owner) @@ -381,7 +381,7 @@ describe Planting do end end # interesting plantings - context 'finished' do + context "finished" do it 'has finished fields' do @planting = FactoryBot.create(:finished_planting) @planting.finished.should be true @@ -402,7 +402,7 @@ describe Planting do Planting.current.should_not include @f end - context 'finished date validation' do + context "finished date validation" do it 'requires finished date after planting date' do @f = FactoryBot.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4eb8d6ad6..98880ce2b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,33 +3,33 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } - it_behaves_like 'it is likeable' + it_behaves_like "it is likeable" - it 'should have a slug' do + it "should have a slug" do post = FactoryBot.create(:post, author: member) time = post.created_at - datestr = time.strftime('%Y%m%d') + datestr = time.strftime("%Y%m%d") # 2 digit day and month, full-length years # Counting digits using Math.log is not precise enough! datestr.size.should eq(4 + time.year.to_s.size) post.slug.should eq("#{member.login_name}-#{datestr}-a-post") end - it 'has many comments' do + it "has many comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comments.size.should == 2 end - it 'supports counting comments' do + it "supports counting comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comment_count.should == 2 end - it 'destroys comments when deleted' do + it "destroys comments when deleted" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) @@ -39,7 +39,7 @@ describe Post do Comment.count.should eq(all - 2) end - it 'belongs to a forum' do + it "belongs to a forum" do post = FactoryBot.create(:forum_post) post.forum.should be_an_instance_of Forum end @@ -50,40 +50,40 @@ describe Post do end it "doesn't allow a blank subject" do - post = FactoryBot.build(:post, subject: '') + post = FactoryBot.build(:post, subject: "") post.should_not be_valid end it "doesn't allow a subject with only spaces" do - post = FactoryBot.build(:post, subject: ' ') + post = FactoryBot.build(:post, subject: " ") post.should_not be_valid end - context 'recent activity' do + context "recent activity" do before do Time.stub(now: Time.now) end let!(:post) { FactoryBot.create(:post, created_at: 1.day.ago) } - it 'sets recent activity to post time' do + it "sets recent activity to post time" do post.recent_activity.to_i.should eq post.created_at.to_i end - it 'sets recent activity to comment time' do + it "sets recent activity to comment time" do comment = FactoryBot.create(:comment, post: post, created_at: 1.hour.ago) post.recent_activity.to_i.should eq comment.created_at.to_i end - it 'shiny new post is recently active' do + it "shiny new post is recently active" do # create a shiny new post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq post2 Post.recently_active.second.should eq post end - it 'new comment on old post is recently active' do + it "new comment on old post is recently active" do # now comment on an older post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) FactoryBot.create(:comment, post: post, created_at: 1.second.ago) @@ -92,22 +92,22 @@ describe Post do end end - context 'notifications' do + context "notifications" do let(:member2) { FactoryBot.create(:member) } - it 'sends a notification when a member is mentioned using @-syntax' do + it "sends a notification when a member is mentioned using @-syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2}") end.to change(Notification, :count).by(1) end - it 'sends a notification when a member is mentioned using [](member) syntax' do + it "sends a notification when a member is mentioned using [](member) syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)") end.to change(Notification, :count).by(1) end - it 'sets the notification field' do + it "sets the notification field" do p = FactoryBot.create(:post, author: member, body: "Hey @#{member2}") n = Notification.first n.sender.should eq member @@ -116,7 +116,7 @@ describe Post do n.body.should eq p.body end - it 'sends notifications to all members mentioned' do + it "sends notifications to all members mentioned" do member3 = FactoryBot.create(:member) expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}") @@ -130,23 +130,23 @@ describe Post do end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:chard) { FactoryBot.create(:chard) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - it 'should be generated' do + it "should be generated" do expect(tomato.posts).to eq [post] expect(maize.posts).to eq [post] end - it 'should not duplicate' do + it "should not duplicate" do expect(post.crops) =~ [tomato, maize] end - it 'should be updated when post was modified' do - post.update_attributes(body: '[chard](crop)') + it "should be updated when post was modified" do + post.update_attributes(body: "[chard](crop)") expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] @@ -154,17 +154,17 @@ describe Post do expect(maize.posts).to eq [] end - describe 'destroying the post' do + describe "destroying the post" do before do post.destroy end - it 'should delete the association' do + it "should delete the association" do expect(Crop.find(tomato.id).posts).to eq [] expect(Crop.find(maize.id).posts).to eq [] end - it 'should not delete the crops' do + it "should not delete the crops" do expect(Crop.find(tomato.id)).not_to eq nil expect(Crop.find(maize.id)).not_to eq nil end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index 1ff0ba516..2cc684667 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Product do - it 'stringifies using the name' do + it "stringifies using the name" do @product = FactoryBot.create(:product) @product.to_s.should eq @product.name end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 020e37741..e45d0e240 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -7,7 +7,7 @@ describe Seed do seed.save.should be(true) end - it 'should have a slug' do + it "should have a slug" do seed.save seed.slug.should match(/member\d+-magic-bean/) end @@ -28,7 +28,7 @@ describe Seed do @seed.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @seed = FactoryBot.build(:seed, quantity: nil) @seed.should be_valid @seed = FactoryBot.build(:seed, quantity: '') @@ -48,8 +48,8 @@ describe Seed do @seed = FactoryBot.build(:seed, tradable_to: 'not valid') @seed.should_not be_valid @seed.errors[:tradable_to].should include( - 'You may only trade seed nowhere, locally, '\ - 'nationally, or internationally' + "You may only trade seed nowhere, locally, "\ + "nationally, or internationally" ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dfced9e4b..e28dd6e24 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' +ENV["RAILS_ENV"] ||= 'test' require 'simplecov' require 'coveralls' @@ -17,7 +17,7 @@ SimpleCov.start :rails do end require 'spec_helper' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! Rails.application.eager_load! @@ -58,8 +58,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } -Dir[Rails.root.join('spec/features/shared_examples/**/*.rb')].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 936d1a7a6..6a392eb74 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -5,53 +5,53 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do - { 'id' => crop.id.to_s, - 'type' => 'crops', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'plantings' => plantings_as_json_api, - 'parent' => parent_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:parent_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/parent", - 'related' => "#{resource_url}/parent" } } + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'name' => crop.name, - 'en-wikipedia-url' => crop.en_wikipedia_url, - 'perennial' => false, - 'median-lifespan' => nil, - 'median-days-to-first-harvest' => nil, - 'median-days-to-last-harvest' => nil + "name" => crop.name, + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil } end @@ -63,25 +63,25 @@ RSpec.describe 'Plantings', type: :request do describe '#show' do before { get "/api/v1/crops/#{crop.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('parent' => parent_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } it { expect(subject['data']).to eq(crop_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/crops/#{crop.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 234606bcd..d6005e286 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -5,36 +5,36 @@ RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do - { 'id' => garden.id.to_s, - 'type' => 'gardens', - 'links' => { 'self' => resource_url }, - 'attributes' => { 'name' => garden.name }, - 'relationships' => + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => resource_url }, + "attributes" => { "name" => garden.name }, + "relationships" => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'photos' => photos_as_json_api + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end scenario '#index' do @@ -49,16 +49,16 @@ RSpec.describe 'Gardens', type: :request do scenario '#create' do post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/gardens/#{garden.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index b685b2990..af2d4201e 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Harvests', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do - { 'id' => harvest.id.to_s, - 'type' => 'harvests', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'crop' => crop_as_json_api, - 'planting' => planting_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:planting_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/planting", - 'related' => "#{resource_url}/planting" } } + "related" => "#{resource_url}/planting" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'harvested-at' => '2015-09-17', - 'description' => harvest.description, - 'unit' => harvest.unit, - 'weight-quantity' => harvest.weight_quantity.to_s, - 'weight-unit' => harvest.weight_unit, - 'si-weight' => harvest.si_weight + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight } end @@ -64,25 +64,25 @@ RSpec.describe 'Harvests', type: :request do describe '#show' do before { get "/api/v1/harvests/#{harvest.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('planting' => planting_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 2e9977132..6067e59b6 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Members', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do - { 'id' => member.id.to_s, - 'type' => 'members', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'gardens' => gardens_as_json_api, - 'harvests' => harvests_as_json_api, - 'photos' => photos_as_json_api, - 'plantings' => plantings_as_json_api, - 'seeds' => seeds_as_json_api + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:seeds_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/seeds", - 'related' => "#{resource_url}/seeds" } } + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:attributes) do { - 'login-name' => member.login_name + "login-name" => member.login_name } end @@ -63,26 +63,26 @@ RSpec.describe 'Members', type: :request do describe '#show' do before { get "/api/v1/members/#{member.id}", {}, headers } - it { expect(subject['data']['relationships']).to include('gardens' => gardens_as_json_api) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('seeds' => seeds_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } it { expect(subject['data']).to eq(member_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/members/#{member.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index 6f5c1434b..e9e584a60 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -5,52 +5,52 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do - { 'id' => photo.id.to_s, - 'type' => 'photos', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'harvests' => harvests_as_json_api, - 'gardens' => gardens_as_json_api + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:attributes) do { - 'thumbnail-url' => photo.thumbnail_url, - 'fullsize-url' => photo.fullsize_url, - 'link-url' => photo.link_url, - 'license-name' => photo.license_name, - 'title' => photo.title + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "title" => photo.title } end @@ -62,24 +62,24 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/photos/#{photo.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(photo_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/photos/#{photo.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 02a7be3f4..4e96cefb4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -5,65 +5,65 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do - { 'id' => planting.id.to_s, - 'type' => 'plantings', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'garden' => garden_as_json_api, - 'crop' => crop_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:garden_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/garden", - 'related' => "#{resource_url}/garden" } } + { "links" => + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } end let(:attributes) do { - 'planted-at' => '2014-07-30', - 'finished-at' => nil, - 'finished' => false, - 'quantity' => 33, - 'description' => planting.description, - 'sunniness' => nil, - 'planted-from' => nil, - 'expected-lifespan' => nil, - 'finish-predicted-at' => nil, - 'percentage-grown' => nil, - 'first-harvest-date' => nil, - 'last-harvest-date' => nil + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil } end @@ -74,26 +74,26 @@ RSpec.describe 'Plantings', type: :request do scenario '#show' do get "/api/v1/plantings/#{planting.id}", {}, headers - expect(subject['data']['relationships']).to include('garden' => garden_as_json_api) - expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) - expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) - expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) - expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end scenario '#create' do post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/plantings/#{planting.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index 733ab7e22..f518e91de 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -5,41 +5,41 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do - { 'id' => seed.id.to_s, - 'type' => 'seeds', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'crop' => crop_as_json_api + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } end let(:attributes) do { - 'description' => seed.description, - 'quantity' => seed.quantity, - 'plant-before' => '2013-07-15', - 'tradable-to' => seed.tradable_to, - 'days-until-maturity-min' => seed.days_until_maturity_min, - 'days-until-maturity-max' => seed.days_until_maturity_max, - 'organic' => seed.organic, - 'gmo' => seed.gmo, - 'heirloom' => seed.heirloom + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom } end @@ -51,23 +51,23 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/seeds/#{seed.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } it { expect(subject['data']).to eq(seed_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/seeds/#{seed.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 45b7754b9..6cc612f44 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Authentications' do - describe 'GET /authentications' do +describe "Authentications" do + describe "GET /authentications" do end end diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb index 6e5544657..c9b2ba9dc 100644 --- a/spec/requests/comments_spec.rb +++ b/spec/requests/comments_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Comments' do - describe 'GET /comments' do - it 'works! (now write some real specs)' do +describe "Comments" do + describe "GET /comments" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get comments_path response.status.should be(200) diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index 34a86ea66..ff7cb283d 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Forums' do - describe 'GET /forums' do - it 'works! (now write some real specs)' do +describe "Forums" do + describe "GET /forums" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get forums_path response.status.should be(200) diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 74a9931fb..91a8dc8b7 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Gardens' do - describe 'GET /gardens' do - it 'works! (now write some real specs)' do +describe "Gardens" do + describe "GET /gardens" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get gardens_path response.status.should be(200) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index 17785af18..f3774b3c0 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Harvests' do - describe 'GET /harvests' do - it 'works! (now write some real specs)' do +describe "Harvests" do + describe "GET /harvests" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path response.status.should be(200) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index b5879f678..85afbdd9f 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Notifications' do - describe 'GET /notifications' do - it 'works! (now write some real specs)' do +describe "Notifications" do + describe "GET /notifications" do + it "works! (now write some real specs)" do get notifications_path # can't see notifications because not logged in # therefore redirect to homepage diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index a3d39871c..b937ded3d 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Photos' do - describe 'GET /photos' do - it 'works! (now write some real specs)' do +describe "Photos" do + describe "GET /photos" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get photos_path response.status.should be(200) diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index c44e42599..1fc2150b2 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'PlantParts' do - describe 'GET /plant_parts' do - it 'works! (now write some real specs)' do +describe "PlantParts" do + describe "GET /plant_parts" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plant_parts_path response.status.should be(200) diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index e156f9589..cb66922e0 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Plantings' do - describe 'GET /plantings' do - it 'works! (now write some real specs)' do +describe "Plantings" do + describe "GET /plantings" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plantings_path response.status.should be(200) diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index a2e316c38..3bb479aa8 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Posts' do - describe 'GET /posts' do - it 'works! (now write some real specs)' do +describe "Posts" do + describe "GET /posts" do + it "works! (now write some real specs)" do get posts_path response.status.should be(200) end diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 02785b4ad..922f6f270 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'ScientificNames' do - describe 'GET /scientific_names' do - it 'works! (now write some real specs)' do +describe "ScientificNames" do + describe "GET /scientific_names" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get scientific_names_path response.status.should be(200) diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 08d3c0f18..8bc5aeccf 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Seeds' do - describe 'GET /seeds' do - it 'works! (now write some real specs)' do +describe "Seeds" do + describe "GET /seeds" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get seeds_path response.status.should be(200) diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb index 53ed9b4a3..8402dd727 100644 --- a/spec/routing/account_types_routing_spec.rb +++ b/spec/routing/account_types_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe AccountTypesController do - describe 'routing' do - it 'routes to #index' do - get('/account_types').should route_to('account_types#index') + describe "routing" do + it "routes to #index" do + get("/account_types").should route_to("account_types#index") end - it 'routes to #new' do - get('/account_types/new').should route_to('account_types#new') + it "routes to #new" do + get("/account_types/new").should route_to("account_types#new") end - it 'routes to #show' do - get('/account_types/1').should route_to('account_types#show', id: '1') + it "routes to #show" do + get("/account_types/1").should route_to("account_types#show", id: "1") end - it 'routes to #edit' do - get('/account_types/1/edit').should route_to('account_types#edit', id: '1') + it "routes to #edit" do + get("/account_types/1/edit").should route_to("account_types#edit", id: "1") end - it 'routes to #create' do - post('/account_types').should route_to('account_types#create') + it "routes to #create" do + post("/account_types").should route_to("account_types#create") end - it 'routes to #update' do - put('/account_types/1').should route_to('account_types#update', id: '1') + it "routes to #update" do + put("/account_types/1").should route_to("account_types#update", id: "1") end - it 'routes to #destroy' do - delete('/account_types/1').should route_to('account_types#destroy', id: '1') + it "routes to #destroy" do + delete("/account_types/1").should route_to("account_types#destroy", id: "1") end end end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 39d814011..0601b9924 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,13 +1,13 @@ -require 'rails_helper' +require "rails_helper" describe AuthenticationsController do - describe 'routing' do - it 'routes to #create' do - post('/authentications').should route_to('authentications#create') + describe "routing" do + it "routes to #create" do + post("/authentications").should route_to("authentications#create") end - it 'routes to #destroy' do - delete('/authentications/1').should route_to('authentications#destroy', id: '1') + it "routes to #destroy" do + delete("/authentications/1").should route_to("authentications#destroy", id: "1") end end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 8f9363dcc..5390ab066 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CommentsController do - describe 'routing' do - it 'routes to #index' do - get('/comments').should route_to('comments#index') + describe "routing" do + it "routes to #index" do + get("/comments").should route_to("comments#index") end - it 'routes to #new' do - get('/comments/new').should route_to('comments#new') + it "routes to #new" do + get("/comments/new").should route_to("comments#new") end - it 'routes to #show' do - get('/comments/1').should route_to('comments#show', id: '1') + it "routes to #show" do + get("/comments/1").should route_to("comments#show", id: "1") end - it 'routes to #edit' do - get('/comments/1/edit').should route_to('comments#edit', id: '1') + it "routes to #edit" do + get("/comments/1/edit").should route_to("comments#edit", id: "1") end - it 'routes to #create' do - post('/comments').should route_to('comments#create') + it "routes to #create" do + post("/comments").should route_to("comments#create") end - it 'routes to #update' do - put('/comments/1').should route_to('comments#update', id: '1') + it "routes to #update" do + put("/comments/1").should route_to("comments#update", id: "1") end - it 'routes to #destroy' do - delete('/comments/1').should route_to('comments#destroy', id: '1') + it "routes to #destroy" do + delete("/comments/1").should route_to("comments#destroy", id: "1") end end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 644bad3d6..97c1a874c 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CropsController do - describe 'routing' do - it 'routes to #index' do - get('/crops').should route_to('crops#index') + describe "routing" do + it "routes to #index" do + get("/crops").should route_to("crops#index") end - it 'routes to #new' do - get('/crops/new').should route_to('crops#new') + it "routes to #new" do + get("/crops/new").should route_to("crops#new") end - it 'routes to #show' do - get('/crops/1').should route_to('crops#show', id: '1') + it "routes to #show" do + get("/crops/1").should route_to("crops#show", id: "1") end - it 'routes to #edit' do - get('/crops/1/edit').should route_to('crops#edit', id: '1') + it "routes to #edit" do + get("/crops/1/edit").should route_to("crops#edit", id: "1") end - it 'routes to #create' do - post('/crops').should route_to('crops#create') + it "routes to #create" do + post("/crops").should route_to("crops#create") end - it 'routes to #update' do - put('/crops/1').should route_to('crops#update', id: '1') + it "routes to #update" do + put("/crops/1").should route_to("crops#update", id: "1") end - it 'routes to #destroy' do - delete('/crops/1').should route_to('crops#destroy', id: '1') + it "routes to #destroy" do + delete("/crops/1").should route_to("crops#destroy", id: "1") end end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index 06aaa6b76..ddb01e00c 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,13 +1,13 @@ -require 'spec_helper' +require "spec_helper" describe FollowsController do - describe 'routing' do - it 'routes to #create' do - post('/follows').should route_to('follows#create') + describe "routing" do + it "routes to #create" do + post("/follows").should route_to("follows#create") end - it 'routes to #destroy' do - delete('/follows/1').should route_to('follows#destroy', id: '1') + it "routes to #destroy" do + delete("/follows/1").should route_to("follows#destroy", id: "1") end end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index ca229917f..9ce6f427b 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ForumsController do - describe 'routing' do - it 'routes to #index' do - get('/forums').should route_to('forums#index') + describe "routing" do + it "routes to #index" do + get("/forums").should route_to("forums#index") end - it 'routes to #new' do - get('/forums/new').should route_to('forums#new') + it "routes to #new" do + get("/forums/new").should route_to("forums#new") end - it 'routes to #show' do - get('/forums/1').should route_to('forums#show', id: '1') + it "routes to #show" do + get("/forums/1").should route_to("forums#show", id: "1") end - it 'routes to #edit' do - get('/forums/1/edit').should route_to('forums#edit', id: '1') + it "routes to #edit" do + get("/forums/1/edit").should route_to("forums#edit", id: "1") end - it 'routes to #create' do - post('/forums').should route_to('forums#create') + it "routes to #create" do + post("/forums").should route_to("forums#create") end - it 'routes to #update' do - put('/forums/1').should route_to('forums#update', id: '1') + it "routes to #update" do + put("/forums/1").should route_to("forums#update", id: "1") end - it 'routes to #destroy' do - delete('/forums/1').should route_to('forums#destroy', id: '1') + it "routes to #destroy" do + delete("/forums/1").should route_to("forums#destroy", id: "1") end end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 8ec871b3b..6888f099f 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe GardensController do - describe 'routing' do - it 'routes to #index' do - get('/gardens').should route_to('gardens#index') + describe "routing" do + it "routes to #index" do + get("/gardens").should route_to("gardens#index") end - it 'routes to #new' do - get('/gardens/new').should route_to('gardens#new') + it "routes to #new" do + get("/gardens/new").should route_to("gardens#new") end - it 'routes to #show' do - get('/gardens/1').should route_to('gardens#show', id: '1') + it "routes to #show" do + get("/gardens/1").should route_to("gardens#show", id: "1") end - it 'routes to #edit' do - get('/gardens/1/edit').should route_to('gardens#edit', id: '1') + it "routes to #edit" do + get("/gardens/1/edit").should route_to("gardens#edit", id: "1") end - it 'routes to #create' do - post('/gardens').should route_to('gardens#create') + it "routes to #create" do + post("/gardens").should route_to("gardens#create") end - it 'routes to #update' do - put('/gardens/1').should route_to('gardens#update', id: '1') + it "routes to #update" do + put("/gardens/1").should route_to("gardens#update", id: "1") end - it 'routes to #destroy' do - delete('/gardens/1').should route_to('gardens#destroy', id: '1') + it "routes to #destroy" do + delete("/gardens/1").should route_to("gardens#destroy", id: "1") end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 41ad0c187..c6890df15 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe HarvestsController do - describe 'routing' do - it 'routes to #index' do - get('/harvests').should route_to('harvests#index') + describe "routing" do + it "routes to #index" do + get("/harvests").should route_to("harvests#index") end - it 'routes to #new' do - get('/harvests/new').should route_to('harvests#new') + it "routes to #new" do + get("/harvests/new").should route_to("harvests#new") end - it 'routes to #show' do - get('/harvests/1').should route_to('harvests#show', id: '1') + it "routes to #show" do + get("/harvests/1").should route_to("harvests#show", id: "1") end - it 'routes to #edit' do - get('/harvests/1/edit').should route_to('harvests#edit', id: '1') + it "routes to #edit" do + get("/harvests/1/edit").should route_to("harvests#edit", id: "1") end - it 'routes to #create' do - post('/harvests').should route_to('harvests#create') + it "routes to #create" do + post("/harvests").should route_to("harvests#create") end - it 'routes to #update' do - put('/harvests/1').should route_to('harvests#update', id: '1') + it "routes to #update" do + put("/harvests/1").should route_to("harvests#update", id: "1") end - it 'routes to #destroy' do - delete('/harvests/1').should route_to('harvests#destroy', id: '1') + it "routes to #destroy" do + delete("/harvests/1").should route_to("harvests#destroy", id: "1") end end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 8b0628575..bb7335e1b 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe NotificationsController do - describe 'routing' do - it 'routes to #index' do - get('/notifications').should route_to('notifications#index') + describe "routing" do + it "routes to #index" do + get("/notifications").should route_to("notifications#index") end - it 'routes to #new' do - get('/notifications/new').should route_to('notifications#new') + it "routes to #new" do + get("/notifications/new").should route_to("notifications#new") end - it 'routes to #show' do - get('/notifications/1').should route_to('notifications#show', id: '1') + it "routes to #show" do + get("/notifications/1").should route_to("notifications#show", id: "1") end - it 'routes to #edit' do - get('/notifications/1/edit').should route_to('notifications#edit', id: '1') + it "routes to #edit" do + get("/notifications/1/edit").should route_to("notifications#edit", id: "1") end - it 'routes to #create' do - post('/notifications').should route_to('notifications#create') + it "routes to #create" do + post("/notifications").should route_to("notifications#create") end - it 'routes to #update' do - put('/notifications/1').should route_to('notifications#update', id: '1') + it "routes to #update" do + put("/notifications/1").should route_to("notifications#update", id: "1") end - it 'routes to #destroy' do - delete('/notifications/1').should route_to('notifications#destroy', id: '1') + it "routes to #destroy" do + delete("/notifications/1").should route_to("notifications#destroy", id: "1") end end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb index 095842d7f..7487cb9f5 100644 --- a/spec/routing/order_items_routing_spec.rb +++ b/spec/routing/order_items_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrderItemsController do - describe 'routing' do - it 'routes to #index' do - get('/order_items').should route_to('order_items#index') + describe "routing" do + it "routes to #index" do + get("/order_items").should route_to("order_items#index") end - it 'routes to #new' do - get('/order_items/new').should route_to('order_items#new') + it "routes to #new" do + get("/order_items/new").should route_to("order_items#new") end - it 'routes to #show' do - get('/order_items/1').should route_to('order_items#show', id: '1') + it "routes to #show" do + get("/order_items/1").should route_to("order_items#show", id: "1") end - it 'routes to #edit' do - get('/order_items/1/edit').should route_to('order_items#edit', id: '1') + it "routes to #edit" do + get("/order_items/1/edit").should route_to("order_items#edit", id: "1") end - it 'routes to #create' do - post('/order_items').should route_to('order_items#create') + it "routes to #create" do + post("/order_items").should route_to("order_items#create") end - it 'routes to #update' do - put('/order_items/1').should route_to('order_items#update', id: '1') + it "routes to #update" do + put("/order_items/1").should route_to("order_items#update", id: "1") end - it 'routes to #destroy' do - delete('/order_items/1').should route_to('order_items#destroy', id: '1') + it "routes to #destroy" do + delete("/order_items/1").should route_to("order_items#destroy", id: "1") end end end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb index 4c7d925c5..38184ef33 100644 --- a/spec/routing/orders_routing_spec.rb +++ b/spec/routing/orders_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrdersController do - describe 'routing' do - it 'routes to #index' do - get('/orders').should route_to('orders#index') + describe "routing" do + it "routes to #index" do + get("/orders").should route_to("orders#index") end - it 'routes to #new' do - get('/orders/new').should route_to('orders#new') + it "routes to #new" do + get("/orders/new").should route_to("orders#new") end - it 'routes to #show' do - get('/orders/1').should route_to('orders#show', id: '1') + it "routes to #show" do + get("/orders/1").should route_to("orders#show", id: "1") end - it 'routes to #edit' do - get('/orders/1/edit').should route_to('orders#edit', id: '1') + it "routes to #edit" do + get("/orders/1/edit").should route_to("orders#edit", id: "1") end - it 'routes to #create' do - post('/orders').should route_to('orders#create') + it "routes to #create" do + post("/orders").should route_to("orders#create") end - it 'routes to #update' do - put('/orders/1').should route_to('orders#update', id: '1') + it "routes to #update" do + put("/orders/1").should route_to("orders#update", id: "1") end - it 'routes to #destroy' do - delete('/orders/1').should route_to('orders#destroy', id: '1') + it "routes to #destroy" do + delete("/orders/1").should route_to("orders#destroy", id: "1") end end end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index 1337de4b2..a645d0a60 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PhotosController do - describe 'routing' do - it 'routes to #index' do - get('/photos').should route_to('photos#index') + describe "routing" do + it "routes to #index" do + get("/photos").should route_to("photos#index") end - it 'routes to #new' do - get('/photos/new').should route_to('photos#new') + it "routes to #new" do + get("/photos/new").should route_to("photos#new") end - it 'routes to #show' do - get('/photos/1').should route_to('photos#show', id: '1') + it "routes to #show" do + get("/photos/1").should route_to("photos#show", id: "1") end - it 'routes to #edit' do - get('/photos/1/edit').should route_to('photos#edit', id: '1') + it "routes to #edit" do + get("/photos/1/edit").should route_to("photos#edit", id: "1") end - it 'routes to #create' do - post('/photos').should route_to('photos#create') + it "routes to #create" do + post("/photos").should route_to("photos#create") end - it 'routes to #update' do - put('/photos/1').should route_to('photos#update', id: '1') + it "routes to #update" do + put("/photos/1").should route_to("photos#update", id: "1") end - it 'routes to #destroy' do - delete('/photos/1').should route_to('photos#destroy', id: '1') + it "routes to #destroy" do + delete("/photos/1").should route_to("photos#destroy", id: "1") end end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 2a00948bc..966047f3f 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantPartsController do - describe 'routing' do - it 'routes to #index' do - get('/plant_parts').should route_to('plant_parts#index') + describe "routing" do + it "routes to #index" do + get("/plant_parts").should route_to("plant_parts#index") end - it 'routes to #new' do - get('/plant_parts/new').should route_to('plant_parts#new') + it "routes to #new" do + get("/plant_parts/new").should route_to("plant_parts#new") end - it 'routes to #show' do - get('/plant_parts/1').should route_to('plant_parts#show', id: '1') + it "routes to #show" do + get("/plant_parts/1").should route_to("plant_parts#show", id: "1") end - it 'routes to #edit' do - get('/plant_parts/1/edit').should route_to('plant_parts#edit', id: '1') + it "routes to #edit" do + get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") end - it 'routes to #create' do - post('/plant_parts').should route_to('plant_parts#create') + it "routes to #create" do + post("/plant_parts").should route_to("plant_parts#create") end - it 'routes to #update' do - put('/plant_parts/1').should route_to('plant_parts#update', id: '1') + it "routes to #update" do + put("/plant_parts/1").should route_to("plant_parts#update", id: "1") end - it 'routes to #destroy' do - delete('/plant_parts/1').should route_to('plant_parts#destroy', id: '1') + it "routes to #destroy" do + delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") end end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 4098d7703..473fe827e 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantingsController do - describe 'routing' do - it 'routes to #index' do - get('/plantings').should route_to('plantings#index') + describe "routing" do + it "routes to #index" do + get("/plantings").should route_to("plantings#index") end - it 'routes to #new' do - get('/plantings/new').should route_to('plantings#new') + it "routes to #new" do + get("/plantings/new").should route_to("plantings#new") end - it 'routes to #show' do - get('/plantings/1').should route_to('plantings#show', id: '1') + it "routes to #show" do + get("/plantings/1").should route_to("plantings#show", id: "1") end - it 'routes to #edit' do - get('/plantings/1/edit').should route_to('plantings#edit', id: '1') + it "routes to #edit" do + get("/plantings/1/edit").should route_to("plantings#edit", id: "1") end - it 'routes to #create' do - post('/plantings').should route_to('plantings#create') + it "routes to #create" do + post("/plantings").should route_to("plantings#create") end - it 'routes to #update' do - put('/plantings/1').should route_to('plantings#update', id: '1') + it "routes to #update" do + put("/plantings/1").should route_to("plantings#update", id: "1") end - it 'routes to #destroy' do - delete('/plantings/1').should route_to('plantings#destroy', id: '1') + it "routes to #destroy" do + delete("/plantings/1").should route_to("plantings#destroy", id: "1") end end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb index c19642a21..15166a805 100644 --- a/spec/routing/products_routing_spec.rb +++ b/spec/routing/products_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ProductsController do - describe 'routing' do - it 'routes to #index' do - get('/products').should route_to('products#index') + describe "routing" do + it "routes to #index" do + get("/products").should route_to("products#index") end - it 'routes to #new' do - get('/products/new').should route_to('products#new') + it "routes to #new" do + get("/products/new").should route_to("products#new") end - it 'routes to #show' do - get('/products/1').should route_to('products#show', id: '1') + it "routes to #show" do + get("/products/1").should route_to("products#show", id: "1") end - it 'routes to #edit' do - get('/products/1/edit').should route_to('products#edit', id: '1') + it "routes to #edit" do + get("/products/1/edit").should route_to("products#edit", id: "1") end - it 'routes to #create' do - post('/products').should route_to('products#create') + it "routes to #create" do + post("/products").should route_to("products#create") end - it 'routes to #update' do - put('/products/1').should route_to('products#update', id: '1') + it "routes to #update" do + put("/products/1").should route_to("products#update", id: "1") end - it 'routes to #destroy' do - delete('/products/1').should route_to('products#destroy', id: '1') + it "routes to #destroy" do + delete("/products/1").should route_to("products#destroy", id: "1") end end end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 589c40dd8..7b6469efb 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe RolesController do - describe 'routing' do - it 'routes to #index' do - get('/roles').should route_to('roles#index') + describe "routing" do + it "routes to #index" do + get("/roles").should route_to("roles#index") end - it 'routes to #new' do - get('/roles/new').should route_to('roles#new') + it "routes to #new" do + get("/roles/new").should route_to("roles#new") end - it 'routes to #show' do - get('/roles/1').should route_to('roles#show', id: '1') + it "routes to #show" do + get("/roles/1").should route_to("roles#show", id: "1") end - it 'routes to #edit' do - get('/roles/1/edit').should route_to('roles#edit', id: '1') + it "routes to #edit" do + get("/roles/1/edit").should route_to("roles#edit", id: "1") end - it 'routes to #create' do - post('/roles').should route_to('roles#create') + it "routes to #create" do + post("/roles").should route_to("roles#create") end - it 'routes to #update' do - put('/roles/1').should route_to('roles#update', id: '1') + it "routes to #update" do + put("/roles/1").should route_to("roles#update", id: "1") end - it 'routes to #destroy' do - delete('/roles/1').should route_to('roles#destroy', id: '1') + it "routes to #destroy" do + delete("/roles/1").should route_to("roles#destroy", id: "1") end end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 5020404ea..7bbbfa764 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ScientificNamesController do - describe 'routing' do - it 'routes to #index' do - get('/scientific_names').should route_to('scientific_names#index') + describe "routing" do + it "routes to #index" do + get("/scientific_names").should route_to("scientific_names#index") end - it 'routes to #new' do - get('/scientific_names/new').should route_to('scientific_names#new') + it "routes to #new" do + get("/scientific_names/new").should route_to("scientific_names#new") end - it 'routes to #show' do - get('/scientific_names/1').should route_to('scientific_names#show', id: '1') + it "routes to #show" do + get("/scientific_names/1").should route_to("scientific_names#show", id: "1") end - it 'routes to #edit' do - get('/scientific_names/1/edit').should route_to('scientific_names#edit', id: '1') + it "routes to #edit" do + get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") end - it 'routes to #create' do - post('/scientific_names').should route_to('scientific_names#create') + it "routes to #create" do + post("/scientific_names").should route_to("scientific_names#create") end - it 'routes to #update' do - put('/scientific_names/1').should route_to('scientific_names#update', id: '1') + it "routes to #update" do + put("/scientific_names/1").should route_to("scientific_names#update", id: "1") end - it 'routes to #destroy' do - delete('/scientific_names/1').should route_to('scientific_names#destroy', id: '1') + it "routes to #destroy" do + delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index ad8615cc4..74f4aff64 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe SeedsController do - describe 'routing' do - it 'routes to #index' do - get('/seeds').should route_to('seeds#index') + describe "routing" do + it "routes to #index" do + get("/seeds").should route_to("seeds#index") end - it 'routes to #new' do - get('/seeds/new').should route_to('seeds#new') + it "routes to #new" do + get("/seeds/new").should route_to("seeds#new") end - it 'routes to #show' do - get('/seeds/1').should route_to('seeds#show', id: '1') + it "routes to #show" do + get("/seeds/1").should route_to("seeds#show", id: "1") end - it 'routes to #edit' do - get('/seeds/1/edit').should route_to('seeds#edit', id: '1') + it "routes to #edit" do + get("/seeds/1/edit").should route_to("seeds#edit", id: "1") end - it 'routes to #create' do - post('/seeds').should route_to('seeds#create') + it "routes to #create" do + post("/seeds").should route_to("seeds#create") end - it 'routes to #update' do - put('/seeds/1').should route_to('seeds#update', id: '1') + it "routes to #update" do + put("/seeds/1").should route_to("seeds#update", id: "1") end - it 'routes to #destroy' do - delete('/seeds/1').should route_to('seeds#destroy', id: '1') + it "routes to #destroy" do + delete("/seeds/1").should route_to("seeds#destroy", id: "1") end end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 1b3c8ea59..966647515 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PostsController do - describe 'routing' do - it 'routes to #index' do - get('/posts').should route_to('posts#index') + describe "routing" do + it "routes to #index" do + get("/posts").should route_to("posts#index") end - it 'routes to #new' do - get('/posts/new').should route_to('posts#new') + it "routes to #new" do + get("/posts/new").should route_to("posts#new") end - it 'routes to #show' do - get('/posts/1').should route_to('posts#show', id: '1') + it "routes to #show" do + get("/posts/1").should route_to("posts#show", id: "1") end - it 'routes to #edit' do - get('/posts/1/edit').should route_to('posts#edit', id: '1') + it "routes to #edit" do + get("/posts/1/edit").should route_to("posts#edit", id: "1") end - it 'routes to #create' do - post('/posts').should route_to('posts#create') + it "routes to #create" do + post("/posts").should route_to("posts#create") end - it 'routes to #update' do - put('/posts/1').should route_to('posts#update', id: '1') + it "routes to #update" do + put("/posts/1").should route_to("posts#update", id: "1") end - it 'routes to #destroy' do - delete('/posts/1').should route_to('posts#destroy', id: '1') + it "routes to #destroy" do + delete("/posts/1").should route_to("posts#destroy", id: "1") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 300bca74d..9a0b542df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,5 +87,5 @@ RSpec.configure do |config| Kernel.srand config.seed # Remember which tests failed, so you can run rspec with the `--only-failures` flag. - config.example_status_persistence_file_path = 'tmp/examples.txt' + config.example_status_persistence_file_path = "tmp/examples.txt" end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index b8236e95f..354c64069 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,7 +3,7 @@ module ControllerMacros def login_member(member_factory = :member) let(:member) { FactoryBot.create(member_factory || :member) } before(:each) do - @request.env['devise.mapping'] = Devise.mappings[:member] + @request.env["devise.mapping"] = Devise.mappings[:member] sign_in member end end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 5b73b5b0c..aaa4fd689 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,6 +1,6 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) - return unless ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + return unless ENV['GROWSTUFF_ELASTICSEARCH'] == "true" crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end @@ -10,6 +10,6 @@ RSpec.configure do |config| config.include ElasticsearchHelpers config.before(:all, elasticsearch: true) do - Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" end end diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index fb24eaa02..e1a590b30 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,4 +1,4 @@ -shared_examples 'it is likeable' do +shared_examples "it is likeable" do before(:each) do # Possibly a horrible hack. # Will fail if factory name does not match the model name.. @@ -9,7 +9,7 @@ shared_examples 'it is likeable' do @like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable) end - it 'has many likes' do + it "has many likes" do expect(@likeable.likes.length).to eq 2 end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index e8f934358..1bd22be03 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/edit' do +describe "account_types/edit" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false)) end - it 'renders the edit account_type form' do + it "renders the edit account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path(@account_type), method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path(@account_type), method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index 94f19d072..56020fc35 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/index' do +describe "account_types/index" do before(:each) do @type = FactoryBot.create(:account_type) assign(:account_types, [@type, @type]) end - it 'renders a list of account_types' do + it "renders a list of account_types" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @type.name.to_s, count: 2 + assert_select "tr>td", text: @type.name.to_s, count: 2 end end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index db7cec061..027a1b7c1 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/new' do +describe "account_types/new" do before(:each) do assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false).as_new_record) end - it 'renders new account_type form' do + it "renders new account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path, method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path, method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 6bb888f1a..a31d4bc33 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/show' do +describe "account_types/show" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'Name', + name: "Name", is_paid: false, is_permanent_paid: false)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index d77edd8c8..bc5c3b5a3 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/edit' do +describe "accounts/edit" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it 'renders the edit account form' do + it "renders the edit account form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: accounts_path(@account), method: 'post' do - assert_select 'input#account_member_id', name: 'account[member_id]' - assert_select 'input#account_account_type', name: 'account[account_type]' + assert_select "form", action: accounts_path(@account), method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 7e54347fb..4ec76151e 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'accounts/index' do +describe "accounts/index" do before(:each) do @member = FactoryBot.create(:member) @account = @member.account assign(:accounts, [@account, @account]) end - it 'renders a list of accounts' do + it "renders a list of accounts" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @account.member_id.to_s, count: 2 + assert_select "tr>td", text: @account.member_id.to_s, count: 2 end end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 5bc6ba812..77f6ff20f 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/new' do +describe "accounts/new" do before(:each) do @member = FactoryBot.create(:member) assign(:account, @member.account) end - it 'renders new account form' do + it "renders new account form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: accounts_path, method: 'post' do - assert_select 'input#account_member_id', name: 'account[member_id]' - assert_select 'input#account_account_type', name: 'account[account_type]' + assert_select "form", action: accounts_path, method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb index b852b12d1..d96fbbd96 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'accounts/show' do +describe "accounts/show" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @account.member_id.to_s diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 442a0c36c..beb0eacbd 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/index.html.haml', type: 'view' do +describe 'admin/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,14 +8,14 @@ describe 'admin/index.html.haml', type: 'view' do render end - it 'includes links to manage various things' do - assert_select 'a', href: account_types_path - assert_select 'a', href: products_path - assert_select 'a', href: roles_path - assert_select 'a', href: forums_path + it "includes links to manage various things" do + assert_select "a", href: account_types_path + assert_select "a", href: products_path + assert_select "a", href: roles_path + assert_select "a", href: forums_path end - it 'has a link to newsletter subscribers' do - rendered.should have_content 'Newsletter subscribers' + it "has a link to newsletter subscribers" do + rendered.should have_content "Newsletter subscribers" end end diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 8faca4e18..384833034 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/newsletter.html.haml', type: 'view' do +describe 'admin/newsletter.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -10,7 +10,7 @@ describe 'admin/newsletter.html.haml', type: 'view' do render end - it 'lists newsletter subscribers by email' do + it "lists newsletter subscribers by email" do rendered.should have_content @subscriber.email end end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index 905b6a3ff..8d80dc3ef 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/orders/index.html.haml', type: 'view' do +describe 'admin/orders/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,13 +8,13 @@ describe 'admin/orders/index.html.haml', type: 'view' do render end - it 'includes a search form for orders' do - assert_select 'form' - assert_select 'input#search_text' - assert_select 'select#search_by' + it "includes a search form for orders" do + assert_select "form" + assert_select "input#search_text" + assert_select "select#search_by" end - it 'lets you search by referral code' do - assert_select 'option[value=referral_code]', text: 'Referral code' + it "lets you search by referral code" do + assert_select "option[value=referral_code]", text: "Referral code" end end diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index 41a46858d..2ef7d480f 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'comments/edit' do +describe "comments/edit" do before(:each) do controller.stub(:current_user) { nil } assign(:comment, FactoryBot.create(:comment)) end - it 'renders the edit comment form' do + it "renders the edit comment form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: comments_path(@comment), method: 'post' do - assert_select 'textarea#comment_body', name: 'comment[body]' + assert_select "form", action: comments_path(@comment), method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end end diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 3677782e2..91ed15a88 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/index' do +describe "comments/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -16,13 +16,13 @@ describe 'comments/index' do render end - it 'renders a list of comments' do + it "renders a list of comments" do render rendered.should have_content 'OMG LOL' rendered.should have_content 'ROFL' end - it 'contains an RSS feed link' do - assert_select 'a', href: comments_path(format: 'rss') + it "contains an RSS feed link" do + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index 6d0db9169..672658bac 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -13,7 +13,7 @@ describe 'comments/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent comments on all posts' + rendered.should have_content "Recent comments on all posts" end it 'shows item title' do @@ -26,6 +26,6 @@ describe 'comments/index.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index e5bdcfb39..e0533ea5b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/new' do +describe "comments/new" do before(:each) do controller.stub(:current_user) { nil } @post = FactoryBot.create(:post) @@ -10,21 +10,21 @@ describe 'comments/new' do render end - it 'shows the text of the post under discussion' do + it "shows the text of the post under discussion" do rendered.should have_content @post.body end - it 'shows previous comments' do + it "shows previous comments" do rendered.should have_content @comment.body end - it 'shows the correct comment count' do - rendered.should have_content '1 comment' + it "shows the correct comment count" do + rendered.should have_content "1 comment" end - it 'renders new comment form' do - assert_select 'form', action: comments_path, method: 'post' do - assert_select 'textarea#comment_body', name: 'comment[body]' + it "renders new comment form" do + assert_select "form", action: comments_path, method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index 91e045359..6315b4f69 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'comments/show' do +describe "comments/show" do before(:each) do controller.stub(:current_user) { nil } @comment = assign(:comment, FactoryBot.create(:comment)) render end - it 'renders the comment' do + it "renders the comment" do rendered.should have_content @comment.author.login_name rendered.should have_content @comment.body end diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index deb541bb4..c378c296c 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_grown_for' do +describe "crops/_grown_for" do let(:crop) { FactoryBot.create(:crop) } let(:plant_path) { FactoryBot.create(:plant_part) } let!(:harvest) do @@ -12,6 +12,6 @@ describe 'crops/_grown_for' do it 'shows plant parts' do render partial: 'crops/grown_for', locals: { crop: crop } rendered.should have_content plant_path.name - assert_select 'a', href: plant_part_path(plant_path) + assert_select "a", href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 4cb5aa0a2..12064a1b8 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,62 +1,62 @@ require 'rails_helper' -describe 'crops/_planting_advice' do +describe "crops/_planting_advice" do subject { rendered } let(:planting) { FactoryBot.create(:planting) } - shared_examples 'render planting_advice' do + shared_examples "render planting_advice" do before { render 'crops/planting_advice', crop: planting.crop } end - describe 'sunniness' do - context 'with no sunniness set' do - include_examples 'render planting_advice' + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" it "doesn't show sunniness" do - is_expected.to have_content 'Plant in: not known.' + is_expected.to have_content "Plant in: not known." end end - context 'with sunniness frequencies' do + context "with sunniness frequencies" do before { FactoryBot.create(:sunny_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - context 'with multiple sunniness frequencies' do + context "with multiple sunniness frequencies" do before do FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) FactoryBot.create(:shady_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (2), shade (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - describe 'planted from' do - context 'when none are set' do - include_examples 'render planting_advice' + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" it "doesn't show planted_from " do - is_expected.to have_content 'Plant from: not known.' + is_expected.to have_content "Plant from: not known." end end - context 'with planted_from frequencies' do + context "with planted_from frequencies" do before { FactoryBot.create(:seed_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - context 'with multiple planted_from frequencies' do + context "with multiple planted_from frequencies" do before do FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) FactoryBot.create(:cutting_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (2), cutting (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index e5f1f92ac..dde4a893f 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_popover' do +describe "crops/_popover" do before(:each) do @tomato = FactoryBot.create(:tomato) @sn = FactoryBot.create(:solanum_lycopersicum, crop: @tomato) diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index eeadf603d..19fac21af 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/edit' do +describe "crops/edit" do before(:each) do controller.stub(:current_user) do FactoryBot.create(:crop_wrangling_member) @@ -13,7 +13,7 @@ describe 'crops/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@crop.creator} less than a minute ago." end end diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index 0740142bb..833bb2b98 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/hierarchy' do +describe "crops/hierarchy" do before(:each) do controller.stub(:current_user) { nil } @tomato = FactoryBot.create(:tomato) @@ -9,7 +9,7 @@ describe 'crops/hierarchy' do render end - it 'shows crop hierarchy' do - assert_select 'ul>li>ul>li', text: @roma.name + it "shows crop hierarchy" do + assert_select "ul>li>ul>li", text: @roma.name end end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index ef7081444..9f2985035 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/index' do +describe "crops/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -15,20 +15,20 @@ describe 'crops/index' do assign(:crops, crops) end - it 'shows photos where available' do + it "shows photos where available" do @planting = FactoryBot.create(:planting, crop: @tomato) @photo = FactoryBot.create(:photo) @planting.photos << @photo render - assert_select 'img', src: @photo.thumbnail_url + assert_select "img", src: @photo.thumbnail_url end - it 'linkifies crop images' do + it "linkifies crop images" do render - assert_select 'img', src: :tomato + assert_select "img", src: :tomato end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member @@ -36,18 +36,18 @@ describe 'crops/index' do render end - it 'shows a new crop link' do - rendered.should have_content 'New Crop' + it "shows a new crop link" do + rendered.should have_content "New Crop" end end - context 'downloads' do - it 'offers data downloads' do + context "downloads" do + it "offers data downloads" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: crops_path(format: 'csv') - assert_select 'a', href: crops_path(format: 'json') - assert_select 'a', href: crops_path(format: 'rss') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: crops_path(format: 'csv') + assert_select "a", href: crops_path(format: 'json') + assert_select "a", href: crops_path(format: 'rss') end end end diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index cb218b9cd..72a8bbdff 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -11,7 +11,7 @@ describe 'crops/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recently added crops' + rendered.should have_content "Recently added crops" end it 'shows names of crops' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index 229474cac..5ce7eefdc 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/new' do +describe "crops/new" do before(:each) do @crop = FactoryBot.create(:maize) 3.times do @@ -13,7 +13,7 @@ describe 'crops/new' do render end - it 'shows a link to crop wrangling guidelines' do - assert_select "a[href^='http://wiki.growstuff.org']", 'crop wrangling guide' + it "shows a link to crop wrangling guidelines" do + assert_select "a[href^='http://wiki.growstuff.org']", "crop wrangling guide" end end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index d97eab036..085060570 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/wrangle' do +describe "crops/wrangle" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) controller.stub(:current_user) { @member } @@ -18,18 +18,18 @@ describe 'crops/wrangle' do it 'contains handy links for wranglers' do render - rendered.should have_content 'Crop wrangler guidelines' - rendered.should have_content 'mailing list' + rendered.should have_content "Crop wrangler guidelines" + rendered.should have_content "mailing list" end it 'has a link to add a crop' do render - assert_select 'a', href: new_crop_path + assert_select "a", href: new_crop_path end - it 'renders a list of crops' do + it "renders a list of crops" do render - assert_select 'a', text: @maize.name - assert_select 'a', text: @tomato.name + assert_select "a", text: @maize.name + assert_select "a", text: @tomato.name end end diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb index 3dd70cd20..720822083 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,13 +1,13 @@ -describe 'devise/confirmations/new.html.haml', type: 'view' do +describe 'devise/confirmations/new.html.haml', type: "view" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render end it 'should contain a login field' do - rendered.should have_content 'Enter either your login name or your email address' + rendered.should have_content "Enter either your login name or your email address" end end diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index b2dcf645a..d2cce98c4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'devise/mailer/confirmation_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index d64dbc30d..fc2ad1bbe 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'devise/mailer/reset_password_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = mock_model(Member) - @resource.stub(:email).and_return('example@example.com') - @resource.stub(:reset_password_token).and_return('joe') + @resource.stub(:email).and_return("example@example.com") + @resource.stub(:reset_password_token).and_return("joe") render end diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index bafbb484c..633545cf3 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'devise/mailer/unlock_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render end it "should explain what's happened" do - rendered.should have_content 'account has been locked' + rendered.should have_content "account has been locked" end - it 'should have an unlock link' do - rendered.should have_content 'Unlock my account' + it "should have an unlock link" do + rendered.should have_content "Unlock my account" end end end diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 52999595f..3d9dae906 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'devise/registrations/edit.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/edit.html.haml', type: "view" do + context "logged in" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) controller.stub(:current_member) { @member } @view.stub(:resource).and_return(@member) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) end @@ -23,11 +23,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'has a checkbox for email notifications' do - assert_select 'input[id=member_send_notification_email][type=checkbox]' + assert_select "input[id=member_send_notification_email][type=checkbox]" end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end @@ -37,23 +37,23 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'shows show_email checkbox' do - assert_select 'input[id=member_show_email][type=checkbox]' + assert_select "input[id=member_show_email][type=checkbox]" end - it 'contains a gravatar icon' do - assert_select 'img', src: /gravatar\.com\/avatar/ + it "contains a gravatar icon" do + assert_select "img", src: /gravatar\.com\/avatar/ end it 'contains a link to gravatar.com' do - assert_select 'a', href: /gravatar\.com/ + assert_select "a", href: /gravatar\.com/ end it 'shows bio field' do - assert_select 'textarea[id=member_bio]' + assert_select "textarea[id=member_bio]" end it 'shows location field' do - assert_select 'input[id=member_location][type=text]' + assert_select "input[id=member_location][type=text]" end end @@ -61,7 +61,7 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do context 'not connected to twitter' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Twitter' + assert_select "a", "Connect to Twitter" end end context 'connected to twitter' do @@ -70,18 +70,18 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do render end it 'has a link to twitter profile' do - assert_select 'a', href: "http://twitter.com/#{@twitter_auth.name}" + assert_select "a", href: "http://twitter.com/#{@twitter_auth.name}" end it 'has a link to disconnect' do render - assert_select 'a', href: @twitter_auth, text: 'Disconnect' + assert_select "a", href: @twitter_auth, text: "Disconnect" end end context 'not connected to flickr' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Flickr' + assert_select "a", "Connect to Flickr" end end context 'connected to flickr' do @@ -90,11 +90,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do render end it 'has a link to flickr photostream' do - assert_select 'a', href: "http://flickr.com/photos/#{@flickr_auth.uid}" + assert_select "a", href: "http://flickr.com/photos/#{@flickr_auth.uid}" end it 'has a link to disconnect' do render - assert_select 'a', href: @flickr_auth, text: 'Disconnect' + assert_select "a", href: @flickr_auth, text: "Disconnect" end end end diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 3424fbef9..48805b806 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/registrations/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render @@ -15,7 +15,7 @@ describe 'devise/registrations/new.html.haml', type: 'view' do end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end end diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 9d83e51b3..dfe91af2a 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/sessions/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/sessions/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index 63f2fd52d..39147113f 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,6 +1,6 @@ -describe 'devise/shared/_links.haml', type: 'view' do +describe 'devise/shared/_links.haml', type: "view" do def devise_mapping(register, recover, confirm, lock, oauth) - dm = double('mappings') + dm = double("mappings") dm.stub(registerable?: register) dm.stub(recoverable?: recover) dm.stub(confirmable?: confirm) @@ -10,15 +10,15 @@ describe 'devise/shared/_links.haml', type: 'view' do end it 'should have a sign-in link if not in sessions' do - @view.stub(:controller_name).and_return('anything but sessions') - @view.stub(:resource_name).and_return('member') + @view.stub(:controller_name).and_return("anything but sessions") + @view.stub(:resource_name).and_return("member") @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end it "shouldn't have a sign-in link if in sessions" do - @view.stub(:controller_name).and_return('sessions') - @view.stub(:resource_name).and_return('member') + @view.stub(:controller_name).and_return("sessions") + @view.stub(:resource_name).and_return("member") @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 5fd755cce..60d056d72 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/unlocks/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/unlocks/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 152a34418..44151170a 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'forums/edit' do +describe "forums/edit" do before(:each) do @forum = assign(:forum, stub_model(Forum, - name: 'MyString', - description: 'MyText', + name: "MyString", + description: "MyText", owner_id: 1)) end - it 'renders the edit forum form' do + it "renders the edit forum form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: forums_path(@forum), method: 'post' do - assert_select 'input#forum_name', name: 'forum[name]' - assert_select 'textarea#forum_description', name: 'forum[description]' - assert_select 'select#forum_owner_id', name: 'forum[owner_id]' + assert_select "form", action: forums_path(@forum), method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 279a365fc..02b265e85 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'forums/index' do +describe "forums/index" do before(:each) do @admin = FactoryBot.create(:admin_member) controller.stub(:current_user) { @admin } @@ -9,31 +9,31 @@ describe 'forums/index' do assign(:forums, [@forum1, @forum2]) end - it 'renders a list of forums' do + it "renders a list of forums" do render - assert_select 'h2', text: @forum1.name, count: 2 + assert_select "h2", text: @forum1.name, count: 2 end it "doesn't display posts for empty forums" do render - assert_select 'table', false + assert_select "table", false end - context 'posts' do + context "posts" do before(:each) do @post = FactoryBot.create(:forum_post, forum: @forum1) @comment = FactoryBot.create(:comment, post: @post) render end - it 'displays posts' do - assert_select 'table' + it "displays posts" do + assert_select "table" rendered.should have_content @post.subject rendered.should have_content Time.zone.today.to_s(:short) end - it 'displays comment count' do - assert_select 'td', text: '1' + it "displays comment count" do + assert_select "td", text: "1" end end end diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 58278ee18..72cd7ae45 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'forums/new' do +describe "forums/new" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) render end - it 'renders new forum form' do - assert_select 'form', action: forums_path, method: 'post' do - assert_select 'input#forum_name', name: 'forum[name]' - assert_select 'textarea#forum_description', name: 'forum[description]' - assert_select 'select#forum_owner_id', name: 'forum[owner_id]' + it "renders new forum form" do + assert_select "form", action: forums_path, method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 6e67b8c59..08892df58 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -describe 'forums/show' do +describe "forums/show" do before(:each) do controller.stub(:current_user) { nil } @forum = assign(:forum, FactoryBot.create(:forum)) end - it 'renders attributes' do + it "renders attributes" do render - rendered.should have_content 'Everything about permaculture' + rendered.should have_content "Everything about permaculture" rendered.should have_content @forum.owner.to_s end - it 'parses markdown description into html' do + it "parses markdown description into html" do render - assert_select 'em', 'Everything' + assert_select "em", "Everything" end it 'links to new post with the forum id' do @@ -24,13 +24,13 @@ describe 'forums/show' do it 'has no posts' do render - rendered.should have_content 'No posts yet.' + rendered.should have_content "No posts yet." end it 'shows posts' do @post = FactoryBot.create(:post, forum: @forum) render - assert_select 'table' + assert_select "table" rendered.should have_content @post.subject rendered.should have_content @post.author.to_s end diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index c725af57e..1326f1544 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'gardens/edit' do - context 'logged in' do +describe "gardens/edit" do + context "logged in" do before(:each) do @owner = FactoryBot.create(:member) sign_in @owner @@ -10,17 +10,17 @@ describe 'gardens/edit' do render end - it 'renders the edit garden form' do + it "renders the edit garden form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: gardens_path(@garden), method: 'post' do - assert_select 'input#garden_name', name: 'garden[name]' - assert_select 'textarea#garden_description', name: 'garden[description]' - assert_select 'input#garden_location', name: 'garden[location]' - assert_select 'input#garden_area', name: 'garden[area]' - assert_select 'select#garden_area_unit', name: 'garden[area_unit]' - assert_select 'input#garden_active', name: 'garden[active]' + assert_select "form", action: gardens_path(@garden), method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 39b659b7e..7346997dc 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/new' do +describe "gardens/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -10,14 +10,14 @@ describe 'gardens/new' do render end - it 'renders new garden form' do - assert_select 'form', action: gardens_path, method: 'post' do - assert_select 'input#garden_name', name: 'garden[name]' - assert_select 'textarea#garden_description', name: 'garden[description]' - assert_select 'input#garden_location', name: 'garden[location]' - assert_select 'input#garden_area', name: 'garden[area]' - assert_select 'select#garden_area_unit', name: 'garden[area_unit]' - assert_select 'input#garden_active', name: 'garden[active]' + it "renders new garden form" do + assert_select "form", action: gardens_path, method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fa03c5856..7130e2e4f 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/show' do +describe "gardens/show" do before(:each) do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @@ -21,11 +21,11 @@ describe 'gardens/show' do end it 'should show the description' do - rendered.should have_content 'totally cool garden' + rendered.should have_content "totally cool garden" end it 'renders markdown in the description' do - assert_select 'strong', 'totally' + assert_select "strong", "totally" end it 'should show plantings on the garden page' do @@ -33,7 +33,7 @@ describe 'gardens/show' do end it "doesn't show the note about random plantings" do - rendered.should_not have_content 'Note: these are a random selection' + rendered.should_not have_content "Note: these are a random selection" end context 'signed in' do @@ -47,14 +47,14 @@ describe 'gardens/show' do end it "shows a 'plant something' button" do - rendered.should have_content 'Plant something' + rendered.should have_content "Plant something" end it "shows an 'add photo' button" do - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - it 'links to the right crop in the planting link' do + it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 6d4c55b7e..1193b4284 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'harvests/edit' do +describe "harvests/edit" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it 'renders new harvest form' do - assert_select 'form', action: harvests_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' - assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' - assert_select 'input#harvest_quantity', name: 'harvest[quantity]' - assert_select 'input#harvest_weight_quantity', name: 'harvest[quantity]' - assert_select 'select#harvest_unit', name: 'harvest[unit]' - assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' - assert_select 'textarea#harvest_description', name: 'harvest[description]' + it "renders new harvest form" do + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + assert_select "input#harvest_quantity", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index 62ef81d15..fe205cda6 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/index' do +describe "harvests/index" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @@ -25,11 +25,11 @@ describe 'harvests/index' do render end - it 'provides data links' do + it "provides data links" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: harvests_path(format: 'csv') - assert_select 'a', href: harvests_path(format: 'json') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: harvests_path(format: 'csv') + assert_select "a", href: harvests_path(format: 'json') end it "displays member's name in title" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 4e6050625..d79055a38 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'harvests/new' do +describe "harvests/new" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it 'renders new harvest form' do - assert_select 'form', action: harvests_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' - assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' + it "renders new harvest form" do + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" # some browsers interpret without a step as "integer" - assert_select 'input#harvest_quantity[step=any]', name: 'harvest[quantity]' - assert_select 'input#harvest_weight_quantity[step=any]', name: 'harvest[quantity]' - assert_select 'select#harvest_unit', name: 'harvest[unit]' - assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' - assert_select 'textarea#harvest_description', name: 'harvest[description]' + assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index a182b5269..4aec453ff 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/show' do +describe "harvests/show" do subject { render } let!(:harvest) { FactoryBot.create(:harvest) } @@ -11,7 +11,7 @@ describe 'harvests/show' do render end - describe 'renders attributes' do + describe "renders attributes" do it { is_expected.to have_content harvest.crop.name } it { is_expected.to have_content harvest.harvested_at.to_s } it { is_expected.to have_content harvest.plant_part.to_s } diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 5e661b19d..47244a445 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_blurb.html.haml', type: 'view' do +describe 'home/_blurb.html.haml', type: "view" do context 'signed out' do before :each do controller.stub(:current_user) { nil } @@ -12,13 +12,13 @@ describe 'home/_blurb.html.haml', type: 'view' do end it 'has signup section' do - assert_select 'div.signup' - assert_select 'a', href: new_member_registration_path + assert_select "div.signup" + assert_select "a", href: new_member_registration_path end it 'has a link to sign in' do - rendered.should have_content 'Or sign in if you already have an account' - assert_select 'a', href: new_member_session_path + rendered.should have_content "Or sign in if you already have an account" + assert_select "a", href: new_member_session_path end end end diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index 37dcbd05b..3ed655438 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_crops.html.haml', type: 'view' do +describe 'home/_crops.html.haml', type: "view" do let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } let(:planting) { crop.plantings.first } diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 3d75ea692..76aa434b6 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_members.html.haml', type: 'view' do +describe 'home/_members.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago @@ -11,7 +11,7 @@ describe 'home/_members.html.haml', type: 'view' do end it 'Has a heading' do - rendered.should have_content 'Some of our members' + rendered.should have_content "Some of our members" end it 'Shows members' do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index a551e97f8..7b8d6156c 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', type: 'view' do +describe 'home/_seeds.html.haml', type: "view" do before(:each) do @owner = FactoryBot.create(:london_member) @seed = FactoryBot.create(:tradable_seed, owner: @owner) diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index dc5a0e8a5..a9979190c 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'home/_stats.html.haml', type: 'view' do +describe 'home/_stats.html.haml', type: "view" do it 'has activity stats' do render - rendered.should have_content 'So far, 0 members have planted 0 crops' + rendered.should have_content "So far, 0 members have planted 0 crops" end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5eeae7ff4..5e11882fd 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/index.html.haml', type: 'view' do +describe 'home/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 60f27ca80..5060fc30d 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'layouts/_header.html.haml', type: 'view' do - context 'when not logged in' do +describe 'layouts/_header.html.haml', type: "view" do + context "when not logged in" do before(:each) do controller.stub(:current_user) { nil } render end it 'shows the brand logo in the navbar' do - assert_select('a.navbar-brand img[src]', href: root_path) + assert_select("a.navbar-brand img[src]", href: root_path) end it 'should have signup/signin links' do @@ -17,19 +17,19 @@ describe 'layouts/_header.html.haml', type: 'view' do end it 'has a Crops link' do - rendered.should have_content 'Crops' + rendered.should have_content "Crops" end it 'has a Seeds link' do - rendered.should have_content 'Seeds' + rendered.should have_content "Seeds" end it 'has a Places link' do - rendered.should have_content 'Community Map' + rendered.should have_content "Community Map" end it 'has a Community section' do - rendered.should have_content 'Community' + rendered.should have_content "Community" end it 'links to members' do @@ -46,11 +46,11 @@ describe 'layouts/_header.html.haml', type: 'view' do it 'has a crop search' do assert_select("form[action='#{crops_search_path}']") - assert_select('input#term') + assert_select("input#term") end end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -58,21 +58,21 @@ describe 'layouts/_header.html.haml', type: 'view' do render end - context 'login name' do + context "login name" do it 'should have member login name' do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", 'Gardens') + assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", 'Plantings') + assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", 'Seeds') + assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", "Seeds") end it "should show link to member's posts" do - assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", 'Posts') + assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", "Posts") end end diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 42d4704ad..151c6fe19 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/_meta.html.haml', type: 'view' do +describe 'layouts/_meta.html.haml', type: "view" do before(:each) do render end @@ -21,6 +21,6 @@ describe 'layouts/_meta.html.haml', type: 'view' do end it 'should have a title' do - assert_select 'head>title' + assert_select "head>title" end end diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index 265a0b572..f094ae2c2 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/application.html.haml', type: 'view' do +describe 'layouts/application.html.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } end @@ -8,7 +8,7 @@ describe 'layouts/application.html.haml', type: 'view' do it 'includes the analytics code' do Growstuff::Application.config.analytics_code = '' render - assert_select 'script', text: 'alert("foo!")' + assert_select "script", text: 'alert("foo!")' rendered.should_not have_content 'script' end end diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index d15d69538..50d7b675f 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'members/_location' do - context 'member with location' do +describe "members/_location" do + context "member with location" do let(:member) { FactoryBot.create(:london_member) } before(:each) { render partial: 'members/location', locals: { member: member } } @@ -10,23 +10,23 @@ describe 'members/_location' do expect(rendered).to have_content member.location end - it 'links to the places page' do - assert_select 'a', href: place_path(member.location) + it "links to the places page" do + assert_select "a", href: place_path(member.location) end end - context 'member with no location' do + context "member with no location" do before(:each) do member = FactoryBot.create(:member) render partial: 'members/location', locals: { member: member } end it 'shows unknown location' do - expect(rendered).to have_content 'unknown location' + expect(rendered).to have_content "unknown location" end it "doesn't link anywhere" do - assert_select 'a', false + assert_select "a", false end end end diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 24308bd0e..87dd3a285 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/index' do +describe "members/index" do let(:member) { FactoryBot.create(:london_member) } before(:each) do @@ -15,8 +15,8 @@ describe 'members/index' do render end - it 'contains two gravatar icons' do - assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 + it "contains two gravatar icons" do + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end it 'contains member locations' do diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index 79ea04078..23366a9a8 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/show.rss.haml', type: 'view' do +describe 'members/show.rss.haml', type: "view" do before(:each) do @member = assign(:member, FactoryBot.create(:member)) @post1 = FactoryBot.create(:post, id: 1, author: @member) @@ -16,13 +16,13 @@ describe 'members/show.rss.haml', type: 'view' do end it 'shows content of posts' do - is_expected.to have_content 'This is some text.' + is_expected.to have_content "This is some text." end it 'renders post bodies to HTML and XML-escapes them' do # The variable "rendered" has been entity-replaced and tag-stripped # The literal string output contains "<strong>" etc. - is_expected.to have_content 'strong' + is_expected.to have_content "strong" end it 'gives the author in the item title' do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 76d96f3eb..2c8195069 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'notifications/index' do +describe "notifications/index" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } end - context 'ordinary notifications' do + context "ordinary notifications" do before(:each) do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member) @@ -14,34 +14,34 @@ describe 'notifications/index' do render end - it 'renders a list of notifications' do - assert_select 'table' - assert_select 'tr>td', text: @notification.sender.to_s, count: 2 - assert_select 'tr>td', text: @notification.subject, count: 2 + it "renders a list of notifications" do + assert_select "table" + assert_select "tr>td", text: @notification.sender.to_s, count: 2 + assert_select "tr>td", text: @notification.subject, count: 2 end it "links to sender's profile" do - assert_select 'a', href: member_path(@notification.sender) + assert_select "a", href: member_path(@notification.sender) end end - context 'no subject' do - it 'shows (no subject)' do + context "no subject" do + it "shows (no subject)" do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member, subject: nil) assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content '(no subject)' + rendered.should have_content "(no subject)" end end - context 'whitespace-only subject' do - it 'shows (no subject)' do + context "whitespace-only subject" do + it "shows (no subject)" do @notification = FactoryBot.create(:notification, - sender: @member, recipient: @member, subject: ' ') + sender: @member, recipient: @member, subject: " ") assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content '(no subject)' + rendered.should have_content "(no subject)" end end end diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 091e13cc1..a7f030f47 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/new' do +describe "notifications/new" do before(:each) do @recipient = FactoryBot.create(:member) @sender = FactoryBot.create(:member) @@ -9,38 +9,38 @@ describe 'notifications/new' do controller.stub(:current_user) { @sender } end - it 'renders new message form' do + it "renders new message form" do render - assert_select 'form', action: notifications_path, method: 'notification' do - assert_select 'input#notification_subject', name: 'notification[subject]' - assert_select 'textarea#notification_body', name: 'notification[body]' + assert_select "form", action: notifications_path, method: "notification" do + assert_select "input#notification_subject", name: "notification[subject]" + assert_select "textarea#notification_body", name: "notification[body]" end end - it 'tells you who the recipient is' do + it "tells you who the recipient is" do render rendered.should have_content @recipient.login_name end - it 'puts the recipient in a hidden field' do + it "puts the recipient in a hidden field" do render - assert_select 'input#notification_recipient_id[type=hidden]', name: 'notification[recipient_id]' + assert_select "input#notification_recipient_id[type=hidden]", name: "notification[recipient_id]" end - it 'fills in the subject if provided' do + it "fills in the subject if provided" do assign(:subject, 'Foo') render - assert_select 'input#notification_subject', value: 'Foo' + assert_select "input#notification_subject", value: "Foo" end - it 'leaves the subject empty if not provided' do + it "leaves the subject empty if not provided" do render - assert_select 'input#notification_subject', value: '' + assert_select "input#notification_subject", value: "" end - it 'Tells you to write your message here' do + it "Tells you to write your message here" do render - rendered.should have_content 'Type your message here' + rendered.should have_content "Type your message here" end it 'shows markdown help' do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 1376f7c18..14db0448c 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/show' do +describe "notifications/show" do before(:each) do @member = FactoryBot.create(:member) @notification = FactoryBot.create(:notification, recipient: @member) @@ -10,16 +10,16 @@ describe 'notifications/show' do render end - it 'renders attributes' do + it "renders attributes" do rendered.should have_content @notification.sender.to_s rendered.should have_content @notification.body.to_s end - it 'includes a delete button' do - assert_select 'a', 'Delete' + it "includes a delete button" do + assert_select "a", "Delete" end - it 'includes a reply button' do - assert_select 'a', { href: @reply_link }, 'Reply' + it "includes a reply button" do + assert_select "a", { href: @reply_link }, "Reply" end end diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 2979e6985..913ea10d2 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'notifier/notify.html.haml', type: 'view' do +describe 'notifier/notify.html.haml', type: "view" do before(:each) do @notification = FactoryBot.create(:notification) - @reply_link = 'http://example.com' - @signed_message = 'EncryptedMessage' + @reply_link = "http://example.com" + @signed_message = "EncryptedMessage" assign(:reply_link, @reply_link) render end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 9660b44fb..c95f204e2 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'orders/index' do +describe "orders/index" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,15 +9,15 @@ describe 'orders/index' do assign(:orders, [@order1, @order2]) end - it 'shows your current account status' do + it "shows your current account status" do render - rendered.should have_content 'Your current account status' + rendered.should have_content "Your current account status" end - it 'renders a list of orders' do + it "renders a list of orders" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td a/@href', text: "/orders/#{@order1.id}" - assert_select 'tr>td a/@href', text: "/orders/#{@order2.id}" + assert_select "tr>td a/@href", text: "/orders/#{@order1.id}" + assert_select "tr>td a/@href", text: "/orders/#{@order2.id}" end end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index 233616b9e..a9f662de9 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'orders/show' do +describe "orders/show" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } end - context 'current order' do + context "current order" do before(:each) do @order = assign(:order, FactoryBot.create(:order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -17,38 +17,38 @@ describe 'orders/show' do render end - it 'displays order number' do - rendered.should have_content 'Order number' + it "displays order number" do + rendered.should have_content "Order number" end - it 'shows order items in a table' do - assert_select 'table>tr>th', text: 'Product' + it "shows order items in a table" do + assert_select "table>tr>th", text: "Product" end - it 'shows the total' do - rendered.should have_content 'Total:' - assert_select 'strong', /198.00/ + it "shows the total" do + rendered.should have_content "Total:" + assert_select "strong", /198.00/ end - it 'shows a foreign exchange link for the total' do + it "shows a foreign exchange link for the total" do currency = Growstuff::Application.config.currency assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") end - it 'asks for a referral code' do + it "asks for a referral code" do assert_select "input[id='referral_code']" end - it 'shows a checkout button' do + it "shows a checkout button" do assert_select "input[value='Checkout with PayPal']" end - it 'shows a delete order button' do - assert_select 'a', text: 'Delete this order' + it "shows a delete order button" do + assert_select "a", text: "Delete this order" end end - context 'completed order' do + context "completed order" do before(:each) do @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -59,11 +59,11 @@ describe 'orders/show' do end it "doesn't show a checkout button" do - assert_select 'a', text: 'Checkout', count: 0 + assert_select "a", text: "Checkout", count: 0 end it "doesn't show delete order button" do - assert_select 'a', text: 'Delete this order', count: 0 + assert_select "a", text: "Delete this order", count: 0 end end end diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index 7376ad759..a52b51a79 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'photos/edit' do +describe "photos/edit" do before(:each) do @photo = assign(:photo, stub_model(Photo, owner_id: 1, flickr_photo_id: 1, - thumbnail_url: 'MyString', - fullsize_url: 'MyString')) + thumbnail_url: "MyString", + fullsize_url: "MyString")) end end diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index b99eb8309..b603de1e6 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/index' do +describe "photos/index" do before(:each) do page = 1 per_page = 2 @@ -14,9 +14,9 @@ describe 'photos/index' do assign(:photos, photos) end - it 'renders a gallery of photos' do + it "renders a gallery of photos" do render - assert_select '.thumbnail', count: 2 - assert_select 'img', count: 2 + assert_select ".thumbnail", count: 2 + assert_select "img", count: 2 end end diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 3ae91e1a3..e4f24f9e4 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/new' do +describe "photos/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -14,27 +14,27 @@ describe 'photos/new' do assign(:flickr_auth, FactoryBot.create(:flickr_authentication, member: @member)) end - context 'user has no photosets' do + context "user has no photosets" do it "doesn't show a dropdown with sets from Flickr" do render - assert_select 'select#set', false + assert_select "select#set", false end end - context 'user has photosets' do + context "user has photosets" do before(:each) do - assign(:sets, 'foo' => 'bar') # Hash of names => IDs + assign(:sets, "foo" => "bar") # Hash of names => IDs end - it 'shows a dropdown with sets from Flickr' do + it "shows a dropdown with sets from Flickr" do render - assert_select 'select#set' + assert_select "select#set" end - it 'shows the current photoset' do - assign(:current_set, 'bar') # the ID of the set + it "shows the current photoset" do + assign(:current_set, "bar") # the ID of the set render - assert_select 'h2', 'foo' # the name of the set + assert_select "h2", "foo" # the name of the set end end end diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index ce60a0b47..cecb0008b 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/show' do +describe "photos/show" do let(:photo) { FactoryBot.create :photo, owner: member } before { @photo = photo } @@ -11,70 +11,70 @@ describe 'photos/show' do let(:seed) { FactoryBot.create :seed, owner: member } let(:garden) { FactoryBot.create :garden, owner: member } - shared_examples 'photo data renders' do - it 'shows the image' do + shared_examples "photo data renders" do + it "shows the image" do assert_select "img[src='#{@photo.fullsize_url}']" end it "links to the owner's profile" do - assert_select 'a', href: @photo.owner + assert_select "a", href: @photo.owner end - it 'shows a link to the original image' do - assert_select 'a', href: @photo.link_url, text: 'View on Flickr' + it "shows a link to the original image" do + assert_select "a", href: @photo.link_url, text: "View on Flickr" end - it 'links to harvest' do - assert_select 'a', href: harvest_path(harvest) + it "links to harvest" do + assert_select "a", href: harvest_path(harvest) end - it 'links to planting' do - assert_select 'a', href: planting_path(planting) + it "links to planting" do + assert_select "a", href: planting_path(planting) end - it 'links to garden' do - assert_select 'a', href: garden_path(garden) + it "links to garden" do + assert_select "a", href: garden_path(garden) end - it 'links to seeds' do - assert_select 'a', href: seed_path(seed) + it "links to seeds" do + assert_select "a", href: seed_path(seed) end end - shared_examples 'No links to change data' do - it 'does not have a delete button' do + shared_examples "No links to change data" do + it "does not have a delete button" do assert_select "a[href='#{photo_path(@photo)}']", false end end - context 'signed in as owner' do + context "signed in as owner" do before(:each) do controller.stub(:current_user) { member } render end - include_examples 'photo data renders' + include_examples "photo data renders" - it 'has a delete button' do + it "has a delete button" do assert_select "a[href='#{photo_path(@photo)}']" end end - context 'signed in as another member' do + context "signed in as another member" do before(:each) do controller.stub(:current_user) { FactoryBot.create :member } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'not signed in' do + context "not signed in" do before(:each) do controller.stub(:current_user) { nil } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'CC-licensed photo' do + context "CC-licensed photo" do before(:each) do controller.stub(:current_user) { nil } # @photo = assign(:photo, FactoryBot.create(:photo, owner: @member)) @@ -84,13 +84,13 @@ describe 'photos/show' do @photo.gardens << garden render end - it 'links to the CC license' do - assert_select 'a', href: @photo.license_url, + it "links to the CC license" do + assert_select "a", href: @photo.license_url, text: @photo.license_name end end - context 'unlicensed photo' do + context "unlicensed photo" do before(:each) do controller.stub(:current_user) { nil } @photo = assign(:photo, FactoryBot.create(:unlicensed_photo)) @@ -98,7 +98,7 @@ describe 'photos/show' do end it "contains the phrase 'All rights reserved'" do - rendered.should have_content 'All rights reserved' + rendered.should have_content "All rights reserved" end end end diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index 62022a303..7082290c8 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'places/_map_attribution.html.haml', type: :view do +describe "places/_map_attribution.html.haml", type: :view do before(:each) do render end - it 'links to OpenStreetMap' do - assert_select 'a', href: 'http://openstreetmap.org', - text: 'OpenStreetMap' + it "links to OpenStreetMap" do + assert_select "a", href: "http://openstreetmap.org", + text: "OpenStreetMap" end - it 'links to the ODbL' do - assert_select 'a', href: 'http://www.openstreetmap.org/copyright', - text: 'ODbL' + it "links to the ODbL" do + assert_select "a", href: "http://www.openstreetmap.org/copyright", + text: "ODbL" end - it 'links to CloudMade' do - assert_select 'a', href: 'http://cloudmade.com', text: 'CloudMade' + it "links to CloudMade" do + assert_select "a", href: "http://cloudmade.com", text: "CloudMade" end end diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 3639719d2..f3a3661ae 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'places/index' do +describe "places/index" do before(:each) do render end - it 'shows a map' do - assert_select 'div#placesmap' + it "shows a map" do + assert_select "div#placesmap" end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 463134684..635d06ab9 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'places/show' do +describe "places/show" do before(:each) do @member = FactoryBot.create(:london_member) @nearby_members = [FactoryBot.create(:member)] @@ -10,15 +10,15 @@ describe 'places/show' do render end - it 'shows the selected place' do + it "shows the selected place" do view.content_for(:title).should match @place end - it 'shows the selected place in the textbox' do - assert_select '#new_place', value: @place + it "shows the selected place in the textbox" do + assert_select "#new_place", value: @place end - it 'shows the names of nearby members' do + it "shows the names of nearby members" do @nearby_members.each do |m| rendered.should have_content m.login_name end diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index 33dab3bc8..683dd6ab0 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/edit' do +describe "plant_parts/edit" do before(:each) do @plant_part = assign(:plant_part, stub_model(PlantPart, - name: 'MyString')) + name: "MyString")) end - it 'renders the edit plant_part form' do + it "renders the edit plant_part form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: plant_parts_path(@plant_part), method: 'post' do - assert_select 'input#plant_part_name', name: 'plant_part[name]' + assert_select "form", action: plant_parts_path(@plant_part), method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index ff1955637..65ecf2d63 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'plant_parts/index' do +describe "plant_parts/index" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) assign(:plant_parts, [@pp]) end - it 'renders a list of plant_parts' do + it "renders a list of plant_parts" do render rendered.should have_content @pp.name - assert_select 'a', href: plant_part_path(@pp) + assert_select "a", href: plant_part_path(@pp) end end diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index 476987a98..b1b3f12ae 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/new' do +describe "plant_parts/new" do before(:each) do assign(:plant_part, stub_model(PlantPart, - name: 'MyString').as_new_record) + name: "MyString").as_new_record) end - it 'renders new plant_part form' do + it "renders new plant_part form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: plant_parts_path, method: 'post' do - assert_select 'input#plant_part_name', name: 'plant_part[name]' + assert_select "form", action: plant_parts_path, method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index a725121fa..b367a723b 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plant_parts/show' do +describe "plant_parts/show" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) @@ -8,11 +8,11 @@ describe 'plant_parts/show' do assign(:plant_part, @pp) end - it 'renders a list of crops harvested for this part' do + it "renders a list of crops harvested for this part" do render @pp.crops.each do |c| rendered.should have_content c.name - assert_select 'a', href: crop_path(c) + assert_select "a", href: crop_path(c) end end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 36e4aaeab..6371311ae 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/_form' do +describe "plantings/_form" do before(:each) do @member = FactoryBot.create(:member) @garden = FactoryBot.create(:garden, owner: @member) @@ -18,7 +18,7 @@ describe 'plantings/_form' do render end - it 'has a free-form text field containing the planting date in ISO format' do + it "has a free-form text field containing the planting date in ISO format" do assert_select "input#planting_planted_at[type='text'][value='2013-03-01']" end end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index 1de078e4a..b83af0028 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/edit' do +describe "plantings/edit" do before(:each) do @member = FactoryBot.create(:member, login_name: 'right', @@ -19,32 +19,32 @@ describe 'plantings/edit' do FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member controller.stub(:current_user) { @member } render end - it 'renders the edit planting form' do - assert_select 'form', action: plantings_path(@planting), method: 'post' do - assert_select 'input#planting_quantity', name: 'planting[quantity]' - assert_select 'textarea#planting_description', name: 'planting[description]' - assert_select 'select#planting_sunniness', name: 'planting[sunniness]' - assert_select 'select#planting_planted_from', name: 'planting[planted_from]' + it "renders the edit planting form" do + assert_select "form", action: plantings_path(@planting), method: "post" do + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select "a[href='#{new_garden_path}']", text: 'Add a garden.' + assert_select "a[href='#{new_garden_path}']", text: "Add a garden." end - it 'chooses the right crop' do - assert_select 'input#crop[value=?]', 'tomato' + it "chooses the right crop" do + assert_select "input#crop[value=?]", "tomato" end - it 'chooses the right garden' do - assert_select 'select#planting_garden_id', + it "chooses the right garden" do + assert_select "select#planting_garden_id", html: /option selected value="#{@garden.id}"/ end end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index eed256f87..a3a713100 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/index' do +describe "plantings/index" do let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -36,27 +36,27 @@ describe 'plantings/index' do render end - it 'renders a list of plantings' do + it "renders a list of plantings" do rendered.should have_content tomato.name rendered.should have_content maize.name rendered.should have_content member.login_name rendered.should have_content garden.name end - it 'displays planting time' do + it "displays planting time" do rendered.should have_content 'January 13, 2013' end - it 'displays finished time' do + it "displays finished time" do rendered.should have_content 'January 20, 2013' end - it 'provides data links' do + it "provides data links" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: plantings_path(format: 'csv') - assert_select 'a', href: plantings_path(format: 'json') - assert_select 'a', href: plantings_path(format: 'rss') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: plantings_path(format: 'csv') + assert_select "a", href: plantings_path(format: 'json') + assert_select "a", href: plantings_path(format: 'rss') end it "displays member's name in title" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index bed19f685..c4a394561 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -15,7 +15,7 @@ describe 'plantings/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent plantings from all members' + rendered.should have_content "Recent plantings from all members" end it 'item title shows owner and location' do @@ -23,7 +23,7 @@ describe 'plantings/index.rss.haml' do end it 'shows formatted content of posts' do - rendered.should have_content 'This is a really good plant.' + rendered.should have_content "This is a really good plant." end it 'shows sunniness' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 46971c706..6667a05ee 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/new' do +describe "plantings/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -17,7 +17,7 @@ describe 'plantings/new' do owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member assign(:planting, Planting.new) @@ -26,24 +26,24 @@ describe 'plantings/new' do render end - it 'renders new planting form' do - assert_select 'form', action: plantings_path, method: 'post' do - assert_select 'select#planting_garden_id', name: 'planting[garden_id]' - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#planting_crop_id', name: 'planting[crop_id]' - assert_select 'input#planting_quantity', name: 'planting[quantity]' - assert_select 'textarea#planting_description', name: 'planting[description]' - assert_select 'select#planting_sunniness', name: 'planting[sunniness]' - assert_select 'select#planting_planted_from', name: 'planting[planted_from]' + it "renders new planting form" do + assert_select "form", action: plantings_path, method: "post" do + assert_select "select#planting_garden_id", name: "planting[garden_id]" + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#planting_crop_id", name: "planting[crop_id]" + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select 'a', href: new_garden_path, text: 'Add a garden.' + assert_select "a", href: new_garden_path, text: "Add a garden." end - it 'selects a garden given in a param' do - assert_select 'select#planting_garden_id', + it "selects a garden given in a param" do + assert_select "select#planting_garden_id", html: /option selected value="#{@garden_z.id}"/ end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 748ceee3d..899724ac7 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/show' do +describe "plantings/show" do let(:crop) { FactoryBot.create(:tomato) } let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -19,7 +19,7 @@ describe 'plantings/show' do context 'sunniness' do let(:planting) { FactoryBot.create(:sunny_planting) } - it 'shows the sunniness' do + it "shows the sunniness" do render rendered.should have_content 'Sun or shade?' rendered.should have_content 'sun' @@ -29,7 +29,7 @@ describe 'plantings/show' do context 'planted from' do let(:planting) { FactoryBot.create(:cutting_planting) } - it 'shows planted_from' do + it "shows planted_from" do render rendered.should have_content 'Planted from:' rendered.should have_content 'cutting' @@ -43,41 +43,41 @@ describe 'plantings/show' do end end - it 'shows photos' do + it "shows photos" do photo = FactoryBot.create(:photo, owner: member) planting.photos << photo render assert_select "img[src='#{photo.thumbnail_url}']" end - it 'shows a link to add photos' do + it "shows a link to add photos" do render - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - context 'no location set' do + context "no location set" do before(:each) do render end - it 'renders the quantity planted' do + it "renders the quantity planted" do rendered.should match(/3/) end - it 'renders the description' do + it "renders the description" do rendered.should match(/This is a/) end - it 'renders markdown in the description' do - assert_select 'em', 'really' + it "renders markdown in the description" do + assert_select "em", "really" end it "doesn't contain a () if no location is set" do - rendered.should_not have_content '()' + rendered.should_not have_content "()" end end - context 'location set' do + context "location set" do before(:each) do planting.owner.update(location: 'Greenwich, UK') render diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 9217d6729..a153995c5 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'posts/_single' do +describe "posts/_single" do def render_post - render partial: 'single', locals: { post: @post } + render partial: "single", locals: { post: @post } end before(:each) do @@ -15,16 +15,16 @@ describe 'posts/_single' do render_post end - it 'contains a permanent link to post' do - assert_select "a[href='#{post_path @post}']", 'Permalink' + it "contains a permanent link to post" do + assert_select "a[href='#{post_path @post}']", "Permalink" end it "doesn't contain a link to new comment" do - assert_select('a', { href: new_comment_path(post_id: @post.id) }, false) + assert_select("a", { href: new_comment_path(post_id: @post.id) }, false) end end - context 'when logged in' do + context "when logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -32,16 +32,16 @@ describe 'posts/_single' do render_post end - it 'contains link to new comment' do - assert_select('a', { href: new_comment_path(post_id: @post.id) }, 'Reply') + it "contains link to new comment" do + assert_select("a", { href: new_comment_path(post_id: @post.id) }, "Reply") end - it 'does not contain an edit link' do + it "does not contain an edit link" do assert_select "a[href='#{edit_post_path(@post)}']", false end end - context 'when logged in as post author' do + context "when logged in as post author" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -50,88 +50,88 @@ describe 'posts/_single' do render_post end - it 'contains an edit link' do - assert_select "a[href='#{edit_post_path(@post)}']", 'Edit' + it "contains an edit link" do + assert_select "a[href='#{edit_post_path(@post)}']", "Edit" end end - context 'when there are no comments' do + context "when there are no comments" do before(:each) do render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '0 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "0 comments" end end - context 'when there is 1 comment' do + context "when there is 1 comment" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '1 comment' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "1 comment" end end - context 'when there are 2 comments' do + context "when there are 2 comments" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) @comment2 = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '2 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "2 comments" end end - context 'when comments should be hidden' do + context "when comments should be hidden" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @comment = FactoryBot.create(:comment, post: @post) - render partial: 'single', locals: { + render partial: "single", locals: { post: @post, hide_comments: true } end - it 'renders no value of comments' do - rendered.should_not have_content '1 comment' + it "renders no value of comments" do + rendered.should_not have_content "1 comment" end - it 'does not contain link to post' do + it "does not contain link to post" do assert_select "a[href='#{post_path @post}']", false end - it 'does not contain link to new comment' do + it "does not contain link to new comment" do assert_select "a[href='#{new_comment_path(post_id: @post.id)}']", false end end - context 'when post has been edited' do + context "when post has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @post = FactoryBot.create(:post, author: @member) - @post.update(body: 'I am updated') + @post.update(body: "I am updated") render_post end - it 'shows edited at' do - rendered.should have_content 'edited at' + it "shows edited at" do + rendered.should have_content "edited at" end - it 'shows the updated time' do + it "shows the updated time" do rendered.should have_content @post.updated_at end end - context 'when comment has been edited' do + context "when comment has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -139,19 +139,19 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(body: "I've been updated") - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'shows edited at time' do - rendered.should have_content 'edited at' + it "shows edited at time" do + rendered.should have_content "edited at" end - it 'shows updated time' do + it "shows updated time" do rendered.should have_content @comment.updated_at end end - context 'when post has not been edited' do + context "when post has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -161,12 +161,12 @@ describe 'posts/_single' do render_post end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@post.updated_at}" end end - context 'when comment has not been edited' do + context "when comment has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -174,10 +174,10 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(updated_at: @comment.created_at) - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@comment.updated_at}" end end diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 6867185c3..48d64a267 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,34 +1,34 @@ require 'rails_helper' -describe 'posts/edit' do +describe "posts/edit" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @post = assign(:post, FactoryBot.create(:post, author: @author)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @author render end - it 'renders the edit post form' do - assert_select 'form', action: posts_path(@post), method: 'post' do - assert_select 'input#post_subject', name: 'post[subject]' - assert_select 'textarea#post_body', name: 'post[body]' + it "renders the edit post form" do + assert_select "form", action: posts_path(@post), method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end it 'no hidden forum field' do - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index ca924a855..eeebac8b6 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index' do +describe "posts/index" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @@ -17,19 +17,19 @@ describe 'posts/index' do render end - it 'renders a list of posts' do - assert_select 'div.post', count: 2 - assert_select 'h3', text: 'A Post'.to_s, count: 2 - assert_select 'div.post-body', - text: 'This is some text.'.to_s, count: 2 + it "renders a list of posts" do + assert_select "div.post", count: 2 + assert_select "h3", text: "A Post".to_s, count: 2 + assert_select "div.post-body", + text: "This is some text.".to_s, count: 2 end - it 'contains two gravatar icons' do - assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 + it "contains two gravatar icons" do + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end - it 'contains RSS feed links for posts and comments' do - assert_select 'a', href: posts_path(format: 'rss') - assert_select 'a', href: comments_path(format: 'rss') + it "contains RSS feed links for posts and comments" do + assert_select "a", href: posts_path(format: 'rss') + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 23fd0a4b8..3d4ec11f2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index.rss.haml', type: 'view' do +describe 'posts/index.rss.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } author = FactoryBot.create(:member) @@ -11,11 +11,11 @@ describe 'posts/index.rss.haml', type: 'view' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent posts from all members' + rendered.should have_content "Recent posts from all members" end it 'shows content of posts' do - rendered.should have_content 'This is some text.' + rendered.should have_content "This is some text." end it 'gives the author in the item title' do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 37e251bea..fa344e55b 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/new' do +describe "posts/new" do before(:each) do @author = FactoryBot.create(:member) assign(:post, FactoryBot.create(:post, author: @author)) @@ -9,22 +9,22 @@ describe 'posts/new' do controller.stub(:current_user) { @author } end - it 'renders new post form' do + it "renders new post form" do render - assert_select 'form', action: posts_path, method: 'post' do - assert_select 'input#post_subject', name: 'post[subject]' - assert_select 'textarea#post_body', name: 'post[body]' + assert_select "form", action: posts_path, method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end it 'no hidden forum field' do render - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do render - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end it "asks what's going on in your garden" do @@ -32,7 +32,7 @@ describe 'posts/new' do rendered.should have_content "What's going on in your food garden?" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, forum: @forum)) diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index e29fb3f1b..ba6921e4e 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/show' do +describe "posts/show" do subject { rendered } let(:author) { FactoryBot.create(:member) } @@ -11,7 +11,7 @@ describe 'posts/show' do describe 'render post' do before { render } - describe 'basic post' do + describe "basic post" do let(:post) { FactoryBot.create(:post, author: author) } # show the name of the member who posted the post @@ -23,17 +23,17 @@ describe 'posts/show' do it { is_expected.not_to have_text('An Update') } end - describe 'should parse markdown into html' do + describe "should parse markdown into html" do let(:post) { FactoryBot.create(:markdown_post, author: author) } - it { assert_select 'strong', 'strong' } + it { assert_select "strong", "strong" } end describe "shouldn't let html through in body" do let(:post) { FactoryBot.create(:post, author: author, body: 'EVIL') } it { is_expected.to have_content('EVIL') } - it { is_expected.not_to have_link('http://evil.com') } + it { is_expected.not_to have_link("http://evil.com") } end describe 'script tag in post body' do let(:post) { FactoryBot.create(:post, author: author, body: "") } @@ -53,7 +53,7 @@ describe 'posts/show' do end end - context 'when there is one comment' do + context "when there is one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } let!(:comment) { FactoryBot.create(:comment, post: post) } @@ -63,10 +63,10 @@ describe 'posts/show' do end it 'shows comment count only 1' do - assert_select 'div.post_comments', false + assert_select "div.post_comments", false end - it 'shows comments' do + it "shows comments" do is_expected.to have_content comment.body end @@ -75,36 +75,36 @@ describe 'posts/show' do end end - context 'when there is more than one comment' do + context "when there is more than one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } before(:each) do - @comment1 = FactoryBot.create(:comment, post: post, body: 'F1rst!!!', + @comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!", created_at: Date.new(2010, 5, 17)) - @comment3 = FactoryBot.create(:comment, post: post, body: 'Th1rd!!!', + @comment3 = FactoryBot.create(:comment, post: post, body: "Th1rd!!!", created_at: Date.new(2012, 5, 17)) - @comment4 = FactoryBot.create(:comment, post: post, body: 'F0urth!!!') - @comment2 = FactoryBot.create(:comment, post: post, body: 'S3c0nd!!1!', + @comment4 = FactoryBot.create(:comment, post: post, body: "F0urth!!!") + @comment2 = FactoryBot.create(:comment, post: post, body: "S3c0nd!!1!", created_at: Date.new(2011, 5, 17)) @comments = post.comments render end - it 'shows the oldest comments first' do + it "shows the oldest comments first" do is_expected.to have_content(/#{@comment1.body}.*#{@comment2.body}.*#{@comment3.body}.*#{@comment4.body}/m) end end - context 'forum post' do + context "forum post" do let(:post) { FactoryBot.create(:forum_post, author: author) } before { render } - it 'shows forum name' do + it "shows forum name" do is_expected.to have_content "in #{post.forum.name}" end end - context 'signed in' do + context "signed in" do let(:post) { FactoryBot.create(:post, author: author) } before(:each) do @@ -114,7 +114,7 @@ describe 'posts/show' do end it 'shows a comment button' do - is_expected.to have_link 'Comment', href: new_comment_path(post_id: post.id) + is_expected.to have_link "Comment", href: new_comment_path(post_id: post.id) end end end diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index f952c6e70..c22c4196f 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -25,6 +25,6 @@ describe 'posts/show.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index 568445d72..3d60c9e95 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'products/edit' do +describe "products/edit" do before(:each) do @product = assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99')) + name: "MyString", + description: "MyString", + min_price: "9.99")) end - it 'renders the edit product form' do + it "renders the edit product form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: products_path(@product), method: 'post' do - assert_select 'input#product_name', name: 'product[name]' - assert_select 'textarea#product_description', name: 'product[description]' - assert_select 'input#product_min_price', name: 'product[min_price]' - assert_select 'input#product_recommended_price', name: 'product[recommended_price]' + assert_select "form", action: products_path(@product), method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" end end end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index c92e2dc02..90e08e2a3 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'products/index' do +describe "products/index" do before(:each) do @product = FactoryBot.create(:product) assign(:products, [@product, @product]) end - it 'renders a list of products' do + it "renders a list of products" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @product.name, count: 2 - assert_select 'tr>td', text: @product.description, count: 2 - assert_select 'tr>td', text: @product.min_price.to_s, count: 2 + assert_select "tr>td", text: @product.name, count: 2 + assert_select "tr>td", text: @product.description, count: 2 + assert_select "tr>td", text: @product.min_price.to_s, count: 2 end end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index f4b596eaf..336c6bac1 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -1,24 +1,24 @@ require 'rails_helper' -describe 'products/new' do +describe "products/new" do before(:each) do assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99').as_new_record) + name: "MyString", + description: "MyString", + min_price: "9.99").as_new_record) end - it 'renders new product form' do + it "renders new product form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: products_path, method: 'post' do - assert_select 'input#product_name', name: 'product[name]' - assert_select 'textarea#product_description', name: 'product[description]' - assert_select 'input#product_min_price', name: 'product[min_price]' - assert_select 'input#product_recommended_price', name: 'product[recommended_price]' - assert_select 'select#product_account_type_id', name: 'product[account_type_id]' - assert_select 'input#product_paid_months', name: 'product[paid_months]' + assert_select "form", action: products_path, method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" + assert_select "select#product_account_type_id", name: "product[account_type_id]" + assert_select "input#product_paid_months", name: "product[paid_months]" end end end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb index 243eae01b..315d9caae 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'products/show' do +describe "products/show" do before(:each) do @product = assign(:product, FactoryBot.create(:product)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @product.name diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index 28a5283f2..a86f67ceb 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/edit' do +describe "roles/edit" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText')) + name: "MyString", + description: "MyText")) end - it 'renders the edit role form' do + it "renders the edit role form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: roles_path(@role), method: 'post' do - assert_select 'input#role_name', name: 'role[name]' - assert_select 'textarea#role_description', name: 'role[description]' + assert_select "form", action: roles_path(@role), method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index 232b750df..e4b28e9ba 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'roles/index' do +describe "roles/index" do before(:each) do controller.stub(:current_user) { nil } assign(:roles, [ stub_model(Role, - name: 'Name', - description: 'MyText'), + name: "Name", + description: "MyText"), stub_model(Role, - name: 'Name', - description: 'MyText') + name: "Name", + description: "MyText") ]) end - it 'renders a list of roles' do + it "renders a list of roles" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: 'Name'.to_s, count: 2 - assert_select 'tr>td', text: 'MyText'.to_s, count: 2 + assert_select "tr>td", text: "Name".to_s, count: 2 + assert_select "tr>td", text: "MyText".to_s, count: 2 end end diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index d11424840..1cdce8c41 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/new' do +describe "roles/new" do before(:each) do assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText').as_new_record) + name: "MyString", + description: "MyText").as_new_record) end - it 'renders new role form' do + it "renders new role form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: roles_path, method: 'post' do - assert_select 'input#role_name', name: 'role[name]' - assert_select 'textarea#role_description', name: 'role[description]' + assert_select "form", action: roles_path, method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 2d3ea832f..56f1cc4fb 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'roles/show' do +describe "roles/show" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'Name', - description: 'MyText')) + name: "Name", + description: "MyText")) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 081e5a548..ecaa2056f 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'scientific_names/edit' do - context 'logged in' do +describe "scientific_names/edit" do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -11,14 +11,14 @@ describe 'scientific_names/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@scientific_name.creator} less than a minute ago." end - it 'renders the edit scientific_name form' do - assert_select 'form', action: scientific_names_path(@scientific_name), method: 'post' do - assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' - assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' + it "renders the edit scientific_name form" do + assert_select "form", action: scientific_names_path(@scientific_name), method: "post" do + assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end end diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 682b7078d..4d63ac9e1 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'scientific_names/index' do +describe "scientific_names/index" do before(:each) do controller.stub(:current_user) { nil } assign(:scientific_names, [ @@ -9,29 +9,29 @@ describe 'scientific_names/index' do ]) end - it 'renders a list of scientific_names' do + it "renders a list of scientific_names" do render - assert_select 'tr>td', text: 'Zea mays'.to_s - assert_select 'tr>td', text: 'Solanum lycopersicum'.to_s + assert_select "tr>td", text: "Zea mays".to_s + assert_select "tr>td", text: "Solanum lycopersicum".to_s end it "doesn't show edit/destroy links" do render - rendered.should_not have_content 'Edit' - rendered.should_not have_content 'Delete' + rendered.should_not have_content "Edit" + rendered.should_not have_content "Delete" end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member controller.stub(:current_user) { @member } end - it 'shows edit/destroy links' do + it "shows edit/destroy links" do render - rendered.should have_content 'Edit' - rendered.should have_content 'Delete' + rendered.should have_content "Edit" + rendered.should have_content "Delete" end end end diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index a7ad30252..0cf5a4205 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'scientific_names/new' do +describe "scientific_names/new" do before(:each) do assign(:scientific_name, FactoryBot.create(:zea_mays)) end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -13,12 +13,12 @@ describe 'scientific_names/new' do render end - it 'renders new scientific_name form' do + it "renders new scientific_name form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: scientific_names_path, method: 'post' do - assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' - assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' + assert_select "form", action: scientific_names_path, method: "post" do + assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end end diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index 85d3be9ba..b728df2b3 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'scientific_names/show' do +describe "scientific_names/show" do before(:each) do controller.stub(:current_user) { nil } @scientific_name = assign(:scientific_name, FactoryBot.create(:zea_mays)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Zea mays/) diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 14e604816..f450d7065 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/edit' do +describe "seeds/edit" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -8,23 +8,23 @@ describe 'seeds/edit' do @seed = FactoryBot.create(:seed, owner: @member) end - it 'renders the edit seed form' do + it "renders the edit seed form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: seeds_path(@seed), method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#seed_crop_id', name: 'seed[crop_id]' - assert_select 'textarea#seed_description', name: 'seed[description]' - assert_select 'input#seed_quantity', name: 'seed[quantity]' - assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' + assert_select "form", action: seeds_path(@seed), method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it "doesn't revert tradable_to to nowhere" do @seed = FactoryBot.create(:tradable_seed, owner: @member) - @seed.tradable_to.should_not eq 'nowhere' + @seed.tradable_to.should_not eq "nowhere" render - assert_select 'option[selected=selected]', text: @seed.tradable_to + assert_select "option[selected=selected]", text: @seed.tradable_to end end diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index bfb6e27c4..4df8e526c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -14,7 +14,7 @@ describe 'seeds/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent seeds from all members' + rendered.should have_content "Recent seeds from all members" end it 'has a useful item title' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index 0270d831c..5c5cf3ae4 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/new' do +describe "seeds/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,21 +9,21 @@ describe 'seeds/new' do assign(:seed, @seed1) end - it 'renders new seed form' do + it "renders new seed form" do render - assert_select 'form', action: seeds_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#seed_crop_id', name: 'seed[crop_id]' - assert_select 'textarea#seed_description', name: 'seed[description]' - assert_select 'input#seed_quantity', name: 'seed[quantity]' - assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' + assert_select "form", action: seeds_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it 'reminds you to set your location' do render rendered.should have_content "Don't forget to set your location." - assert_select 'a', text: 'set your location' + assert_select "a", text: "set your location" end context 'member has location' do @@ -43,7 +43,7 @@ describe 'seeds/new' do it 'links to change location' do render - assert_select 'a', text: 'Change your location.' + assert_select "a", text: "Change your location." end end end diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 854b87e2c..fd2848f97 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/show' do +describe "seeds/show" do before(:each) do controller.stub(:current_user) { nil } @seed = FactoryBot.create(:seed) @@ -8,12 +8,12 @@ describe 'seeds/show' do assign(:photos, @seed.photos.paginate(page: 1)) end - it 'renders attributes in

' do + it "renders attributes in

" do render rendered.should have_content @seed.crop.name end - context 'tradable' do + context "tradable" do before(:each) do @owner = FactoryBot.create(:london_member) assign(:seed, FactoryBot.create(:tradable_seed, @@ -24,12 +24,12 @@ describe 'seeds/show' do controller.stub(:current_user) { @member } end - it 'shows tradable attributes' do + it "shows tradable attributes" do render - rendered.should have_content 'Will trade: locally' + rendered.should have_content "Will trade: locally" end - it 'shows location of seed owner' do + it "shows location of seed owner" do render rendered.should have_content @owner.location assert_select 'a', href: place_path(@owner.location) @@ -45,18 +45,18 @@ describe 'seeds/show' do it 'says "from unspecified location"' do render - rendered.should have_content '(from unspecified location)' + rendered.should have_content "(from unspecified location)" end - it 'links to profile to set location' do + it "links to profile to set location" do render - assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: 'Set Location' + assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: "Set Location" end end - it 'shows button to send message' do + it "shows button to send message" do render - rendered.should have_content 'Request seeds' + rendered.should have_content "Request seeds" end end end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index a23320f44..754f05c09 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'shop/index.html.haml', type: 'view' do +describe 'shop/index.html.haml', type: "view" do before(:each) do @product1 = FactoryBot.create(:product) @product2 = FactoryBot.create(:product_with_recommended_price) @@ -8,7 +8,7 @@ describe 'shop/index.html.haml', type: 'view' do assign(:order_item, OrderItem.new) end - context 'signed in' do + context "signed in" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -16,7 +16,7 @@ describe 'shop/index.html.haml', type: 'view' do end it 'shows products' do - assert_select('h2', text: @product1.name) + assert_select("h2", text: @product1.name) end it 'shows prices in configured currency' do @@ -38,15 +38,15 @@ describe 'shop/index.html.haml', type: 'view' do end it 'displays the order form' do - assert_select 'form', count: 2 + assert_select "form", count: 2 end it 'renders markdown in product descriptions' do - assert_select 'em', text: 'hurrah', count: 2 + assert_select "em", text: 'hurrah', count: 2 end end - context 'is paid' do + context "is paid" do before(:each) do @member = FactoryBot.create(:member) @member.account.account_type = FactoryBot.create(:paid_account_type) @@ -54,29 +54,29 @@ describe 'shop/index.html.haml', type: 'view' do controller.stub(:current_member) { @member } end - it 'recognises the paid member' do + it "recognises the paid member" do @member.paid?.should be(true) end - it 'tells you you have a paid membership' do + it "tells you you have a paid membership" do render - rendered.should have_content 'You currently have a paid' + rendered.should have_content "You currently have a paid" end it "doesn't show shop" do render - assert_select 'form', false + assert_select "form", false end end - context 'signed out' do + context "signed out" do before(:each) do controller.stub(:current_user) { nil } render end - it 'tells you to sign up/sign in' do - rendered.should have_content 'sign in or sign up' + it "tells you to sign up/sign in" do + rendered.should have_content "sign in or sign up" end end end From 65b4c7dbc1db6eee3ea6e761cbd6ec1ebf1403f6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 9 Feb 2018 07:44:48 +1300 Subject: [PATCH 083/101] Revert "Auto corrected by following Style/StringLiterals" This reverts commit ab56a3c6b32f0cabe9ea116f317e4727631adc81. --- Gemfile | 14 +- Guardfile | 6 +- app/controllers/alternate_names_controller.rb | 4 +- app/controllers/application_controller.rb | 14 +- app/controllers/authentications_controller.rb | 4 +- app/controllers/charts/crops_controller.rb | 2 +- app/controllers/crops_controller.rb | 16 +- app/controllers/follows_controller.rb | 2 +- app/controllers/likes_controller.rb | 2 +- app/controllers/members_controller.rb | 4 +- app/controllers/notifications_controller.rb | 4 +- .../omniauth_callbacks_controller.rb | 8 +- app/controllers/order_items_controller.rb | 2 +- app/controllers/orders_controller.rb | 4 +- app/controllers/pages_controller.rb | 2 +- .../photo_associations_controller.rb | 2 +- app/controllers/photos_controller.rb | 6 +- app/controllers/registrations_controller.rb | 6 +- app/controllers/sessions_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +- app/helpers/crops_helper.rb | 2 +- app/helpers/gardens_helper.rb | 10 +- app/helpers/harvests_helper.rb | 2 +- app/helpers/plantings_helper.rb | 8 +- app/helpers/seeds_helper.rb | 4 +- app/mailers/notifier.rb | 8 +- app/models/ability.rb | 2 +- app/models/account.rb | 2 +- app/models/alternate_name.rb | 2 +- app/models/comment.rb | 2 +- app/models/crop.rb | 48 +-- app/models/csv_importer.rb | 2 +- app/models/follow.rb | 4 +- app/models/forum.rb | 2 +- app/models/garden.rb | 10 +- app/models/harvest.rb | 48 +-- app/models/member.rb | 20 +- app/models/notification.rb | 2 +- app/models/order.rb | 12 +- app/models/order_item.rb | 2 +- app/models/planting.rb | 14 +- app/models/scientific_name.rb | 2 +- app/models/seed.rb | 14 +- app/services/crop_search_service.rb | 16 +- config.rb | 10 +- config/application.rb | 8 +- config/environments/test.rb | 20 +- config/initializers/devise.rb | 2 +- config/initializers/geocoder.rb | 4 +- config/initializers/time_formats.rb | 8 +- config/routes.rb | 10 +- config/setup_load_paths.rb | 2 +- .../20120903092956_devise_create_users.rb | 4 +- ...0201053200_add_approval_status_to_crops.rb | 2 +- .../20171105011017_set_prediction_data.rb | 4 +- .../20171129041341_create_photographings.rb | 8 +- db/seeds.rb | 52 +-- lib/actions/oauth_signup_action.rb | 2 +- lib/tasks/growstuff.rake | 108 +++--- lib/tasks/hooks.rake | 2 +- lib/tasks/i18n.rake | 4 +- lib/tasks/testing.rake | 4 +- script/heroku_maintenance.rb | 4 +- spec/controllers/accounts_controller_spec.rb | 2 +- .../admin/orders_controller_spec.rb | 6 +- spec/controllers/admin_controller_spec.rb | 4 +- .../charts/gardens_controller_spec.rb | 4 +- spec/controllers/comments_controller_spec.rb | 50 +-- spec/controllers/crops_controller_spec.rb | 24 +- spec/controllers/forums_controller_spec.rb | 6 +- spec/controllers/gardens_controller_spec.rb | 4 +- spec/controllers/harvests_controller_spec.rb | 84 ++--- spec/controllers/home_controller_spec.rb | 2 +- spec/controllers/likes_controller_spec.rb | 18 +- spec/controllers/member_controller_spec.rb | 24 +- .../notifications_controller_spec.rb | 36 +- .../order_items_controller_spec.rb | 8 +- spec/controllers/orders_controller_spec.rb | 14 +- .../photo_associations_controller_spec.rb | 6 +- spec/controllers/photos_controller_spec.rb | 88 ++--- spec/controllers/places_controller_spec.rb | 14 +- spec/controllers/plantings_controller_spec.rb | 14 +- spec/controllers/posts_controller_spec.rb | 22 +- spec/controllers/products_controller_spec.rb | 2 +- .../registrations_controller_spec.rb | 8 +- spec/controllers/roles_controller_spec.rb | 6 +- .../scientific_names_controller_spec.rb | 4 +- spec/controllers/seeds_controller_spec.rb | 4 +- spec/controllers/shop_controller_spec.rb | 8 +- spec/factories/account_types.rb | 8 +- spec/factories/alternate_names.rb | 4 +- spec/factories/crop.rb | 46 +-- spec/factories/forums.rb | 4 +- spec/factories/garden.rb | 6 +- spec/factories/harvests.rb | 12 +- spec/factories/like.rb | 2 +- spec/factories/member.rb | 2 +- spec/factories/notifications.rb | 4 +- spec/factories/order_items.rb | 2 +- spec/factories/photos.rb | 8 +- spec/factories/plant_parts.rb | 2 +- spec/factories/planting.rb | 2 +- spec/factories/post.rb | 6 +- spec/factories/products.rb | 8 +- spec/factories/roles.rb | 10 +- spec/factories/scientific_name.rb | 6 +- spec/factories/seeds.rb | 8 +- spec/features/admin/account_types_spec.rb | 20 +- spec/features/admin/forums_spec.rb | 26 +- spec/features/admin/products_spec.rb | 12 +- spec/features/cms_spec.rb | 8 +- .../comments/commenting_a_comment_spec.rb | 22 +- spec/features/crops/alternate_name_spec.rb | 48 +-- spec/features/crops/browse_crops_spec.rb | 12 +- spec/features/crops/creating_a_crop_spec.rb | 40 +-- spec/features/crops/crop_detail_page_spec.rb | 100 +++--- spec/features/crops/crop_photos_spec.rb | 24 +- spec/features/crops/crop_search_spec.rb | 20 +- spec/features/crops/crop_wranglers_spec.rb | 32 +- .../crops/crop_wrangling_button_spec.rb | 14 +- spec/features/crops/inflections_spec.rb | 28 +- spec/features/crops/request_new_crop_spec.rb | 40 +-- spec/features/crops/requested_crops_spec.rb | 6 +- spec/features/following_spec.rb | 40 +-- spec/features/footer_spec.rb | 4 +- spec/features/gardens/adding_gardens_spec.rb | 32 +- spec/features/gardens/gardens_index_spec.rb | 28 +- spec/features/gardens_spec.rb | 82 ++--- .../features/harvests/browse_harvests_spec.rb | 8 +- .../harvests/harvesting_a_crop_spec.rb | 84 ++--- spec/features/locale_spec.rb | 8 +- spec/features/member_profile_spec.rb | 108 +++--- spec/features/members/deletion_spec.rb | 72 ++-- spec/features/members_list_spec.rb | 28 +- spec/features/notifications_spec.rb | 18 +- spec/features/photos/new_photo_spec.rb | 26 +- spec/features/photos/show_photo_spec.rb | 20 +- .../features/places/searching_a_place_spec.rb | 44 +-- spec/features/planting_reminder_spec.rb | 34 +- .../plantings/planting_a_crop_spec.rb | 328 +++++++++--------- spec/features/posts/posting_a_post_spec.rb | 24 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/features/scientific_name_spec.rb | 48 +-- spec/features/seeds/adding_seeds_spec.rb | 64 ++-- spec/features/seeds/misc_seeds_spec.rb | 32 +- spec/features/seeds/seed_photos.rb | 10 +- spec/features/shared_examples/append_date.rb | 18 +- spec/features/shared_examples/crop_suggest.rb | 50 +-- spec/features/signin_spec.rb | 26 +- spec/features/signout_spec.rb | 18 +- spec/features/signup_spec.rb | 12 +- spec/features/unsubscribing_spec.rb | 12 +- spec/helpers/application_helper_spec.rb | 6 +- spec/helpers/crops_helper_spec.rb | 12 +- spec/helpers/gardens_helper_spec.rb | 50 +-- spec/helpers/harvests_helper_spec.rb | 4 +- spec/helpers/notifications_helper_spec.rb | 6 +- spec/helpers/plantings_helper_spec.rb | 30 +- spec/helpers/seeds_helper_spec.rb | 14 +- spec/lib/actions/oauth_signup_action_spec.rb | 4 +- .../lib/haml/filters/escaped_markdown_spec.rb | 4 +- .../haml/filters/growstuff_markdown_spec.rb | 24 +- spec/mailers/notifier_spec.rb | 20 +- spec/models/ability_spec.rb | 76 ++-- spec/models/account_spec.rb | 4 +- spec/models/alternate_name_spec.rb | 2 +- spec/models/comment_spec.rb | 14 +- spec/models/crop_spec.rb | 154 ++++---- spec/models/follow_spec.rb | 12 +- spec/models/forum_spec.rb | 6 +- spec/models/garden_spec.rb | 42 +-- spec/models/harvest_spec.rb | 56 +-- spec/models/member_spec.rb | 74 ++-- spec/models/notification_spec.rb | 24 +- spec/models/order_item_spec.rb | 4 +- spec/models/order_spec.rb | 16 +- spec/models/photo_spec.rb | 6 +- spec/models/planting_spec.rb | 26 +- spec/models/post_spec.rb | 56 +-- spec/models/product_spec.rb | 2 +- spec/models/seed_spec.rb | 8 +- spec/rails_helper.rb | 8 +- spec/requests/api/v1/crop_request_spec.rb | 68 ++-- spec/requests/api/v1/gardens_request_spec.rb | 40 +-- spec/requests/api/v1/harvest_request_spec.rb | 68 ++-- spec/requests/api/v1/member_request_spec.rb | 68 ++-- spec/requests/api/v1/photos_request_spec.rb | 64 ++-- .../requests/api/v1/plantings_request_spec.rb | 90 ++--- spec/requests/api/v1/seeds_request_spec.rb | 54 +-- spec/requests/authentications_spec.rb | 4 +- spec/requests/comments_spec.rb | 6 +- spec/requests/forums_spec.rb | 6 +- spec/requests/gardens_spec.rb | 6 +- spec/requests/harvests_spec.rb | 6 +- spec/requests/notifications_spec.rb | 6 +- spec/requests/photos_spec.rb | 6 +- spec/requests/plant_parts_spec.rb | 6 +- spec/requests/plantings_spec.rb | 6 +- spec/requests/post_spec.rb | 6 +- spec/requests/scientific_names_spec.rb | 6 +- spec/requests/seeds_spec.rb | 6 +- spec/routing/account_types_routing_spec.rb | 32 +- spec/routing/authentications_routing_spec.rb | 12 +- spec/routing/comments_routing_spec.rb | 32 +- spec/routing/crops_routing_spec.rb | 32 +- spec/routing/follows_routing_spec.rb | 12 +- spec/routing/forums_routing_spec.rb | 32 +- spec/routing/gardens_routing_spec.rb | 32 +- spec/routing/harvests_routing_spec.rb | 32 +- spec/routing/notifications_routing_spec.rb | 32 +- spec/routing/order_items_routing_spec.rb | 32 +- spec/routing/orders_routing_spec.rb | 32 +- spec/routing/photos_routing_spec.rb | 32 +- spec/routing/plant_parts_routing_spec.rb | 32 +- spec/routing/plantings_routing_spec.rb | 32 +- spec/routing/products_routing_spec.rb | 32 +- spec/routing/roles_routing_spec.rb | 32 +- spec/routing/scientific_names_routing_spec.rb | 32 +- spec/routing/seeds_routing_spec.rb | 32 +- spec/routing/updates_routing_spec.rb | 32 +- spec/spec_helper.rb | 2 +- spec/support/controller_macros.rb | 2 +- spec/support/elasticsearch_helpers.rb | 4 +- spec/support/is_likeable.rb | 4 +- .../account_types/edit.html.haml_spec.rb | 14 +- .../account_types/index.html.haml_spec.rb | 6 +- .../views/account_types/new.html.haml_spec.rb | 14 +- .../account_types/show.html.haml_spec.rb | 6 +- spec/views/accounts/edit.html.haml_spec.rb | 10 +- spec/views/accounts/index.html.haml_spec.rb | 6 +- spec/views/accounts/new.html.haml_spec.rb | 10 +- spec/views/accounts/show.html.haml_spec.rb | 4 +- spec/views/admin/index_spec.rb | 16 +- spec/views/admin/newsletter_spec.rb | 4 +- spec/views/admin/orders/index_spec.rb | 14 +- spec/views/comments/edit.html.haml_spec.rb | 8 +- spec/views/comments/index.html.haml_spec.rb | 8 +- spec/views/comments/index.rss.haml_spec.rb | 4 +- spec/views/comments/new.html.haml_spec.rb | 16 +- spec/views/comments/show.html.haml_spec.rb | 4 +- spec/views/crops/_grown_for.html.haml_spec.rb | 4 +- .../crops/_planting_advice.html.haml_spec.rb | 52 +-- spec/views/crops/_popover.html.haml_spec.rb | 2 +- spec/views/crops/edit.html.haml_spec.rb | 4 +- spec/views/crops/hierarchy.html.haml_spec.rb | 6 +- spec/views/crops/index.html.haml_spec.rb | 28 +- spec/views/crops/index.rss.haml_spec.rb | 2 +- spec/views/crops/new.html.haml_spec.rb | 6 +- spec/views/crops/wrangle.html.haml_spec.rb | 14 +- spec/views/devise/confirmations/new_spec.rb | 6 +- .../mailer/confirmation_instructions_spec.rb | 4 +- .../reset_password_instructions_spec.rb | 8 +- .../devise/mailer/unlock_instructions_spec.rb | 10 +- spec/views/devise/registrations/edit_spec.rb | 34 +- spec/views/devise/registrations/new_spec.rb | 8 +- spec/views/devise/sessions/new_spec.rb | 6 +- spec/views/devise/shared/_links_spec.rb | 12 +- spec/views/devise/unlocks/new_spec.rb | 6 +- spec/views/forums/edit.html.haml_spec.rb | 16 +- spec/views/forums/index.html.haml_spec.rb | 18 +- spec/views/forums/new.html.haml_spec.rb | 12 +- spec/views/forums/show.html.haml_spec.rb | 14 +- spec/views/gardens/edit.html.haml_spec.rb | 20 +- spec/views/gardens/new.html.haml_spec.rb | 18 +- spec/views/gardens/show.html.haml_spec.rb | 14 +- spec/views/harvests/edit.html.haml_spec.rb | 22 +- spec/views/harvests/index.html.haml_spec.rb | 10 +- spec/views/harvests/new.html.haml_spec.rb | 22 +- spec/views/harvests/show.html.haml_spec.rb | 4 +- spec/views/home/_blurb.html.haml_spec.rb | 10 +- spec/views/home/_crops.html.haml_spec.rb | 2 +- spec/views/home/_members.html.haml_spec.rb | 4 +- spec/views/home/_seeds.html.haml_spec.rb | 2 +- spec/views/home/_stats.html.haml_spec.rb | 4 +- spec/views/home/index_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 28 +- spec/views/layouts/_meta_spec.rb | 4 +- spec/views/layouts/application_spec.rb | 4 +- .../views/members/_location.html.haml_spec.rb | 14 +- spec/views/members/index.html.haml_spec.rb | 6 +- spec/views/members/show.rss.haml_spec.rb | 6 +- .../notifications/index.html.haml_spec.rb | 28 +- .../views/notifications/new.html.haml_spec.rb | 28 +- .../notifications/show.html.haml_spec.rb | 12 +- spec/views/notifier/notify.html.haml_spec.rb | 6 +- spec/views/orders/index.html.haml_spec.rb | 12 +- spec/views/orders/show.html.haml_spec.rb | 34 +- spec/views/photos/edit.html.haml_spec.rb | 6 +- spec/views/photos/index.html.haml_spec.rb | 8 +- spec/views/photos/new.html.haml_spec.rb | 20 +- spec/views/photos/show.html.haml_spec.rb | 60 ++-- .../places/_map_attribution.html.haml_spec.rb | 18 +- spec/views/places/index.html.haml_spec.rb | 6 +- spec/views/places/show.html.haml_spec.rb | 10 +- spec/views/plant_parts/edit.html.haml_spec.rb | 10 +- .../views/plant_parts/index.html.haml_spec.rb | 6 +- spec/views/plant_parts/new.html.haml_spec.rb | 10 +- spec/views/plant_parts/show.html.haml_spec.rb | 6 +- spec/views/plantings/_form.html.haml_spec.rb | 4 +- spec/views/plantings/edit.html.haml_spec.rb | 26 +- spec/views/plantings/index.html.haml_spec.rb | 18 +- spec/views/plantings/index.rss.haml_spec.rb | 4 +- spec/views/plantings/new.html.haml_spec.rb | 28 +- spec/views/plantings/show.html.haml_spec.rb | 26 +- spec/views/posts/_single.html.haml_spec.rb | 84 ++--- spec/views/posts/edit.html.haml_spec.rb | 18 +- spec/views/posts/index.html.haml_spec.rb | 22 +- spec/views/posts/index.rss.haml_spec.rb | 6 +- spec/views/posts/new.html.haml_spec.rb | 16 +- spec/views/posts/show.html.haml_spec.rb | 36 +- spec/views/posts/show.rss.haml_spec.rb | 2 +- spec/views/products/edit.html.haml_spec.rb | 20 +- spec/views/products/index.html.haml_spec.rb | 10 +- spec/views/products/new.html.haml_spec.rb | 24 +- spec/views/products/show.html.haml_spec.rb | 4 +- spec/views/roles/edit.html.haml_spec.rb | 14 +- spec/views/roles/index.html.haml_spec.rb | 16 +- spec/views/roles/new.html.haml_spec.rb | 14 +- spec/views/roles/show.html.haml_spec.rb | 8 +- .../scientific_names/edit.html.haml_spec.rb | 14 +- .../scientific_names/index.html.haml_spec.rb | 20 +- .../scientific_names/new.html.haml_spec.rb | 12 +- .../scientific_names/show.html.haml_spec.rb | 4 +- spec/views/seeds/edit.html.haml_spec.rb | 20 +- spec/views/seeds/index.rss.haml_spec.rb | 2 +- spec/views/seeds/new.html.haml_spec.rb | 20 +- spec/views/seeds/show.html.haml_spec.rb | 22 +- spec/views/shop/index_spec.rb | 26 +- 330 files changed, 3121 insertions(+), 3121 deletions(-) diff --git a/Gemfile b/Gemfile index 4e6dc5797..488a3b9ab 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' -gem 'chartkick' +gem "chartkick" # client for Elasticsearch. Elasticsearch is a flexible # and powerful, distributed, real-time search and analytics engine. @@ -87,15 +87,15 @@ gem 'chartkick' # Project does not use semver, so we want to be in sync with the version of # elasticsearch we use # See https://github.com/elastic/elasticsearch-ruby#compatibility -gem 'elasticsearch-api', '~> 2.0.0' -gem 'elasticsearch-model' -gem 'elasticsearch-rails' -gem 'hashie', '>= 3.5.3' +gem "elasticsearch-api", "~> 2.0.0" +gem "elasticsearch-model" +gem "elasticsearch-rails" +gem "hashie", ">= 3.5.3" gem 'rake', '>= 10.0.0' # locale based flash notices for controllers -gem 'responders' +gem "responders" # allows soft delete. Used for members. gem 'acts_as_paranoid', '~> 0.5.0' @@ -125,7 +125,7 @@ group :development do end group :development, :test do - gem 'active_merchant-paypal-bogus-gateway' + gem "active_merchant-paypal-bogus-gateway" gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Guardfile b/Guardfile index dabd4b9d5..4b5f3ccb5 100644 --- a/Guardfile +++ b/Guardfile @@ -3,11 +3,11 @@ guard :rspec, failed_mode: :keep do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } + watch('spec/spec_helper.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } - watch('config/routes.rb') { 'spec/routing' } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } end diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index e06a07b5a..0f1471a8c 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -30,7 +30,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.save redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.' else - render action: 'new' + render action: "new" end end @@ -40,7 +40,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.update(alternate_name_params) redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.' else - render action: 'edit' + render action: "edit" end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b5a0bf32..3e6221d06 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,12 +7,12 @@ class ApplicationController < ActionController::Base before_action :set_locale def store_location - unless request.path.in?(['/members/sign_in', - '/members/sign_up', - '/members/password/new', - '/members/password/edit', - '/members/confirmation', - '/members/sign_out']) || request.xhr? + unless request.path.in?(["/members/sign_in", + "/members/sign_up", + "/members/password/new", + "/members/password/edit", + "/members/confirmation", + "/members/sign_out"]) || request.xhr? store_location_for(:member, request.fullpath) end end @@ -77,6 +77,6 @@ class ApplicationController < ActionController::Base end def expire_homepage - expire_fragment('homepage_stats') + expire_fragment("homepage_stats") end end diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 7c603eb6a..fc18ff4d7 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -22,9 +22,9 @@ class AuthenticationsController < ApplicationController name: name ) - flash[:notice] = 'Authentication successful.' + flash[:notice] = "Authentication successful." else - flash[:notice] = 'Authentication failed.' + flash[:notice] = "Authentication failed." end redirect_to request.env['omniauth.origin'] || edit_member_registration_path end diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 17c774c14..b5fe3d4a7 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -14,7 +14,7 @@ module Charts @crop = Crop.find(params[:crop_id]) render json: Harvest.joins(:plant_part) .where(crop: @crop) - .group('plant_parts.name').count(:id) + .group("plant_parts.name").count(:id) end private diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index e6ff7c7e0..361e28031 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -23,9 +23,9 @@ class CropsController < ApplicationController def wrangle @approval_status = params[:approval_status] @crops = case @approval_status - when 'pending' + when "pending" Crop.pending_approval - when 'rejected' + when "rejected" Crop.rejected else Crop.recent @@ -78,7 +78,7 @@ class CropsController < ApplicationController @crop.creator = current_member else @crop.requester = current_member - @crop.approval_status = 'pending' + @crop.approval_status = "pending" end notify_wranglers if Crop.transaction { @crop.save && save_crop_names } @@ -89,13 +89,13 @@ class CropsController < ApplicationController def update previous_status = @crop.approval_status - @crop.creator = current_member if previous_status == 'pending' + @crop.creator = current_member if previous_status == "pending" if @crop.update(crop_params) recreate_names('alt_name', 'alternate') recreate_names('sci_name', 'scientific') - notifier.deliver_now! if previous_status == 'pending' + notifier.deliver_now! if previous_status == "pending" end respond_with @crop @@ -110,9 +110,9 @@ class CropsController < ApplicationController def notifier case @crop.approval_status - when 'approved' + when "approved" Notifier.crop_request_approved(@crop.requester, @crop) - when 'rejected' + when "rejected" Notifier.crop_request_rejected(@crop.requester, @crop) end end @@ -185,7 +185,7 @@ class CropsController < ApplicationController def crops q = Crop.approved.includes(:scientific_names, plantings: :photos) q = q.popular unless @sort == 'alpha' - q.order('LOWER(crops.name)').includes(:photos).paginate(page: params[:page]) + q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page]) end def requested_crops diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 80341035f..2c4b2daab 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -11,7 +11,7 @@ class FollowsController < ApplicationController flash[:notice] = "Followed #{@follow.followed.login_name}" redirect_to :back else - flash[:error] = 'Already following or error while following.' + flash[:error] = "Already following or error while following." redirect_to :back end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index d5a8506d7..5f7c5dac9 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -26,7 +26,7 @@ class LikesController < ApplicationController { id: like.likeable.id, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, 'like'), + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), url: like_path(like, format: :json) } end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index e435ef08a..c346eb8e3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -49,8 +49,8 @@ class MembersController < ApplicationController end EMAIL_TYPE_STRING = { - send_notification_email: 'direct message notifications', - send_planting_reminder: 'planting reminders' + send_notification_email: "direct message notifications", + send_planting_reminder: "planting reminders" }.freeze def unsubscribe diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 61dbea6dd..7c3c1f322 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -21,7 +21,7 @@ class NotificationsController < ApplicationController def new @notification = Notification.new @recipient = Member.find_by(id: params[:recipient_id]) - @subject = params[:subject] || '' + @subject = params[:subject] || "" end # GET /notifications/1/reply @@ -53,7 +53,7 @@ class NotificationsController < ApplicationController if @notification.save redirect_to notifications_path, notice: 'Message was successfully sent.' else - render action: 'new' + render action: "new" end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index c70da1443..3d642cd3d 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -12,8 +12,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def failure - flash[:alert] = 'Authentication failed.' - redirect_to request.env['omniauth.origin'] || '/' + flash[:alert] = "Authentication failed." + redirect_to request.env['omniauth.origin'] || "/" end private @@ -30,9 +30,9 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) if action.member_created? - raise 'Invalid provider' unless %w(facebook twitter flickr).index(auth['provider'].to_s) + raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s) - session["devise.#{auth['provider']}_data"] = request.env['omniauth.auth'] + session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] sign_in member redirect_to finish_signup_url(member) else diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 9c3e79dae..326cff21f 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -24,7 +24,7 @@ class OrderItemsController < ApplicationController def errors if @order_item.errors.empty? - 'There was a problem with your order.' + "There was a problem with your order." else @order_item.errors.full_messages.to_sentence end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 0929d3948..3bc9fe45c 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -42,7 +42,7 @@ class OrdersController < ApplicationController ) format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } else - format.html { render action: 'show' } + format.html { render action: "show" } end end end @@ -60,7 +60,7 @@ class OrdersController < ApplicationController @order.completed_at = Time.zone.now @order.record_paypal_details(params[:token]) else - flash[:alert] = 'Could not complete your order. Please notify support.' + flash[:alert] = "Could not complete your order. Please notify support." end else flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ec270b2a6..9ffb98af8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def letsencrypt # use your code here, not mine - render text: 'y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU' + render text: "y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" end end diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 35ef97632..126aaf9b3 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -3,7 +3,7 @@ class PhotoAssociationsController < ApplicationController respond_to :json, :html def destroy - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class @photo = Photo.find_by!(id: params[:photo_id], owner: current_member) @item = Photographing.item(item_id, item_class) @item.photos.delete(@photo) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 3757894a8..57b10e5d8 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -75,10 +75,10 @@ class PhotosController < ApplicationController # Item with photos attached def item_to_link_to - raise 'No item id provided' if item_id.nil? - raise 'No item type provided' if item_type.nil? + raise "No item id provided" if item_id.nil? + raise "No item type provided" if item_type.nil? item_class = item_type.capitalize - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class item_class.constantize.find_by!(id: params[:id], owner_id: current_member.id) end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index a83d6b466..72e92b9fd 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,7 +5,7 @@ class RegistrationsController < Devise::RegistrationsController @twitter_auth = current_member.auth('twitter') @flickr_auth = current_member.auth('flickr') @facebook_auth = current_member.auth('facebook') - render 'edit' + render "edit" end # we need this subclassed method so that Devise doesn't force people to @@ -32,7 +32,7 @@ class RegistrationsController < Devise::RegistrationsController sign_in @member, bypass: true redirect_to edit_member_registration_path else - render 'edit' + render "edit" end end @@ -40,7 +40,7 @@ class RegistrationsController < Devise::RegistrationsController if @member.destroy_with_password(params.require(:member)[:current_password]) redirect_to root_path else - render 'edit' + render "edit" end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ee1fddc3c..6106e0c75 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ class SessionsController < Devise::SessionsController def create super do |_resource| if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) - flash[:alert] = 'There are crops waiting to be wrangled.' + flash[:alert] = "There are crops waiting to be wrangled." end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6076d98ef..639d27686 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper currency = Growstuff::Application.config.currency link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" - link_to '(convert)', link, target: '_blank', rel: 'noopener noreferrer' + link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer" end def build_alert_classes(alert_type = :info) @@ -37,7 +37,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier = 'all') + def cache_key_for(klass, identifier = "all") count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" @@ -102,7 +102,7 @@ module ApplicationHelper elsif planting t(".title.planting_#{type}", planting: planting.to_s) else - t('.title.default') + t(".title.default") end end diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index c96ff8fa1..b99d687aa 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -13,7 +13,7 @@ module CropsHelper if total_quantity != 0 "You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop." else - 'You have an unknown quantity of seeds of this crop.' + "You have an unknown quantity of seeds of this crop." end end diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index cfbf90024..a72505558 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,10 +1,10 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - 'no description provided.' + "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') do - link_to 'Read more', garden_path(garden) + link_to "Read more", garden_path(garden) end end end @@ -19,12 +19,12 @@ module GardensHelper def display_garden_plantings(plantings) if plantings.blank? - 'None' + "None" else output = '

    ' plantings.each do |planting| - output += '
  • ' - output += planting.quantity.nil? ? '0 ' : "#{planting.quantity} " + output += "
  • " + output += planting.quantity.nil? ? "0 " : "#{planting.quantity} " output += link_to planting.crop.name, planting.crop output += ", planted on #{planting.planted_at}
  • " end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 6d9430b74..14277817b 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -28,7 +28,7 @@ module HarvestsHelper end def display_harvest_description(harvest) - return 'No description provided.' if harvest.description.nil? + return "No description provided." if harvest.description.nil? harvest.description end end diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index 3e093d1e9..f71dc8158 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -3,18 +3,18 @@ module PlantingsHelper if planting.finished_at.present? planting.finished_at elsif planting.finished - 'Yes (no date specified)' + "Yes (no date specified)" else - '(no date specified)' + "(no date specified)" end end def display_planted_from(planting) - planting.planted_from.present? ? planting.planted_from : 'not specified' + planting.planted_from.present? ? planting.planted_from : "not specified" end def display_planting_quantity(planting) - planting.quantity.present? ? planting.quantity : 'not specified' + planting.quantity.present? ? planting.quantity : "not specified" end def display_planting(planting) diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb index 7a7948dec..f0bc76dd9 100644 --- a/app/helpers/seeds_helper.rb +++ b/app/helpers/seeds_helper.rb @@ -1,9 +1,9 @@ module SeedsHelper def display_seed_description(seed) if seed.description.nil? - 'no description provided.' + "no description provided." else - truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to 'Read more', seed_path(seed) } + truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) } end end end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index f191263bc..6c479f51f 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,11 +1,11 @@ class Notifier < ActionMailer::Base include NotificationsHelper - default from: 'Growstuff ' + default from: "Growstuff " def verifier unless ENV['RAILS_SECRET_TOKEN'] - raise 'RAILS_SECRET_TOKEN environment variable'\ - 'not set - have you created config/application.yml?' + raise "RAILS_SECRET_TOKEN environment variable"\ + "not set - have you created config/application.yml?" end ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN']) @@ -33,7 +33,7 @@ class Notifier < ActionMailer::Base message = { member_id: @member.id, type: :send_planting_reminder } @signed_message = verifier.generate(message) - mail(to: @member.email, subject: 'What have you planted lately?') if @member.send_planting_reminder + mail(to: @member.email, subject: "What have you planted lately?") if @member.send_planting_reminder end def new_crop_request(member, request) diff --git a/app/models/ability.rb b/app/models/ability.rb index e0e99dc30..283bf45cc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -36,7 +36,7 @@ class Ability # nobody should be able to view unapproved crops unless they # are wranglers or admins cannot :read, Crop - can :read, Crop, approval_status: 'approved' + can :read, Crop, approval_status: "approved" # scientific names should only be viewable if associated crop is approved cannot :read, ScientificName can :read, ScientificName do |sn| diff --git a/app/models/account.rb b/app/models/account.rb index cfd4b2979..646e9db78 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -15,7 +15,7 @@ class Account < ActiveRecord::Base def paid_until_string if account_type.is_permanent_paid - 'forever' + "forever" elsif account_type.is_paid paid_until.to_s end diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb index 1e989cbca..aa960e1f4 100644 --- a/app/models/alternate_name.rb +++ b/app/models/alternate_name.rb @@ -1,5 +1,5 @@ class AlternateName < ActiveRecord::Base - after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } + after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/comment.rb b/app/models/comment.rb index 0f11bfb6f..7098e0b46 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ class Comment < ActiveRecord::Base belongs_to :author, class_name: 'Member' belongs_to :post - scope :post_order, -> { reorder('created_at ASC') } # for display on post page + scope :post_order, -> { reorder("created_at ASC") } # for display on post page after_create do recipient = post.author.id diff --git a/app/models/crop.rb b/app/models/crop.rb index 4466e31e7..15787f6f1 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -15,7 +15,7 @@ class Crop < ActiveRecord::Base has_many :photos, through: :plantings has_many :seeds has_many :harvests - has_many :plant_parts, -> { uniq.reorder('plant_parts.name') }, through: :harvests + has_many :plant_parts, -> { uniq.reorder("plant_parts.name") }, through: :harvests belongs_to :creator, class_name: 'Member' belongs_to :requester, class_name: 'Member' belongs_to :parent, class_name: 'Crop' @@ -26,12 +26,12 @@ class Crop < ActiveRecord::Base ## Scopes scope :recent, -> { approved.order(created_at: :desc) } scope :toplevel, -> { approved.where(parent_id: nil) } - scope :popular, -> { approved.reorder('plantings_count desc, lower(name) asc') } + scope :popular, -> { approved.reorder("plantings_count desc, lower(name) asc") } # ok on sqlite and psql, but not on mysql scope :randomized, -> { approved.reorder('random()') } - scope :pending_approval, -> { where(approval_status: 'pending') } - scope :approved, -> { where(approval_status: 'approved') } - scope :rejected, -> { where(approval_status: 'rejected') } + scope :pending_approval, -> { where(approval_status: "pending") } + scope :approved, -> { where(approval_status: "approved") } + scope :rejected, -> { where(approval_status: "rejected") } scope :interesting, -> { approved.has_photos.randomized } scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } @@ -53,17 +53,17 @@ class Crop < ActiveRecord::Base #################################### # Elastic search configuration - if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" include Elasticsearch::Model include Elasticsearch::Model::Callbacks # In order to avoid clashing between different environments, # use Rails.env as a part of index name (eg. development_growstuff) - index_name [Rails.env, 'growstuff'].join('_') + index_name [Rails.env, "growstuff"].join('_') settings index: { number_of_shards: 1 }, analysis: { tokenizer: { gs_edgeNGram_tokenizer: { - type: 'edgeNGram', # edgeNGram: NGram match from the start of a token + type: "edgeNGram", # edgeNGram: NGram match from the start of a token min_gram: 3, max_gram: 10, # token_chars: Elasticsearch will split on characters @@ -73,8 +73,8 @@ class Crop < ActiveRecord::Base }, analyzer: { gs_edgeNGram_analyzer: { - tokenizer: 'gs_edgeNGram_tokenizer', - filter: ['lowercase'] + tokenizer: "gs_edgeNGram_tokenizer", + filter: ["lowercase"] } } } do @@ -104,7 +104,7 @@ class Crop < ActiveRecord::Base # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) - __elasticsearch__.index_document if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" end # End Elasticsearch section @@ -148,10 +148,10 @@ class Crop < ActiveRecord::Base # value: count of how many times it's been used by harvests def popular_plant_parts PlantPart.joins(:harvests) - .where('crop_id = ?', id) - .order('count_harvests_id DESC') - .group('plant_parts.id', 'plant_parts.name') - .count('harvests.id') + .where("crop_id = ?", id) + .order("count_harvests_id DESC") + .group("plant_parts.id", "plant_parts.name") + .count("harvests.id") end def annual? @@ -167,15 +167,15 @@ class Crop < ActiveRecord::Base end def pending? - approval_status == 'pending' + approval_status == "pending" end def approved? - approval_status == 'approved' + approval_status == "approved" end def rejected? - approval_status == 'rejected' + approval_status == "rejected" end def approval_statuses @@ -183,11 +183,11 @@ class Crop < ActiveRecord::Base end def reasons_for_rejection - ['already in database', 'not edible', 'not enough information', 'other'] + ["already in database", "not edible", "not enough information", "other"] end def rejection_explanation - return rejection_notes if reason_for_rejection == 'other' + return rejection_notes if reason_for_rejection == "other" reason_for_rejection end @@ -212,7 +212,7 @@ class Crop < ActiveRecord::Base end def self.case_insensitive_name(name) - where(['lower(crops.name) = :value', { value: name.downcase }]) + where(["lower(crops.name) = :value", { value: name.downcase }]) end private @@ -235,11 +235,11 @@ class Crop < ActiveRecord::Base def must_be_rejected_if_rejected_reasons_present return if rejected? return unless reason_for_rejection.present? || rejection_notes.present? - errors.add(:approval_status, 'must be rejected if a reason for rejection is present') + errors.add(:approval_status, "must be rejected if a reason for rejection is present") end def must_have_meaningful_reason_for_rejection - return unless reason_for_rejection == 'other' && rejection_notes.blank? - errors.add(:rejection_notes, 'must be added if the reason for rejection is "other"') + return unless reason_for_rejection == "other" && rejection_notes.blank? + errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") end end diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index 477ac1a37..2f646b6ab 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -65,6 +65,6 @@ class CsvImporter @cropbot ||= Member.find_by!(login_name: 'cropbot') @cropbot rescue StandardError - raise 'cropbot account not found: run rake db:seed' + raise "cropbot account not found: run rake db:seed" end end diff --git a/app/models/follow.rb b/app/models/follow.rb index b00a50138..557887cb6 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,6 +1,6 @@ class Follow < ActiveRecord::Base - belongs_to :follower, class_name: 'Member' - belongs_to :followed, class_name: 'Member' + belongs_to :follower, class_name: "Member" + belongs_to :followed, class_name: "Member" validates :follower_id, uniqueness: { scope: :followed_id } after_create do diff --git a/app/models/forum.rb b/app/models/forum.rb index 47fea88cc..7cbc0d43d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -4,7 +4,7 @@ class Forum < ActiveRecord::Base friendly_id :name, use: %i(slugged finders) has_many :posts - belongs_to :owner, class_name: 'Member' + belongs_to :owner, class_name: "Member" def to_s name diff --git a/app/models/garden.rb b/app/models/garden.rb index 3f7defffa..0c3378b00 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -35,13 +35,13 @@ class Garden < ActiveRecord::Base allow_nil: true AREA_UNITS_VALUES = { - 'square metres' => 'square metre', - 'square feet' => 'square foot', - 'hectares' => 'hectare', - 'acres' => 'acre' + "square metres" => "square metre", + "square feet" => "square foot", + "hectares" => "hectare", + "acres" => "acre" }.freeze validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values, - message: '%s is not a valid area unit' }, + message: "%s is not a valid area unit" }, allow_nil: true, allow_blank: true diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 9d73ab100..6bb9aa048 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -7,22 +7,22 @@ class Harvest < ActiveRecord::Base # Constants UNITS_VALUES = { - 'individual' => 'individual', - 'bunches' => 'bunch', - 'sprigs' => 'sprig', - 'handfuls' => 'handful', - 'litres' => 'litre', - 'pints' => 'pint', - 'quarts' => 'quart', - 'buckets' => 'bucket', - 'baskets' => 'basket', - 'bushels' => 'bushel' + "individual" => "individual", + "bunches" => "bunch", + "sprigs" => "sprig", + "handfuls" => "handful", + "litres" => "litre", + "pints" => "pint", + "quarts" => "quart", + "buckets" => "bucket", + "baskets" => "basket", + "bushels" => "bushel" }.freeze WEIGHT_UNITS_VALUES = { - 'kg' => 'kg', - 'lb' => 'lb', - 'oz' => 'oz' + "kg" => "kg", + "lb" => "lb", + "oz" => "oz" }.freeze ## @@ -44,18 +44,18 @@ class Harvest < ActiveRecord::Base ## ## Validations validates :crop, approved: true - validates :crop, presence: { message: 'must be present and exist in our database' } - validates :plant_part, presence: { message: 'must be present and exist in our database' } + validates :crop, presence: { message: "must be present and exist in our database" } + validates :plant_part, presence: { message: "must be present and exist in our database" } validates :harvested_at, presence: true validates :quantity, allow_nil: true, numericality: { only_integer: false, greater_than_or_equal_to: 0 } validates :unit, allow_nil: true, allow_blank: true, inclusion: { - in: UNITS_VALUES.values, message: '%s is not a valid unit' + in: UNITS_VALUES.values, message: "%s is not a valid unit" } validates :weight_quantity, allow_nil: true, numericality: { only_integer: false } validates :weight_unit, allow_nil: true, allow_blank: true, inclusion: { - in: WEIGHT_UNITS_VALUES.values, message: '%s is not a valid unit' + in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting validate :owner_must_match_planting @@ -71,7 +71,7 @@ class Harvest < ActiveRecord::Base def set_si_weight return if weight_unit.nil? weight_string = "#{weight_quantity} #{weight_unit}" - self.si_weight = Unit.new(weight_string).convert_to('kg').to_s('%0.3f').delete(' kg').to_f + self.si_weight = Unit.new(weight_string).convert_to("kg").to_s("%0.3f").delete(" kg").to_f end def cleanup_quantities @@ -94,11 +94,11 @@ class Harvest < ActiveRecord::Base def quantity_to_human return number_to_human(quantity.to_s, strip_insignificant_zeros: true) if quantity - '' + "" end def unit_to_human - return '' unless quantity + return "" unless quantity if unit == 'individual' 'individual' elsif quantity == 1 @@ -109,7 +109,7 @@ class Harvest < ActiveRecord::Base end def weight_to_human - return '' unless weight_quantity + return "" unless weight_quantity "weighing #{number_to_human(weight_quantity, strip_insignificant_zeros: true)} #{weight_unit}" end @@ -131,17 +131,17 @@ class Harvest < ActiveRecord::Base def crop_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:planting, 'must be the same crop') unless crop == planting.crop + errors.add(:planting, "must be the same crop") unless crop == planting.crop end def owner_must_match_planting return if planting.blank? # only check if we are linked to a planting - errors.add(:owner, 'of harvest must be the same as planting') unless owner == planting.owner + errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner end def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? - errors.add(:planting, 'cannot be harvested before planting') unless harvested_at > planting.planted_at + errors.add(:planting, "cannot be harvested before planting") unless harvested_at > planting.planted_at end end diff --git a/app/models/member.rb b/app/models/member.rb index 07840383a..9828a005c 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -25,8 +25,8 @@ class Member < ActiveRecord::Base has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy - has_many :follows, class_name: 'Follow', foreign_key: 'follower_id', dependent: :destroy - has_many :inverse_follows, class_name: 'Follow', foreign_key: 'followed_id', dependent: :destroy + has_many :follows, class_name: "Follow", foreign_key: "follower_id", dependent: :destroy + has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id", dependent: :destroy has_many :followed, through: :follows has_many :followers, through: :inverse_follows, source: :follower @@ -38,7 +38,7 @@ class Member < ActiveRecord::Base scope :recently_joined, -> { reorder(confirmed_at: :desc) } scope :wants_newsletter, -> { where(newsletter: true) } scope :interesting, -> { confirmed.located.recently_signed_in.has_plantings } - scope :has_plantings, -> { joins(:plantings).group('members.id') } + scope :has_plantings, -> { joins(:plantings).group("members.id") } # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, @@ -60,13 +60,13 @@ class Member < ActiveRecord::Base validates :tos_agreement, acceptance: { allow_nil: true, accept: true } validates :login_name, length: { - minimum: 2, maximum: 25, message: 'should be between 2 and 25 characters long' + minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long" }, exclusion: { - in: %w(growstuff admin moderator staff nearby), message: 'name is reserved' + in: %w(growstuff admin moderator staff nearby), message: "name is reserved" }, format: { - with: /\A\w+\z/, message: 'may only include letters, numbers, or underscores' + with: /\A\w+\z/, message: "may only include letters, numbers, or underscores" }, uniqueness: { case_sensitive: false @@ -82,7 +82,7 @@ class Member < ActiveRecord::Base # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations - after_create { |member| Garden.create(name: 'Garden', owner_id: member.id) } + after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address @@ -98,7 +98,7 @@ class Member < ActiveRecord::Base end def role?(role_sym) - roles.any? { |r| r.name.gsub(/\s+/, '_').underscore.to_sym == role_sym } + roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end def current_order @@ -179,11 +179,11 @@ class Member < ActiveRecord::Base end def self.login_name_or_email(login) - where(['lower(login_name) = :value OR lower(email) = :value', { value: login.downcase }]) + where(["lower(login_name) = :value OR lower(email) = :value", { value: login.downcase }]) end def self.case_insensitive_login_name(login) - where(['lower(login_name) = :value', { value: login.downcase }]) + where(["lower(login_name) = :value", { value: login.downcase }]) end def self.nearest_to(place) diff --git a/app/models/notification.rb b/app/models/notification.rb index 071dcc2b0..1b09b1e5e 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -16,7 +16,7 @@ class Notification < ActiveRecord::Base end def replace_blank_subject - self.subject = '(no subject)' if subject.nil? || subject =~ /^\s*$/ + self.subject = "(no subject)" if subject.nil? || subject =~ /^\s*$/ end def send_email diff --git a/app/models/order.rb b/app/models/order.rb index 1356df8be..53a309c35 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -8,7 +8,7 @@ class Order < ActiveRecord::Base # Validations validates :referral_code, format: { with: /\A[a-zA-Z0-9 ]*\z/, - message: 'may only include letters and numbers' + message: "may only include letters and numbers" } # @@ -68,19 +68,19 @@ class Order < ActiveRecord::Base def self.search(args = {}) if args[:for] case args[:by] - when 'member' + when "member" member = Member.with_deleted.find_by(login_name: args[:for]) return member.orders if member - when 'order_id' + when "order_id" order = Order.find_by(id: args[:for]) return [order] if order - when 'paypal_token' + when "paypal_token" order = Order.find_by(paypal_express_token: args[:for]) return [order] if order - when 'paypal_payer_id' + when "paypal_payer_id" order = Order.find_by(paypal_express_payer_id: args[:for]) return [order] if order - when 'referral_code' + when "referral_code" # coerce to uppercase return Order.where(referral_code: args[:for].upcase) end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index b693c2cd3..380fbff58 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -3,7 +3,7 @@ class OrderItem < ActiveRecord::Base belongs_to :product validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: 'may only have one item.' } + validates :order_id, uniqueness: { message: "may only have one item." } def price_must_be_greater_than_minimum @product = Product.find(product_id) diff --git a/app/models/planting.rb b/app/models/planting.rb index 165dcfcd3..6fd4aec17 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -30,7 +30,7 @@ class Planting < ActiveRecord::Base scope :one_per_owner, lambda { joins("JOIN members m ON (m.id=plantings.owner_id) LEFT OUTER JOIN plantings p2 - ON (m.id=p2.owner_id AND plantings.id < p2.id)").where('p2 IS NULL') + ON (m.id=p2.owner_id AND plantings.id < p2.id)").where("p2 IS NULL") } ## @@ -41,17 +41,17 @@ class Planting < ActiveRecord::Base ## ## Validations validates :garden, presence: true - validates :crop, presence: true, approved: { message: 'must be present and exist in our database' } + validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validate :finished_must_be_after_planted validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :sunniness, allow_nil: true, allow_blank: true, inclusion: { - in: SUNNINESS_VALUES, message: '%s is not a valid sunniness value' + in: SUNNINESS_VALUES, message: "%s is not a valid sunniness value" } validates :planted_from, allow_nil: true, allow_blank: true, inclusion: { - in: PLANTED_FROM_VALUES, message: '%s is not a valid planting method' + in: PLANTED_FROM_VALUES, message: "%s is not a valid planting method" } def planting_slug @@ -64,7 +64,7 @@ class Planting < ActiveRecord::Base # location = garden owner + garden name, i.e. "Skud's backyard" def location - I18n.t('gardens.location', garden: garden.name, owner: garden.owner.login_name) + I18n.t("gardens.location", garden: garden.name, owner: garden.owner.login_name) end # stringify as "beet in Skud's backyard" or similar @@ -134,10 +134,10 @@ class Planting < ActiveRecord::Base # check that any finished_at date occurs after planted_at def finished_must_be_after_planted return unless planted_at && finished_at # only check if we have both - errors.add(:finished_at, 'must be after the planting date') unless planted_at < finished_at + errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at end def owner_must_match_garden_owner - errors.add(:owner, 'must be the same as garden') unless owner == garden.owner + errors.add(:owner, "must be the same as garden") unless owner == garden.owner end end diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb index b25b06a76..bca467b5b 100644 --- a/app/models/scientific_name.rb +++ b/app/models/scientific_name.rb @@ -1,5 +1,5 @@ class ScientificName < ActiveRecord::Base - after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' } + after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop belongs_to :creator, class_name: 'Member' validates :name, presence: true diff --git a/app/models/seed.rb b/app/models/seed.rb index 525bbf105..7abae922c 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -16,7 +16,7 @@ class Seed < ActiveRecord::Base # # Validations validates :crop, approved: true - validates :crop, presence: { message: 'must be present and exist in our database' } + validates :crop, presence: { message: "must be present and exist in our database" } validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :days_until_maturity_min, allow_nil: true, @@ -24,17 +24,17 @@ class Seed < ActiveRecord::Base validates :days_until_maturity_max, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :tradable_to, allow_nil: false, allow_blank: false, - inclusion: { in: TRADABLE_TO_VALUES, message: 'You may only trade seed nowhere, '\ - 'locally, nationally, or internationally' } + inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\ + "locally, nationally, or internationally" } validates :organic, allow_nil: false, allow_blank: false, - inclusion: { in: ORGANIC_VALUES, message: 'You must say whether the seeds '\ + inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\ "are organic or not, or that you don't know" } validates :gmo, allow_nil: false, allow_blank: false, - inclusion: { in: GMO_VALUES, message: 'You must say whether the seeds are '\ + inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\ "genetically modified or not, or that you don't know" } validates :heirloom, allow_nil: false, allow_blank: false, - inclusion: { in: HEIRLOOM_VALUES, message: 'You must say whether the seeds'\ - 'are heirloom, hybrid, or unknown' } + inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ + "are heirloom, hybrid, or unknown" } # # Delegations diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 82d6933fb..af6085737 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -1,21 +1,21 @@ class CropSearchService # Crop.search(string) def self.search(query) - if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' - search_str = query.nil? ? '' : query.downcase + if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" + search_str = query.nil? ? "" : query.downcase response = Crop.__elasticsearch__.search( # Finds documents which match any field, but uses the _score from # the best field insead of adding up _score from each field. query: { multi_match: { query: search_str.to_s, - analyzer: 'standard', - fields: ['name', - 'scientific_names.scientific_name', - 'alternate_names.name'] + analyzer: "standard", + fields: ["name", + "scientific_names.scientific_name", + "alternate_names.name"] } }, filter: { - term: { approval_status: 'approved' } + term: { approval_status: "approved" } }, size: 50 ) @@ -26,7 +26,7 @@ class CropSearchService # collection, so it matches what we get from elasticsearch and we can # manipulate it in the same ways (eg. deleting elements without deleting # the whole record from the db) - matches = Crop.approved.where('name ILIKE ?', "%#{query}%").to_a + matches = Crop.approved.where("name ILIKE ?", "%#{query}%").to_a # we want to make sure that exact matches come first, even if not # using elasticsearch (eg. in development) diff --git a/config.rb b/config.rb index 89ca5df52..f816551c1 100644 --- a/config.rb +++ b/config.rb @@ -1,11 +1,11 @@ # Require any additional compass plugins here. # rubocop:disable Lint/UselessAssignment # Set this to the root of your project when deployed: -http_path = '/' -css_dir = 'app/assets/stylesheets' -sass_dir = 'app/assets/stylesheets' -javascripts_dir = 'app/assets/javascripts' -images_dir = 'app/assets/images' +http_path = "/" +css_dir = "app/assets/stylesheets" +sass_dir = "app/assets/stylesheets" +javascripts_dir = "app/assets/javascripts" +images_dir = "app/assets/images" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed diff --git a/config/application.rb b/config/application.rb index 36ccf09e5..5280dce7e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -42,10 +42,10 @@ module Growstuff config.i18n.fallbacks = [:en] # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = 'utf-8' + config.encoding = "utf-8" # Configure a default account type - config.default_account_type = 'Free' + config.default_account_type = "Free" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] @@ -84,9 +84,9 @@ module Growstuff # Growstuff-specific configuration variables config.currency = 'AUD' - config.bot_email = 'noreply@growstuff.org' + config.bot_email = "noreply@growstuff.org" config.user_agent = 'Growstuff' - config.user_agent_email = 'info@growstuff.org' + config.user_agent_email = "info@growstuff.org" Gibbon::API.api_key = ENV['GROWSTUFF_MAILCHIMP_APIKEY'] || 'notarealkey' # API key can't be blank or tests fail diff --git a/config/environments/test.rb b/config/environments/test.rb index b3f6b46d5..bf4135f64 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -20,7 +20,7 @@ Growstuff::Application.configure do # Configure static asset server for tests with Cache-Control for performance config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching config.consider_all_requests_local = true @@ -53,7 +53,7 @@ Growstuff::Application.configure do end config.after_initialize do - require 'active_merchant/ext/paypal_bogus_gateway' + require "active_merchant/ext/paypal_bogus_gateway" ActiveMerchant::Billing::Base.mode = :test ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new @@ -63,7 +63,7 @@ end Geocoder.configure(lookup: :test) Geocoder::Lookup::Test.add_stub( - 'Amundsen-Scott Base, Antarctica', [ + "Amundsen-Scott Base, Antarctica", [ { 'latitude' => -90.0, 'longitude' => 0.0 @@ -72,7 +72,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Philippines', [ + "Philippines", [ { 'latitude' => 12.7503486, 'longitude' => 122.7312101, @@ -86,7 +86,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Greenwich, UK', [ + "Greenwich, UK", [ { 'latitude' => 51.483061, 'longitude' => -0.004151 @@ -95,7 +95,7 @@ Geocoder::Lookup::Test.add_stub( ) Geocoder::Lookup::Test.add_stub( - 'Edinburgh', [ + "Edinburgh", [ { 'latitude' => 55.953252, 'longitude' => -3.188267 @@ -104,7 +104,7 @@ Geocoder::Lookup::Test.add_stub( ) # Unknown location -Geocoder::Lookup::Test.add_stub('Tatooine', []) +Geocoder::Lookup::Test.add_stub("Tatooine", []) Capybara.configure do |config| config.always_include_port = true @@ -115,12 +115,12 @@ OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(provider: 'facebook', uid: '123545', info: { - name: 'John Testerson', + name: "John Testerson", nickname: 'JohnnyT', email: 'example.oauth.facebook@example.com', image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, credentials: { - token: 'token', - secret: 'donttell' + token: "token", + secret: "donttell" }) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 40f94b72a..ec28eb983 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -5,7 +5,7 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = 'Growstuff ' + config.mailer_sender = "Growstuff " config.secret_key = ENV['RAILS_SECRET_TOKEN'] diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index a16483e35..afe41f574 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -4,9 +4,9 @@ Geocoder.configure( units: :km, timeout: 10, http_headers: { - 'User-Agent' => + "User-Agent" => "#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}", - 'From' => Growstuff::Application.config.user_agent_email + "From" => Growstuff::Application.config.user_agent_email } ) # This configuration takes precedence over environment/test.rb diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index f6f268bc8..3f3adf454 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1,9 +1,9 @@ Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' -Date::DATE_FORMATS[:default] = '%B %d, %Y' +Date::DATE_FORMATS[:default] = "%B %d, %Y" -Time::DATE_FORMATS[:date] = '%B %d, %Y' -Date::DATE_FORMATS[:date] = '%B %d, %Y' +Time::DATE_FORMATS[:date] = "%B %d, %Y" +Date::DATE_FORMATS[:date] = "%B %d, %Y" -Date::DATE_FORMATS[:ymd] = '%Y-%m-%d' +Date::DATE_FORMATS[:ymd] = "%Y-%m-%d" Time::DATE_FORMATS[:datetime] = '%B %d, %Y at %H:%M' diff --git a/config/routes.rb b/config/routes.rb index f4a22a2c6..f1588fa17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,10 @@ Growstuff::Application.routes.draw do resources :plant_parts devise_for :members, controllers: { - registrations: 'registrations', - passwords: 'passwords', - sessions: 'sessions', - omniauth_callbacks: 'omniauth_callbacks' + registrations: "registrations", + passwords: "passwords", + sessions: "sessions", + omniauth_callbacks: "omniauth_callbacks" } devise_scope :member do get '/members/unsubscribe/:message' => 'members#unsubscribe', as: 'unsubscribe_member' @@ -85,7 +85,7 @@ Growstuff::Application.routes.draw do resources :likes, only: %i(create destroy) - get 'home/index' + get "home/index" root to: 'home#index' get 'auth/:provider/callback' => 'authentications#create' diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index 4f891ff40..c1a0f95fd 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -4,7 +4,7 @@ if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') RVM.use_from_path! File.dirname(File.dirname(__FILE__)) rescue LoadError # RVM is unavailable at this point. - raise 'RVM ruby lib is currently unavailable.' + raise "RVM ruby lib is currently unavailable." end end diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb index 4eac342d8..cf02cbe2a 100644 --- a/db/migrate/20120903092956_devise_create_users.rb +++ b/db/migrate/20120903092956_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable - t.string :email, null: false, default: '' - t.string :encrypted_password, null: false, default: '' + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb index b338f43ef..07b1e0879 100644 --- a/db/migrate/20150201053200_add_approval_status_to_crops.rb +++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb @@ -1,5 +1,5 @@ class AddApprovalStatusToCrops < ActiveRecord::Migration def change - add_column :crops, :approval_status, :string, default: 'approved' + add_column :crops, :approval_status, :string, default: "approved" end end diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb index dce1225aa..149001927 100644 --- a/db/migrate/20171105011017_set_prediction_data.rb +++ b/db/migrate/20171105011017_set_prediction_data.rb @@ -1,8 +1,8 @@ class SetPredictionData < ActiveRecord::Migration def up - say 'Updating all plantings time to first harvest' + say "Updating all plantings time to first harvest" Planting.all.each(&:update_harvest_days) - say 'Updating crop median time to first harvest, and lifespan' + say "Updating crop median time to first harvest, and lifespan" Crop.all.each do |crop| crop.update_lifespan_medians crop.update_harvest_medians diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb index ed099382c..8054ba9cd 100644 --- a/db/migrate/20171129041341_create_photographings.rb +++ b/db/migrate/20171129041341_create_photographings.rb @@ -18,19 +18,19 @@ class CreatePhotographings < ActiveRecord::Migration end def migrate_data - say 'migrating garden photos' + say "migrating garden photos" GardensPhoto.all.each do |g| Photographing.create! photo_id: g.photo_id, photographable_id: g.garden_id, photographable_type: 'Garden' end - say 'migrating planting photos' + say "migrating planting photos" PhotosPlanting.all.each do |p| Photographing.create! photo_id: p.photo_id, photographable_id: p.planting_id, photographable_type: 'Planting' end - say 'migrating harvest photos' + say "migrating harvest photos" HarvestsPhoto.all.each do |h| Photographing.create! photo_id: h.photo_id, photographable_id: h.harvest_id, photographable_type: 'Harvest' end - say 'migrating seed photos' + say "migrating seed photos" PhotosSeed.all.each do |s| Photographing.create! photo_id: s.photo_id, photographable_id: s.seed_id, photographable_type: 'Seed' end diff --git a/db/seeds.rb b/db/seeds.rb index 637467ee3..be885a352 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -23,7 +23,7 @@ def load_data end end - puts 'Done!' + puts "Done!" end def load_crops @@ -34,39 +34,39 @@ def load_crops CsvImporter.new.import_crop(row) end end - puts 'Finished loading crops' + puts "Finished loading crops" end def load_roles - puts 'Creating admin role...' + puts "Creating admin role..." @admin = Role.create(name: 'Admin') - puts 'Creating crop wrangler role...' + puts "Creating crop wrangler role..." @wrangler = Role.create(name: 'Crop Wrangler') end def load_basic_account_types puts "Adding 'free' and 'staff' account types..." AccountType.create!( - name: 'Free', + name: "Free", is_paid: false, is_permanent_paid: false ) AccountType.create!( - name: 'Staff', + name: "Staff", is_paid: true, is_permanent_paid: true ) end def load_test_users # rubocop:disable Metrics/AbcSize - puts 'Loading test users...' + puts "Loading test users..." # Open suburb csv source_path = Rails.root.join('db', 'seeds') begin suburb_file = File.open("#{source_path}/suburbs.csv") rescue StandardError - puts 'Warning: unable to open suburbs.csv' + puts "Warning: unable to open suburbs.csv" end # rake parameter (eg. 'rake db:seed member_size=10') @@ -105,15 +105,15 @@ def load_test_users # rubocop:disable Metrics/AbcSize ) end - puts 'Finished loading test users' + puts "Finished loading test users" end def load_admin_users - puts 'Adding admin and crop wrangler members...' + puts "Adding admin and crop wrangler members..." @admin_user = Member.new( - login_name: 'admin1', - email: 'admin1@example.com', - password: 'password1', + login_name: "admin1", + email: "admin1@example.com", + password: "password1", tos_agreement: true ) @admin_user.skip_confirmation! @@ -121,9 +121,9 @@ def load_admin_users @admin_user.save! @wrangler_user = Member.new( - login_name: 'wrangler1', - email: 'wrangler1@example.com', - password: 'password1', + login_name: "wrangler1", + email: "wrangler1@example.com", + password: "password1", tos_agreement: true ) @wrangler_user.skip_confirmation! @@ -133,7 +133,7 @@ end def create_cropbot @cropbot_user = Member.new( - login_name: 'cropbot', + login_name: "cropbot", email: Growstuff::Application.config.bot_email, password: SecureRandom.urlsafe_base64(64), tos_agreement: true @@ -141,43 +141,43 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: 'Staff') + @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") @cropbot_user.account.save end def load_paid_account_types puts "Adding 'paid' and 'seed' account types..." @paid_account = AccountType.create!( - name: 'Paid', + name: "Paid", is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.create!( - name: 'Seed', + name: "Seed", is_paid: true, is_permanent_paid: true ) end def load_products - puts 'Adding products...' + puts "Adding products..." Product.create!( - name: 'Annual subscription', - description: 'Paid account, 1 year', + name: "Annual subscription", + description: "Paid account, 1 year", min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.create!( - name: 'Seed account', - description: 'Paid account, in perpetuity', + name: "Seed account", + description: "Paid account, in perpetuity", min_price: 15_000, account_type_id: @seed_account.id ) end def load_plant_parts - puts 'Loading plant parts...' + puts "Loading plant parts..." plant_parts = [ 'fruit', 'flower', diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index f3b22c24b..de274dc35 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -14,7 +14,7 @@ class Growstuff::OauthSignupAction m.password = Devise.friendly_token[0, 20] # First, try the nickname or friendly generate from the email - m.login_name = auth.info.nickname || auth.info.email.split('@').first.gsub(/[^A-Za-z]+/, '_').underscore + m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore # Do we have a collision with an existing account? Generate a 20 character long random name # so the user can update it later diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 8b3c670ff..03b2e3d0e 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -1,12 +1,12 @@ namespace :growstuff do - desc 'Add an admin user, by name' + desc "Add an admin user, by name" # usage: rake growstuff:admin_user name=skud task admin_user: :environment do add_role_to_member! ENV['name'], 'admin' end - desc 'Add a crop wrangler user, by name' + desc "Add a crop wrangler user, by name" # usage: rake growstuff:cropwrangler_user name=skud task cropwrangler_user: :environment do @@ -15,7 +15,7 @@ namespace :growstuff do def add_role_to_member!(login_name, role_name) unless login_name && role_name - raise 'Usage: rake growstuff:[rolename] name=[username] '\ + raise "Usage: rake growstuff:[rolename] name=[username] "\ "\n (login name is case-sensitive)\n" end member = Member.find_by!(login_name: login_name) @@ -23,23 +23,23 @@ namespace :growstuff do member.roles << role end - desc 'Upload crops from a CSV file' + desc "Upload crops from a CSV file" # usage: rake growstuff:import_crops file=filename.csv task import_crops: :environment do require 'csv' - @file = ENV['file'] or raise 'Usage: rake growstuff:import_crops file=file.csv' + @file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv" puts "Loading crops from #{@file}..." CSV.foreach(@file) do |row| CsvImporter.new.import_crop(row) end Rails.cache.delete('full_crop_hierarchy') - puts 'Finished loading crops' + puts "Finished loading crops" end - desc 'Send planting reminder email' + desc "Send planting reminder email" # usage: rake growstuff:send_planting_reminder task send_planting_reminder: :environment do @@ -58,7 +58,7 @@ namespace :growstuff do end end - desc 'Depopulate Null Island' + desc "Depopulate Null Island" # this fixes up anyone who has erroneously wound up with a 0,0 lat/long task depopulate_null_island: :environment do Member.find_each do |m| @@ -69,9 +69,9 @@ namespace :growstuff do end end - desc 'One-off tasks needed at various times and kept for posterity' + desc "One-off tasks needed at various times and kept for posterity" namespace :oneoff do - desc 'May 2013: replace any empty notification subjects with (no subject)' + desc "May 2013: replace any empty notification subjects with (no subject)" task empty_subjects: :environment do # this is inefficient as it checks every Notification, but the # site is small and there aren't many of them, so it shouldn't matter @@ -82,81 +82,81 @@ namespace :growstuff do end end - desc 'May 2013: replace any empty garden names with Garden' + desc "May 2013: replace any empty garden names with Garden" task empty_garden_names: :environment do # this is inefficient as it checks every Garden, but the # site is small and there aren't many of them, so it shouldn't matter # for this one-off script. Garden.all.each do |g| if g.name.nil? or g.name =~ /^\s*$/ - g.name = 'Garden' + g.name = "Garden" g.save end end end - desc 'June 2013: create account types and products.' + desc "June 2013: create account types and products." task setup_shop: :environment do - puts 'Adding account types...' + puts "Adding account types..." AccountType.find_or_create_by( - name: 'Free', + name: "Free", is_paid: false, is_permanent_paid: false ) @paid_account = AccountType.find_or_create_by( - name: 'Paid', + name: "Paid", is_paid: true, is_permanent_paid: false ) @seed_account = AccountType.find_or_create_by( - name: 'Seed', + name: "Seed", is_paid: true, is_permanent_paid: true ) @staff_account = AccountType.find_or_create_by( - name: 'Staff', + name: "Staff", is_paid: true, is_permanent_paid: true ) - puts 'Adding products...' + puts "Adding products..." Product.find_or_create_by( - name: 'Annual subscription', - description: 'An annual subscription gives you access '\ - 'to paid account features for one year. Does not auto-renew.', + name: "Annual subscription", + description: "An annual subscription gives you access "\ + "to paid account features for one year. Does not auto-renew.", min_price: 3000, account_type_id: @paid_account.id, paid_months: 12 ) Product.find_or_create_by( - name: 'Seed account', - description: 'A seed account helps Growstuff grow in its '\ - 'early days. It gives you all the features of '\ - 'a paid account, in perpetuity. This account '\ - 'type never expires.', + name: "Seed account", + description: "A seed account helps Growstuff grow in its "\ + "early days. It gives you all the features of "\ + "a paid account, in perpetuity. This account "\ + "type never expires.", min_price: 15_000, account_type_id: @seed_account.id ) - puts 'Giving each member an account record...' + puts "Giving each member an account record..." Member.all.each do |m| Account.create(member_id: m.id) unless m.account end - puts 'Making Skud a staff account...' + puts "Making Skud a staff account..." @skud = Member.find_by(login_name: 'Skud') if @skud @skud.account.account_type = @staff_account @skud.account.save end - puts 'Done setting up shop.' + puts "Done setting up shop." end - desc 'June 2013: replace nil account_types with free accounts' + desc "June 2013: replace nil account_types with free accounts" task nil_account_type: :environment do - free = AccountType.find_by(name: 'Free') - raise 'Free account type not found: run rake growstuff:oneoff:setup_shop'\ + free = AccountType.find_by(name: "Free") + raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ unless free Account.all.each do |a| unless a.account_type @@ -166,7 +166,7 @@ namespace :growstuff do end end - desc 'July 2013: replace nil seed.tradable_to with nowhere' + desc "July 2013: replace nil seed.tradable_to with nowhere" task tradable_to_nowhere: :environment do Seed.all.each do |s| unless s.tradable_to @@ -176,18 +176,18 @@ namespace :growstuff do end end - desc 'August 2013: set up plantings_count cache on crop' + desc "August 2013: set up plantings_count cache on crop" task reset_crop_plantings_count: :environment do Crop.find_each do |c| Crop.reset_counters c.id, :plantings end end - desc 'August 2013: set default creator on existing crops' + desc "August 2013: set default creator on existing crops" task set_default_crop_creator: :environment do - cropbot = Member.find_by(login_name: 'cropbot') - raise 'cropbot not found: create cropbot member on site or run rake db:seed' unless cropbot - cropbot.account.account_type = AccountType.find_by(name: 'Staff') # set this just because it's nice + cropbot = Member.find_by(login_name: "cropbot") + raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot + cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice cropbot.account.save Crop.find_each do |crop| unless crop.creator @@ -203,7 +203,7 @@ namespace :growstuff do end end - desc 'August 2013: set planting owner' + desc "August 2013: set planting owner" task set_planting_owner: :environment do Planting.find_each do |p| p.owner = p.garden.owner @@ -211,14 +211,14 @@ namespace :growstuff do end end - desc 'August 2013: initialize member planting counter' + desc "August 2013: initialize member planting counter" task initialize_member_planting_count: :environment do Member.find_each do |m| Member.reset_counters m.id, :plantings end end - desc 'October 2013: set garden locations to member locations' + desc "October 2013: set garden locations to member locations" task initialize_garden_locations: :environment do Member.located.find_each do |m| m.gardens.each do |g| @@ -231,7 +231,7 @@ namespace :growstuff do end end - desc 'October 2013: import initial plant parts' + desc "October 2013: import initial plant parts" task import_plant_parts: :environment do plant_parts = [ 'fruit', @@ -252,7 +252,7 @@ namespace :growstuff do end end - desc 'July 2014: set planting_count to 0 by default, not nil' + desc "July 2014: set planting_count to 0 by default, not nil" task zero_plantings_count: :environment do Crop.find_each do |c| if c.plantings_count.nil? @@ -262,32 +262,32 @@ namespace :growstuff do end end - desc 'August 2014: fix ping to pint in database' + desc "August 2014: fix ping to pint in database" task ping_to_pint: :environment do Harvest.find_each do |h| - if h.unit == 'ping' - h.unit = 'pint' + if h.unit == "ping" + h.unit = "pint" h.save end end end - desc 'October 2014: remove unused photos' + desc "October 2014: remove unused photos" task remove_unused_photos: :environment do Photo.find_each(&:destroy_if_unused) end - desc 'October 2014: generate crops_posts records for existing posts' + desc "October 2014: generate crops_posts records for existing posts" task generate_crops_posts_records: :environment do Post.find_each(&:save) end - desc 'October 2014: add alternate names for crops' + desc "October 2014: add alternate names for crops" task add_alternate_names: :environment do require 'csv' - file = 'db/seeds/alternate_names_201410.csv' + file = "db/seeds/alternate_names_201410.csv" puts "Loading alternate names from #{file}..." - cropbot = Member.find_by(login_name: 'cropbot') + cropbot = Member.find_by(login_name: "cropbot") CSV.foreach(file) do |row| _crop_id, crop_name, alternate_names = row next if alternate_names.blank? @@ -305,7 +305,7 @@ namespace :growstuff do end end - desc 'January 2015: fill in si_weight column' + desc "January 2015: fill in si_weight column" task populate_si_weight: :environment do Harvest.find_each do |h| h.set_si_weight @@ -313,7 +313,7 @@ namespace :growstuff do end end - desc 'January 2015: build Elasticsearch index' + desc "January 2015: build Elasticsearch index" task elasticsearch_create_index: :environment do Crop.__elasticsearch__.create_index! force: true Crop.import diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake index 07113f935..7543404b2 100644 --- a/lib/tasks/hooks.rake +++ b/lib/tasks/hooks.rake @@ -1,4 +1,4 @@ -desc 'Install git hooks' +desc "Install git hooks" task :hooks do FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', force: true diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index 4ed2ae2ee..04fa8001b 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -1,10 +1,10 @@ namespace :i18n do - desc 'sort all i18n locale keys' + desc "sort all i18n locale keys" task :normalize do `i18n-tasks normalize` end - desc 'translate haml strings into i18 en locale using haml-i18n-extractor' + desc "translate haml strings into i18 en locale using haml-i18n-extractor" task :extractor, [:haml_path] do |_t, args| require 'haml-i18n-extractor' haml_path = args[:haml_path] diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 7ab937e27..1120f6ca9 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -10,13 +10,13 @@ begin rescue LoadError end -desc 'Run static code-quality checks' +desc "Run static code-quality checks" task :static do system('script/check_static') end namespace :spec do - desc 'Run only unit tests' + desc "Run only unit tests" task unit: ['jasmine:ci'] do suites = %w(controllers helpers lib mailers models requests routing views) system('rspec', *suites.collect { |s| "spec/#{s}" }) diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb index 375d03117..d2a20d67a 100755 --- a/script/heroku_maintenance.rb +++ b/script/heroku_maintenance.rb @@ -13,9 +13,9 @@ else end case ARGV[0] -when 'on' +when "on" maintenance_state = true -when 'off' +when "off" maintenance_state = false else abort "usage: #{$PROGRAM_NAME} (on|off)" diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index a63890bf3..2b4222f1d 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -4,7 +4,7 @@ describe AccountsController do login_member(:admin_member) def valid_attributes - { 'paid_until' => Time.now } + { "paid_until" => Time.now } end def create_account diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index 0a23dd88a..fb475b34c 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' describe Admin::OrdersController do login_member(:admin_member) - describe 'GET search' do - it 'assigns @orders' do + describe "GET search" do + it "assigns @orders" do order = FactoryBot.create(:order) get :search, search_by: 'order_id', search_text: order.id assigns(:orders).should eq([order]) end - it 'sets an error message if nothing found' do + it "sets an error message if nothing found" do get :search, search_by: 'order_id', search_text: 'foo' flash[:alert].should have_text "Couldn't find order with" end diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index e123b2b02..9f134bbab 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe AdminController do login_member(:admin_member) - describe 'GET admin/newsletter' do + describe "GET admin/newsletter" do it 'fetches the admin newsletter page' do get :newsletter response.should be_success - response.should render_template('admin/newsletter') + response.should render_template("admin/newsletter") end it 'assigns @members' do diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index 288e652b3..daa50a811 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -5,13 +5,13 @@ describe Charts::GardensController do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context 'when not signed in' do + context "when not signed in" do describe 'GET timeline' do before { get :timeline, garden_id: garden.to_param } it { expect(response).to be_success } end end - context 'when signed in' do + context "when signed in" do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index c705917ce..2d265de5f 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -11,106 +11,106 @@ describe CommentsController do def valid_attributes @post = FactoryBot.create(:post) - { post_id: @post.id, body: 'some text' } + { post_id: @post.id, body: "some text" } end - describe 'GET RSS feed' do + describe "GET RSS feed" do let!(:first_comment) { FactoryBot.create :comment, created_at: 10.days.ago } let!(:last_comment) { FactoryBot.create :comment, created_at: 4.minutes.ago } - describe 'returns an RSS feed' do - before { get :index, format: 'rss' } + describe "returns an RSS feed" do + before { get :index, format: "rss" } it { is_expected.to be_success } - it { is_expected.to render_template('comments/index') } - it { expect(response.content_type).to eq('application/rss+xml') } + it { is_expected.to render_template("comments/index") } + it { expect(response.content_type).to eq("application/rss+xml") } it { expect(assigns(:comments)).to eq([last_comment, first_comment]) } end end - describe 'GET new' do + describe "GET new" do let(:post) { FactoryBot.create(:post) } - describe 'with valid params' do + describe "with valid params" do before { get :new, post_id: post.id } - it 'picks up post from params' do + it "picks up post from params" do assigns(:post).should eq(post) end let(:old_comment) { FactoryBot.create(:comment, post: post) } - it 'assigns the old comments as @comments' do + it "assigns the old comments as @comments" do assigns(:comments).should eq [old_comment] end end - it 'dies if no post specified' do + it "dies if no post specified" do get :new expect(response).not_to be_success end end - describe 'GET edit' do + describe "GET edit" do let(:post) { FactoryBot.create(:post) } before { get :edit, id: comment.to_param } - describe 'my comment' do + describe "my comment" do let!(:comment) { FactoryBot.create :comment, author: member, post: post } let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) } - it 'assigns previous comments as @comments' do + it "assigns previous comments as @comments" do expect(assigns(:comments)).to eq([comment, old_comment]) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment, post: post } it { expect(response).not_to be_success } end end - describe 'PUT update' do + describe "PUT update" do before { put :update, id: comment.to_param, comment: valid_attributes } - describe 'my comment' do + describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } it "redirects to the comment's post" do expect(response).to redirect_to(comment.post) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } end - describe 'attempting to change post_id' do + describe "attempting to change post_id" do let(:post) { FactoryBot.create :post, subject: 'our post' } let(:other_post) { FactoryBot.create :post, subject: 'the other post' } - let(:valid_attributes) { { post_id: other_post.id, body: 'kōrero' } } + let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } } let(:comment) { FactoryBot.create :comment, author: member, post: post } - it 'does not change post_id' do + it "does not change post_id" do comment.reload expect(comment.post_id).to eq(post.id) end end end - describe 'DELETE destroy' do + describe "DELETE destroy" do before { delete :destroy, id: comment.to_param } - describe 'my comment' do + describe "my comment" do let(:comment) { FactoryBot.create :comment, author: member } - it 'redirects to the post the comment was on' do + it "redirects to the post the comment was on" do expect(response).to redirect_to(comment.post) end end - describe 'not my comment' do + describe "not my comment" do let(:comment) { FactoryBot.create :comment } it { expect(response).not_to be_success } diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index ab6aaced4..5b682f6c2 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -5,7 +5,7 @@ describe CropsController do def valid_attributes { - name: 'Tomato', + name: "Tomato", en_wikipedia_url: 'http://en.wikipedia.org/wiki/Tomato', approval_status: 'approved' } @@ -13,37 +13,37 @@ describe CropsController do subject { response } - describe 'GET crop wrangler homepage' do + describe "GET crop wrangler homepage" do describe 'fetches the crop wrangler homepage' do before { get :wrangle } it { is_expected.to be_success } - it { is_expected.to render_template('crops/wrangle') } + it { is_expected.to render_template("crops/wrangle") } it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) } end end - describe 'GET crop hierarchy ' do + describe "GET crop hierarchy " do describe 'fetches the crop hierarchy page' do before { get :hierarchy } it { is_expected.to be_success } - it { is_expected.to render_template('crops/hierarchy') } + it { is_expected.to render_template("crops/hierarchy") } end end - describe 'GET crop search' do + describe "GET crop search" do describe 'fetches the crop search page' do before { get :search } it { is_expected.to be_success } - it { is_expected.to render_template('crops/search') } + it { is_expected.to render_template("crops/search") } end end - describe 'GET RSS feed' do - describe 'returns an RSS feed' do - before { get :index, format: 'rss' } + describe "GET RSS feed" do + describe "returns an RSS feed" do + before { get :index, format: "rss" } it { is_expected.to be_success } - it { is_expected.to render_template('crops/index') } - it { expect(response.content_type).to eq('application/rss+xml') } + it { is_expected.to render_template("crops/index") } + it { expect(response.content_type).to eq("application/rss+xml") } end end end diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index 995c4aabd..5c59473cb 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -5,9 +5,9 @@ describe ForumsController do def valid_attributes { - 'name' => 'MyString', - 'description' => 'Something', - 'owner_id' => 1 + "name" => "MyString", + "description" => "Something", + "owner_id" => 1 } end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 4d4c77d8e..2e31f2d78 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -5,7 +5,7 @@ RSpec.describe GardensController, type: :controller do let(:valid_params) { { name: 'My second Garden' } } let(:garden) { FactoryBot.create :garden } - context 'when not signed in' do + context "when not signed in" do describe 'GET new' do before { get :new, id: garden.to_param } it { expect(response).to redirect_to(new_member_session_path) } @@ -37,7 +37,7 @@ RSpec.describe GardensController, type: :controller do end end end - context 'when signed in' do + context "when signed in" do before(:each) { sign_in member } let!(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 1dbdfe431..705f954b5 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -12,7 +12,7 @@ describe HarvestsController do } end - describe 'GET index' do + describe "GET index" do let(:member1) { FactoryBot.create(:member) } let(:member2) { FactoryBot.create(:member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -20,7 +20,7 @@ describe HarvestsController do let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } - describe 'assigns all harvests as @harvests' do + describe "assigns all harvests as @harvests" do before { get :index, {} } it { assigns(:harvests).should =~ [harvest1, harvest2] } end @@ -31,68 +31,68 @@ describe HarvestsController do it { expect(assigns(:harvests)).to eq [harvest1] } end - describe 'picks up crop from params and shows the harvests for the crop only' do + describe "picks up crop from params and shows the harvests for the crop only" do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:harvests)).to eq [harvest2] } end - describe 'generates a csv' do - before { get :index, format: 'csv' } + describe "generates a csv" do + before { get :index, format: "csv" } it { expect(response.status).to eq 200 } end end - describe 'GET show' do + describe "GET show" do let(:harvest) { Harvest.create! valid_attributes } - describe 'assigns the requested harvest as @harvest' do + describe "assigns the requested harvest as @harvest" do before { get :show, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe 'GET new' do + describe "GET new" do before { get :new, {} } - describe 'assigns a new harvest as @harvest' do + describe "assigns a new harvest as @harvest" do it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - describe 'sets the date of the harvest to today' do + describe "sets the date of the harvest to today" do it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end - describe 'GET edit' do + describe "GET edit" do let(:harvest) { Harvest.create! valid_attributes } - describe 'assigns the requested harvest as @harvest' do + describe "assigns the requested harvest as @harvest" do before { get :edit, id: harvest.to_param } it { expect(assigns(:harvest)).to eq(harvest) } end end - describe 'POST create' do - describe 'with valid params' do - it 'creates a new Harvest' do + describe "POST create" do + describe "with valid params" do + it "creates a new Harvest" do expect do post :create, harvest: valid_attributes end.to change(Harvest, :count).by(1) end - it 'assigns a newly created harvest as @harvest' do + it "assigns a newly created harvest as @harvest" do post :create, harvest: valid_attributes assigns(:harvest).should be_a(Harvest) assigns(:harvest).should be_persisted end - it 'redirects to the created harvest' do + it "redirects to the created harvest" do post :create, harvest: valid_attributes response.should redirect_to(Harvest.last) end - describe 'links to planting' do + describe "links to planting" do let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } @@ -100,26 +100,26 @@ describe HarvestsController do end end - describe 'with invalid params' do - it 'assigns a newly created but unsaved harvest as @harvest' do + describe "with invalid params" do + it "assigns a newly created but unsaved harvest as @harvest" do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - post :create, harvest: { 'crop_id' => 'invalid value' } + post :create, harvest: { "crop_id" => "invalid value" } assigns(:harvest).should be_a_new(Harvest) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted - post :create, harvest: { 'crop_id' => 'invalid value' } - response.should render_template('new') + post :create, harvest: { "crop_id" => "invalid value" } + response.should render_template("new") end end - describe 'not my planting' do + describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe 'does not save planting_id' do + describe "does not save planting_id" do before do allow(Harvest).to receive(:new).and_return(harvest) post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -129,52 +129,52 @@ describe HarvestsController do end end - describe 'PUT update' do - describe 'with valid params' do - it 'updates the requested harvest' do + describe "PUT update" do + describe "with valid params" do + it "updates the requested harvest" do harvest = Harvest.create! valid_attributes # Assuming there are no other harvests in the database, this # specifies that the Harvest created on the previous line # receives the :update message with whatever params are # submitted in the request. - Harvest.any_instance.should_receive(:update).with('crop_id' => '1', "owner_id": member.id) - put :update, id: harvest.to_param, harvest: { 'crop_id' => '1' } + Harvest.any_instance.should_receive(:update).with("crop_id" => "1", "owner_id": member.id) + put :update, id: harvest.to_param, harvest: { "crop_id" => "1" } end - it 'assigns the requested harvest as @harvest' do + it "assigns the requested harvest as @harvest" do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes assigns(:harvest).should eq(harvest) end - it 'redirects to the harvest' do + it "redirects to the harvest" do harvest = Harvest.create! valid_attributes put :update, id: harvest.to_param, harvest: valid_attributes response.should redirect_to(harvest) end end - describe 'with invalid params' do - it 'assigns the harvest as @harvest' do + describe "with invalid params" do + it "assigns the harvest as @harvest" do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } + put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } assigns(:harvest).should eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes - put :update, id: harvest.to_param, harvest: { 'crop_id' => 'invalid value' } - response.should render_template('edit') + put :update, id: harvest.to_param, harvest: { "crop_id" => "invalid value" } + response.should render_template("edit") end end - describe 'not my planting' do + describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - describe 'does not save planting_id' do + describe "does not save planting_id" do before do put :update, id: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) @@ -184,15 +184,15 @@ describe HarvestsController do end end - describe 'DELETE destroy' do - it 'destroys the requested harvest' do + describe "DELETE destroy" do + it "destroys the requested harvest" do harvest = Harvest.create! valid_attributes expect do delete :destroy, id: harvest.to_param end.to change(Harvest, :count).by(-1) end - it 'redirects to the harvests list' do + it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes delete :destroy, id: harvest.to_param response.should redirect_to(harvests_url) diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 44615dbd2..cb12b2bb4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' describe HomeController do - describe 'GET index' do + describe "GET index" do end end diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 6ed93b136..a80fc0d56 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -8,36 +8,36 @@ describe LikesController do before { sign_in member } - describe 'POST create' do - it { expect(response.content_type).to eq 'application/json' } + describe "POST create" do + it { expect(response.content_type).to eq "application/json" } before { post :create, post_id: blogpost.id, format: :json } it { expect(Like.last.likeable_id).to eq(blogpost.id) } it { expect(Like.last.likeable_type).to eq('Post') } - it { JSON.parse(response.body)['description'] == '1 like' } + it { JSON.parse(response.body)["description"] == "1 like" } describe "Liking someone else's post" do it { expect(response.code).to eq('201') } end - describe 'Liking your own post' do + describe "Liking your own post" do let(:blogpost) { FactoryBot.create(:post, author: member) } end end - describe 'DELETE destroy' do + describe "DELETE destroy" do before { delete :destroy, id: like.id, format: :json } - it { expect(response.content_type).to eq 'application/json' } + it { expect(response.content_type).to eq "application/json" } - describe 'un-liking something i liked before' do + describe "un-liking something i liked before" do it { expect(response.code).to eq('200') } - it { JSON.parse(response.body)['description'] == '0 likes' } + it { JSON.parse(response.body)["description"] == "0 likes" } end describe "Deleting someone else's like" do let(:like) { FactoryBot.create :like } it { expect(response.code).to eq('403') } - it { JSON.parse(response.body)['error'] == 'Unable to like' } + it { JSON.parse(response.body)["error"] == "Unable to like" } end end end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 9be56ccfd..14ba85e08 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -8,22 +8,22 @@ describe MembersController do @flickr_auth = FactoryBot.create(:flickr_authentication, member: @member) end - describe 'GET index' do - it 'assigns only confirmed members as @members' do + describe "GET index" do + it "assigns only confirmed members as @members" do get :index, {} assigns(:members).should eq([@member]) end end - describe 'GET JSON index' do - it 'provides JSON for members' do + describe "GET JSON index" do + it "provides JSON for members" do get :index, format: 'json' response.should be_success end end - describe 'GET show' do - it 'provides JSON for member profile' do + describe "GET show" do + it "provides JSON for member profile" do get :show, id: @member.id, format: 'json' response.should be_success end @@ -33,12 +33,12 @@ describe MembersController do assigns(:posts).should eq(@posts) end - it 'assigns @twitter_auth' do + it "assigns @twitter_auth" do get :show, id: @member.id assigns(:twitter_auth).should eq(@twitter_auth) end - it 'assigns @flickr_auth' do + it "assigns @flickr_auth" do get :show, id: @member.id assigns(:flickr_auth).should eq(@flickr_auth) end @@ -54,11 +54,11 @@ describe MembersController do end describe "GET member's RSS feed" do - it 'returns an RSS feed' do - get :show, id: @member.to_param, format: 'rss' + it "returns an RSS feed" do + get :show, id: @member.to_param, format: "rss" response.should be_success - response.should render_template('members/show') - response.content_type.should eq('application/rss+xml') + response.should render_template("members/show") + response.content_type.should eq("application/rss+xml") end end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 8340ac4fb..fd6f40aa1 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -5,9 +5,9 @@ describe NotificationsController do def valid_attributes { - 'recipient_id' => subject.current_member.id, - 'sender_id' => FactoryBot.create(:member).id, - 'subject' => 'test' + "recipient_id" => subject.current_member.id, + "sender_id" => FactoryBot.create(:member).id, + "subject" => 'test' } end @@ -18,9 +18,9 @@ describe NotificationsController do # attributes. def valid_attributes_for_sender { - 'sender_id' => subject.current_member.id, - 'recipient_id' => FactoryBot.create(:member).id, - 'subject' => 'test' + "sender_id" => subject.current_member.id, + "recipient_id" => FactoryBot.create(:member).id, + "subject" => 'test' } end @@ -28,22 +28,22 @@ describe NotificationsController do {} end - describe 'GET index' do - it 'assigns all notifications as @notifications' do + describe "GET index" do + it "assigns all notifications as @notifications" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :index, {} assigns(:notifications).should eq([notification]) end end - describe 'GET show' do - it 'assigns the requested notification as @notification' do + describe "GET show" do + it "assigns the requested notification as @notification" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param assigns(:notification).should eq(notification) end - it 'assigns the reply link for a post comment' do + it "assigns the reply link for a post comment" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param @@ -53,7 +53,7 @@ describe NotificationsController do ) end - it 'marks notifications as read' do + it "marks notifications as read" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :show, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -62,8 +62,8 @@ describe NotificationsController do end end - describe 'GET reply' do - it 'marks notifications as read' do + describe "GET reply" do + it "marks notifications as read" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) get :reply, id: notification.to_param # we need to fetch it from the db again, can't test against the old one @@ -72,16 +72,16 @@ describe NotificationsController do end end - describe 'GET new' do - it 'assigns a recipient' do + describe "GET new" do + it "assigns a recipient" do @recipient = FactoryBot.create(:member) get :new, recipient_id: @recipient.id assigns(:recipient).should be_an_instance_of(Member) end end - describe 'POST create' do - describe 'with valid params' do + describe "POST create" do + describe "with valid params" do it "redirects to the recipient's profile" do @recipient = FactoryBot.create(:member) post :create, notification: { recipient_id: @recipient.id, subject: 'foo' } diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 08203c852..4de8eb98d 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -16,8 +16,8 @@ describe OrderItemsController do context 'signed in' do before { sign_in member } - describe 'POST create' do - describe 'redirects to order' do + describe "POST create" do + describe "redirects to order" do before do post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } end @@ -36,8 +36,8 @@ describe OrderItemsController do end end - describe 'with non-int price' do - it 'converts 3.33 to 333 cents' do + describe "with non-int price" do + it "converts 3.33 to 333 cents" do order = FactoryBot.create(:order, member: member) product = FactoryBot.create(:product, min_price: 1) expect do diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index ef792ab69..3c6631d8c 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -4,14 +4,14 @@ describe OrdersController do login_member(:admin_member) def valid_attributes - { 'member_id' => 1 } + { "member_id" => 1 } end def valid_session {} end - describe 'GET checkout' do + describe "GET checkout" do it 'sets the referral_code' do member = FactoryBot.create(:member) sign_in member @@ -21,7 +21,7 @@ describe OrdersController do order.referral_code.should eq 'FOOBAR' end - it 'redirects to Paypal' do + it "redirects to Paypal" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -31,8 +31,8 @@ describe OrdersController do end end - describe 'GET complete' do - it 'assigns the requested order as @order' do + describe "GET complete" do + it "assigns the requested order as @order" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) @@ -41,8 +41,8 @@ describe OrdersController do end end - describe 'DELETE destroy' do - it 'redirects to the shop' do + describe "DELETE destroy" do + it "redirects to the shop" do member = FactoryBot.create(:member) sign_in member order = Order.create!(member_id: member.id) diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index 30c629576..f021d5aa8 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe PhotoAssociationsController do login_member - describe 'destroy' do + describe "destroy" do let(:valid_params) do { id: harvest.id, @@ -14,11 +14,11 @@ describe PhotoAssociationsController do before { photo.harvests << harvest } - describe 'my harvest my photo' do + describe "my harvest my photo" do let(:harvest) { FactoryBot.create :harvest, owner: member } let(:photo) { FactoryBot.create :photo, owner: member } - it 'removes link' do + it "removes link" do expect { delete :destroy, valid_params }.to change { photo.harvests.count }.by(-1) end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index ce5c71b66..76869ebf3 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -8,13 +8,13 @@ describe PhotosController do def valid_attributes member = FactoryBot.create(:member) { - 'owner_id' => member.id, - 'flickr_photo_id' => 1, - 'title' => 'Photo', - 'license_name' => 'CC-BY', - 'thumbnail_url' => 'http://example.com/thumb.jpg', - 'fullsize_url' => 'http://example.com/full.jpg', - 'link_url' => 'http://example.com' + "owner_id" => member.id, + "flickr_photo_id" => 1, + "title" => "Photo", + "license_name" => "CC-BY", + "thumbnail_url" => 'http://example.com/thumb.jpg', + "fullsize_url" => 'http://example.com/full.jpg', + "link_url" => 'http://example.com' } end @@ -22,7 +22,7 @@ describe PhotosController do {} end - describe 'GET new' do + describe "GET new" do let(:tomato) { FactoryBot.create(:tomato) } let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -33,39 +33,39 @@ describe PhotosController do before(:each) do sign_in member member.stub(:flickr_photos) { [[], 0] } - member.stub(:flickr_sets) { { 'foo' => 'bar' } } + member.stub(:flickr_sets) { { "foo" => "bar" } } controller.stub(:current_member) { member } end - describe 'planting photos' do - before(:each) { get :new, type: 'planting', id: planting.id } + describe "planting photos" do + before(:each) { get :new, type: "planting", id: planting.id } it { assigns(:flickr_auth).should be_an_instance_of(Authentication) } it { assigns(:item).should eq planting } it { expect(flash[:alert]).not_to be_present } it { expect(flash[:alert]).not_to be_present } end - describe 'harvest photos' do - before { get :new, type: 'harvest', id: harvest.id } + describe "harvest photos" do + before { get :new, type: "harvest", id: harvest.id } it { assigns(:item).should eq harvest } it { expect(flash[:alert]).not_to be_present } end - describe 'garden photos' do - before { get :new, type: 'garden', id: garden.id } + describe "garden photos" do + before { get :new, type: "garden", id: garden.id } it { assigns(:item).should eq garden } it { expect(flash[:alert]).not_to be_present } end end - describe 'POST create' do + describe "POST create" do before(:each) do - Photo.any_instance.stub(:flickr_metadata).and_return(title: 'A Heartbreaking work of staggering genius', - license_name: 'CC-BY', - license_url: 'http://example.com/aybpl', - thumbnail_url: 'http://example.com/thumb.jpg', - fullsize_url: 'http://example.com/full.jpg', - link_url: 'http://example.com') + Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", + thumbnail_url: "http://example.com/thumb.jpg", + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com") end let(:member) { FactoryBot.create(:member) } @@ -74,32 +74,32 @@ describe PhotosController do let(:harvest) { FactoryBot.create(:harvest, owner: member) } let(:photo) { FactoryBot.create(:photo, owner: member) } - describe 'with valid params' do + describe "with valid params" do before { controller.stub(:current_member) { member } } - it 'attaches the photo to a planting' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + it "attaches the photo to a planting" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end describe "doesn't attach a photo to a planting twice" do before do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id end it { expect(flash[:alert]).not_to be_present } it { expect(Photo.last.plantings.size).to eq 1 } end - it 'attaches the photo to a harvest' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + it "attaches the photo to a harvest" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end it "doesn't attach a photo to a harvest twice" do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.size.should eq 1 end @@ -107,15 +107,15 @@ describe PhotosController do it "doesn't attach photo to a comment" do comment = FactoryBot.create(:comment) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'comment', id: comment.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id end.to raise_error end end - describe 'for the second time' do + describe "for the second time" do let(:planting) { FactoryBot.create :planting, owner: member } - it 'does not add a photo twice' do + it "does not add a photo twice" do expect do post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' end.to change(Photo, :count).by(1) @@ -125,40 +125,40 @@ describe PhotosController do end end - describe 'with matching owners' do + describe "with matching owners" do before { controller.stub(:current_member) { member } } - it 'creates the planting/photo link' do + it "creates the planting/photo link" do planting = FactoryBot.create(:planting, garden: garden, owner: member) photo = FactoryBot.create(:photo, owner: member) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end - it 'creates the harvest/photo link' do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: harvest.id + it "creates the harvest/photo link" do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end end - describe 'with mismatched owners' do + describe "with mismatched owners" do let(:photo) { FactoryBot.create(:photo) } - it 'does not create the planting/photo link' do + it "does not create the planting/photo link" do # members will be auto-created, and different another_planting = FactoryBot.create(:planting) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'planting', id: another_planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.plantings.first.should_not eq another_planting end - it 'does not create the harvest/photo link' do + it "does not create the harvest/photo link" do # members will be auto-created, and different another_harvest = FactoryBot.create(:harvest) expect do - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: 'harvest', id: another_harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.harvests.first.should_not eq another_harvest end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 761334e43..8b6cb0a31 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -5,27 +5,27 @@ describe PlacesController do controller.stub(:current_member) { nil } end - describe 'GET show' do + describe "GET show" do before(:each) do @member_london = FactoryBot.create(:london_member) @member_south_pole = FactoryBot.create(:south_pole_member) end - it 'assigns place name' do + it "assigns place name" do get :show, place: @member_london.location assigns(:place).should eq @member_london.location end - it 'assigns nearby members' do + it "assigns nearby members" do get :show, place: @member_london.location assigns(:nearby_members).should eq [@member_london, @member_south_pole] end end - describe 'GET search' do - it 'redirects to the new place' do - get :search, new_place: 'foo' - response.should redirect_to place_path('foo') + describe "GET search" do + it "redirects to the new place" do + get :search, new_place: "foo" + response.should redirect_to place_path("foo") end end end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index bdfdfc2bf..abe5ea626 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -10,7 +10,7 @@ describe PlantingsController do } end - describe 'GET index' do + describe "GET index" do let!(:member1) { FactoryBot.create(:member) } let!(:member2) { FactoryBot.create(:member) } let!(:tomato) { FactoryBot.create(:tomato) } @@ -18,7 +18,7 @@ describe PlantingsController do let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - describe 'assigns all plantings as @plantings' do + describe "assigns all plantings as @plantings" do before { get :index, {} } it { expect(assigns(:plantings)).to match [planting1, planting2] } end @@ -29,15 +29,15 @@ describe PlantingsController do it { expect(assigns(:plantings)).to eq [planting1] } end - describe 'picks up crop from params and shows the plantings for the crop only' do + describe "picks up crop from params and shows the plantings for the crop only" do before { get :index, crop: maize.name } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:plantings)).to eq [planting2] } end end - describe 'GET new' do - describe 'picks up crop from params' do + describe "GET new" do + describe "picks up crop from params" do let(:crop) { FactoryBot.create(:crop) } before { get :new, crop_id: crop.id } @@ -85,12 +85,12 @@ describe PlantingsController do it { expect(assigns(:garden)).to be_a_new(Garden) } end - describe 'sets the date of the planting to today' do + describe "sets the date of the planting to today" do before { get :new, {} } it { expect(assigns(:planting).planted_at).to eq Time.zone.today } end - describe 'sets the owner automatically' do + describe "sets the owner automatically" do before { post :create, planting: valid_attributes } it { expect(assigns(:planting).owner).to eq subject.current_member } end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 4c2aadf28..cbfe8b46c 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -5,25 +5,25 @@ describe PostsController do def valid_attributes member = FactoryBot.create(:member) - { author_id: member.id, subject: 'blah', body: 'blah blah' } + { author_id: member.id, subject: "blah", body: "blah blah" } end - describe 'GET RSS feed' do - it 'returns an RSS feed' do - get :index, format: 'rss' + describe "GET RSS feed" do + it "returns an RSS feed" do + get :index, format: "rss" response.should be_success - response.should render_template('posts/index') - response.content_type.should eq('application/rss+xml') + response.should render_template("posts/index") + response.content_type.should eq("application/rss+xml") end end - describe 'GET RSS feed for individual post' do - it 'returns an RSS feed' do + describe "GET RSS feed for individual post" do + it "returns an RSS feed" do post = Post.create! valid_attributes - get :show, format: 'rss', id: post.slug + get :show, format: "rss", id: post.slug response.should be_success - response.should render_template('posts/show') - response.content_type.should eq('application/rss+xml') + response.should render_template("posts/show") + response.content_type.should eq("application/rss+xml") end end end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 4e28e70c3..173ef9ba4 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -5,7 +5,7 @@ describe ProductsController do def valid_attributes { - name: 'product name', + name: "product name", description: 'some description', min_price: 9.99 } diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 210357fa8..015bbb705 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -8,19 +8,19 @@ describe RegistrationsController do controller.stub(:devise_mapping).and_return(Devise.mappings[:member]) end - describe 'GET edit' do - it 'assigns the requested member as @member' do + describe "GET edit" do + it "assigns the requested member as @member" do get :edit assigns(:member).should eq(@member) end - it 'picks up the twitter auth' do + it "picks up the twitter auth" do @auth = FactoryBot.create(:authentication, member: @member) get :edit assigns(:twitter_auth).should eq @auth end - it 'picks up the flickr auth' do + it "picks up the flickr auth" do @auth = FactoryBot.create(:flickr_authentication, member: @member) get :edit assigns(:flickr_auth).should eq @auth diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index 8901c8d61..9bf0ea1b5 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -2,13 +2,13 @@ require 'rails_helper' describe RolesController do def valid_attributes - { 'name' => 'MyString' } + { "name" => "MyString" } end login_member(:admin_member) - describe 'GET index' do - it 'assigns all roles as @roles' do + describe "GET index" do + it "assigns all roles as @roles" do role = Role.create! valid_attributes get :index, {} # note that admin role exists because of login_admin_member diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index bd2da752c..412f53224 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -11,8 +11,8 @@ describe ScientificNamesController do { name: 'Solanum lycopersicum', crop_id: @crop.id } end - describe 'GET new' do - it 'assigns crop if specified' do + describe "GET new" do + it "assigns crop if specified" do get :new, crop_id: 1 assigns(:crop).should be_an_instance_of Crop end diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 4c73a1d49..c2fd699eb 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe SeedsController do - describe 'GET index' do - it 'picks up owner from params' do + describe "GET index" do + it "picks up owner from params" do owner = FactoryBot.create(:member) get :index, owner: owner.slug assigns(:owner).should eq(owner) diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 0b5931ec9..2fc6b77f7 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -4,15 +4,15 @@ describe ShopController do let!(:product1) { FactoryBot.create(:product, name: 'aaa') } let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - describe 'GET index' do + describe "GET index" do describe 'not logged in' do before { get :index, {} } - describe 'assigns all products as @products ordered by name' do + describe "assigns all products as @products ordered by name" do it { expect(assigns(:products)).to eq([product1, product2]) } end - describe 'assigns a new @order_item to build forms' do + describe "assigns a new @order_item to build forms" do it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } end @@ -21,7 +21,7 @@ describe ShopController do end end describe 'logged in' do - describe 'assigns @order as current_order if there is one' do + describe "assigns @order as current_order if there is one" do let(:member) { FactoryBot.create(:member) } let!(:order) { FactoryBot.create(:order, member: member) } diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb index ccd8aa0c6..66717492f 100644 --- a/spec/factories/account_types.rb +++ b/spec/factories/account_types.rb @@ -7,25 +7,25 @@ FactoryBot.define do is_permanent_paid false factory :free_account_type do - name 'Free' + name "Free" is_paid false is_permanent_paid false end factory :paid_account_type do - name 'Paid' + name "Paid" is_paid true is_permanent_paid false end factory :permanent_paid_account_type do - name 'Permanent paid' + name "Permanent paid" is_paid true is_permanent_paid true end factory :staff_account_type do - name 'Staff' + name "Staff" is_paid true is_permanent_paid true end diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb index 95db4a7c2..32c609cc3 100644 --- a/spec/factories/alternate_names.rb +++ b/spec/factories/alternate_names.rb @@ -2,13 +2,13 @@ FactoryBot.define do factory :alternate_name do - name 'alternate name' + name "alternate name" crop creator factory :alternate_eggplant do association :crop, factory: :eggplant - name 'aubergine' + name "aubergine" end end end diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index 221023fd2..2a8c6b656 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :crop do - name 'magic bean' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Magic_bean' - approval_status 'approved' + name "magic bean" + en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean" + approval_status "approved" creator factory :annual_crop, parent: :crop do @@ -13,71 +13,71 @@ FactoryBot.define do end factory :tomato do - name 'tomato' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Tomato' + name "tomato" + en_wikipedia_url "http://en.wikipedia.org/wiki/Tomato" end factory :maize do - name 'maize' - en_wikipedia_url 'http://en.wikipedia.org/wiki/Maize' + name "maize" + en_wikipedia_url "http://en.wikipedia.org/wiki/Maize" end factory :chard do - name 'chard' + name "chard" end factory :walnut do - name 'walnut' + name "walnut" end factory :apple do - name 'apple' + name "apple" end factory :pear do - name 'pear' + name "pear" end # for testing varieties factory :roma do - name 'roma tomato' + name "roma tomato" end factory :popcorn do - name 'popcorn' + name "popcorn" end factory :eggplant do - name 'eggplant' + name "eggplant" end # This should have a name that is alphabetically earlier than :uppercase # crop to ensure that the ordering tests work. factory :lowercasecrop do - name 'ffrench bean' + name "ffrench bean" end factory :uppercasecrop do - name 'Swiss chard' + name "Swiss chard" end factory :autoloaded_crop do - creator 'cropbot' + creator "cropbot" end # for testing crop request factory :crop_request do - name 'Ultra berry' - en_wikipedia_url '' - approval_status 'pending' + name "Ultra berry" + en_wikipedia_url "" + approval_status "pending" association :requester, factory: :member request_notes "Please approve this even though it's fake." end factory :rejected_crop do - name 'Fail bean' - approval_status 'rejected' - reason_for_rejection 'Totally fake' + name "Fail bean" + approval_status "rejected" + reason_for_rejection "Totally fake" end end end diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb index 7c3828604..5636981fb 100644 --- a/spec/factories/forums.rb +++ b/spec/factories/forums.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :forum do - name 'Permaculture' - description '*Everything* about permaculture!' + name "Permaculture" + description "*Everything* about permaculture!" owner end end diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb index 3dfa11ac5..1f3d7461d 100644 --- a/spec/factories/garden.rb +++ b/spec/factories/garden.rb @@ -1,12 +1,12 @@ FactoryBot.define do factory :garden do name 'Springfield Community Garden' - description 'This is a **totally** cool garden' + description "This is a **totally** cool garden" owner active true area 23 - area_unit 'acre' - location 'Greenwich, UK' + area_unit "acre" + location "Greenwich, UK" factory :inactive_garden do active false diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index ce41589c1..ae3144a1e 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -7,11 +7,11 @@ FactoryBot.define do planting nil owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at { Time.zone.local(2015, 9, 17) } - quantity '3' - unit 'individual' + quantity "3" + unit "individual" weight_quantity 6 - weight_unit 'kg' - description 'A lovely harvest' + weight_unit "kg" + description "A lovely harvest" factory :harvest_with_planting do planting @@ -19,10 +19,10 @@ FactoryBot.define do end trait :long_description do - description 'This is a very long description that is so very long that it will need to be cut off' + description "This is a very long description that is so very long that it will need to be cut off" end trait :no_description do - description '' + description "" end end diff --git a/spec/factories/like.rb b/spec/factories/like.rb index 43500ddbe..bf19554bb 100644 --- a/spec/factories/like.rb +++ b/spec/factories/like.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :like do member - association :likeable, factory: 'post' + association :likeable, factory: "post" end end diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 2f9373b82..016b12263 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -77,7 +77,7 @@ FactoryBot.define do end factory :invalid_member_spaces do - login_name 'a b' + login_name "a b" end factory :invalid_member_badchars do diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 215fb83ab..b893fcc1b 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -4,8 +4,8 @@ FactoryBot.define do factory :notification, aliases: [:message] do sender recipient - subject 'MyString' - body 'MyText' + subject "MyString" + body "MyText" read false post diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb index b4089f4b1..5dfba00ab 100644 --- a/spec/factories/order_items.rb +++ b/spec/factories/order_items.rb @@ -4,7 +4,7 @@ FactoryBot.define do factory :order_item do order product - price '999' + price "999" quantity 42 end end diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index 305121c30..455d721c7 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -5,15 +5,15 @@ FactoryBot.define do owner flickr_photo_id 1 title { Faker::HarryPotter.quote } - license_name 'CC-BY' - license_url 'http://example.com/license.html' + license_name "CC-BY" + license_url "http://example.com/license.html" thumbnail_url { "http://example.com/#{Faker::File.file_name}.jpg" } fullsize_url { "http://example.com/#{Faker::File.file_name}.jpg" } link_url { Faker::Internet.url } factory :unlicensed_photo do - license_name 'All rights reserved' - license_url '' + license_name "All rights reserved" + license_url "" end end end diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb index ad0576129..695bf7542 100644 --- a/spec/factories/plant_parts.rb +++ b/spec/factories/plant_parts.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :plant_part do - name 'pollen' + name "pollen" end end diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index adba79848..5b7311025 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -5,7 +5,7 @@ FactoryBot.define do crop planted_at { Time.zone.local(2014, 7, 30) } quantity 33 - description 'This is a *really* good plant.' + description "This is a *really* good plant." factory :seed_planting do planted_from 'seed' diff --git a/spec/factories/post.rb b/spec/factories/post.rb index e7e72c0b5..da6390ef8 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -1,13 +1,13 @@ FactoryBot.define do factory :post do - subject 'A Post' - body 'This is some text.' + subject "A Post" + body "This is some text." author created_at { Time.now } # Markdown is allowed in posts factory :markdown_post do - body 'This is some **strong** text.' + body "This is some **strong** text." end # HTML isn't allowed in posts diff --git a/spec/factories/products.rb b/spec/factories/products.rb index ab9d9556b..444c8597d 100644 --- a/spec/factories/products.rb +++ b/spec/factories/products.rb @@ -2,14 +2,14 @@ FactoryBot.define do factory :product do - name 'annual subscription' - description 'paid membership, renewing yearly, *hurrah*' - min_price '999' + name "annual subscription" + description "paid membership, renewing yearly, *hurrah*" + min_price "999" account_type paid_months 12 factory :product_with_recommended_price do - recommended_price '1200' + recommended_price "1200" end end end diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 833191aac..fed5e5e00 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -2,17 +2,17 @@ FactoryBot.define do factory :role do - name 'Moderator' - description 'These people moderate the forums' + name "Moderator" + description "These people moderate the forums" initialize_with { Role.find_or_create_by(name: name) } factory :admin do - name 'admin' + name "admin" end factory :crop_wrangler do - name 'Crop Wrangler' - description 'they wrangle crops' + name "Crop Wrangler" + description "they wrangle crops" end end end diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb index 3032eaa21..aa0911504 100644 --- a/spec/factories/scientific_name.rb +++ b/spec/factories/scientific_name.rb @@ -1,17 +1,17 @@ FactoryBot.define do factory :scientific_name do association :crop, factory: :crop - name 'Beanus Magicus' + name "Beanus Magicus" creator factory :zea_mays do association :crop, factory: :maize - name 'Zea mays' + name "Zea mays" end factory :solanum_lycopersicum do association :crop, factory: :tomato - name 'Solanum lycopersicum' + name "Solanum lycopersicum" end end end diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index 9509750f9..41b3d404f 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -4,9 +4,9 @@ FactoryBot.define do factory :seed do owner crop - description 'MyText' + description "MyText" quantity 1 - plant_before '2013-07-15' + plant_before "2013-07-15" tradable_to 'nowhere' organic 'unknown' gmo 'unknown' @@ -15,11 +15,11 @@ FactoryBot.define do days_until_maturity_max nil factory :tradable_seed do - tradable_to 'locally' + tradable_to "locally" end factory :untradable_seed do - tradable_to 'nowhere' + tradable_to "nowhere" end end end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb index 5dddeeaab..dac241586 100644 --- a/spec/features/admin/account_types_spec.rb +++ b/spec/features/admin/account_types_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'account types', js: true do - context 'admin user' do +feature "account types", js: true do + context "admin user" do let(:member) { create :admin_member } let(:account_type) { create :account_type } @@ -9,28 +9,28 @@ feature 'account types', js: true do login_as member end - scenario 'navigating to account type admin with JavaScript on' do + scenario "navigating to account type admin with JavaScript on" do visit root_path # Extra click for the expandable login menu click_link member.login_name - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path - click_link 'Account types' + click_link "Account types" expect(current_path).to eq account_types_path end - scenario 'navigating to account type admin without JavaScript - Accessility version', js: false do + scenario "navigating to account type admin without JavaScript - Accessility version", js: false do visit root_path # Extra link not needed as menu is already expanded - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path - click_link 'Account types' + click_link "Account types" expect(current_path).to eq account_types_path end - scenario 'adding an account type' do + scenario "adding an account type" do visit account_types_path - click_link 'New Account type' + click_link "New Account type" expect(current_path).to eq new_account_type_path fill_in 'Name', with: 'Guest' click_button 'Save' diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index da6704134..87f44f26d 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'forums', js: true do - context 'as an admin user' do +feature "forums", js: true do + context "as an admin user" do let(:member) { create :admin_member } let(:forum) { create :forum } @@ -9,35 +9,35 @@ feature 'forums', js: true do login_as member end - scenario 'navigating to forum admin without js', js: false do + scenario "navigating to forum admin without js", js: false do visit root_path - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link 'Forums' + click_link "Forums" end expect(current_path).to eq forums_path - expect(page).to have_content 'New forum' + expect(page).to have_content "New forum" end - scenario 'navigating to forum admin with js' do + scenario "navigating to forum admin with js" do visit root_path click_link member.login_name - click_link 'Admin' + click_link "Admin" expect(current_path).to eq admin_path within 'ul#site_admin' do - click_link 'Forums' + click_link "Forums" end expect(current_path).to eq forums_path - expect(page).to have_content 'New forum' + expect(page).to have_content "New forum" end - scenario 'adding a forum' do + scenario "adding a forum" do visit forums_path - click_link 'New forum' + click_link "New forum" expect(current_path).to eq new_forum_path fill_in 'Name', with: 'Discussion' - fill_in 'Description', with: 'this is a new forum' + fill_in 'Description', with: "this is a new forum" click_button 'Save' expect(current_path).to eq forum_path(Forum.last) expect(page).to have_content 'Forum was successfully created' diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 918e3fd7c..ca24daf83 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'products' do - context 'admin user' do +feature "products" do + context "admin user" do let(:member) { create :admin_member } let(:product) { create :product } @@ -9,15 +9,15 @@ feature 'products' do login_as member end - scenario 'navigating to product admin' do + scenario "navigating to product admin" do visit admin_path - click_link 'Products' + click_link "Products" expect(current_path).to eq products_path end - scenario 'adding a product' do + scenario "adding a product" do visit products_path - click_link 'New Product' + click_link "New Product" expect(current_path).to eq new_product_path fill_in 'Name', with: 'Special offer' # note that failing to fill in a mandatory field has a messy error. diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index e41d1d25d..176c531a8 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -feature 'cms admin' do +feature "cms admin" do let(:member) { create :member } let(:admin_member) { create :admin_member } scenario "can't view CMS admin if not signed in" do visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content 'Please sign in as an admin user' + expect(page).to have_content "Please sign in as an admin user" end scenario "can't view CMS admin if not an admin member" do @@ -15,10 +15,10 @@ feature 'cms admin' do login_as member visit comfy_admin_cms_path expect(current_path).to eq root_path - expect(page).to have_content 'Please sign in as an admin user' + expect(page).to have_content "Please sign in as an admin user" end - scenario 'admin members can view CMS admin area' do + scenario "admin members can view CMS admin area" do login_as admin_member visit comfy_admin_cms_path expect(current_path).to match(/#{comfy_admin_cms_path}/) # match any CMS admin page diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 604bf311e..75024ffb6 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -9,25 +9,25 @@ feature 'Commenting on a post' do visit new_comment_path post_id: post.id end - scenario 'creating a comment' do - fill_in 'comment_body', with: 'This is a sample test for comment' - click_button 'Post comment' - expect(page).to have_content 'comment was successfully created.' - expect(page).to have_content 'Posted by' + scenario "creating a comment" do + fill_in "comment_body", with: "This is a sample test for comment" + click_button "Post comment" + expect(page).to have_content "comment was successfully created." + expect(page).to have_content "Posted by" end - context 'editing a comment' do + context "editing a comment" do let(:existing_comment) { create :comment, post: post, author: member } background do visit edit_comment_path existing_comment end - scenario 'saving edit' do - fill_in 'comment_body', with: 'Testing edit for comment' - click_button 'Post comment' - expect(page).to have_content 'comment was successfully updated.' - expect(page).to have_content 'edited at' + scenario "saving edit" do + fill_in "comment_body", with: "Testing edit for comment" + click_button "Post comment" + expect(page).to have_content "comment was successfully updated." + expect(page).to have_content "edited at" end end end diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index fe4667cf5..e3b36c4a8 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature 'Alternate names', js: true do +feature "Alternate names", js: true do let!(:alternate_eggplant) { create :alternate_eggplant } let(:crop) { alternate_eggplant.crop } - scenario 'Display alternate names on crop page' do + scenario "Display alternate names on crop page" do visit crop_path(alternate_eggplant.crop) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end - scenario 'Index page for alternate names' do + scenario "Index page for alternate names" do visit alternate_names_path expect(page).to have_content alternate_eggplant.name end - context 'User is a crop wrangler' do + context "User is a crop wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -23,59 +23,59 @@ feature 'Alternate names', js: true do login_as member end - scenario 'Crop wranglers can edit alternate names' do + scenario "Crop wranglers can edit alternate names" do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content 'CROP WRANGLER' + expect(page).to have_content "CROP WRANGLER" expect(page).to have_content alternate_eggplant.name - expect(page).to have_link 'Edit', href: edit_alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on 'Edit' } + expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) + within('.alternate_names') { click_on "Edit" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'alternative aubergine' - click_on 'Save' + fill_in 'Name', with: "alternative aubergine" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'alternative aubergine' + expect(page).to have_content "alternative aubergine" expect(page).to have_content 'Alternate name was successfully updated' end - scenario 'Crop wranglers can delete alternate names' do + scenario "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) - expect(page).to have_link 'Delete', + expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on 'Delete' } + within('.alternate_names') { click_on "Delete" } expect(page.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end - scenario 'Crop wranglers can add alternate names' do + scenario "Crop wranglers can add alternate names" do visit crop_path(crop) - expect(page).to have_link 'Add', + expect(page).to have_link "Add", href: new_alternate_name_path(crop_id: crop.id) - within('.alternate_names') { click_on 'Add' } + within('.alternate_names') { click_on "Add" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'not an aubergine' - click_on 'Save' + fill_in 'Name', with: "not an aubergine" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'not an aubergine' + expect(page).to have_content "not an aubergine" expect(page).to have_content 'Alternate name was successfully created' end - scenario 'The show-alternate-name page works' do + scenario "The show-alternate-name page works" do visit alternate_name_path(alternate_eggplant) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name end - context 'When alternate name is rejected' do + context "When alternate name is rejected" do let(:rejected_crop) { create :rejected_crop } let(:pending_alt_name) { create :alternate_name, crop: rejected_crop } - scenario 'Displays crop rejection message' do + scenario "Displays crop rejection message" do visit alternate_name_path(pending_alt_name) - expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' + expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end end end diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 7f8b87467..72e63c8fd 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'browse crops' do +feature "browse crops" do let(:tomato) { create :tomato } let(:maize) { create :maize } let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } - scenario 'has a form for sorting by' do + scenario "has a form for sorting by" do visit crops_path - expect(page).to have_css 'select#sort' + expect(page).to have_css "select#sort" end - scenario 'shows a list of crops' do + scenario "shows a list of crops" do crop1 = tomato visit crops_path expect(page).to have_content crop1.name end - scenario 'pending crops are not listed' do + scenario "pending crops are not listed" do visit crops_path expect(page).not_to have_content pending_crop.name end - scenario 'rejected crops are not listed' do + scenario "rejected crops are not listed" do visit crops_path expect(page).not_to have_content rejected_crop.name end diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index c5c12617e..2b1300485 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Crop - ' do +feature "Crop - " do let!(:crop_wrangler) { create :crop_wrangling_member } let!(:member) { create :member } @@ -9,27 +9,27 @@ feature 'Crop - ' do visit new_crop_path end - scenario 'creating a crop with multiple scientific and alternate name', :js do - within 'form#new_crop' do - fill_in 'crop_name', with: 'Philippine flower' - fill_in 'en_wikipedia_url', with: 'https://en.wikipedia.org/wiki/Jasminum_sambac' - click_button 'add-sci_name-row' - fill_in 'sci_name[1]', with: 'Jasminum sambac 1' - fill_in 'sci_name[2]', with: 'Jasminum sambac 2' - fill_in 'alt_name[1]', with: 'Sampaguita' - click_button 'add-alt_name-row' - click_button 'add-alt_name-row' - fill_in 'alt_name[2]', with: 'Manol' - click_button 'add-alt_name-row' - fill_in 'alt_name[3]', with: 'Jazmin' - fill_in 'alt_name[4]', with: 'Matsurika' - fill_in 'request_notes', with: 'This is the Philippine national flower.' - click_button 'Save' + scenario "creating a crop with multiple scientific and alternate name", :js do + within "form#new_crop" do + fill_in "crop_name", with: "Philippine flower" + fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac" + click_button "add-sci_name-row" + fill_in "sci_name[1]", with: "Jasminum sambac 1" + fill_in "sci_name[2]", with: "Jasminum sambac 2" + fill_in "alt_name[1]", with: "Sampaguita" + click_button "add-alt_name-row" + click_button "add-alt_name-row" + fill_in "alt_name[2]", with: "Manol" + click_button "add-alt_name-row" + fill_in "alt_name[3]", with: "Jazmin" + fill_in "alt_name[4]", with: "Matsurika" + fill_in "request_notes", with: "This is the Philippine national flower." + click_button "Save" end expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content 'This crop is currently pending approval.' - expect(page).to have_content 'Jasminum sambac 2' - expect(page).to have_content 'Matsurika' + expect(page).to have_content "This crop is currently pending approval." + expect(page).to have_content "Jasminum sambac 2" + expect(page).to have_content "Matsurika" end end diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 8270660e7..b7dca2e8d 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'crop detail page', js: true do +feature "crop detail page", js: true do subject do # Update the medians after all the # data has been loaded @@ -12,22 +12,22 @@ feature 'crop detail page', js: true do end let(:crop) { create :crop } - context 'varieties' do - scenario 'The crop DOES NOT have varieties' do + context "varieties" do + scenario "The crop DOES NOT have varieties" do visit crop_path(crop) - within '.varieties' do + within ".varieties" do expect(page).to have_no_selector('li', text: /tomato/i) expect(page).to have_no_selector('button', text: /Show+/i) end end - scenario 'The crop has one variety' do + scenario "The crop has one variety" do create :crop, name: 'Roma tomato 1', parent: crop subject - within '.varieties' do + within ".varieties" do # It lists all 2 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 2) # It DOES NOT have "Show all/less" toggle link @@ -35,16 +35,16 @@ feature 'crop detail page', js: true do end end - context 'many' do + context "many" do let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop } let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop } let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop } let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop } - scenario 'The crop has 4 varieties' do + scenario "The crop has 4 varieties" do subject - within '.varieties' do + within ".varieties" do # It lists all 5 items (note: including the top level item.) expect(page).to have_selector('li', text: /tomato/i, count: 5) # It DOES NOT have "Show all/less" toggle link @@ -52,12 +52,12 @@ feature 'crop detail page', js: true do end end - scenario 'The crop has 5 varieties, including grandchild', js: true do + scenario "The crop has 5 varieties, including grandchild", js: true do create :crop, name: 'Roma tomato child 1', parent: roma4 subject - within '.varieties' do + within ".varieties" do # It lists the first 5 items (note: including the top level item.) # It HAS have "Show all" toggle link but not "Show less" link expect(page).to have_selector('li', text: /tomato/i, count: 5) @@ -93,90 +93,90 @@ feature 'crop detail page', js: true do end end - context 'signed in member' do + context "signed in member" do let(:member) { create :member } background do login_as(member) end - context 'action buttons' do + context "action buttons" do background { subject } - scenario 'has a link to plant the crop' do - expect(page).to have_link 'Plant this', href: new_planting_path(crop_id: crop.id) + scenario "has a link to plant the crop" do + expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) end - scenario 'has a link to harvest the crop' do - expect(page).to have_link 'Harvest this', href: new_harvest_path(crop_id: crop.id) + scenario "has a link to harvest the crop" do + expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) end - scenario 'has a link to add seeds' do - expect(page).to have_link 'Add seeds to stash', href: new_seed_path(crop_id: crop.id) + scenario "has a link to add seeds" do + expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) end end - context 'SEO' do + context "SEO" do background { subject } - scenario 'has seed heading with SEO' do + scenario "has seed heading with SEO" do expect(page).to have_content "Find #{crop.name} seeds" end - scenario 'has harvest heading with SEO' do + scenario "has harvest heading with SEO" do expect(page).to have_content "#{crop.name.capitalize} harvests" end - scenario 'has planting heading with SEO' do + scenario "has planting heading with SEO" do expect(page).to have_content "See who's planted #{crop.name.pluralize}" end - scenario 'has planting advice with SEO' do + scenario "has planting advice with SEO" do expect(page).to have_content "How to grow #{crop.name}" end - scenario 'has a link to Wikipedia with SEO' do + scenario "has a link to Wikipedia with SEO" do expect(page).to have_content "Learn more about #{crop.name}" - expect(page).to have_link 'Wikipedia (English)', href: crop.en_wikipedia_url + expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url end - scenario 'has a link to OpenFarm' do - expect(page).to have_link 'OpenFarm - Growing guide', + scenario "has a link to OpenFarm" do + expect(page).to have_link "OpenFarm - Growing guide", href: "https://openfarm.cc/en/crops/#{URI.escape crop.name}" end - scenario 'has a link to gardenate' do - expect(page).to have_link 'Gardenate - Planting reminders', + scenario "has a link to gardenate" do + expect(page).to have_link "Gardenate - Planting reminders", href: "http://www.gardenate.com/plant/#{URI.escape crop.name}" end end end - context 'seed quantity for a crop' do + context "seed quantity for a crop" do let(:member) { create :member } let(:seed) { create :seed, crop: crop, quantity: 20, owner: member } - scenario 'User not signed in' do + scenario "User not signed in" do visit crop_path(seed.crop) - expect(page).not_to have_content 'You have 20 seeds of this crop' + expect(page).not_to have_content "You have 20 seeds of this crop" expect(page).not_to have_content "You don't have any seeds of this crop" - expect(page).not_to have_link 'View your seeds' + expect(page).not_to have_link "View your seeds" end - scenario 'User signed in' do + scenario "User signed in" do login_as(member) visit crop_path(seed.crop) - expect(page).to have_content 'You have 20 seeds of this crop.' - expect(page).to have_link 'View your seeds' + expect(page).to have_content "You have 20 seeds of this crop." + expect(page).to have_link "View your seeds" end - scenario 'click link to your owned seeds' do + scenario "click link to your owned seeds" do login_as(member) visit crop_path(seed.crop) - click_link 'View your seeds' + click_link "View your seeds" expect(current_path).to eq seeds_by_owner_path(owner: member.slug) end end - shared_examples 'predicts harvest' do + shared_examples "predicts harvest" do describe 'with harvest history data' do before do # 50 days to harvest @@ -190,8 +190,8 @@ feature 'crop detail page', js: true do planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) planting.crop.update_medians end - it 'predicts harvest' do - is_expected.to have_text('First harvest expected 20 days after planting') + it "predicts harvest" do + is_expected.to have_text("First harvest expected 20 days after planting") end end end @@ -210,15 +210,15 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end - it 'predicts lifespan' do - is_expected.to have_text 'Median lifespan' - is_expected.to have_text '99 days' + it "predicts lifespan" do + is_expected.to have_text "Median lifespan" + is_expected.to have_text "99 days" end - it 'describes annual crops' do + it "describes annual crops" do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -232,10 +232,10 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end - it 'describes perennial crops' do + it "describes perennial crops" do is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end end @@ -247,7 +247,7 @@ feature 'crop detail page', js: true do end describe 'with harvests' do - include_examples 'predicts harvest' + include_examples "predicts harvest" end end end diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 0c79d55d8..ccc5288f0 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'crop detail page', js: true do +feature "crop detail page", js: true do subject { page } let(:member) { create :member } @@ -29,29 +29,29 @@ feature 'crop detail page', js: true do visit crop_path(crop) end - shared_examples 'shows photos' do - describe 'show planting photos' do + shared_examples "shows photos" do + describe "show planting photos" do it { is_expected.to have_xpath("//img[contains(@src,'#{photo1.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo2.thumbnail_url}')]") } end - describe 'show harvest photos' do + describe "show harvest photos" do it { is_expected.to have_xpath("//img[contains(@src,'#{photo3.thumbnail_url}')]") } it { is_expected.to have_xpath("//img[contains(@src,'#{photo4.thumbnail_url}')]") } end - describe 'link to more photos' do - it { is_expected.to have_link 'more photos' } + describe "link to more photos" do + it { is_expected.to have_link "more photos" } end end - context 'when signed in' do + context "when signed in" do background { login_as(create(:member)) } - include_examples 'shows photos' + include_examples "shows photos" end - context 'when signed in as photos owner' do + context "when signed in as photos owner" do background { login_as(member) } - include_examples 'shows photos' + include_examples "shows photos" end - context 'when not signed in ' do - include_examples 'shows photos' + context "when not signed in " do + include_examples "shows photos" end end diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index b10aa043d..f2f86980c 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature 'crop search' do - scenario 'search results show the search term in title' do +feature "crop search" do + scenario "search results show the search term in title" do visit root_path - within 'form#navbar-search' do - fill_in 'term', with: 'tomato' - click_button 'Search' + within "form#navbar-search" do + fill_in "term", with: "tomato" + click_button "Search" end - expect(page).to have_css 'h1', text: 'Crops matching "tomato"' + expect(page).to have_css "h1", text: "Crops matching \"tomato\"" end - scenario 'search page with no search term shows suitable title' do + scenario "search page with no search term shows suitable title" do visit crops_search_path - expect(page).to have_css 'h1', text: 'Crop search' + expect(page).to have_css "h1", text: "Crop search" end - scenario 'search page has a search form on it' do + scenario "search page has a search form on it" do visit crops_search_path - expect(page).to have_css 'form#crop-search' + expect(page).to have_css "form#crop-search" end end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index c5ae2c9a2..eafc7039f 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'crop wranglers', js: true do - context 'signed in wrangler' do +feature "crop wranglers", js: true do + context "signed in wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:wrangler) { crop_wranglers.first } let!(:crops) { create_list :crop, 2 } @@ -10,7 +10,7 @@ feature 'crop wranglers', js: true do background { login_as wrangler } - scenario 'sees crop wranglers listed on the crop wrangler page' do + scenario "sees crop wranglers listed on the crop wrangler page" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -23,7 +23,7 @@ feature 'crop wranglers', js: true do end end - scenario 'can see list of crops with extra detail of who created a crop' do + scenario "can see list of crops with extra detail of who created a crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -32,39 +32,39 @@ feature 'crop wranglers', js: true do end end - scenario 'visiting a crop can see wrangler links' do + scenario "visiting a crop can see wrangler links" do visit crop_path(crops.first) expect(page).to have_content 'You are a CROP WRANGLER' expect(page).to have_link 'Edit crop' expect(page).to have_link 'Delete crop' end - scenario 'can create a new crop' do + scenario "can create a new crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' click_link 'Add Crop' - fill_in 'Name', with: 'aubergine' - fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Maize' - fill_in 'sci_name[1]', with: 'planticus maximus' + fill_in 'Name', with: "aubergine" + fill_in 'en_wikipedia_url', with: "http://en.wikipedia.org/wiki/Maize" + fill_in 'sci_name[1]', with: "planticus maximus" click_on 'Save' expect(page).to have_content 'crop was successfully created.' expect(page).to have_content 'planticus maximus' end - scenario 'View pending crops' do + scenario "View pending crops" do visit crop_path(requested_crop) - expect(page).to have_content 'This crop is currently pending approval.' + expect(page).to have_content "This crop is currently pending approval." expect(page).to have_content "Please approve this even though it's fake." end - scenario 'View rejected crops' do + scenario "View rejected crops" do visit crop_path(rejected_crop) - expect(page).to have_content 'This crop was rejected for the following reason: Totally fake' + expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end end - context 'signed in non-wrangler' do + context "signed in non-wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { create :member } @@ -72,13 +72,13 @@ feature 'crop wranglers', js: true do scenario "can't see wrangling page without js", js: false do visit root_path - expect(page).not_to have_link 'Crop Wrangling' + expect(page).not_to have_link "Crop Wrangling" end scenario "can't see wrangling page with js" do visit root_path click_link member.login_name - expect(page).not_to have_link 'Crop Wrangling' + expect(page).not_to have_link "Crop Wrangling" end end end diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index dd1f439c8..ede88f003 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'crop wrangling button' do +feature "crop wrangling button" do let(:crop_wrangler) { create :crop_wrangling_member } let(:member) { create :member } - context 'crop wrangling button' do + context "crop wrangling button" do background do login_as crop_wrangler visit crops_path end - scenario 'has a link to crop wrangling page' do - expect(page).to have_link 'Wrangle Crops', href: wrangle_crops_path + scenario "has a link to crop wrangling page" do + expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path end end - context 'crop wrangling button' do + context "crop wrangling button" do background do login_as member visit crops_path end - scenario 'has no link to crop wrangling page' do - expect(page).to have_no_link 'Wrangle Crops', href: wrangle_crops_path + scenario "has no link to crop wrangling page" do + expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path end end end diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index 015b19d6d..d08f2490b 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -feature 'irregular crop inflections' do +feature "irregular crop inflections" do # We're just testing a couple of representative crops to # check that inflection works: you don't need to add # every crop here. - scenario 'crops which are mass nouns' do - expect('kale'.pluralize).to eq 'kale' - expect('broccoli'.pluralize).to eq 'broccoli' - expect('square foot'.pluralize).to eq 'square feet' - expect('squash'.pluralize).to eq 'squash' - expect('bok choy'.pluralize).to eq 'bok choy' - expect('achiote'.pluralize).to eq 'achiote' - expect('alfalfa'.pluralize).to eq 'alfalfa' - expect('allspice'.pluralize).to eq 'allspice' - expect('spinach'.pluralize).to eq 'spinach' - expect('garlic'.pluralize).to eq 'garlic' - expect('licorice'.pluralize).to eq 'licorice' - expect('lillipilli'.pluralize).to eq 'lillipillies' + scenario "crops which are mass nouns" do + expect("kale".pluralize).to eq "kale" + expect("broccoli".pluralize).to eq "broccoli" + expect("square foot".pluralize).to eq "square feet" + expect("squash".pluralize).to eq "squash" + expect("bok choy".pluralize).to eq "bok choy" + expect("achiote".pluralize).to eq "achiote" + expect("alfalfa".pluralize).to eq "alfalfa" + expect("allspice".pluralize).to eq "allspice" + expect("spinach".pluralize).to eq "spinach" + expect("garlic".pluralize).to eq "garlic" + expect("licorice".pluralize).to eq "licorice" + expect("lillipilli".pluralize).to eq "lillipillies" end end diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index 5dc54d8cb..9cccac4f8 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'Requesting a new crop' do - context 'As a regular member' do +feature "Requesting a new crop" do + context "As a regular member" do let(:member) { create :member } let!(:wrangler) { create :crop_wrangling_member } @@ -9,39 +9,39 @@ feature 'Requesting a new crop' do login_as member end - scenario 'Submit request' do + scenario "Submit request" do visit new_crop_path - fill_in 'Name', with: 'Couch potato' - fill_in 'request_notes', with: 'Couch potatoes are real for real.' - click_button 'Save' + fill_in "Name", with: "Couch potato" + fill_in "request_notes", with: "Couch potatoes are real for real." + click_button "Save" expect(page).to have_content 'crop was successfully created.' - expect(page).to have_content 'This crop is currently pending approval.' + expect(page).to have_content "This crop is currently pending approval." end end - context 'As a crop wrangler' do + context "As a crop wrangler" do let(:wrangler) { create :crop_wrangling_member } let!(:crop) { create :crop_request } let!(:already_approved) { create :crop } background { login_as wrangler } - scenario 'Approve a request' do + scenario "Approve a request" do visit edit_crop_path(crop) - select 'approved', from: 'Approval status' - click_button 'Save' - expect(page).to have_content 'En wikipedia url is not a valid English Wikipedia URL' - fill_in 'en_wikipedia_url', with: 'http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi' - click_button 'Save' - expect(page).to have_content 'crop was successfully updated.' + select "approved", from: "Approval status" + click_button "Save" + expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL" + fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi" + click_button "Save" + expect(page).to have_content "crop was successfully updated." end - scenario 'Rejecting a crop' do + scenario "Rejecting a crop" do visit edit_crop_path(crop) - select 'rejected', from: 'Approval status' - select 'not edible', from: 'Reason for rejection' - click_button 'Save' - expect(page).to have_content 'crop was successfully updated.' + select "rejected", from: "Approval status" + select "not edible", from: "Reason for rejection" + click_button "Save" + expect(page).to have_content "crop was successfully updated." end end end diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index c3329635a..15226efe4 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Crop - ' do +feature "Crop - " do let(:member) { create :member } let!(:requested_crop) { create :crop, requester: member, approval_status: 'pending', name: 'puha for dinner' } @@ -9,7 +9,7 @@ feature 'Crop - ' do visit requested_crops_path end - scenario 'creating a crop with multiple scientific and alternate name', :js do - expect(page).to have_content 'puha for dinner' + scenario "creating a crop with multiple scientific and alternate name", :js do + expect(page).to have_content "puha for dinner" end end diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 5fbeb5296..735883e77 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature 'follows', :js do - context 'when signed out' do +feature "follows", :js do + context "when signed out" do let(:member) { create :member } - scenario 'follow buttons on member profile page' do + scenario "follow buttons on member profile page" do visit member_path(member) - expect(page).not_to have_link 'Follow' - expect(page).not_to have_link 'Unfollow' + expect(page).not_to have_link "Follow" + expect(page).not_to have_link "Unfollow" end end - context 'when signed in' do + context "when signed in" do let(:member) { create :member } let(:other_member) { create :member } @@ -21,45 +21,45 @@ feature 'follows', :js do scenario "your profile doesn't have a follow button" do visit member_path(member) - expect(page).not_to have_link 'Follow' - expect(page).not_to have_link 'Unfollow' + expect(page).not_to have_link "Follow" + expect(page).not_to have_link "Unfollow" end - context 'following another member' do + context "following another member" do background do visit member_path(other_member) end - scenario 'has a follow button' do - expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) + scenario "has a follow button" do + expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) end - scenario 'has correct message and unfollow button' do + scenario "has correct message and unfollow button" do click_link 'Follow' expect(page).to have_content "Followed #{other_member.login_name}" - expect(page).to have_link 'Unfollow', href: follow_path(member.get_follow(other_member)) + expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member)) end - scenario 'has a followed member listed in the following page' do + scenario "has a followed member listed in the following page" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s end - scenario 'does not die when passed an authenticity_token' do - visit member_follows_path member, params: { authenticity_token: 'Ultima ratio regum' } + scenario "does not die when passed an authenticity_token" do + visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" } expect(page.status_code).to equal 200 end - scenario 'has correct message and follow button after unfollow' do + scenario "has correct message and follow button after unfollow" do click_link 'Follow' click_link 'Unfollow' expect(page).to have_content "Unfollowed #{other_member.login_name}" visit member_path(other_member) # unfollowing redirects to root - expect(page).to have_link 'Follow', href: follows_path(followed_id: other_member.id) + expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) end - scenario 'has member in following list' do + scenario "has member in following list" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name.to_s @@ -71,7 +71,7 @@ feature 'follows', :js do expect(page).to have_content member.login_name.to_s end - scenario 'removes members from following and followers lists after unfollow' do + scenario "removes members from following and followers lists after unfollow" do click_link 'Follow' click_link 'Unfollow' visit member_follows_path(member) diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index 3023212f7..b7d109773 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'footer', js: true do +feature "footer", js: true do before { visit root_path } - scenario 'footer is on home page' do + scenario "footer is on home page" do expect(page).to have_css 'footer' end diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index 746acc1f0..c3f78dd18 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Gardens', :js do +feature "Gardens", :js do let(:member) { FactoryBot.create :member } background do @@ -9,30 +9,30 @@ feature 'Gardens', :js do visit new_garden_path end - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'Name' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "Name" expect(page).to have_optional 'textarea#garden_description' expect(page).to have_optional 'input#garden_location' expect(page).to have_optional 'input#garden_area' end - scenario 'Create new garden' do - fill_in 'Name', with: 'New garden' - click_button 'Save' - expect(page).to have_content 'Garden was successfully created' - expect(page).to have_content 'New garden' + scenario "Create new garden" do + fill_in "Name", with: "New garden" + click_button "Save" + expect(page).to have_content "Garden was successfully created" + expect(page).to have_content "New garden" end - scenario 'Refuse to create new garden with negative area' do + scenario "Refuse to create new garden with negative area" do visit new_garden_path - fill_in 'Name', with: 'Negative Garden' - fill_in 'Area', with: -5 - click_button 'Save' - expect(page).not_to have_content 'Garden was successfully created' - expect(page).to have_content 'Area must be greater than or equal to 0' + fill_in "Name", with: "Negative Garden" + fill_in "Area", with: -5 + click_button "Save" + expect(page).not_to have_content "Garden was successfully created" + expect(page).to have_content "Area must be greater than or equal to 0" end end diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/gardens_index_spec.rb index 9cd03a930..39161d5c8 100644 --- a/spec/features/gardens/gardens_index_spec.rb +++ b/spec/features/gardens/gardens_index_spec.rb @@ -1,46 +1,46 @@ require 'rails_helper' require 'custom_matchers' -feature 'Gardens#index', :js do - context 'Logged in as member' do +feature "Gardens#index", :js do + context "Logged in as member" do let(:member) { FactoryBot.create :member } background { login_as member } - context 'with 10 gardens' do + context "with 10 gardens" do before do FactoryBot.create_list :garden, 10, owner: member visit gardens_path(member: member) end - it 'displays each of the gardens' do + it "displays each of the gardens" do member.gardens.each do |garden| expect(page).to have_text garden.name end end - it 'links to each garden' do + it "links to each garden" do member.gardens.each do |garden| expect(page).to have_link(garden.name, href: garden_path(garden)) end end end - context 'with inactive gardens' do - let!(:active_garden) { FactoryBot.create :garden, name: 'My active garden', owner: member } - let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: 'retired garden', owner: member } + context "with inactive gardens" do + let!(:active_garden) { FactoryBot.create :garden, name: "My active garden", owner: member } + let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: "retired garden", owner: member } before { visit gardens_path(member: member) } - it 'show active garden' do + it "show active garden" do expect(page).to have_text active_garden.name end - it 'should not show inactive garden' do + it "should not show inactive garden" do expect(page).not_to have_text inactive_garden.name end - it 'links to active garden' do + it "links to active garden" do expect(page).to have_link(active_garden.name, href: garden_path(active_garden)) end - it 'does not link to inactive gardens' do + it "does not link to inactive gardens" do expect(page).not_to have_link(inactive_garden.name, href: garden_path(inactive_garden)) end end @@ -59,10 +59,10 @@ feature 'Gardens#index', :js do before do visit gardens_path(member: member) end - it 'shows planting in garden' do + it "shows planting in garden" do expect(page).to have_link(planting.crop.name, href: planting_path(planting)) end - it 'does not show finished planting' do + it "does not show finished planting" do expect(page).not_to have_text(finished_planting.crop.name) end end diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 613fb688d..0954d35eb 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'Planting a crop', js: true do +feature "Planting a crop", js: true do # name is aaa to ensure it is ordered first let!(:garden) { create :garden, name: 'aaa' } - let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse('2013-3-10') } + let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") } let!(:tomato) { create :tomato } let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } @@ -11,88 +11,88 @@ feature 'Planting a crop', js: true do login_as garden.owner end - scenario 'View gardens' do + scenario "View gardens" do visit gardens_path expect(page).to have_content "Everyone's gardens" - click_link 'My Gardens' + click_link "My Gardens" expect(page).to have_content "#{garden.owner.login_name}'s gardens" click_link "Everyone's gardens" expect(page).to have_content "Everyone's gardens" end - scenario 'Marking a garden as inactive' do + scenario "Marking a garden as inactive" do visit garden_path(garden) - click_link 'Mark as inactive' - expect(page).to have_content 'Garden was successfully updated' - expect(page).to have_content 'This garden is inactive' - expect(page).to have_content 'Mark as active' - expect(page).not_to have_content 'Mark as inactive' + click_link "Mark as inactive" + expect(page).to have_content "Garden was successfully updated" + expect(page).to have_content "This garden is inactive" + expect(page).to have_content "Mark as active" + expect(page).not_to have_content "Mark as inactive" end - scenario 'List only active gardens' do + scenario "List only active gardens" do visit garden_path(garden) - click_link 'Mark as inactive' + click_link "Mark as inactive" visit gardens_path expect(page).not_to have_link garden_path(garden) end - scenario 'Create new garden' do + scenario "Create new garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' - expect(page).to have_content 'Garden was successfully created' - expect(page).to have_content 'New garden' + fill_in "Name", with: "New garden" + click_button "Save" + expect(page).to have_content "Garden was successfully created" + expect(page).to have_content "New garden" end - scenario 'Refuse to create new garden with negative area' do + scenario "Refuse to create new garden with negative area" do visit new_garden_path - fill_in 'Name', with: 'Negative Garden' - fill_in 'Area', with: -5 - click_button 'Save' - expect(page).not_to have_content 'Garden was successfully created' - expect(page).to have_content 'Area must be greater than or equal to 0' + fill_in "Name", with: "Negative Garden" + fill_in "Area", with: -5 + click_button "Save" + expect(page).not_to have_content "Garden was successfully created" + expect(page).to have_content "Area must be greater than or equal to 0" end - context 'Clicking edit from the index page' do + context "Clicking edit from the index page" do background do visit gardens_path end - scenario 'button on index to edit garden' do - first('.garden-info').click_link('edit_garden_link') + scenario "button on index to edit garden" do + first(".garden-info").click_link("edit_garden_link") expect(page).to have_content 'Edit garden' end end - scenario 'Edit garden' do + scenario "Edit garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' + fill_in "Name", with: "New garden" + click_button "Save" click_link 'edit_garden_link' - fill_in 'Name', with: 'Different name' - click_button 'Save' - expect(page).to have_content 'Garden was successfully updated' - expect(page).to have_content 'Different name' + fill_in "Name", with: "Different name" + click_button "Save" + expect(page).to have_content "Garden was successfully updated" + expect(page).to have_content "Different name" end - scenario 'Delete garden' do + scenario "Delete garden" do visit new_garden_path - fill_in 'Name', with: 'New garden' - click_button 'Save' + fill_in "Name", with: "New garden" + click_button "Save" visit garden_path(Garden.last) click_link 'delete_garden_link' - expect(page).to have_content 'Garden was successfully deleted' + expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end - describe 'Making a planting inactive from garden show' do + describe "Making a planting inactive from garden show" do let(:path) { garden_path garden } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end - scenario 'List only active plantings on a garden' do + scenario "List only active plantings on a garden" do visit gardens_path expect(page).not_to have_content finished_planting.crop_name end diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 30339219a..2a8400c2e 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'browse harvests' do +feature "browse harvests" do let!(:member) { create :member } let!(:harvest) { create :harvest, owner: member } @@ -16,11 +16,11 @@ feature 'browse harvests' do end scenario 'read more' do - expect(page).not_to have_link 'Read more' + expect(page).not_to have_link "Read more" end end - feature 'filled in optional fields' do + feature "filled in optional fields" do let!(:harvest) { create :harvest, :long_description } before(:each) do @@ -28,7 +28,7 @@ feature 'browse harvests' do end scenario 'read more' do - expect(page).to have_link 'Read more' + expect(page).to have_link "Read more" end it 'links to #show' do diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 6c2b253c0..84c4b5a7f 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Harvesting a crop', :js, :elasticsearch do +feature "Harvesting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let!(:plant_part) { create :plant_part } @@ -13,44 +13,44 @@ feature 'Harvesting a crop', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'harvest', 'crop' + it_behaves_like "crop suggest", "harvest", "crop" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'What did you harvest?' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "What did you harvest?" expect(page).to have_optional 'input#harvest_quantity' expect(page).to have_optional 'input#harvest_weight_quantity' expect(page).to have_optional 'textarea#harvest_description' end - scenario 'Creating a new harvest', :js do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' + scenario "Creating a new harvest", :js do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" - within 'form#new_harvest' do + within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' - fill_in 'When?', with: '2014-06-15' - fill_in 'How many?', with: 42 - fill_in 'Weighing (in total):', with: 42 - fill_in 'Notes', with: "It's killer." - click_button 'Save' + fill_in "When?", with: "2014-06-15" + fill_in "How many?", with: 42 + fill_in "Weighing (in total):", with: 42 + fill_in "Notes", with: "It's killer." + click_button "Save" end - expect(page).to have_content 'harvest was successfully created.' + expect(page).to have_content "harvest was successfully created." end - context 'Clicking edit from the index page' do + context "Clicking edit from the index page" do let!(:harvest) { create :harvest, crop: maize, owner: member } background do visit harvests_path end - scenario 'button on index to edit harvest' do - click_link 'edit_harvest_glyphicon' + scenario "button on index to edit harvest" do + click_link "edit_harvest_glyphicon" expect(current_path).to eq edit_harvest_path(harvest) expect(page).to have_content 'Editing harvest' end @@ -62,58 +62,58 @@ feature 'Harvesting a crop', :js, :elasticsearch do expect(current_path).to eq member_path member end - scenario 'Harvesting from crop page' do + scenario "Harvesting from crop page" do visit crop_path(maize) - click_link 'Harvest this' - within 'form#new_harvest' do + click_link "Harvest this" + within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'harvest was successfully created.' - expect(page).to have_content 'maize' + expect(page).to have_content "harvest was successfully created." + expect(page).to have_content "maize" end - scenario 'Harvesting from planting page' do + scenario "Harvesting from planting page" do planting = create :planting, crop: maize, owner: member, garden: member.gardens.first visit planting_path(planting) - click_link 'Harvest' + click_link "Harvest" select plant_part.name, from: 'harvest[plant_part_id]' - click_button 'Save' + click_button "Save" - expect(page).to have_content 'harvest was successfully created.' + expect(page).to have_content "harvest was successfully created." expect(page).to have_content planting.garden.name - expect(page).to have_content 'maize' + expect(page).to have_content "maize" end - context 'Editing a harvest' do + context "Editing a harvest" do let(:existing_harvest) { create :harvest, crop: maize, owner: member } let!(:other_plant_part) { create :plant_part, name: 'chocolate' } background do visit harvest_path(existing_harvest) - click_link 'Edit' + click_link "Edit" end - scenario 'Saving without edits' do + scenario "Saving without edits" do # Check that the autosuggest helper properly fills inputs with # existing resource's data - click_button 'Save' - expect(page).to have_content 'harvest was successfully updated.' - expect(page).to have_content 'maize' + click_button "Save" + expect(page).to have_content "harvest was successfully updated." + expect(page).to have_content "maize" end - scenario 'change plant part' do + scenario "change plant part" do select other_plant_part.name, from: 'harvest[plant_part_id]' - click_button 'Save' - expect(page).to have_content 'harvest was successfully updated.' + click_button "Save" + expect(page).to have_content "harvest was successfully updated." expect(page).to have_content other_plant_part.name end end - context 'Viewing a harvest' do + context "Viewing a harvest" do let(:existing_harvest) do create :harvest, crop: maize, owner: member, harvested_at: Time.zone.today @@ -127,10 +127,10 @@ feature 'Harvesting a crop', :js, :elasticsearch do visit harvest_path(existing_harvest) end - scenario 'linking to a planting' do + scenario "linking to a planting" do expect(page).to have_content planting.to_s choose("harvest_planting_id_#{existing_planting.id}") - click_button 'save' + click_button "save" expect(page).to have_link(href: planting_path(existing_planting)) end end diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 5dabbfa5e..01d164f3c 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Changing locales', js: true do +feature "Changing locales", js: true do after { I18n.locale = :en } - scenario 'Locale can be set with a query param' do + scenario "Locale can be set with a query param" do visit root_path - expect(page).to have_content('a community of food gardeners.') + expect(page).to have_content("a community of food gardeners.") visit root_path(locale: 'ja') - expect(page).to have_content('はガーデナーのコミュニティです。') + expect(page).to have_content("はガーデナーのコミュニティです。") end end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index bf54c637f..32b11bda1 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -1,109 +1,109 @@ require 'rails_helper' -feature 'member profile', js: true do - context 'signed out member' do +feature "member profile", js: true do + context "signed out member" do let(:member) { create :member } - scenario 'basic details on member profile page' do + scenario "basic details on member profile page" do visit member_path(member) - expect(page).to have_css('h1', text: member.login_name) + expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content 'Account type: Free account' + expect(page).to have_content "Account type: Free account" expect(page).to have_content "#{member.login_name}'s gardens" - expect(page).to have_link 'More about this garden...', href: garden_path(member.gardens.first) + expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end - scenario 'no bio' do + scenario "no bio" do member.bio = nil member.save visit member_path(member) expect(page).to have_content "hasn't written a bio yet" end - scenario 'gravatar' do + scenario "gravatar" do visit member_path(member) - expect(page).to have_css 'img.avatar' + expect(page).to have_css "img.avatar" end - context 'location' do - scenario 'member has set location' do + context "location" do + scenario "member has set location" do london_member = create :london_member visit member_path(london_member) - expect(page).to have_css('h1>small', text: london_member.location) - expect(page).to have_css('#membermap') + expect(page).to have_css("h1>small", text: london_member.location) + expect(page).to have_css("#membermap") expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}" end - scenario 'member has not set location' do + scenario "member has not set location" do visit member_path(member) - expect(page).not_to have_css('h1>small') - expect(page).not_to have_css('#membermap') - expect(page).not_to have_content 'See other members' + expect(page).not_to have_css("h1>small") + expect(page).not_to have_css("#membermap") + expect(page).not_to have_content "See other members" end end - context 'email privacy' do - scenario 'public email address' do + context "email privacy" do + scenario "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario 'private email address' do + scenario "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end - context 'email privacy' do - scenario 'public email address' do + context "email privacy" do + scenario "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario 'private email address' do + scenario "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end - context 'activity stats' do - scenario 'with no activity' do + context "activity stats" do + scenario "with no activity" do visit member_path(member) - expect(page).to have_content 'Activity' - expect(page).to have_content '0 plantings' - expect(page).to have_content '0 harvests' - expect(page).to have_content '0 seeds' - expect(page).to have_content '0 posts' + expect(page).to have_content "Activity" + expect(page).to have_content "0 plantings" + expect(page).to have_content "0 harvests" + expect(page).to have_content "0 seeds" + expect(page).to have_content "0 posts" end - scenario 'with some activity' do + scenario "with some activity" do create_list :planting, 2, owner: member create_list :harvest, 3, owner: member create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link '2 plantings', href: plantings_by_owner_path(owner: member) - expect(page).to have_link '3 harvests', href: harvests_by_owner_path(owner: member) - expect(page).to have_link '4 seeds', href: seeds_by_owner_path(owner: member) - expect(page).to have_link '5 posts', href: posts_by_author_path(author: member) + expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member) + expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member) + expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member) + expect(page).to have_link "5 posts", href: posts_by_author_path(author: member) end end - scenario 'twitter link' do + scenario "twitter link" do twitter_auth = create :authentication, member: member visit member_path(member) expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}" end - scenario 'flickr link' do + scenario "flickr link" do flickr_auth = create :flickr_authentication, member: member visit member_path(member) expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}" end end - context 'signed in member' do + context "signed in member" do let(:member) { create :member } let(:other_member) { create :member } let(:admin_member) { create :admin_member } @@ -115,35 +115,35 @@ feature 'member profile', js: true do scenario "admin user's page" do visit member_path(admin_member) - expect(page).to have_text 'Admin' + expect(page).to have_text "Admin" end scenario "crop wrangler's page" do visit member_path(crop_wrangler) - expect(page).to have_text 'Crop Wrangler' + expect(page).to have_text "Crop Wrangler" end scenario "ordinary user's page" do visit member_path(other_member) - expect(page).not_to have_text 'Crop Wrangler' - expect(page).not_to have_text 'Admin' + expect(page).not_to have_text "Crop Wrangler" + expect(page).not_to have_text "Admin" end - context 'your own profile page' do + context "your own profile page" do background do visit member_path(member) end - scenario 'has a link to create new garden' do - expect(page).to have_link 'New Garden', href: new_garden_path + scenario "has a link to create new garden" do + expect(page).to have_link "New Garden", href: new_garden_path end - scenario 'has a button to edit profile' do - expect(page).to have_link 'Edit profile', href: edit_member_registration_path + scenario "has a button to edit profile" do + expect(page).to have_link "Edit profile", href: edit_member_registration_path end - scenario 'has a button to upgrade account' do - expect(page).to have_link 'Upgrade account', href: shop_path + scenario "has a button to upgrade account" do + expect(page).to have_link "Upgrade account", href: shop_path end end @@ -152,18 +152,18 @@ feature 'member profile', js: true do visit member_path(other_member) end - scenario 'has a private message button' do - expect(page).to have_link 'Send message', href: new_notification_path(recipient_id: other_member.id) + scenario "has a private message button" do + expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) end end - context 'home page' do + context "home page" do background do visit root_path end - scenario 'does not have a button to edit profile' do - expect(page).not_to have_link 'Edit profile', href: edit_member_registration_path + scenario "does not have a button to edit profile" do + expect(page).not_to have_link "Edit profile", href: edit_member_registration_path end end end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 58041c581..793a6ada5 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'member deletion' do - context 'with activity and followers' do +feature "member deletion" do + context "with activity and followers" do let(:member) { FactoryBot.create(:member) } let(:other_member) { FactoryBot.create(:member) } let(:memberpost) { FactoryBot.create(:post, author: member) } @@ -24,86 +24,86 @@ feature 'member deletion' do logout login_as(member) FactoryBot.create(:comment, author: member, post: othermemberpost) - FactoryBot.create(:comment, author: other_member, post: memberpost, body: 'Fun comment-y thing') + FactoryBot.create(:comment, author: other_member, post: memberpost, body: "Fun comment-y thing") # deletion breaks if no wranglers exist FactoryBot.create(:cropbot) # deletion breaks if ex_member doesn't exist - FactoryBot.create(:member, login_name: 'ex_member') + FactoryBot.create(:member, login_name: "ex_member") end - scenario 'has option to delete on member profile page' do + scenario "has option to delete on member profile page" do visit member_path(member) click_link 'Edit profile' - expect(page).to have_link 'Delete Account' + expect(page).to have_link "Delete Account" end - scenario 'asks for password before deletion' do + scenario "asks for password before deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - click_button 'Delete' + click_button "Delete" expect(page).to have_content "Current password can't be blank" end - scenario 'password must be correct' do + scenario "password must be correct" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'wrongpassword' - click_button 'Delete' - expect(page).to have_content 'Current password is invalid' + fill_in "current_pw_for_delete", with: "wrongpassword" + click_button "Delete" + expect(page).to have_content "Current password is invalid" end - scenario 'deletes and removes bio' do + scenario "deletes and removes bio" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" visit member_path(member) expect(page.status_code).to eq(404) end - context 'deletes and' do + context "deletes and" do background do logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" logout end - scenario 'removes plantings' do + scenario "removes plantings" do visit planting_path(planting) expect(page.status_code).to eq(404) end - scenario 'removes gardens' do + scenario "removes gardens" do visit garden_path(secondgarden) expect(page.status_code).to eq(404) end - scenario 'removes harvests and seeds' do + scenario "removes harvests and seeds" do visit harvest_path(harvest) expect(page.status_code).to eq(404) end - scenario 'removes seeds' do + scenario "removes seeds" do visit seed_path(seed) expect(page.status_code).to eq(404) end - scenario 'removes members from following' do + scenario "removes members from following" do visit member_follows_path(other_member) expect(page).not_to have_content member.login_name.to_s visit member_followers_path(other_member) expect(page).not_to have_content member.login_name.to_s end - scenario 'replaces posts with deletion note' do + scenario "replaces posts with deletion note" do visit post_path(memberpost) expect(page.status_code).to eq(404) end @@ -112,16 +112,16 @@ feature 'member deletion' do visit post_path(othermemberpost) expect(page).not_to have_content member.login_name expect(page).to have_content other_member.login_name - expect(page).to have_content 'Member Deleted' + expect(page).to have_content "Member Deleted" end - scenario 'leaves a record of orders and payments intact' do + scenario "leaves a record of orders and payments intact" do login_as(admin) visit admin_path - fill_in 'search_text', with: member.login_name.to_s - find('#maincontainer').click_button('Search', exact: true) + fill_in "search_text", with: member.login_name.to_s + find("#maincontainer").click_button("Search", exact: true) expect(page).to have_content member.login_name.to_s - expect(page).to have_content 'Found 1 result' + expect(page).to have_content "Found 1 result" logout end @@ -133,7 +133,7 @@ feature 'member deletion' do pending "doesn't show in nearby" - scenario 'can no longer sign in' do + scenario "can no longer sign in" do visit new_member_session_path fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password @@ -143,25 +143,25 @@ feature 'member deletion' do end end - context 'for a crop wrangler' do + context "for a crop wrangler" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:otherwrangler) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop, creator: member) } FactoryBot.create(:cropbot) - let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: 'ex_wrangler') } + let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: "ex_wrangler") } - scenario 'leaves crops behind' do + scenario "leaves crops behind" do login_as(otherwrangler) visit edit_crop_path(crop) expect(page).to have_content member.login_name - expect(page).not_to have_content 'cropbot' + expect(page).not_to have_content "cropbot" logout login_as(member) visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - fill_in 'current_pw_for_delete', with: 'password1', match: :prefer_exact - click_button 'Delete' + fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact + click_button "Delete" login_as(otherwrangler) visit edit_crop_path(crop) expect(page).not_to have_content member.login_name diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 395766fb9..01b6ee8bd 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature 'members list' do - context 'list all members' do - let!(:member1) { create :member, login_name: 'Archaeopteryx', confirmed_at: Time.zone.parse('2013-02-10') } - let!(:member2) { create :member, login_name: 'Zephyrosaurus', confirmed_at: Time.zone.parse('2014-01-11') } - let!(:member3) { create :member, login_name: 'Testingname', confirmed_at: Time.zone.parse('2014-05-09') } +feature "members list" do + context "list all members" do + let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') } + let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') } + let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') } - scenario 'default alphabetical sort' do + scenario "default alphabetical sort" do visit members_path - expect(page).to have_css '#sort' - expect(page).to have_selector 'form' + expect(page).to have_css "#sort" + expect(page).to have_selector "form" click_button('Show') - all_links = page.all('#maincontainer p.login-name') + all_links = page.all("#maincontainer p.login-name") expect(all_links.first).to have_text member1.login_name expect(all_links.last).to have_text member2.login_name end - scenario 'recently joined sort' do + scenario "recently joined sort" do visit members_path - expect(page).to have_css '#sort' - expect(page).to have_selector 'form' - select('recently', from: 'sort') + expect(page).to have_css "#sort" + expect(page).to have_selector "form" + select("recently", from: 'sort') click_button('Show') - all_links = page.all('#maincontainer p.login-name') + all_links = page.all("#maincontainer p.login-name") expect(all_links.first).to have_text member3.login_name expect(all_links.last).to have_text member1.login_name end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 1c0f31110..aa81403d6 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature 'Notifications', :js do +feature "Notifications", :js do let(:sender) { create :member } let(:recipient) { create :member } - context 'On existing notification' do + context "On existing notification" do let!(:notification) do create :notification, sender: sender, recipient: recipient, - body: 'Notification body', + body: "Notification body", post_id: nil end @@ -18,14 +18,14 @@ feature 'Notifications', :js do visit notification_path(notification) end - scenario 'Replying to the notification' do - click_link 'Reply' - expect(page).to have_content 'Notification body' + scenario "Replying to the notification" do + click_link "Reply" + expect(page).to have_content "Notification body" - fill_in 'notification_body', with: 'Response body' - click_button 'Send' + fill_in 'notification_body', with: "Response body" + click_button "Send" - expect(page).to have_content 'Message was successfully sent' + expect(page).to have_content "Message was successfully sent" end end diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index cc2c16593..1c13b2793 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -1,49 +1,49 @@ require 'rails_helper' -feature 'new photo page' do +feature "new photo page" do let(:photo) { FactoryBot.create :photo } - context 'signed in member' do + context "signed in member" do let(:member) { FactoryBot.create :member } background { login_as member } - context 'viewing a planting' do + context "viewing a planting" do let(:planting) { FactoryBot.create :planting, owner: member } - scenario 'add photo' do + scenario "add photo" do visit planting_path(planting) click_link('Add photo', match: :first) expect(page).to have_text planting.crop.name end end - context 'viewing a harvest' do + context "viewing a harvest" do let(:harvest) { FactoryBot.create :harvest, owner: member } - scenario 'add photo' do + scenario "add photo" do visit harvest_path(harvest) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text harvest.crop.name end end - context 'viewing a garden' do + context "viewing a garden" do let(:garden) { FactoryBot.create :garden, owner: member } - scenario 'add photo' do + scenario "add photo" do visit garden_path(garden) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text garden.name end end - pending 'viewing a seed' do + pending "viewing a seed" do let(:seed) { FactoryBot.create :seed, owner: member } - scenario 'add photo' do + scenario "add photo" do visit seed_path(seed) - click_link 'Add photo' + click_link "Add photo" expect(page).to have_text seed.to_s end end diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index 4d96a0193..bac25b370 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature 'show photo page' do +feature "show photo page" do let(:photo) { create :photo } - context 'signed in member' do + context "signed in member" do let(:member) { create :member } background { login_as member } - context 'linked to planting' do + context "linked to planting" do let(:planting) { create :planting } - scenario 'shows linkback to planting' do + scenario "shows linkback to planting" do planting.photos << photo visit photo_path(photo) expect(page).to have_link "#{planting.crop.name} planting in #{planting.garden.name} by #{planting.owner}", @@ -19,30 +19,30 @@ feature 'show photo page' do end end - context 'linked to harvest' do + context "linked to harvest" do let(:harvest) { create :harvest } - scenario 'shows linkback to harvest' do + scenario "shows linkback to harvest" do harvest.photos << photo visit photo_path(photo) expect(page).to have_link "#{harvest.crop.name} harvest by #{harvest.owner}", href: harvest_path(harvest) end end - context 'linked to garden' do + context "linked to garden" do let(:garden) { create :garden } - scenario 'shows linkback to garden' do + scenario "shows linkback to garden" do garden.photos << photo visit photo_path(photo) expect(page).to have_link "garden named \"#{garden.name}\" by #{garden.owner}", href: garden_path(garden) end end - context 'linked to seed' do + context "linked to seed" do let(:seed) { create :seed } - scenario 'shows linkback to seed' do + scenario "shows linkback to seed" do seed.photos << photo visit photo_path(photo) expect(page).to have_link "#{seed.crop.name} seeds belonging to #{seed.owner}", href: seed_path(seed) diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index dd2b47712..edbb06e59 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -1,39 +1,39 @@ -require 'rails_helper' +require "rails_helper" -feature 'User searches' do - let(:member) { create :member, location: 'Philippines' } +feature "User searches" do + let(:member) { create :member, location: "Philippines" } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:seed1) { create :seed, owner: member } - let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') } + let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") } - scenario 'with a valid place' do + scenario "with a valid place" do visit places_path - search_with 'Philippines' - expect(page).to have_content 'community near Philippines' - expect(page).to have_button 'search_button' - expect(page).to have_content 'Nearby members' - expect(page).not_to have_content 'No results found' + search_with "Philippines" + expect(page).to have_content "community near Philippines" + expect(page).to have_button "search_button" + expect(page).to have_content "Nearby members" + expect(page).not_to have_content "No results found" end - scenario 'with a blank search string' do + scenario "with a blank search string" do visit places_path - search_with '' - expect(page).to have_content 'Please enter a valid location' - expect(page).to have_button 'search_button' + search_with "" + expect(page).to have_content "Please enter a valid location" + expect(page).to have_button "search_button" end - describe 'Nearby plantings, seed, and members' do + describe "Nearby plantings, seed, and members" do before do login_as member visit places_path - search_with 'Philippines' + search_with "Philippines" end - it 'should show that there are nearby seeds, plantings, and members' do - expect(page).to have_content 'Nearby members' - expect(page).to have_content 'Seeds available for trade near Philippines' - expect(page).to have_content 'Recent plantings near Philippines' + it "should show that there are nearby seeds, plantings, and members" do + expect(page).to have_content "Nearby members" + expect(page).to have_content "Seeds available for trade near Philippines" + expect(page).to have_content "Recent plantings near Philippines" end it "should go to members' index page" do @@ -55,7 +55,7 @@ feature 'User searches' do private def search_with(search_string) - fill_in 'new_place', with: search_string - click_button 'search_button' + fill_in "new_place", with: search_string + click_button "search_button" end end diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 5a9d954b8..3b407c3df 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature 'Planting reminder email', :js do +feature "Planting reminder email", :js do let(:member) { create :member } let(:mail) { Notifier.planting_reminder(member) } @@ -11,13 +11,13 @@ feature 'Planting reminder email', :js do { host: 'localhost', port: 8080 } end - scenario 'has a greeting' do - expect(mail).to have_content 'Hello' + scenario "has a greeting" do + expect(mail).to have_content "Hello" end - context 'when member has no plantings' do - scenario 'tells you to track your plantings' do - expect(mail).to have_content 'planting your first crop' + context "when member has no plantings" do + scenario "tells you to track your plantings" do + expect(mail).to have_content "planting your first crop" end scenario "doesn't list plantings" do @@ -25,41 +25,41 @@ feature 'Planting reminder email', :js do end end - context 'when member has some plantings' do + context "when member has some plantings" do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the email is generated: otherwise, they won't be present in the email. let!(:p1) { create :planting, garden: member.gardens.first, owner: member } let!(:p2) { create :planting, garden: member.gardens.first, owner: member } - scenario 'lists plantings' do + scenario "lists plantings" do expect(mail).to have_content "most recent plantings you've told us about" expect(mail).to have_link p1.to_s, href: planting_url(p1) expect(mail).to have_link p2.to_s, href: planting_url(p2) - expect(mail).to have_content 'keep your garden records up to date' + expect(mail).to have_content "keep your garden records up to date" end end - context 'when member has no harvests' do - scenario 'tells you to tracking plantings' do - expect(mail).to have_content 'Get started now by tracking your first harvest' + context "when member has no harvests" do + scenario "tells you to tracking plantings" do + expect(mail).to have_content "Get started now by tracking your first harvest" end scenario "doesn't list plantings" do - expect(mail).not_to have_content 'the last few things you harvested were' + expect(mail).not_to have_content "the last few things you harvested were" end end - context 'when member has some harvests' do + context "when member has some harvests" do # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present # in the database before the spec is run. let!(:h1) { create :harvest, owner: member } let!(:h2) { create :harvest, owner: member } - scenario 'lists harvests' do - expect(mail).to have_content 'the last few things you harvested were' + scenario "lists harvests" do + expect(mail).to have_content "the last few things you harvested were" expect(mail).to have_link h1.to_s, href: harvest_url(h1) expect(mail).to have_link h2.to_s, href: harvest_url(h2) - expect(mail).to have_content 'Harvested anything else lately?' + expect(mail).to have_content "Harvested anything else lately?" end end end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index ad1cfb5ff..0e26d7078 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,12 +1,12 @@ -require 'rails_helper' +require "rails_helper" require 'custom_matchers' -feature 'Planting a crop', :js, :elasticsearch do +feature "Planting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:planting) do - create :planting, garden: garden, owner: member, planted_at: Date.parse('2013-3-10') + create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") end background do @@ -15,15 +15,15 @@ feature 'Planting a crop', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'planting' + it_behaves_like "crop suggest", "planting" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'What did you plant?' - expect(page).to have_selector '.form-group.required', text: 'Where did you plant it?' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "What did you plant?" + expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" expect(page).to have_optional 'input#planting_planted_at' expect(page).to have_optional 'input#planting_quantity' expect(page).to have_optional 'select#planting_planted_from' @@ -32,20 +32,20 @@ feature 'Planting a crop', :js, :elasticsearch do expect(page).to have_optional 'input#planting_finished_at' end - scenario 'Creating a new planting' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2014-06-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + scenario "Creating a new planting" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2014-06-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: Not enough data" end scenario "Clicking link to owner's profile" do @@ -54,230 +54,230 @@ feature 'Planting a crop', :js, :elasticsearch do expect(current_path).to eq member_path(member) end - describe 'Progress bar status on planting creation' do + describe "Progress bar status on planting creation" do before do login_as member visit new_planting_path - @a_past_date = 15.days.ago.strftime('%Y-%m-%d') - @right_now = Time.zone.today.strftime('%Y-%m-%d') - @a_future_date = 1.year.from_now.strftime('%Y-%m-%d') + @a_past_date = 15.days.ago.strftime("%Y-%m-%d") + @right_now = Time.zone.today.strftime("%Y-%m-%d") + @a_future_date = 1.year.from_now.strftime("%Y-%m-%d") end - it 'should show that it is not planted yet' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_future_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + it "should show that it is not planted yet" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_future_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: 0% - not planted yet' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: 0% - not planted yet" end - it 'should show that days before maturity is unknown' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_past_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - click_button 'Save' + it "should show that days before maturity is unknown" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_past_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Progress: Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Progress: Not enough data" end - it 'should show that planting is in progress' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @right_now - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - fill_in 'Finished date', with: @a_future_date - click_button 'Save' + it "should show that planting is in progress" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @right_now + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + fill_in "Finished date", with: @a_future_date + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).not_to have_content 'Progress: 0% - not planted yet' - expect(page).not_to have_content 'Not enough data' + expect(page).to have_content "planting was successfully created" + expect(page).not_to have_content "Progress: 0% - not planted yet" + expect(page).not_to have_content "Not enough data" end - it 'should show that planting is 100% complete (no date specified)' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @right_now - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + it "should show that planting is 100% complete (no date specified)" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @right_now + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content '100%' - expect(page).to have_content 'Yes (no date specified)' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "100%" + expect(page).to have_content "Yes (no date specified)" end - it 'should show that planting is 100% complete (date specified)' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: @a_past_date - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'semi-shade', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - fill_in 'Finished date', with: @right_now - click_button 'Save' + it "should show that planting is 100% complete (date specified)" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: @a_past_date + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "semi-shade", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + fill_in "Finished date", with: @right_now + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content '100%' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "100%" end end - scenario 'Planting from crop page' do + scenario "Planting from crop page" do visit crop_path(maize) - click_link 'Plant this' - within 'form#new_planting' do + click_link "Plant this" + within "form#new_planting" do expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'maize' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "maize" end - scenario 'Editing a planting to add details' do + scenario "Editing a planting to add details" do visit planting_path(planting) - click_link 'Edit' - fill_in 'Tell us more about it', with: 'Some extra notes' - click_button 'Save' - expect(page).to have_content 'planting was successfully updated' + click_link "Edit" + fill_in "Tell us more about it", with: "Some extra notes" + click_button "Save" + expect(page).to have_content "planting was successfully updated" end - scenario 'Editing a planting to fill in the finished date' do + scenario "Editing a planting to fill in the finished date" do visit planting_path(planting) - expect(page).to have_content 'Progress: Not enough data' - click_link 'Edit' - check 'finished' - fill_in 'Finished date', with: '2015-06-25' - click_button 'Save' - expect(page).to have_content 'planting was successfully updated' - expect(page).not_to have_content 'Progress: Not enough data' + expect(page).to have_content "Progress: Not enough data" + click_link "Edit" + check "finished" + fill_in "Finished date", with: "2015-06-25" + click_button "Save" + expect(page).to have_content "planting was successfully updated" + expect(page).not_to have_content "Progress: Not enough data" end - scenario 'Marking a planting as finished' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When?', with: '2014-07-01' - check 'Mark as finished' - fill_in 'Finished date', with: '2014-08-30' + scenario "Marking a planting as finished" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When?", with: "2014-07-01" + check "Mark as finished" + fill_in "Finished date", with: "2014-08-30" # Trigger click instead of using Capybara"s uncheck # because a date selection widget is overlapping # the checkbox preventing interaction. - find('#planting_finished').trigger 'click' + find("#planting_finished").trigger 'click' end # Javascript removes the finished at date when the # planting is marked unfinished. - expect(find('#planting_finished_at').value).to eq('') + expect(find("#planting_finished_at").value).to eq("") - within 'form#new_planting' do - find('#planting_finished').trigger 'click' + within "form#new_planting" do + find("#planting_finished").trigger 'click' end # The finished at date was cached in Javascript in # case the user clicks unfinished accidentally. - expect(find('#planting_finished_at').value).to eq('2014-08-30') + expect(find("#planting_finished_at").value).to eq("2014-08-30") - within 'form#new_planting' do - click_button 'Save' + within "form#new_planting" do + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Finished: August 30, 2014' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Finished: August 30, 2014" # shouldn't be on the page visit plantings_path - expect(page).not_to have_content 'maize' + expect(page).not_to have_content "maize" # show all plantings to see this finished planting visit plantings_path(all: 1) - expect(page).to have_content 'August 30, 2014' + expect(page).to have_content "August 30, 2014" end - scenario 'Marking a planting as finished without a date' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - check 'Mark as finished' - click_button 'Save' + scenario "Marking a planting as finished without a date" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + check "Mark as finished" + click_button "Save" end - expect(page).to have_content 'planting was successfully created' - expect(page).to have_content 'Finished: Yes (no date specified)' - expect(page).to have_content '100%' + expect(page).to have_content "planting was successfully created" + expect(page).to have_content "Finished: Yes (no date specified)" + expect(page).to have_content "100%" end - describe 'Planting sunniness' do - it 'should show the a sunny image' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2015-10-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - select 'sun', from: 'Sun or shade?' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + describe "Planting sunniness" do + it "should show the a sunny image" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2015-10-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + select "sun", from: "Sun or shade?" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end expect(page).to have_css("img[alt='sun']") end - it 'should show a sunniness not specified image' do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_planting' do - fill_in 'When', with: '2015-10-15' - fill_in 'How many?', with: 42 - select 'cutting', from: 'Planted from:' - fill_in 'Tell us more about it', with: "It's rad." - check 'Mark as finished' - click_button 'Save' + it "should show a sunniness not specified image" do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_planting" do + fill_in "When", with: "2015-10-15" + fill_in "How many?", with: 42 + select "cutting", from: "Planted from:" + fill_in "Tell us more about it", with: "It's rad." + check "Mark as finished" + click_button "Save" end expect(page).to have_css("img[alt='not specified']") end end - describe 'Marking a planting as finished from the show page' do + describe "Marking a planting as finished from the show page" do let(:path) { planting_path(planting) } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end - describe 'Marking a planting as finished from the list page' do + describe "Marking a planting as finished from the list page" do let(:path) { plantings_path } - let(:link_text) { 'Mark as finished' } + let(:link_text) { "Mark as finished" } - it_behaves_like 'append date' + it_behaves_like "append date" end end diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index 6e1b7aa55..ac31b6fec 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -8,26 +8,26 @@ feature 'Post a post' do visit new_post_path end - scenario 'creating a post' do - fill_in 'post_subject', with: 'Testing' - fill_in 'post_body', with: 'This is a sample test' - click_button 'Post' - expect(page).to have_content 'Post was successfully created' - expect(page).to have_content 'Posted by' + scenario "creating a post" do + fill_in "post_subject", with: "Testing" + fill_in "post_body", with: "This is a sample test" + click_button "Post" + expect(page).to have_content "Post was successfully created" + expect(page).to have_content "Posted by" end - context 'editing a post' do + context "editing a post" do let(:existing_post) { create :post, author: member } background do visit edit_post_path(existing_post) end - scenario 'saving edit' do - fill_in 'post_subject', with: 'Testing Edit' - click_button 'Post' - expect(page).to have_content 'Post was successfully updated' - expect(page).to have_content 'edited at' + scenario "saving edit" do + fill_in "post_subject", with: "Testing Edit" + click_button "Post" + expect(page).to have_content "Post was successfully updated" + expect(page).to have_content "edited at" end end end diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index a7b15d1a9..59833eff1 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -8,7 +8,7 @@ feature 'Plantings RSS feed' do scenario 'The index title is what we expect' do visit plantings_path(format: 'rss') - expect(page).to have_content 'Recent plantings from '\ + expect(page).to have_content "Recent plantings from "\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 869c00214..445a50cca 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -8,7 +8,7 @@ feature 'Posts RSS feed' do scenario 'The index title is what we expect' do visit posts_path(format: 'rss') - expect(page).to have_content 'Recent posts from '\ + expect(page).to have_content "Recent posts from "\ "#{@author ? @author : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index d4981aea5..888cc42ec 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -8,7 +8,7 @@ feature 'Seeds RSS feed' do scenario 'The index title is what we expect' do visit seeds_path(format: 'rss') - expect(page).to have_content 'Recent seeds from '\ + expect(page).to have_content "Recent seeds from "\ "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index a232b9d0d..d6daf709b 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -feature 'Scientific names', js: true do +feature "Scientific names", js: true do let!(:zea_mays) { create :zea_mays } let(:crop) { zea_mays.crop } - scenario 'Display scientific names on crop page' do + scenario "Display scientific names on crop page" do visit crop_path(zea_mays.crop) expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - scenario 'Index page for scientific names' do + scenario "Index page for scientific names" do visit scientific_names_path expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - context 'User is a crop wrangler' do + context "User is a crop wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } @@ -24,59 +24,59 @@ feature 'Scientific names', js: true do login_as(member) end - scenario 'Crop wranglers can edit scientific names' do + scenario "Crop wranglers can edit scientific names" do visit crop_path(crop) expect(page.status_code).to equal 200 - expect(page).to have_content 'CROP WRANGLER' + expect(page).to have_content "CROP WRANGLER" expect(page).to have_content zea_mays.name - expect(page).to have_link 'Edit', href: edit_scientific_name_path(zea_mays) - within('.scientific_names') { click_on 'Edit' } + expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays) + within('.scientific_names') { click_on "Edit" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'Zea mirabila' - click_on 'Save' - expect(page).to have_content 'Zea mirabila' + fill_in 'Name', with: "Zea mirabila" + click_on "Save" + expect(page).to have_content "Zea mirabila" expect(page).to have_content 'crop was successfully updated' end - scenario 'Crop wranglers can delete scientific names' do + scenario "Crop wranglers can delete scientific names" do visit crop_path(zea_mays.crop) - expect(page).to have_link 'Delete', + expect(page).to have_link "Delete", href: scientific_name_path(zea_mays) - within('.scientific_names') { click_on 'Delete' } + within('.scientific_names') { click_on "Delete" } expect(page.status_code).to equal 200 expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' end - scenario 'Crop wranglers can add scientific names' do + scenario "Crop wranglers can add scientific names" do visit crop_path(crop) - expect(page).to have_link 'Add', + expect(page).to have_link "Add", href: new_scientific_name_path(crop_id: crop.id) - within('.scientific_names') { click_on 'Add' } + within('.scientific_names') { click_on "Add" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" - fill_in 'Name', with: 'Zea mirabila' - click_on 'Save' + fill_in 'Name', with: "Zea mirabila" + click_on "Save" expect(page.status_code).to equal 200 - expect(page).to have_content 'Zea mirabila' + expect(page).to have_content "Zea mirabila" expect(page).to have_content 'crop was successfully created.' end - scenario 'The show-scientific-name page works' do + scenario "The show-scientific-name page works" do visit scientific_name_path(zea_mays) expect(page.status_code).to equal 200 expect(page).to have_link zea_mays.crop.name, href: crop_path(zea_mays.crop) end - context 'When scientific name is pending' do + context "When scientific name is pending" do let(:pending_crop) { create :crop_request } let(:pending_sci_name) { create :scientific_name, crop: pending_crop } - scenario 'Displays crop pending message' do + scenario "Displays crop pending message" do visit scientific_name_path(pending_sci_name) - expect(page).to have_content 'This crop is currently pending approval' + expect(page).to have_content "This crop is currently pending approval" end end end diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index d1f6acfac..4c183ae24 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Seeds', :js, :elasticsearch do +feature "Seeds", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } @@ -11,14 +11,14 @@ feature 'Seeds', :js, :elasticsearch do sync_elasticsearch [maize] end - it_behaves_like 'crop suggest', 'seed', 'crop' + it_behaves_like "crop suggest", "seed", "crop" - it 'has the required fields help text' do - expect(page).to have_content '* denotes a required field' + it "has the required fields help text" do + expect(page).to have_content "* denotes a required field" end - it 'displays required and optional fields properly' do - expect(page).to have_selector '.form-group.required', text: 'Crop:' + it "displays required and optional fields properly" do + expect(page).to have_selector ".form-group.required", text: "Crop:" expect(page).to have_optional 'input#seed_quantity' expect(page).to have_optional 'input#seed_plant_before' expect(page).to have_optional 'input#seed_days_until_maturity_min' @@ -30,40 +30,40 @@ feature 'Seeds', :js, :elasticsearch do expect(page).to have_selector '.form-group.required', text: 'Will trade:' end - scenario 'Adding a new seed', js: true do - fill_autocomplete 'crop', with: 'mai' - select_from_autocomplete 'maize' - within 'form#new_seed' do - fill_in 'Quantity:', with: 42 - fill_in 'Plant before:', with: '2014-06-15' - fill_in 'Days until maturity:', with: 999 - fill_in 'to', with: 1999 - select 'certified organic', from: 'Organic?' - select 'non-certified GMO-free', from: 'GMO?' - select 'heirloom', from: 'Heirloom?' - fill_in 'Description', with: "It's killer." - select 'internationally', from: 'Will trade:' - click_button 'Save' + scenario "Adding a new seed", js: true do + fill_autocomplete "crop", with: "mai" + select_from_autocomplete "maize" + within "form#new_seed" do + fill_in "Quantity:", with: 42 + fill_in "Plant before:", with: "2014-06-15" + fill_in "Days until maturity:", with: 999 + fill_in "to", with: 1999 + select "certified organic", from: "Organic?" + select "non-certified GMO-free", from: "GMO?" + select "heirloom", from: "Heirloom?" + fill_in "Description", with: "It's killer." + select "internationally", from: "Will trade:" + click_button "Save" end - expect(page).to have_content 'Successfully added maize seed to your stash' - expect(page).to have_content 'Quantity: 42' - expect(page).to have_content 'Days until maturity: 999–1999' - expect(page).to have_content 'certified organic' - expect(page).to have_content 'non-certified GMO-free' - expect(page).to have_content 'Heirloom? heirloom' + expect(page).to have_content "Successfully added maize seed to your stash" + expect(page).to have_content "Quantity: 42" + expect(page).to have_content "Days until maturity: 999–1999" + expect(page).to have_content "certified organic" + expect(page).to have_content "non-certified GMO-free" + expect(page).to have_content "Heirloom? heirloom" expect(page).to have_content "It's killer." end - scenario 'Adding a seed from crop page' do + scenario "Adding a seed from crop page" do visit crop_path(maize) - click_link 'Add seeds to stash' - within 'form#new_seed' do + click_link "Add seeds to stash" + within "form#new_seed" do expect(page).to have_selector "input[value='maize']" - click_button 'Save' + click_button "Save" end - expect(page).to have_content 'Successfully added maize seed to your stash' - expect(page).to have_content 'maize' + expect(page).to have_content "Successfully added maize seed to your stash" + expect(page).to have_content "maize" end end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 824a2f5c7..1db053a80 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'seeds', js: true do - context 'signed in user' do +feature "seeds", js: true do + context "signed in user" do let(:member) { create :member } let(:crop) { create :crop } @@ -9,17 +9,17 @@ feature 'seeds', js: true do login_as member end - scenario 'button on index to edit seed' do + scenario "button on index to edit seed" do seed = create :seed, owner: member visit seeds_path - click_link 'edit_seed_glyphicon' + click_link "edit_seed_glyphicon" expect(current_path).to eq edit_seed_path(seed) expect(page).to have_content 'Editing seeds' end - scenario 'button on front page to add seeds' do + scenario "button on front page to add seeds" do visit root_path - click_link 'Add seeds' + click_link "Add seeds" expect(current_path).to eq new_seed_path expect(page).to have_content 'Add seeds' end @@ -32,7 +32,7 @@ feature 'seeds', js: true do # actually adding seeds is in spec/features/seeds_new_spec.rb - scenario 'edit seeds' do + scenario "edit seeds" do seed = create :seed, owner: member visit seed_path(seed) click_link 'Edit' @@ -42,35 +42,35 @@ feature 'seeds', js: true do expect(current_path).to eq seed_path(seed) end - scenario 'delete seeds' do + scenario "delete seeds" do seed = create :seed, owner: member visit seed_path(seed) click_link 'Delete' expect(current_path).to eq seeds_path end - scenario 'view seeds with max and min days until maturity' do + scenario "view seeds with max and min days until maturity" do seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 5–7' + expect(page).to have_content "Days until maturity: 5–7" end - scenario 'view seeds with only max days until maturity' do + scenario "view seeds with only max days until maturity" do seed = create :seed, days_until_maturity_max: 7 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 7' + expect(page).to have_content "Days until maturity: 7" end - scenario 'view seeds with only min days until maturity' do + scenario "view seeds with only min days until maturity" do seed = create :seed, days_until_maturity_min: 5 visit seed_path(seed) - expect(page).to have_content 'Days until maturity: 5' + expect(page).to have_content "Days until maturity: 5" end - scenario 'view seeds with neither max nor min days until maturity' do + scenario "view seeds with neither max nor min days until maturity" do seed = create :seed visit seed_path(seed) - expect(page).to have_content 'Days until maturity: unknown' + expect(page).to have_content "Days until maturity: unknown" end end end diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index d0bd8531b..7e26ece28 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature 'Seeds', :js do +feature "Seeds", :js do subject do login_as member visit seed_path(seed) @@ -26,16 +26,16 @@ feature 'Seeds', :js do before { seed.photos = photos } let!(:photos) { FactoryBot.create_list :photo, 50 } - it 'shows newest photo' do + it "shows newest photo" do is_expected.to have_xpath("//img[contains(@src,'#{photos.last.thumbnail_url}')]") end - it 'links to newest photo' do + it "links to newest photo" do is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photos.last)}')]") end - it 'does not show oldest photo' do + it "does not show oldest photo" do is_expected.not_to have_xpath("//img[contains(@src,'#{photos.first.thumbnail_url}')]") end - it 'does not link to oldest photo' do + it "does not link to oldest photo" do is_expected.not_to have_xpath("//a[contains(@href,'#{photo_path(photos.first)}')]") end end diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index eda8257ba..03e29c5f4 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -1,21 +1,21 @@ -shared_examples 'append date' do - let(:this_month) { Time.zone.today.strftime('%B') } - let(:this_year) { Time.zone.today.strftime('%Y') } +shared_examples "append date" do + let(:this_month) { Time.zone.today.strftime("%B") } + let(:this_year) { Time.zone.today.strftime("%Y") } background { visit path } - scenario 'Selecting a date with datepicker' do + scenario "Selecting a date with datepicker" do click_link link_text - within 'div.datepicker' do + within "div.datepicker" do expect(page).to have_content this_month.to_s - find('.datepicker-days td.day', text: '21').click + find(".datepicker-days td.day", text: "21").click end expect(page).to have_content "Finished: #{this_month} 21, #{this_year}" end - scenario 'Confirming without selecting date' do + scenario "Confirming without selecting date" do click_link link_text - click_link 'Confirm without date' - expect(page).to have_content('Finished: Yes (no date specified) ') + click_link "Confirm without date" + expect(page).to have_content("Finished: Yes (no date specified) ") end end diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 5bd51205d..0d2e688a1 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -1,6 +1,6 @@ require 'rails_helper' -shared_examples 'crop suggest' do |resource| +shared_examples "crop suggest" do |resource| let!(:pea) { create :crop, name: 'pea' } let!(:pear) { create :pear } let!(:tomato) { create :tomato } @@ -8,66 +8,66 @@ shared_examples 'crop suggest' do |resource| background { sync_elasticsearch [pea, pear, maize, tomato] } - scenario 'placeholder text in crop auto suggest field' do + scenario "placeholder text in crop auto suggest field" do expect(page).to have_selector("input[placeholder='e.g. lettuce']") end - scenario 'typing in the crop name displays suggestions' do + scenario "typing in the crop name displays suggestions" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pe' + fill_autocomplete "crop", with: "pe" end - expect(page).not_to have_content('pear') - expect(page).not_to have_content('pea') + expect(page).not_to have_content("pear") + expect(page).not_to have_content("pea") within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pea' + fill_autocomplete "crop", with: "pea" end - expect(page).to have_content('pear') - expect(page).to have_content('pea') + expect(page).to have_content("pear") + expect(page).to have_content("pea") within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pear' + fill_autocomplete "crop", with: "pear" end - expect(page).to have_content('pear') + expect(page).to have_content("pear") end - scenario 'selecting crop from dropdown' do + scenario "selecting crop from dropdown" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pear' + fill_autocomplete "crop", with: "pear" end - select_from_autocomplete('pear') + select_from_autocomplete("pear") expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", visible: false) end - scenario 'Typing and pausing does not affect input' do + scenario "Typing and pausing does not affect input" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'pea' + fill_autocomplete "crop", with: "pea" end - expect(page).to have_content('pear') - expect(find_field('crop').value).to eq('pea') + expect(page).to have_content("pear") + expect(find_field("crop").value).to eq("pea") end - scenario 'Searching for a crop casts a wide net on results' do + scenario "Searching for a crop casts a wide net on results" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'tom' + fill_autocomplete "crop", with: "tom" end - expect(page).to have_content('tomato') - expect(page).to have_content('roma tomato') + expect(page).to have_content("tomato") + expect(page).to have_content("roma tomato") end scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do within "form#new_#{resource}" do - fill_autocomplete 'crop', with: 'Ryan Gosling' - click_button 'Save' + fill_autocomplete "crop", with: "Ryan Gosling" + click_button "Save" end - expect(page).to have_content('Crop must be present and exist in our database') + expect(page).to have_content("Crop must be present and exist in our database") end end diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index e2817517b..acd9f5295 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'signin', js: true do +feature "signin", js: true do let(:member) { create :member } let(:recipient) { create :member } let(:wrangler) { create :crop_wrangling_member } @@ -12,14 +12,14 @@ feature 'signin', js: true do click_button 'Sign in' end - scenario 'via email address' do + scenario "via email address" do visit crops_path # some random page click_link 'Sign in' login - expect(page).to have_content('Sign out') + expect(page).to have_content("Sign out") end - scenario 'redirect to previous page after signin' do + scenario "redirect to previous page after signin" do visit crops_path # some random page click_link 'Sign in' login @@ -33,12 +33,12 @@ feature 'signin', js: true do expect(current_path).to eq root_path end - scenario 'redirect to signin page for if not authenticated to view notification' do + scenario "redirect to signin page for if not authenticated to view notification" do visit notification_path(notification) expect(current_path).to eq new_member_session_path end - shared_examples 'redirects to what you were trying to do' do + shared_examples "redirects to what you were trying to do" do scenario do visit "/#{model_name}/new" expect(current_path).to eq new_member_session_path @@ -47,33 +47,33 @@ feature 'signin', js: true do end end - describe 'redirects to what you were trying to do' do + describe "redirects to what you were trying to do" do %w(plantings harvests posts photos gardens seeds).each do |m| - it_behaves_like 'redirects to what you were trying to do' do + it_behaves_like "redirects to what you were trying to do" do let(:model_name) { m } end end end - scenario 'after signin, redirect to new notifications page' do + scenario "after signin, redirect to new notifications page" do visit new_notification_path(recipient: recipient) expect(current_path).to eq new_member_session_path login expect(current_path).to eq new_notification_path end - scenario 'after crop wrangler signs in and crops await wrangling, show alert' do + scenario "after crop wrangler signs in and crops await wrangling, show alert" do create :crop_request visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: wrangler.login_name fill_in 'Password', with: wrangler.password click_button 'Sign in' - expect(page).to have_content('There are crops waiting to be wrangled.') + expect(page).to have_content("There are crops waiting to be wrangled.") end - context 'with facebook' do - scenario 'sign in' do + context "with facebook" do + scenario "sign in" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index e97d31db2..35cd8af9b 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature 'signout' do +feature "signout" do let(:member) { create :member } - scenario 'redirect to previous page after signout' do + scenario "redirect to previous page after signout" do visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: member.login_name @@ -13,8 +13,8 @@ feature 'signout' do expect(current_path).to eq crops_path end - shared_examples 'sign-in redirects' do |path| - scenario 'after signout, redirect to signin page if page needs authentication' do + shared_examples "sign-in redirects" do |path| + scenario "after signout, redirect to signin page if page needs authentication" do visit path expect(current_path).to eq new_member_session_path expect(page).to have_http_status(200) @@ -32,11 +32,11 @@ feature 'signout' do let(:path) {} describe 'after signout, redirect to signin page if page needs authentication' do - include_examples 'sign-in redirects', '/plantings/new' - include_examples 'sign-in redirects', '/harvests/new' - include_examples 'sign-in redirects', '/posts/new' - include_examples 'sign-in redirects', '/gardens/new' - include_examples 'sign-in redirects', '/seeds/new' + include_examples "sign-in redirects", "/plantings/new" + include_examples "sign-in redirects", "/harvests/new" + include_examples "sign-in redirects", "/posts/new" + include_examples "sign-in redirects", "/gardens/new" + include_examples "sign-in redirects", "/seeds/new" end scenario 'photos' do diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 968158879..6afb28119 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature 'signup', js: true do - scenario 'sign up for new account from top menubar' do +feature "signup", js: true do + scenario "sign up for new account from top menubar" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -13,7 +13,7 @@ feature 'signup', js: true do expect(current_path).to eq root_path end - scenario 'sign up for new account with existing username' do + scenario "sign up for new account with existing username" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -32,7 +32,7 @@ feature 'signup', js: true do click_button 'Sign up' end - scenario 'sign up for new account without accepting TOS' do + scenario "sign up for new account without accepting TOS" do visit root_path first('.signup a').click # click the 'Sign up' button in the middle of the page fill_in 'Login name', with: 'person123' @@ -44,8 +44,8 @@ feature 'signup', js: true do expect(current_path).to eq members_path end - context 'with facebook' do - scenario 'sign up' do + context "with facebook" do + scenario "sign up" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all Member.where(email: 'tdawg@hotmail.com').delete_all diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 96dfa92de..8244d207a 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature 'unsubscribe' do +feature "unsubscribe" do let(:member) { create :member } let(:notification) { create :notification } @@ -9,7 +9,7 @@ feature 'unsubscribe' do clear_emails end - scenario 'from planting reminder mailing list' do + scenario "from planting reminder mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -20,13 +20,13 @@ feature 'unsubscribe' do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from planting reminders' - expect(page).to have_content 'You have been unsubscribed from planting reminders' + expect(page).to have_content "You have been unsubscribed from planting reminders" updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(false) expect(updated_member.send_notification_email).to eq(true) end - scenario 'from inbox notification mailing list' do + scenario "from inbox notification mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -38,13 +38,13 @@ feature 'unsubscribe' do # clicking 'Unsubscribe' link will unsubscribe the member current_email.click_link 'Unsubscribe from direct message notifications' - expect(page).to have_content 'You have been unsubscribed from direct message notifications' + expect(page).to have_content "You have been unsubscribed from direct message notifications" updated_member = Member.find(member.id) # reload the member expect(updated_member.send_planting_reminder).to eq(true) expect(updated_member.send_notification_email).to eq(false) end - scenario 'visit unsubscribe page with a non-encrypted parameter' do + scenario "visit unsubscribe page with a non-encrypted parameter" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 64369860f..b3ea0ce52 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe ApplicationHelper do - it 'formats prices' do + it "formats prices" do price_in_dollars(999).should eq '9.99' price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency) end - it 'parses dates' do + it "parses dates" do parse_date(nil).should eq nil parse_date('').should eq nil parse_date('2012-05-12').should eq Date.new(2012, 5, 12) parse_date('may 12th 2012').should eq Date.new(2012, 5, 12) end - it 'shows required field marker help text with proper formatting' do + it "shows required field marker help text with proper formatting" do output = required_field_help_text expect(output).to have_selector '.margin-bottom' expect(output).to have_selector '.red', text: '*' diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb index d47fd90cd..49a570836 100644 --- a/spec/helpers/crops_helper_spec.rb +++ b/spec/helpers/crops_helper_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe CropsHelper do - describe 'display_seed_availability' do + describe "display_seed_availability" do before :each do @member = create :member @crop = create :tomato end - context 'with no seeds' do + context "with no seeds" do it 'should render' do expect(helper.display_seed_availability(@member, @crop)).to eq "You don't have any seeds of this crop." end end - context 'with an unknown quantity of seeds' do + context "with an unknown quantity of seeds" do before do create :seed, crop: @crop, quantity: nil, owner: @member end @@ -21,11 +21,11 @@ describe CropsHelper do it 'should render' do expect( helper.display_seed_availability(@member, @crop) - ).to eq 'You have an unknown quantity of seeds of this crop.' + ).to eq "You have an unknown quantity of seeds of this crop." end end - context 'with an quantity of seeds' do + context "with an quantity of seeds" do before do a_different_crop = create :apple @@ -36,7 +36,7 @@ describe CropsHelper do end it 'should render' do - expect(helper.display_seed_availability(@member, @crop)).to eq 'You have 33 seeds of this crop.' + expect(helper.display_seed_availability(@member, @crop)).to eq "You have 33 seeds of this crop." end end end diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb index bfb9e1bbc..c22b51b79 100644 --- a/spec/helpers/gardens_helper_spec.rb +++ b/spec/helpers/gardens_helper_spec.rb @@ -1,55 +1,55 @@ require 'rails_helper' describe GardensHelper do - describe 'garden description' do - it 'is missing' do + describe "garden description" do + it "is missing" do garden = FactoryBot.create(:garden, description: nil) result = helper.display_garden_description(garden) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 20) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 130) result = helper.display_garden_description(garden) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do garden = FactoryBot.create(:garden, description: 'a' * 140) result = helper.display_garden_description(garden) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', garden_path(garden)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", garden_path(garden)) end end - describe 'garden plantings' do - it 'is missing' do + describe "garden plantings" do + it "is missing" do result = helper.display_garden_plantings(nil) - expect(result).to eq 'None' + expect(result).to eq "None" end - it 'has 1 planting' do + it "has 1 planting" do crop = FactoryBot.create(:crop) plantings = [FactoryBot.create(:planting, quantity: 10, crop: crop)] result = helper.display_garden_plantings(plantings) output = '
    • ' - output += '10 ' + link_to(crop.name, crop) + output += "10 " + link_to(crop.name, crop) output += ", planted on #{plantings.first.planted_at}" - output += '
    ' + output += "
" expect(result).to eq output end - it 'has 2 plantings' do + it "has 2 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -61,17 +61,17 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += '10 ' + link_to(crop1.name, crop1) + output += "10 " + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += '
  • ' - output += '
  • ' - output += '10 ' + link_to(crop2.name, crop2) + output += "
  • " + output += "
  • " + output += "10 " + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += '
' + output += "" expect(result).to eq output end - it 'has 3 plantings' do + it "has 3 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -86,13 +86,13 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '
  • ' - output += '10 ' + link_to(crop1.name, crop1) + output += "10 " + link_to(crop1.name, crop1) output += ", planted on #{plantings.first.planted_at}" - output += '
  • ' - output += '
  • ' - output += '10 ' + link_to(crop2.name, crop2) + output += "
  • " + output += "
  • " + output += "10 " + link_to(crop2.name, crop2) output += ", planted on #{plantings.first.planted_at}" - output += '
' + output += "" expect(result).to eq output end end diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index a234bc260..1ba63810d 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe HarvestsHelper do - describe 'display_quantity' do - it 'blank' do + describe "display_quantity" do + it "blank" do harvest = FactoryBot.create(:harvest, quantity: nil, weight_quantity: nil) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 8281b3712..a00dabff3 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' describe NotificationsHelper do - describe 'reply_link' do + describe "reply_link" do let(:member) { FactoryBot.create(:member) } - it 'replies to PMs with PMs' do + it "replies to PMs with PMs" do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil link.should eq reply_notification_url(notification) end - it 'replies to post comments with post comments' do + it "replies to post comments with post comments" do notification = FactoryBot.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index acde7469f..3af084d5a 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,64 +1,64 @@ require 'rails_helper' describe PlantingsHelper do - describe 'display_planting' do + describe "display_planting" do let!(:member) { FactoryBot.build(:member, login_name: 'crop_lady') } - it 'does not have a quantity nor a planted from value provided' do + it "does not have a quantity nor a planted from value provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady.' + expect(result).to eq "crop_lady." end - it 'does not have a quantity provided' do + it "does not have a quantity provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted seeds.' + expect(result).to eq "crop_lady planted seeds." end - context 'when quantity is greater than 1' do - it 'does not have a planted from value provided' do + context "when quantity is greater than 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 10, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 10 units.' + expect(result).to eq "crop_lady planted 10 units." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 5, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 5 seeds.' + expect(result).to eq "crop_lady planted 5 seeds." end end - context 'when quantity is 1' do - it 'does not have a planted from value provided' do + context "when quantity is 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 unit.' + expect(result).to eq "crop_lady planted 1 unit." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 seed.' + expect(result).to eq "crop_lady planted 1 seed." end end end diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 837e1368a..3d559058e 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,33 +1,33 @@ require 'rails_helper' describe SeedsHelper do - describe 'seed description' do - it 'is missing' do + describe "seed description" do + it "is missing" do seed = FactoryBot.create(:seed, description: nil) result = helper.display_seed_description(seed) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 20) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 130) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 140) result = helper.display_seed_description(seed) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', seed_path(seed)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed)) end end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index a6f7958b1..1710428a4 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -17,8 +17,8 @@ describe 'Growstuff::OauthSignupAction' do 'image' => 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, 'credentials' => { - 'token' => 'token', - 'secret' => 'donttell' + 'token' => "token", + 'secret' => "donttell" }) end diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 4677f596c..415751293 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -10,8 +10,8 @@ describe 'Haml::Filters::Escaped_Markdown' do end it 'converts Markdown to escaped HTML' do - rendered = Haml::Filters::EscapedMarkdown.render('**foo**') - rendered.should == '<p><strong>foo</strong></p>' + rendered = Haml::Filters::EscapedMarkdown.render("**foo**") + rendered.should == "<p><strong>foo</strong></p>" end it 'converts quick crop links' do diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 6c92c5e6d..03ad3b0e1 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -35,17 +35,17 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent crops" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('not a crop')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_link("not a crop")) expect(rendered).to match(/not a crop/) end it "doesn't convert escaped crop links" do @crop = FactoryBot.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) expect(rendered).to match(/\[#{@crop.name}\]\(crop\)/) end - it 'handles multiple crop links' do + it "handles multiple crop links" do tomato = FactoryBot.create(:tomato) maize = FactoryBot.create(:maize) string = "#{input_link(tomato)} #{input_link(maize)}" @@ -53,24 +53,24 @@ describe 'Haml::Filters::Growstuff_Markdown' do expect(rendered).to match(/#{output_link(tomato)} #{output_link(maize)}/) end - it 'converts normal markdown' do - string = '**foo**' + it "converts normal markdown" do + string = "**foo**" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/foo<\/strong>/) end - it 'finds crops case insensitively' do + it "finds crops case insensitively" do @crop = FactoryBot.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end - it 'fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)' do + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do tomato = FactoryBot.create(:tomato) - string = '[test](http://example.com) [tomato](crop)' + string = "[test](http://example.com) [tomato](crop)" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/#{output_link(tomato)}/) - expect(rendered).to match 'test' + expect(rendered).to match "test" end it 'converts quick member links' do @@ -80,13 +80,13 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent members" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link('not a member')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member")) expect(rendered).to include('not a member') end it "doesn't convert escaped members" do @member = FactoryBot.create(:member) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_member_link(@member.login_name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name)) expect(rendered).to match(/\[#{@member.login_name}\]\(member\)/) end @@ -97,7 +97,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert invalid @ members" do - rendered = Haml::Filters::GrowstuffMarkdown.render('@notamember') + rendered = Haml::Filters::GrowstuffMarkdown.render("@notamember") expect(rendered).to include('@notamember') end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 344b26e7f..e50682700 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" describe Notifier do - describe 'notifications' do + describe "notifications" do let(:notification) { FactoryBot.create(:notification) } let(:mail) { Notifier.notify(notification) } @@ -18,12 +18,12 @@ describe Notifier do end end - describe 'planting reminders' do + describe "planting reminders" do let(:member) { FactoryBot.create(:member) } let(:mail) { Notifier.planting_reminder(member) } it 'sets the subject correctly' do - mail.subject.should == 'What have you planted lately?' + mail.subject.should == "What have you planted lately?" end it 'comes from noreply@growstuff.org' do @@ -43,7 +43,7 @@ describe Notifier do end end - describe 'new crop request' do + describe "new crop request" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop_request) } let(:mail) { Notifier.new_crop_request(member, crop) } @@ -65,13 +65,13 @@ describe Notifier do end end - describe 'crop approved' do + describe "crop approved" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:crop) } let(:mail) { Notifier.crop_request_approved(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Magic bean has been approved' + expect(mail.subject).to eq "Magic bean has been approved" end it 'comes from noreply@growstuff.org' do @@ -93,13 +93,13 @@ describe Notifier do end end - describe 'crop rejected' do + describe "crop rejected" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:rejected_crop) } let(:mail) { Notifier.crop_request_rejected(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Fail bean has been rejected' + expect(mail.subject).to eq "Fail bean has been rejected" end it 'comes from noreply@growstuff.org' do @@ -115,7 +115,7 @@ describe Notifier do end it 'includes the reason for rejection' do - expect(mail.body.encoded).to match 'Totally fake' + expect(mail.body.encoded).to match "Totally fake" end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index d69b0ba57..ef746c8bc 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -5,7 +5,7 @@ describe Ability do let(:member) { FactoryBot.create(:member) } let(:ability) { Ability.new(member) } - context 'notifications' do + context "notifications" do it 'member can view their own notifications' do notification = FactoryBot.create(:notification, recipient: member) ability.should be_able_to(:read, notification) @@ -22,7 +22,7 @@ describe Ability do recipient: member, sender: member)) end - it 'member can send messages to someone else' do + it "member can send messages to someone else" do ability.should be_able_to(:create, FactoryBot.create(:notification, recipient: FactoryBot.create(:member), @@ -30,51 +30,51 @@ describe Ability do end end - context 'crop wrangling' do + context "crop wrangling" do let(:crop) { FactoryBot.create(:crop) } - context 'standard member' do + context "standard member" do it "can't manage crops" do ability.should_not be_able_to(:update, crop) ability.should_not be_able_to(:destroy, crop) end - it 'can request crops' do + it "can request crops" do ability.should be_able_to(:create, Crop) end - it 'can read crops' do + it "can read crops" do ability.should be_able_to(:read, crop) end end - context 'crop wrangler' do + context "crop wrangler" do let(:role) { FactoryBot.create(:crop_wrangler) } before(:each) do member.roles << role end - it 'has crop_wrangler role' do + it "has crop_wrangler role" do member.role?(:crop_wrangler).should be true end - it 'can create crops' do + it "can create crops" do ability.should be_able_to(:create, Crop) end - it 'can update crops' do + it "can update crops" do ability.should be_able_to(:update, crop) end - it 'can destroy crops' do + it "can destroy crops" do ability.should be_able_to(:destroy, crop) end end end - context 'products' do + context "products" do let(:product) { FactoryBot.create(:product) } - context 'standard member' do + context "standard member" do it "can't read or manage products" do ability.should_not be_able_to(:read, product) ability.should_not be_able_to(:create, Product) @@ -83,33 +83,33 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read products' do + it "can read products" do ability.should be_able_to(:read, product) end - it 'can create products' do + it "can create products" do ability.should be_able_to(:create, Product) end - it 'can update products' do + it "can update products" do ability.should be_able_to(:update, product) end - it 'can destroy products' do + it "can destroy products" do ability.should be_able_to(:destroy, product) end end end - context 'orders' do + context "orders" do let(:order) { FactoryBot.create(:order, member: member) } let(:strangers_order) do FactoryBot.create(:order, @@ -129,8 +129,8 @@ describe Ability do order: completed_order) end - context 'standard member' do - it 'can read their own orders' do + context "standard member" do + it "can read their own orders" do ability.should be_able_to(:read, order) ability.should be_able_to(:read, completed_order) end @@ -139,11 +139,11 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order) end - it 'can create a new order' do + it "can create a new order" do ability.should be_able_to(:create, Order) end - it 'can complete their own current order' do + it "can complete their own current order" do ability.should be_able_to(:complete, order) end @@ -155,7 +155,7 @@ describe Ability do ability.should_not be_able_to(:complete, completed_order) end - it 'can delete a current order' do + it "can delete a current order" do ability.should be_able_to(:destroy, order) end @@ -176,7 +176,7 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order_item) end - it 'can create a new order item' do + it "can create a new order item" do ability.should be_able_to(:create, OrderItem) end @@ -205,30 +205,30 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read orders' do + it "can read orders" do ability.should be_able_to(:read, order) end - it 'cannot create orders' do + it "cannot create orders" do ability.should_not be_able_to(:create, order) end - it 'cannot complete orders' do + it "cannot complete orders" do ability.should_not be_able_to(:complete, order) end - it 'cannot delete orders' do + it "cannot delete orders" do ability.should_not be_able_to(:destroy, order) end end @@ -255,10 +255,10 @@ describe Ability do member.roles << role end - it 'can read account details' do + it "can read account details" do ability.should be_able_to(:read, account) end - it 'can manage account details' do + it "can manage account details" do ability.should be_able_to(:create, Account) ability.should be_able_to(:update, account) ability.should be_able_to(:destroy, account) @@ -270,7 +270,7 @@ describe Ability do let(:plant_part) { FactoryBot.create(:plant_part) } context 'ordinary member' do - it 'can read plant parts' do + it "can read plant parts" do ability.should be_able_to(:read, plant_part) end it "can't manage plant parts" do @@ -287,15 +287,15 @@ describe Ability do member.roles << role end - it 'can read plant_part details' do + it "can read plant_part details" do ability.should be_able_to(:read, plant_part) end - it 'can manage plant_part details' do + it "can manage plant_part details" do ability.should be_able_to(:create, PlantPart) ability.should be_able_to(:update, plant_part) end - it 'can delete an unused plant part' do + it "can delete an unused plant part" do ability.should be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 915750eaa..15eb68084 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Account do let(:member) { FactoryBot.create(:member) } - it 'auto-creates an account detail record when a member is created' do + it "auto-creates an account detail record when a member is created" do member.account.should be_an_instance_of Account end @@ -17,7 +17,7 @@ describe Account do member.account.paid_until_string.should eq nil member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq 'forever' + member.account.paid_until_string.should eq "forever" member.account.account_type = FactoryBot.create(:paid_account_type) @time = Time.zone.now diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index 64e483446..f358a9fca 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,7 +10,7 @@ describe AlternateName do it 'should be possible to add multiple alternate names to a crop' do crop = an.crop an2 = AlternateName.create( - name: 'really alternative tomato', + name: "really alternative tomato", crop_id: crop.id, creator_id: an.creator.id ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 593d0da1b..bc90ee8ba 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' describe Comment do - context 'basic' do + context "basic" do let(:comment) { FactoryBot.create(:comment) } - it 'belongs to a post' do + it "belongs to a post" do comment.post.should be_an_instance_of Post end - it 'belongs to an author' do + it "belongs to an author" do comment.author.should be_an_instance_of Member end end - context 'notifications' do + context "notifications" do let(:comment) { FactoryBot.create(:comment) } - it 'sends a notification when a comment is posted' do + it "sends a notification when a comment is posted" do expect do FactoryBot.create(:comment) end.to change(Notification, :count).by(1) end - it 'sets the notification fields' do + it "sets the notification fields" do @c = FactoryBot.create(:comment) @n = Notification.first @n.sender.should eq @c.author @@ -41,7 +41,7 @@ describe Comment do end end - context 'ordering' do + context "ordering" do before(:each) do @m = FactoryBot.create(:member) @p = FactoryBot.create(:post, author: @m) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 254573e80..3f49a249d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -11,8 +11,8 @@ describe Crop do it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') - @crop2.en_wikipedia_url.should eq('http://en.wikipedia.org/wiki/Tomato') - @crop2.slug.should eq('tomato') + @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") + @crop2.slug.should eq("tomato") end it 'should stringify as the system name' do @@ -54,7 +54,7 @@ describe Crop do FactoryBot.create_list(:planting, 3, crop: tomato) end - it 'sorts by most plantings' do + it "sorts by most plantings" do Crop.popular.first.should eq maize FactoryBot.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato @@ -77,7 +77,7 @@ describe Crop do @crop.plantings.size.should eq 1 end - context 'wikipedia url' do + context "wikipedia url" do subject { FactoryBot.build(:tomato, en_wikipedia_url: wikipedia_url) } context 'not a url' do @@ -116,7 +116,7 @@ describe Crop do it { expect(subject).not_to be_valid } end - context 'with script tags in url' do + context "with script tags in url" do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } it { expect(subject).not_to be_valid } @@ -331,13 +331,13 @@ describe Crop do let(:pp1) { FactoryBot.create(:plant_part) } let(:pp2) { FactoryBot.create(:plant_part) } - context 'harvests' do + context "harvests" do let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } - it 'has harvests' do + it "has harvests" do expect(crop.harvests).to eq [harvest] end end @@ -350,21 +350,21 @@ describe Crop do @maize.plant_parts.should eq [@pp1] end - context 'search', :elasticsearch do + context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } before { sync_elasticsearch([mushroom]) } - it 'finds exact matches' do + it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] end - it 'finds approximate matches' do + it "finds approximate matches" do Crop.search('mush').should eq [mushroom] end it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end - it 'searches case insensitively' do + it "searches case insensitively" do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do @@ -379,141 +379,141 @@ describe Crop do end end - context 'csv loading' do + context "csv loading" do before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) end - context 'scientific names' do - it 'adds a scientific name to a crop that has none' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar'] + context "scientific names" do + it "adds a scientific name to a crop that has none" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 - expect(tomato.default_scientific_name).to eq 'Foo bar' + expect(tomato.default_scientific_name).to eq "Foo bar" end - it 'picks up scientific name from parent crop if available' do + it "picks up scientific name from parent crop if available" do parent = CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent"] ) expect(tomato.parent).to eq parent - expect(tomato.parent.default_scientific_name).to eq 'Parentis cropis' - expect(tomato.default_scientific_name).to eq 'Parentis cropis' + expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" + expect(tomato.default_scientific_name).to eq "Parentis cropis" end it "doesn't add a duplicate scientific name" do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar, Foo bar'] + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar, Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 end it "doesn't add a duplicate scientific name from parent" do CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent', 'Parentis cropis'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent", "Parentis cropis"] ) expect(tomato.scientific_names.size).to eq 1 end - it 'loads a crop with multiple scientific names' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo,Bar'] + it "loads a crop with multiple scientific names" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo,Bar"] tomato = CsvImporter.new.import_crop(row) - expect(tomato.scientific_names[0].name).to eq 'Foo' - expect(tomato.scientific_names[1].name).to eq 'Bar' + expect(tomato.scientific_names[0].name).to eq "Foo" + expect(tomato.scientific_names[1].name).to eq "Bar" end - it 'loads multiple scientific names with variant spacing' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Baz, Quux'] + it "loads multiple scientific names with variant spacing" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 2 - expect(tomato.scientific_names[0].name).to eq 'Baz' - expect(tomato.scientific_names[1].name).to eq 'Quux' + expect(tomato.scientific_names[0].name).to eq "Baz" + expect(tomato.scientific_names[1].name).to eq "Quux" end end # scientific names - context 'alternate names' do - it 'loads an alternate name' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo'] + context "alternate names" do + it "loads an alternate name" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 - expect(tomato.alternate_names.last.name).to eq 'Foo' + expect(tomato.alternate_names.last.name).to eq "Foo" end - it 'adds multiple alternate names' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo, Bar'] + it "adds multiple alternate names" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo, Bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 2 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" end - it 'adds multiple alt names with variant spacing' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo,Bar,Baz, Quux'] + it "adds multiple alt names with variant spacing" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo,Bar,Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 4 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' - expect(tomato.alternate_names[2].name).to eq 'Baz' - expect(tomato.alternate_names[3].name).to eq 'Quux' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" + expect(tomato.alternate_names[2].name).to eq "Baz" + expect(tomato.alternate_names[3].name).to eq "Quux" end - it 'Adds a duplicate alternate name for second crop' do - row = ['tomato', 'http://en.wikipedia.org/wiki/tomato', '', '', 'Foo'] + it "Adds a duplicate alternate name for second crop" do + row = ["tomato", "http://en.wikipedia.org/wiki/tomato", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) - row = ['tomoto', 'http://en.wikipedia.org/wiki/tomoto', '', '', 'Foo'] + row = ["tomoto", "http://en.wikipedia.org/wiki/tomoto", "", "", "Foo"] tomoto = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 expect(tomoto.alternate_names.size).to eq 1 end end # alternate names - it 'loads the simplest possible crop' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato'] + it "loads the simplest possible crop" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(tomato.creator).to eq @cropbot end - it 'loads a crop with a scientific name' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato', '', 'Solanum lycopersicum'] + it "loads a crop with a scientific name" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato", "", "Solanum lycopersicum"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.scientific_names.size).to eq 1 - expect(tomato.scientific_names.last.name).to eq 'Solanum lycopersicum' + expect(tomato.scientific_names.last.name).to eq "Solanum lycopersicum" end - it 'loads a crop with an alternate name' do + it "loads a crop with an alternate name" do crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', nil, nil, 'Foo'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", nil, nil, "Foo"] ) - expect(crop.name).to eq 'tomato' + expect(crop.name).to eq "tomato" expect(crop.alternate_names.size).to eq 1 - expect(crop.alternate_names.last.name).to eq 'Foo' + expect(crop.alternate_names.last.name).to eq "Foo" end - it 'loads a crop with a parent' do + it "loads a crop with a parent" do parent = FactoryBot.create(:crop, name: 'parent') crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', 'parent'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", "parent"] ) expect(crop.parent).to eq parent end - it 'loads a crop with a missing parent' do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,parent' + it "loads a crop with a missing parent" do + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) @@ -524,40 +524,40 @@ describe Crop do end it "doesn't add unnecessary duplicate crops" do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum' + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) end loaded = Crop.last - expect(loaded.name).to eq 'tomato' + expect(loaded.name).to eq "tomato" expect(loaded.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(loaded.creator).to eq @cropbot end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - describe 'destroying a crop' do + describe "destroying a crop" do before do tomato.destroy end - it 'should delete the association between post and the crop(tomato)' do + it "should delete the association between post and the crop(tomato)" do expect(Post.find(post.id).crops).to eq [maize] end - it 'should not delete the posts' do + it "should not delete the posts" do expect(Post.find(post.id)).not_to eq nil end end end - context 'crop rejections' do + context "crop rejections" do let!(:rejected_reason) do FactoryBot.create(:crop, name: 'tomato', approval_status: 'rejected', @@ -570,13 +570,13 @@ describe Crop do rejection_notes: 'blah blah blah') end - describe 'rejecting a crop' do - it 'should give reason if a default option' do - expect(rejected_reason.rejection_explanation).to eq 'not edible' + describe "rejecting a crop" do + it "should give reason if a default option" do + expect(rejected_reason.rejection_explanation).to eq "not edible" end - it 'should show rejection notes if reason was other' do - expect(rejected_other.rejection_explanation).to eq 'blah blah blah' + it "should show rejection notes if reason was other" do + expect(rejected_other.rejection_explanation).to eq "blah blah blah" end end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 139695a2f..bd61fe2ee 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -6,34 +6,34 @@ describe Follow do @member2 = FactoryBot.create(:member) end - it 'sends a notification when a follow is created' do + it "sends a notification when a follow is created" do expect do Follow.create(follower_id: @member1.id, followed_id: @member2.id) end.to change(Notification, :count).by(1) end - it 'does not delete any members when follow is deleted' do + it "does not delete any members when follow is deleted" do expect do follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy end.not_to change(Member, :count) end - context 'when follow is created' do + context "when follow is created" do before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end - it 'should not duplicate follows' do + it "should not duplicate follows" do expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid end - it 'should list users in following/follower collections when follow is created' do + it "should list users in following/follower collections when follow is created" do expect(@member1.followed).to include(@member2) expect(@member2.followers).to include(@member1) end - it 'should no longer list users in following/follower collections when follow is deleted' do + it "should no longer list users in following/follower collections when follow is deleted" do @follow.destroy expect(@member1.followed).not_to include(@member2) expect(@member2.followers).not_to include(@member1) diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index c0d4d47f5..310c36842 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe Forum do let(:forum) { FactoryBot.create(:forum) } - it 'belongs to an owner' do + it "belongs to an owner" do forum.owner.should be_an_instance_of Member end - it 'stringifies nicely' do + it "stringifies nicely" do forum.to_s.should eq forum.name end @@ -15,7 +15,7 @@ describe Forum do forum.slug.should eq 'permaculture' end - it 'has many posts' do + it "has many posts" do @post1 = FactoryBot.create(:forum_post, forum: forum) @post2 = FactoryBot.create(:forum_post, forum: forum) forum.posts.size.should == 2 diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index ec7d5fae2..f8e5a3311 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -4,12 +4,12 @@ describe Garden do let(:owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: owner) } - it 'should have a slug' do + it "should have a slug" do garden.slug.should match(/member\d+-springfield-community-garden/) end - it 'should have a description' do - garden.description.should == 'This is a **totally** cool garden' + it "should have a description" do + garden.description.should == "This is a **totally** cool garden" end it "doesn't allow a nil name" do @@ -18,27 +18,27 @@ describe Garden do end it "doesn't allow a blank name" do - garden = FactoryBot.build(:garden, name: '') + garden = FactoryBot.build(:garden, name: "") garden.should_not be_valid end - it 'allows numbers' do - garden = FactoryBot.build(:garden, name: '100 vines of 2 kamo-kamo') + it "allows numbers" do + garden = FactoryBot.build(:garden, name: "100 vines of 2 kamo-kamo") garden.should_not be_valid end - it 'allows brackets' do - garden = FactoryBot.build(:garden, name: 'Garden (second)') + it "allows brackets" do + garden = FactoryBot.build(:garden, name: "Garden (second)") garden.should be_valid end - it 'allows macrons' do - garden = FactoryBot.build(:garden, name: 'Kūmara and pūha patch') + it "allows macrons" do + garden = FactoryBot.build(:garden, name: "Kūmara and pūha patch") garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryBot.build(:garden, name: ' ') + garden = FactoryBot.build(:garden, name: " ") garden.should_not be_valid end @@ -47,15 +47,15 @@ describe Garden do garden.should_not be_valid end - it 'should have an owner' do + it "should have an owner" do garden.owner.should be_an_instance_of Member end - it 'should stringify as its name' do + it "should stringify as its name" do garden.to_s.should == garden.name end - context 'featured plantings' do + context "featured plantings" do let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } let(:chard) { FactoryBot.create(:chard) } @@ -63,14 +63,14 @@ describe Garden do let(:pear) { FactoryBot.create(:pear) } let(:walnut) { FactoryBot.create(:walnut) } - it 'should fetch < 4 featured plantings if insufficient exist' do + it "should fetch < 4 featured plantings if insufficient exist" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end - it 'should fetch most recent 4 featured plantings' do + it "should fetch most recent 4 featured plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -80,7 +80,7 @@ describe Garden do garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end - it 'should skip repeated plantings' do + it "should skip repeated plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -93,7 +93,7 @@ describe Garden do end end - it 'destroys plantings when deleted' do + it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @@ -135,7 +135,7 @@ describe Garden do end it "doesn't allow non-numeric quantities" do - garden = FactoryBot.build(:garden, area: '99a') + garden = FactoryBot.build(:garden, area: "99a") garden.should_not be_valid end end @@ -151,7 +151,7 @@ describe Garden do it 'should refuse invalid unit values' do garden = FactoryBot.build(:garden, area_unit: 'not valid') garden.should_not be_valid - garden.errors[:area_unit].should include('not valid is not a valid area unit') + garden.errors[:area_unit].should include("not valid is not a valid area unit") end it 'sets area unit to blank if area is blank' do @@ -175,7 +175,7 @@ describe Garden do end end - it 'marks plantings as finished when garden is inactive' do + it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index da6f06aa8..1944c6365 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe Harvest do - it 'has an owner' do + it "has an owner" do harvest = FactoryBot.create(:harvest) harvest.owner.should be_an_instance_of Member end - it 'has a crop' do + it "has a crop" do harvest = FactoryBot.create(:harvest) harvest.crop.should be_an_instance_of Crop end @@ -38,7 +38,7 @@ describe Harvest do end it "doesn't allow non-numeric quantities" do - @harvest = FactoryBot.build(:harvest, quantity: '99a') + @harvest = FactoryBot.build(:harvest, quantity: "99a") @harvest.should_not be_valid end end @@ -55,7 +55,7 @@ describe Harvest do it 'should refuse invalid unit values' do @harvest = FactoryBot.build(:harvest, unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:unit].should include('not valid is not a valid unit') + @harvest.errors[:unit].should include("not valid is not a valid unit") end it 'sets unit to blank if quantity is blank' do @@ -92,7 +92,7 @@ describe Harvest do end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryBot.build(:harvest, weight_quantity: '99a') + @harvest = FactoryBot.build(:harvest, weight_quantity: "99a") @harvest.should_not be_valid end end @@ -108,7 +108,7 @@ describe Harvest do it 'should refuse invalid weight unit values' do @harvest = FactoryBot.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:weight_unit].should include('not valid is not a valid unit') + @harvest.errors[:weight_unit].should include("not valid is not a valid unit") end it 'sets weight_unit to blank if quantity is blank' do @@ -118,21 +118,21 @@ describe Harvest do end end - context 'standardized weights' do + context "standardized weights" do it 'converts from pounds' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'lb') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "lb") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.907 end it 'converts from ounces' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: 'oz') + @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: "oz") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.454 end it 'leaves kg alone' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'kg') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "kg") @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -146,79 +146,79 @@ describe Harvest do end end - context 'stringification' do - let(:crop) { FactoryBot.create(:crop, name: 'apricot') } + context "stringification" do + let(:crop) { FactoryBot.create(:crop, name: "apricot") } - it 'apricots' do + it "apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq 'apricots' + @h.to_s.should eq "apricots" end - it '1 individual apricot' do + it "1 individual apricot" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 individual apricot' + @h.to_s.should eq "1 individual apricot" end - it '10 individual apricots' do + it "10 individual apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 individual apricots' + @h.to_s.should eq "10 individual apricots" end - it '1 bushel of apricots' do + it "1 bushel of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 bushel of apricots' + @h.to_s.should eq "1 bushel of apricots" end - it '1.5 bushels of apricots' do + it "1.5 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1.5, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1.5 bushels of apricots' + @h.to_s.should eq "1.5 bushels of apricots" end - it '10 bushels of apricots' do + it "10 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 bushels of apricots' + @h.to_s.should eq "10 bushels of apricots" end - it 'apricots weighing 1.2 kg' do + it "apricots weighing 1.2 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: 1.2, weight_unit: 'kg') - @h.to_s.should eq 'apricots weighing 1.2 kg' + @h.to_s.should eq "apricots weighing 1.2 kg" end - it '10 bushels of apricots weighing 100 kg' do + it "10 bushels of apricots weighing 100 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: 100, weight_unit: 'kg') - @h.to_s.should eq '10 bushels of apricots weighing 100 kg' + @h.to_s.should eq "10 bushels of apricots weighing 100 kg" end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 7bdee1fee..cf7b81486 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -28,7 +28,7 @@ describe 'member' do member.account.should be_an_instance_of Account end - it 'should have a default-type account by default' do + it "should have a default-type account by default" do member.account.account_type.name.should eq Growstuff::Application.config.default_account_type member.paid?.should be(false) end @@ -48,7 +48,7 @@ describe 'member' do end it 'should be able to fetch gardens' do - member.gardens.first.name.should eq 'Garden' + member.gardens.first.name.should eq "Garden" end it 'has many plantings' do @@ -56,19 +56,19 @@ describe 'member' do member.plantings.size.should eq 1 end - it 'has many comments' do + it "has many comments" do FactoryBot.create(:comment, author: member) FactoryBot.create(:comment, author: member) member.comments.size.should == 2 end - it 'has many forums' do + it "has many forums" do FactoryBot.create(:forum, owner: member) FactoryBot.create(:forum, owner: member) member.forums.size.should == 2 end - it 'has many likes' do + it "has many likes" do @post1 = FactoryBot.create(:post, author: member) @post2 = FactoryBot.create(:post, author: member) @like1 = FactoryBot.create(:like, member: member, likeable: @post1) @@ -118,24 +118,24 @@ describe 'member' do end context 'same :login_name' do - it 'should not allow two members with the same login_name' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'bob') + it "should not allow two members with the same login_name" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "bob") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end - it 'tests uniqueness case-insensitively' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'BoB') + it "tests uniqueness case-insensitively" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "BoB") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end end context 'case sensitivity' do it 'preserves case of login name' do - FactoryBot.create(:member, login_name: 'BOB') + FactoryBot.create(:member, login_name: "BOB") Member.find('bob').login_name.should eq 'BOB' end end @@ -144,40 +144,40 @@ describe 'member' do it "doesn't allow short names" do member = FactoryBot.build(:invalid_member_shortname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow really long names" do member = FactoryBot.build(:invalid_member_longname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow spaces in names" do member = FactoryBot.build(:invalid_member_spaces) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow other chars in names" do member = FactoryBot.build(:invalid_member_badchars) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow reserved names" do member = FactoryBot.build(:invalid_member_badname) member.should_not be_valid - member.errors[:login_name].should include('name is reserved') + member.errors[:login_name].should include("name is reserved") end end context 'valid login names' do - it 'allows plain alphanumeric chars in names' do + it "allows plain alphanumeric chars in names" do member = FactoryBot.build(:valid_member_alphanumeric) member.should be_valid end - it 'allows uppercase chars in names' do + it "allows uppercase chars in names" do member = FactoryBot.build(:valid_member_uppercase) member.should be_valid end - it 'allows underscores in names' do + it "allows underscores in names" do member = FactoryBot.build(:valid_member_underscore) member.should be_valid end @@ -203,7 +203,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - role = FactoryBot.create(:role, name: 'a b c') + role = FactoryBot.create(:role, name: "a b c") member.roles << role member.role?(:a_b_c).should eq true end @@ -310,17 +310,17 @@ describe 'member' do end end - context 'paid accounts' do + context "paid accounts" do let(:member) { FactoryBot.create(:member) } - it 'recognises a permanent paid account' do + it "recognises a permanent paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: true) member.account.account_type = account_type member.paid?.should be(true) end - it 'recognises a current paid account' do + it "recognises a current paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -328,7 +328,7 @@ describe 'member' do member.paid?.should be(true) end - it 'recognises an expired paid account' do + it "recognises an expired paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -336,14 +336,14 @@ describe 'member' do member.paid?.should be(false) end - it 'recognises a free account' do + it "recognises a free account" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type member.paid?.should be(false) end - it 'recognises a free account even with paid_until set' do + it "recognises a free account even with paid_until set" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type @@ -352,19 +352,19 @@ describe 'member' do end end - context 'update account' do + context "update account" do let(:product) do FactoryBot.create(:product, paid_months: 3) end let(:member) { FactoryBot.create(:member) } - it 'sets account_type' do + it "sets account_type" do member.update_account_after_purchase(product) member.account.account_type.should eq product.account_type end - it 'sets paid_until' do + it "sets paid_until" do member.account.paid_until = nil # blank for now, as if never paid before member.update_account_after_purchase(product) @@ -417,7 +417,7 @@ describe 'member' do context 'subscriptions' do let(:member) { FactoryBot.create(:member) } - let(:gb) { instance_double('Gibbon::API.new') } + let(:gb) { instance_double("Gibbon::API.new") } it 'subscribes to the newsletter' do expect(gb).to receive_message_chain('lists.subscribe') @@ -444,12 +444,12 @@ describe 'member' do it { expect(Member.interesting).not_to include(member) } it { expect(Member.has_plantings).not_to include(member) } end - it 'unsubscribes from mailing list' do + it "unsubscribes from mailing list" do expect(member).to receive(:newsletter_unsubscribe).and_return(true) member.destroy end - context 'deleted admin member' do + context "deleted admin member" do let(:member) { FactoryBot.create(:admin_member) } before { member.destroy } @@ -457,7 +457,7 @@ describe 'member' do context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } - it 'leaves crops behind, reassigned to cropbot' do + it "leaves crops behind, reassigned to cropbot" do expect(Crop.all).to include(crop) end end @@ -465,7 +465,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } - it 'leaves forums behind, reassigned to ex_admin' do + it "leaves forums behind, reassigned to ex_admin" do expect(forum.owner).to eq(member) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 96d390215..4f04573d5 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -3,19 +3,19 @@ require 'rails_helper' describe Notification do let(:notification) { FactoryBot.create(:notification) } - it 'belongs to a post' do + it "belongs to a post" do notification.post.should be_an_instance_of Post end - it 'belongs to a recipient' do + it "belongs to a recipient" do notification.recipient.should be_an_instance_of Member end - it 'belongs to a sender' do + it "belongs to a sender" do notification.sender.should be_an_instance_of Member end - it 'has a scope for unread' do + it "has a scope for unread" do Notification.unread.should eq [notification] @n2 = FactoryBot.create(:notification, read: true) Notification.unread.should eq [notification] @@ -24,13 +24,13 @@ describe Notification do Notification.unread.should include notification end - it 'counts unread' do + it "counts unread" do @who = notification.recipient @n2 = FactoryBot.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end - it 'sends email if asked' do + it "sends email if asked" do @notification2 = FactoryBot.create(:notification) @notification2.send_email ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] @@ -42,18 +42,18 @@ describe Notification do ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email] end - it 'sends email on creation' do + it "sends email on creation" do @notification2 = FactoryBot.create(:notification) ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] end - it 'replaces missing subjects with (no subject)' do + it "replaces missing subjects with (no subject)" do notification = FactoryBot.create(:notification, subject: nil) - notification.subject.should == '(no subject)' + notification.subject.should == "(no subject)" end - it 'replaces whitespace-only subjects with (no subject)' do - notification = FactoryBot.create(:notification, subject: ' ') - notification.subject.should == '(no subject)' + it "replaces whitespace-only subjects with (no subject)" do + notification = FactoryBot.create(:notification, subject: " ") + notification.subject.should == "(no subject)" end end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb index 1d9835d7d..7c2de24c6 100644 --- a/spec/models/order_item_spec.rb +++ b/spec/models/order_item_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe OrderItem do let(:order_item) { FactoryBot.create(:order_item) } - it 'has an order and a product' do + it "has an order and a product" do order_item.order.should be_an_instance_of Order order_item.product.should be_an_instance_of Product end - it 'validates price > product.min_price' do + it "validates price > product.min_price" do @product = FactoryBot.create(:product) order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) order_item.should_not be_valid diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 87ae130a9..9abb381ba 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -16,7 +16,7 @@ describe Order do @order2 = Order.create!(member_id: @member2.id) end - it 'only returns orders belonging to member' do + it "only returns orders belonging to member" do Order.by_member(@member1).should eq [@order1] end end @@ -43,7 +43,7 @@ describe Order do @member.account.paid_until.should_not be_nil end - it 'totals the amount due' do + it "totals the amount due" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -56,7 +56,7 @@ describe Order do @order.total.should eq 1111 end - it 'gives the correct total for quantities more than 1' do + it "gives the correct total for quantities more than 1" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -69,7 +69,7 @@ describe Order do @order.total.should eq 2222 end - it 'formats order items for activemerchant' do + it "formats order items for activemerchant" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -87,18 +87,18 @@ describe Order do }] end - context 'referral codes' do - it 'has a referral code' do + context "referral codes" do + it "has a referral code" do referred_order = FactoryBot.create(:referred_order) referred_order.referral_code.should_not be nil end - it 'validates referral codes' do + it "validates referral codes" do referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') referred_order.should_not be_valid end - it 'cleans up messy referral codes' do + it "cleans up messy referral codes" do referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') referred_order.referral_code.should eq 'CAMPAIGN1' end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 4400f7d2f..5f07a3e29 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -9,7 +9,7 @@ describe Photo do let(:harvest) { FactoryBot.create(:harvest) } let(:garden) { FactoryBot.create(:garden) } - context 'adds photos' do + context "adds photos" do it 'to a planting' do planting.photos << photo expect(planting.photos.size).to eq 1 @@ -29,7 +29,7 @@ describe Photo do end end - context 'removing photos' do + context "removing photos" do it 'from a planting' do planting.photos << photo photo.destroy @@ -48,7 +48,7 @@ describe Photo do expect(garden.photos.size).to eq 0 end - it 'automatically if unused' do + it "automatically if unused" do photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 266b75ed7..60a95c245 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -162,11 +162,11 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it 'generates a location' do + it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end - it 'should have a slug' do + it "should have a slug" do planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/) end @@ -176,15 +176,15 @@ describe Planting do end describe '#planted?' do - it 'should be false for future plantings' do + it "should be false for future plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1 expect(planting.planted?).to eq(false) end - it 'should be false for never planted' do + it "should be false for never planted" do planting = FactoryBot.create :planting, planted_at: nil expect(planting.planted?).to eq(false) end - it 'should be true for past plantings' do + it "should be true for past plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1 expect(planting.planted?).to eq(true) end @@ -224,7 +224,7 @@ describe Planting do @planting.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @planting = FactoryBot.build(:planting, quantity: nil) @planting.should be_valid @planting = FactoryBot.build(:planting, quantity: '') @@ -249,7 +249,7 @@ describe Planting do it 'should refuse invalid sunniness values' do @planting = FactoryBot.build(:planting, sunniness: 'not valid') @planting.should_not be_valid - @planting.errors[:sunniness].should include('not valid is not a valid sunniness value') + @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") end end @@ -271,7 +271,7 @@ describe Planting do it 'should refuse invalid planted_from values' do @planting = FactoryBot.build(:planting, planted_from: 'not valid') @planting.should_not be_valid - @planting.errors[:planted_from].should include('not valid is not a valid planting method') + @planting.errors[:planted_from].should include("not valid is not a valid planting method") end end @@ -336,7 +336,7 @@ describe Planting do end end - context 'default arguments' do + context "default arguments" do it 'ignores plantings without photos' do # first, an interesting planting @planting = FactoryBot.create(:planting) @@ -370,8 +370,8 @@ describe Planting do end end - context 'with howmany argument' do - it 'only returns the number asked for' do + context "with howmany argument" do + it "only returns the number asked for" do @plantings = FactoryBot.create_list(:planting, 10) @plantings.each do |p| p.photos << FactoryBot.create(:photo, owner: planting.owner) @@ -381,7 +381,7 @@ describe Planting do end end # interesting plantings - context 'finished' do + context "finished" do it 'has finished fields' do @planting = FactoryBot.create(:finished_planting) @planting.finished.should be true @@ -402,7 +402,7 @@ describe Planting do Planting.current.should_not include @f end - context 'finished date validation' do + context "finished date validation" do it 'requires finished date after planting date' do @f = FactoryBot.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4eb8d6ad6..98880ce2b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,33 +3,33 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } - it_behaves_like 'it is likeable' + it_behaves_like "it is likeable" - it 'should have a slug' do + it "should have a slug" do post = FactoryBot.create(:post, author: member) time = post.created_at - datestr = time.strftime('%Y%m%d') + datestr = time.strftime("%Y%m%d") # 2 digit day and month, full-length years # Counting digits using Math.log is not precise enough! datestr.size.should eq(4 + time.year.to_s.size) post.slug.should eq("#{member.login_name}-#{datestr}-a-post") end - it 'has many comments' do + it "has many comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comments.size.should == 2 end - it 'supports counting comments' do + it "supports counting comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comment_count.should == 2 end - it 'destroys comments when deleted' do + it "destroys comments when deleted" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) @@ -39,7 +39,7 @@ describe Post do Comment.count.should eq(all - 2) end - it 'belongs to a forum' do + it "belongs to a forum" do post = FactoryBot.create(:forum_post) post.forum.should be_an_instance_of Forum end @@ -50,40 +50,40 @@ describe Post do end it "doesn't allow a blank subject" do - post = FactoryBot.build(:post, subject: '') + post = FactoryBot.build(:post, subject: "") post.should_not be_valid end it "doesn't allow a subject with only spaces" do - post = FactoryBot.build(:post, subject: ' ') + post = FactoryBot.build(:post, subject: " ") post.should_not be_valid end - context 'recent activity' do + context "recent activity" do before do Time.stub(now: Time.now) end let!(:post) { FactoryBot.create(:post, created_at: 1.day.ago) } - it 'sets recent activity to post time' do + it "sets recent activity to post time" do post.recent_activity.to_i.should eq post.created_at.to_i end - it 'sets recent activity to comment time' do + it "sets recent activity to comment time" do comment = FactoryBot.create(:comment, post: post, created_at: 1.hour.ago) post.recent_activity.to_i.should eq comment.created_at.to_i end - it 'shiny new post is recently active' do + it "shiny new post is recently active" do # create a shiny new post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq post2 Post.recently_active.second.should eq post end - it 'new comment on old post is recently active' do + it "new comment on old post is recently active" do # now comment on an older post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) FactoryBot.create(:comment, post: post, created_at: 1.second.ago) @@ -92,22 +92,22 @@ describe Post do end end - context 'notifications' do + context "notifications" do let(:member2) { FactoryBot.create(:member) } - it 'sends a notification when a member is mentioned using @-syntax' do + it "sends a notification when a member is mentioned using @-syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2}") end.to change(Notification, :count).by(1) end - it 'sends a notification when a member is mentioned using [](member) syntax' do + it "sends a notification when a member is mentioned using [](member) syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)") end.to change(Notification, :count).by(1) end - it 'sets the notification field' do + it "sets the notification field" do p = FactoryBot.create(:post, author: member, body: "Hey @#{member2}") n = Notification.first n.sender.should eq member @@ -116,7 +116,7 @@ describe Post do n.body.should eq p.body end - it 'sends notifications to all members mentioned' do + it "sends notifications to all members mentioned" do member3 = FactoryBot.create(:member) expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}") @@ -130,23 +130,23 @@ describe Post do end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:chard) { FactoryBot.create(:chard) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - it 'should be generated' do + it "should be generated" do expect(tomato.posts).to eq [post] expect(maize.posts).to eq [post] end - it 'should not duplicate' do + it "should not duplicate" do expect(post.crops) =~ [tomato, maize] end - it 'should be updated when post was modified' do - post.update_attributes(body: '[chard](crop)') + it "should be updated when post was modified" do + post.update_attributes(body: "[chard](crop)") expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] @@ -154,17 +154,17 @@ describe Post do expect(maize.posts).to eq [] end - describe 'destroying the post' do + describe "destroying the post" do before do post.destroy end - it 'should delete the association' do + it "should delete the association" do expect(Crop.find(tomato.id).posts).to eq [] expect(Crop.find(maize.id).posts).to eq [] end - it 'should not delete the crops' do + it "should not delete the crops" do expect(Crop.find(tomato.id)).not_to eq nil expect(Crop.find(maize.id)).not_to eq nil end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index 1ff0ba516..2cc684667 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Product do - it 'stringifies using the name' do + it "stringifies using the name" do @product = FactoryBot.create(:product) @product.to_s.should eq @product.name end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 020e37741..e45d0e240 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -7,7 +7,7 @@ describe Seed do seed.save.should be(true) end - it 'should have a slug' do + it "should have a slug" do seed.save seed.slug.should match(/member\d+-magic-bean/) end @@ -28,7 +28,7 @@ describe Seed do @seed.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @seed = FactoryBot.build(:seed, quantity: nil) @seed.should be_valid @seed = FactoryBot.build(:seed, quantity: '') @@ -48,8 +48,8 @@ describe Seed do @seed = FactoryBot.build(:seed, tradable_to: 'not valid') @seed.should_not be_valid @seed.errors[:tradable_to].should include( - 'You may only trade seed nowhere, locally, '\ - 'nationally, or internationally' + "You may only trade seed nowhere, locally, "\ + "nationally, or internationally" ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dfced9e4b..e28dd6e24 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' +ENV["RAILS_ENV"] ||= 'test' require 'simplecov' require 'coveralls' @@ -17,7 +17,7 @@ SimpleCov.start :rails do end require 'spec_helper' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! Rails.application.eager_load! @@ -58,8 +58,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } -Dir[Rails.root.join('spec/features/shared_examples/**/*.rb')].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 936d1a7a6..6a392eb74 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -5,53 +5,53 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do - { 'id' => crop.id.to_s, - 'type' => 'crops', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'plantings' => plantings_as_json_api, - 'parent' => parent_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:parent_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/parent", - 'related' => "#{resource_url}/parent" } } + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'name' => crop.name, - 'en-wikipedia-url' => crop.en_wikipedia_url, - 'perennial' => false, - 'median-lifespan' => nil, - 'median-days-to-first-harvest' => nil, - 'median-days-to-last-harvest' => nil + "name" => crop.name, + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil } end @@ -63,25 +63,25 @@ RSpec.describe 'Plantings', type: :request do describe '#show' do before { get "/api/v1/crops/#{crop.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('parent' => parent_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } it { expect(subject['data']).to eq(crop_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/crops/#{crop.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 234606bcd..d6005e286 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -5,36 +5,36 @@ RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do - { 'id' => garden.id.to_s, - 'type' => 'gardens', - 'links' => { 'self' => resource_url }, - 'attributes' => { 'name' => garden.name }, - 'relationships' => + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => resource_url }, + "attributes" => { "name" => garden.name }, + "relationships" => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'photos' => photos_as_json_api + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end scenario '#index' do @@ -49,16 +49,16 @@ RSpec.describe 'Gardens', type: :request do scenario '#create' do post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/gardens/#{garden.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index b685b2990..af2d4201e 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Harvests', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do - { 'id' => harvest.id.to_s, - 'type' => 'harvests', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'crop' => crop_as_json_api, - 'planting' => planting_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:planting_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/planting", - 'related' => "#{resource_url}/planting" } } + "related" => "#{resource_url}/planting" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'harvested-at' => '2015-09-17', - 'description' => harvest.description, - 'unit' => harvest.unit, - 'weight-quantity' => harvest.weight_quantity.to_s, - 'weight-unit' => harvest.weight_unit, - 'si-weight' => harvest.si_weight + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight } end @@ -64,25 +64,25 @@ RSpec.describe 'Harvests', type: :request do describe '#show' do before { get "/api/v1/harvests/#{harvest.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('planting' => planting_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 2e9977132..6067e59b6 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Members', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do - { 'id' => member.id.to_s, - 'type' => 'members', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'gardens' => gardens_as_json_api, - 'harvests' => harvests_as_json_api, - 'photos' => photos_as_json_api, - 'plantings' => plantings_as_json_api, - 'seeds' => seeds_as_json_api + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:seeds_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/seeds", - 'related' => "#{resource_url}/seeds" } } + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:attributes) do { - 'login-name' => member.login_name + "login-name" => member.login_name } end @@ -63,26 +63,26 @@ RSpec.describe 'Members', type: :request do describe '#show' do before { get "/api/v1/members/#{member.id}", {}, headers } - it { expect(subject['data']['relationships']).to include('gardens' => gardens_as_json_api) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('seeds' => seeds_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } it { expect(subject['data']).to eq(member_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/members/#{member.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index 6f5c1434b..e9e584a60 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -5,52 +5,52 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do - { 'id' => photo.id.to_s, - 'type' => 'photos', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'harvests' => harvests_as_json_api, - 'gardens' => gardens_as_json_api + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:attributes) do { - 'thumbnail-url' => photo.thumbnail_url, - 'fullsize-url' => photo.fullsize_url, - 'link-url' => photo.link_url, - 'license-name' => photo.license_name, - 'title' => photo.title + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "title" => photo.title } end @@ -62,24 +62,24 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/photos/#{photo.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(photo_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/photos/#{photo.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 02a7be3f4..4e96cefb4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -5,65 +5,65 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do - { 'id' => planting.id.to_s, - 'type' => 'plantings', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'garden' => garden_as_json_api, - 'crop' => crop_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:garden_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/garden", - 'related' => "#{resource_url}/garden" } } + { "links" => + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } end let(:attributes) do { - 'planted-at' => '2014-07-30', - 'finished-at' => nil, - 'finished' => false, - 'quantity' => 33, - 'description' => planting.description, - 'sunniness' => nil, - 'planted-from' => nil, - 'expected-lifespan' => nil, - 'finish-predicted-at' => nil, - 'percentage-grown' => nil, - 'first-harvest-date' => nil, - 'last-harvest-date' => nil + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil } end @@ -74,26 +74,26 @@ RSpec.describe 'Plantings', type: :request do scenario '#show' do get "/api/v1/plantings/#{planting.id}", {}, headers - expect(subject['data']['relationships']).to include('garden' => garden_as_json_api) - expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) - expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) - expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) - expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end scenario '#create' do post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/plantings/#{planting.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index 733ab7e22..f518e91de 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -5,41 +5,41 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do - { 'id' => seed.id.to_s, - 'type' => 'seeds', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'crop' => crop_as_json_api + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } end let(:attributes) do { - 'description' => seed.description, - 'quantity' => seed.quantity, - 'plant-before' => '2013-07-15', - 'tradable-to' => seed.tradable_to, - 'days-until-maturity-min' => seed.days_until_maturity_min, - 'days-until-maturity-max' => seed.days_until_maturity_max, - 'organic' => seed.organic, - 'gmo' => seed.gmo, - 'heirloom' => seed.heirloom + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom } end @@ -51,23 +51,23 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/seeds/#{seed.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } it { expect(subject['data']).to eq(seed_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/seeds/#{seed.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 45b7754b9..6cc612f44 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Authentications' do - describe 'GET /authentications' do +describe "Authentications" do + describe "GET /authentications" do end end diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb index 6e5544657..c9b2ba9dc 100644 --- a/spec/requests/comments_spec.rb +++ b/spec/requests/comments_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Comments' do - describe 'GET /comments' do - it 'works! (now write some real specs)' do +describe "Comments" do + describe "GET /comments" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get comments_path response.status.should be(200) diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index 34a86ea66..ff7cb283d 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Forums' do - describe 'GET /forums' do - it 'works! (now write some real specs)' do +describe "Forums" do + describe "GET /forums" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get forums_path response.status.should be(200) diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 74a9931fb..91a8dc8b7 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Gardens' do - describe 'GET /gardens' do - it 'works! (now write some real specs)' do +describe "Gardens" do + describe "GET /gardens" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get gardens_path response.status.should be(200) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index 17785af18..f3774b3c0 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Harvests' do - describe 'GET /harvests' do - it 'works! (now write some real specs)' do +describe "Harvests" do + describe "GET /harvests" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path response.status.should be(200) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index b5879f678..85afbdd9f 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Notifications' do - describe 'GET /notifications' do - it 'works! (now write some real specs)' do +describe "Notifications" do + describe "GET /notifications" do + it "works! (now write some real specs)" do get notifications_path # can't see notifications because not logged in # therefore redirect to homepage diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index a3d39871c..b937ded3d 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Photos' do - describe 'GET /photos' do - it 'works! (now write some real specs)' do +describe "Photos" do + describe "GET /photos" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get photos_path response.status.should be(200) diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index c44e42599..1fc2150b2 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'PlantParts' do - describe 'GET /plant_parts' do - it 'works! (now write some real specs)' do +describe "PlantParts" do + describe "GET /plant_parts" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plant_parts_path response.status.should be(200) diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index e156f9589..cb66922e0 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Plantings' do - describe 'GET /plantings' do - it 'works! (now write some real specs)' do +describe "Plantings" do + describe "GET /plantings" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plantings_path response.status.should be(200) diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index a2e316c38..3bb479aa8 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Posts' do - describe 'GET /posts' do - it 'works! (now write some real specs)' do +describe "Posts" do + describe "GET /posts" do + it "works! (now write some real specs)" do get posts_path response.status.should be(200) end diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 02785b4ad..922f6f270 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'ScientificNames' do - describe 'GET /scientific_names' do - it 'works! (now write some real specs)' do +describe "ScientificNames" do + describe "GET /scientific_names" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get scientific_names_path response.status.should be(200) diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 08d3c0f18..8bc5aeccf 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Seeds' do - describe 'GET /seeds' do - it 'works! (now write some real specs)' do +describe "Seeds" do + describe "GET /seeds" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get seeds_path response.status.should be(200) diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb index 53ed9b4a3..8402dd727 100644 --- a/spec/routing/account_types_routing_spec.rb +++ b/spec/routing/account_types_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe AccountTypesController do - describe 'routing' do - it 'routes to #index' do - get('/account_types').should route_to('account_types#index') + describe "routing" do + it "routes to #index" do + get("/account_types").should route_to("account_types#index") end - it 'routes to #new' do - get('/account_types/new').should route_to('account_types#new') + it "routes to #new" do + get("/account_types/new").should route_to("account_types#new") end - it 'routes to #show' do - get('/account_types/1').should route_to('account_types#show', id: '1') + it "routes to #show" do + get("/account_types/1").should route_to("account_types#show", id: "1") end - it 'routes to #edit' do - get('/account_types/1/edit').should route_to('account_types#edit', id: '1') + it "routes to #edit" do + get("/account_types/1/edit").should route_to("account_types#edit", id: "1") end - it 'routes to #create' do - post('/account_types').should route_to('account_types#create') + it "routes to #create" do + post("/account_types").should route_to("account_types#create") end - it 'routes to #update' do - put('/account_types/1').should route_to('account_types#update', id: '1') + it "routes to #update" do + put("/account_types/1").should route_to("account_types#update", id: "1") end - it 'routes to #destroy' do - delete('/account_types/1').should route_to('account_types#destroy', id: '1') + it "routes to #destroy" do + delete("/account_types/1").should route_to("account_types#destroy", id: "1") end end end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 39d814011..0601b9924 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,13 +1,13 @@ -require 'rails_helper' +require "rails_helper" describe AuthenticationsController do - describe 'routing' do - it 'routes to #create' do - post('/authentications').should route_to('authentications#create') + describe "routing" do + it "routes to #create" do + post("/authentications").should route_to("authentications#create") end - it 'routes to #destroy' do - delete('/authentications/1').should route_to('authentications#destroy', id: '1') + it "routes to #destroy" do + delete("/authentications/1").should route_to("authentications#destroy", id: "1") end end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 8f9363dcc..5390ab066 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CommentsController do - describe 'routing' do - it 'routes to #index' do - get('/comments').should route_to('comments#index') + describe "routing" do + it "routes to #index" do + get("/comments").should route_to("comments#index") end - it 'routes to #new' do - get('/comments/new').should route_to('comments#new') + it "routes to #new" do + get("/comments/new").should route_to("comments#new") end - it 'routes to #show' do - get('/comments/1').should route_to('comments#show', id: '1') + it "routes to #show" do + get("/comments/1").should route_to("comments#show", id: "1") end - it 'routes to #edit' do - get('/comments/1/edit').should route_to('comments#edit', id: '1') + it "routes to #edit" do + get("/comments/1/edit").should route_to("comments#edit", id: "1") end - it 'routes to #create' do - post('/comments').should route_to('comments#create') + it "routes to #create" do + post("/comments").should route_to("comments#create") end - it 'routes to #update' do - put('/comments/1').should route_to('comments#update', id: '1') + it "routes to #update" do + put("/comments/1").should route_to("comments#update", id: "1") end - it 'routes to #destroy' do - delete('/comments/1').should route_to('comments#destroy', id: '1') + it "routes to #destroy" do + delete("/comments/1").should route_to("comments#destroy", id: "1") end end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 644bad3d6..97c1a874c 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CropsController do - describe 'routing' do - it 'routes to #index' do - get('/crops').should route_to('crops#index') + describe "routing" do + it "routes to #index" do + get("/crops").should route_to("crops#index") end - it 'routes to #new' do - get('/crops/new').should route_to('crops#new') + it "routes to #new" do + get("/crops/new").should route_to("crops#new") end - it 'routes to #show' do - get('/crops/1').should route_to('crops#show', id: '1') + it "routes to #show" do + get("/crops/1").should route_to("crops#show", id: "1") end - it 'routes to #edit' do - get('/crops/1/edit').should route_to('crops#edit', id: '1') + it "routes to #edit" do + get("/crops/1/edit").should route_to("crops#edit", id: "1") end - it 'routes to #create' do - post('/crops').should route_to('crops#create') + it "routes to #create" do + post("/crops").should route_to("crops#create") end - it 'routes to #update' do - put('/crops/1').should route_to('crops#update', id: '1') + it "routes to #update" do + put("/crops/1").should route_to("crops#update", id: "1") end - it 'routes to #destroy' do - delete('/crops/1').should route_to('crops#destroy', id: '1') + it "routes to #destroy" do + delete("/crops/1").should route_to("crops#destroy", id: "1") end end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index 06aaa6b76..ddb01e00c 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,13 +1,13 @@ -require 'spec_helper' +require "spec_helper" describe FollowsController do - describe 'routing' do - it 'routes to #create' do - post('/follows').should route_to('follows#create') + describe "routing" do + it "routes to #create" do + post("/follows").should route_to("follows#create") end - it 'routes to #destroy' do - delete('/follows/1').should route_to('follows#destroy', id: '1') + it "routes to #destroy" do + delete("/follows/1").should route_to("follows#destroy", id: "1") end end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index ca229917f..9ce6f427b 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ForumsController do - describe 'routing' do - it 'routes to #index' do - get('/forums').should route_to('forums#index') + describe "routing" do + it "routes to #index" do + get("/forums").should route_to("forums#index") end - it 'routes to #new' do - get('/forums/new').should route_to('forums#new') + it "routes to #new" do + get("/forums/new").should route_to("forums#new") end - it 'routes to #show' do - get('/forums/1').should route_to('forums#show', id: '1') + it "routes to #show" do + get("/forums/1").should route_to("forums#show", id: "1") end - it 'routes to #edit' do - get('/forums/1/edit').should route_to('forums#edit', id: '1') + it "routes to #edit" do + get("/forums/1/edit").should route_to("forums#edit", id: "1") end - it 'routes to #create' do - post('/forums').should route_to('forums#create') + it "routes to #create" do + post("/forums").should route_to("forums#create") end - it 'routes to #update' do - put('/forums/1').should route_to('forums#update', id: '1') + it "routes to #update" do + put("/forums/1").should route_to("forums#update", id: "1") end - it 'routes to #destroy' do - delete('/forums/1').should route_to('forums#destroy', id: '1') + it "routes to #destroy" do + delete("/forums/1").should route_to("forums#destroy", id: "1") end end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 8ec871b3b..6888f099f 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe GardensController do - describe 'routing' do - it 'routes to #index' do - get('/gardens').should route_to('gardens#index') + describe "routing" do + it "routes to #index" do + get("/gardens").should route_to("gardens#index") end - it 'routes to #new' do - get('/gardens/new').should route_to('gardens#new') + it "routes to #new" do + get("/gardens/new").should route_to("gardens#new") end - it 'routes to #show' do - get('/gardens/1').should route_to('gardens#show', id: '1') + it "routes to #show" do + get("/gardens/1").should route_to("gardens#show", id: "1") end - it 'routes to #edit' do - get('/gardens/1/edit').should route_to('gardens#edit', id: '1') + it "routes to #edit" do + get("/gardens/1/edit").should route_to("gardens#edit", id: "1") end - it 'routes to #create' do - post('/gardens').should route_to('gardens#create') + it "routes to #create" do + post("/gardens").should route_to("gardens#create") end - it 'routes to #update' do - put('/gardens/1').should route_to('gardens#update', id: '1') + it "routes to #update" do + put("/gardens/1").should route_to("gardens#update", id: "1") end - it 'routes to #destroy' do - delete('/gardens/1').should route_to('gardens#destroy', id: '1') + it "routes to #destroy" do + delete("/gardens/1").should route_to("gardens#destroy", id: "1") end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 41ad0c187..c6890df15 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe HarvestsController do - describe 'routing' do - it 'routes to #index' do - get('/harvests').should route_to('harvests#index') + describe "routing" do + it "routes to #index" do + get("/harvests").should route_to("harvests#index") end - it 'routes to #new' do - get('/harvests/new').should route_to('harvests#new') + it "routes to #new" do + get("/harvests/new").should route_to("harvests#new") end - it 'routes to #show' do - get('/harvests/1').should route_to('harvests#show', id: '1') + it "routes to #show" do + get("/harvests/1").should route_to("harvests#show", id: "1") end - it 'routes to #edit' do - get('/harvests/1/edit').should route_to('harvests#edit', id: '1') + it "routes to #edit" do + get("/harvests/1/edit").should route_to("harvests#edit", id: "1") end - it 'routes to #create' do - post('/harvests').should route_to('harvests#create') + it "routes to #create" do + post("/harvests").should route_to("harvests#create") end - it 'routes to #update' do - put('/harvests/1').should route_to('harvests#update', id: '1') + it "routes to #update" do + put("/harvests/1").should route_to("harvests#update", id: "1") end - it 'routes to #destroy' do - delete('/harvests/1').should route_to('harvests#destroy', id: '1') + it "routes to #destroy" do + delete("/harvests/1").should route_to("harvests#destroy", id: "1") end end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 8b0628575..bb7335e1b 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe NotificationsController do - describe 'routing' do - it 'routes to #index' do - get('/notifications').should route_to('notifications#index') + describe "routing" do + it "routes to #index" do + get("/notifications").should route_to("notifications#index") end - it 'routes to #new' do - get('/notifications/new').should route_to('notifications#new') + it "routes to #new" do + get("/notifications/new").should route_to("notifications#new") end - it 'routes to #show' do - get('/notifications/1').should route_to('notifications#show', id: '1') + it "routes to #show" do + get("/notifications/1").should route_to("notifications#show", id: "1") end - it 'routes to #edit' do - get('/notifications/1/edit').should route_to('notifications#edit', id: '1') + it "routes to #edit" do + get("/notifications/1/edit").should route_to("notifications#edit", id: "1") end - it 'routes to #create' do - post('/notifications').should route_to('notifications#create') + it "routes to #create" do + post("/notifications").should route_to("notifications#create") end - it 'routes to #update' do - put('/notifications/1').should route_to('notifications#update', id: '1') + it "routes to #update" do + put("/notifications/1").should route_to("notifications#update", id: "1") end - it 'routes to #destroy' do - delete('/notifications/1').should route_to('notifications#destroy', id: '1') + it "routes to #destroy" do + delete("/notifications/1").should route_to("notifications#destroy", id: "1") end end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb index 095842d7f..7487cb9f5 100644 --- a/spec/routing/order_items_routing_spec.rb +++ b/spec/routing/order_items_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrderItemsController do - describe 'routing' do - it 'routes to #index' do - get('/order_items').should route_to('order_items#index') + describe "routing" do + it "routes to #index" do + get("/order_items").should route_to("order_items#index") end - it 'routes to #new' do - get('/order_items/new').should route_to('order_items#new') + it "routes to #new" do + get("/order_items/new").should route_to("order_items#new") end - it 'routes to #show' do - get('/order_items/1').should route_to('order_items#show', id: '1') + it "routes to #show" do + get("/order_items/1").should route_to("order_items#show", id: "1") end - it 'routes to #edit' do - get('/order_items/1/edit').should route_to('order_items#edit', id: '1') + it "routes to #edit" do + get("/order_items/1/edit").should route_to("order_items#edit", id: "1") end - it 'routes to #create' do - post('/order_items').should route_to('order_items#create') + it "routes to #create" do + post("/order_items").should route_to("order_items#create") end - it 'routes to #update' do - put('/order_items/1').should route_to('order_items#update', id: '1') + it "routes to #update" do + put("/order_items/1").should route_to("order_items#update", id: "1") end - it 'routes to #destroy' do - delete('/order_items/1').should route_to('order_items#destroy', id: '1') + it "routes to #destroy" do + delete("/order_items/1").should route_to("order_items#destroy", id: "1") end end end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb index 4c7d925c5..38184ef33 100644 --- a/spec/routing/orders_routing_spec.rb +++ b/spec/routing/orders_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrdersController do - describe 'routing' do - it 'routes to #index' do - get('/orders').should route_to('orders#index') + describe "routing" do + it "routes to #index" do + get("/orders").should route_to("orders#index") end - it 'routes to #new' do - get('/orders/new').should route_to('orders#new') + it "routes to #new" do + get("/orders/new").should route_to("orders#new") end - it 'routes to #show' do - get('/orders/1').should route_to('orders#show', id: '1') + it "routes to #show" do + get("/orders/1").should route_to("orders#show", id: "1") end - it 'routes to #edit' do - get('/orders/1/edit').should route_to('orders#edit', id: '1') + it "routes to #edit" do + get("/orders/1/edit").should route_to("orders#edit", id: "1") end - it 'routes to #create' do - post('/orders').should route_to('orders#create') + it "routes to #create" do + post("/orders").should route_to("orders#create") end - it 'routes to #update' do - put('/orders/1').should route_to('orders#update', id: '1') + it "routes to #update" do + put("/orders/1").should route_to("orders#update", id: "1") end - it 'routes to #destroy' do - delete('/orders/1').should route_to('orders#destroy', id: '1') + it "routes to #destroy" do + delete("/orders/1").should route_to("orders#destroy", id: "1") end end end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index 1337de4b2..a645d0a60 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PhotosController do - describe 'routing' do - it 'routes to #index' do - get('/photos').should route_to('photos#index') + describe "routing" do + it "routes to #index" do + get("/photos").should route_to("photos#index") end - it 'routes to #new' do - get('/photos/new').should route_to('photos#new') + it "routes to #new" do + get("/photos/new").should route_to("photos#new") end - it 'routes to #show' do - get('/photos/1').should route_to('photos#show', id: '1') + it "routes to #show" do + get("/photos/1").should route_to("photos#show", id: "1") end - it 'routes to #edit' do - get('/photos/1/edit').should route_to('photos#edit', id: '1') + it "routes to #edit" do + get("/photos/1/edit").should route_to("photos#edit", id: "1") end - it 'routes to #create' do - post('/photos').should route_to('photos#create') + it "routes to #create" do + post("/photos").should route_to("photos#create") end - it 'routes to #update' do - put('/photos/1').should route_to('photos#update', id: '1') + it "routes to #update" do + put("/photos/1").should route_to("photos#update", id: "1") end - it 'routes to #destroy' do - delete('/photos/1').should route_to('photos#destroy', id: '1') + it "routes to #destroy" do + delete("/photos/1").should route_to("photos#destroy", id: "1") end end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 2a00948bc..966047f3f 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantPartsController do - describe 'routing' do - it 'routes to #index' do - get('/plant_parts').should route_to('plant_parts#index') + describe "routing" do + it "routes to #index" do + get("/plant_parts").should route_to("plant_parts#index") end - it 'routes to #new' do - get('/plant_parts/new').should route_to('plant_parts#new') + it "routes to #new" do + get("/plant_parts/new").should route_to("plant_parts#new") end - it 'routes to #show' do - get('/plant_parts/1').should route_to('plant_parts#show', id: '1') + it "routes to #show" do + get("/plant_parts/1").should route_to("plant_parts#show", id: "1") end - it 'routes to #edit' do - get('/plant_parts/1/edit').should route_to('plant_parts#edit', id: '1') + it "routes to #edit" do + get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") end - it 'routes to #create' do - post('/plant_parts').should route_to('plant_parts#create') + it "routes to #create" do + post("/plant_parts").should route_to("plant_parts#create") end - it 'routes to #update' do - put('/plant_parts/1').should route_to('plant_parts#update', id: '1') + it "routes to #update" do + put("/plant_parts/1").should route_to("plant_parts#update", id: "1") end - it 'routes to #destroy' do - delete('/plant_parts/1').should route_to('plant_parts#destroy', id: '1') + it "routes to #destroy" do + delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") end end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 4098d7703..473fe827e 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantingsController do - describe 'routing' do - it 'routes to #index' do - get('/plantings').should route_to('plantings#index') + describe "routing" do + it "routes to #index" do + get("/plantings").should route_to("plantings#index") end - it 'routes to #new' do - get('/plantings/new').should route_to('plantings#new') + it "routes to #new" do + get("/plantings/new").should route_to("plantings#new") end - it 'routes to #show' do - get('/plantings/1').should route_to('plantings#show', id: '1') + it "routes to #show" do + get("/plantings/1").should route_to("plantings#show", id: "1") end - it 'routes to #edit' do - get('/plantings/1/edit').should route_to('plantings#edit', id: '1') + it "routes to #edit" do + get("/plantings/1/edit").should route_to("plantings#edit", id: "1") end - it 'routes to #create' do - post('/plantings').should route_to('plantings#create') + it "routes to #create" do + post("/plantings").should route_to("plantings#create") end - it 'routes to #update' do - put('/plantings/1').should route_to('plantings#update', id: '1') + it "routes to #update" do + put("/plantings/1").should route_to("plantings#update", id: "1") end - it 'routes to #destroy' do - delete('/plantings/1').should route_to('plantings#destroy', id: '1') + it "routes to #destroy" do + delete("/plantings/1").should route_to("plantings#destroy", id: "1") end end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb index c19642a21..15166a805 100644 --- a/spec/routing/products_routing_spec.rb +++ b/spec/routing/products_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ProductsController do - describe 'routing' do - it 'routes to #index' do - get('/products').should route_to('products#index') + describe "routing" do + it "routes to #index" do + get("/products").should route_to("products#index") end - it 'routes to #new' do - get('/products/new').should route_to('products#new') + it "routes to #new" do + get("/products/new").should route_to("products#new") end - it 'routes to #show' do - get('/products/1').should route_to('products#show', id: '1') + it "routes to #show" do + get("/products/1").should route_to("products#show", id: "1") end - it 'routes to #edit' do - get('/products/1/edit').should route_to('products#edit', id: '1') + it "routes to #edit" do + get("/products/1/edit").should route_to("products#edit", id: "1") end - it 'routes to #create' do - post('/products').should route_to('products#create') + it "routes to #create" do + post("/products").should route_to("products#create") end - it 'routes to #update' do - put('/products/1').should route_to('products#update', id: '1') + it "routes to #update" do + put("/products/1").should route_to("products#update", id: "1") end - it 'routes to #destroy' do - delete('/products/1').should route_to('products#destroy', id: '1') + it "routes to #destroy" do + delete("/products/1").should route_to("products#destroy", id: "1") end end end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 589c40dd8..7b6469efb 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe RolesController do - describe 'routing' do - it 'routes to #index' do - get('/roles').should route_to('roles#index') + describe "routing" do + it "routes to #index" do + get("/roles").should route_to("roles#index") end - it 'routes to #new' do - get('/roles/new').should route_to('roles#new') + it "routes to #new" do + get("/roles/new").should route_to("roles#new") end - it 'routes to #show' do - get('/roles/1').should route_to('roles#show', id: '1') + it "routes to #show" do + get("/roles/1").should route_to("roles#show", id: "1") end - it 'routes to #edit' do - get('/roles/1/edit').should route_to('roles#edit', id: '1') + it "routes to #edit" do + get("/roles/1/edit").should route_to("roles#edit", id: "1") end - it 'routes to #create' do - post('/roles').should route_to('roles#create') + it "routes to #create" do + post("/roles").should route_to("roles#create") end - it 'routes to #update' do - put('/roles/1').should route_to('roles#update', id: '1') + it "routes to #update" do + put("/roles/1").should route_to("roles#update", id: "1") end - it 'routes to #destroy' do - delete('/roles/1').should route_to('roles#destroy', id: '1') + it "routes to #destroy" do + delete("/roles/1").should route_to("roles#destroy", id: "1") end end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 5020404ea..7bbbfa764 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ScientificNamesController do - describe 'routing' do - it 'routes to #index' do - get('/scientific_names').should route_to('scientific_names#index') + describe "routing" do + it "routes to #index" do + get("/scientific_names").should route_to("scientific_names#index") end - it 'routes to #new' do - get('/scientific_names/new').should route_to('scientific_names#new') + it "routes to #new" do + get("/scientific_names/new").should route_to("scientific_names#new") end - it 'routes to #show' do - get('/scientific_names/1').should route_to('scientific_names#show', id: '1') + it "routes to #show" do + get("/scientific_names/1").should route_to("scientific_names#show", id: "1") end - it 'routes to #edit' do - get('/scientific_names/1/edit').should route_to('scientific_names#edit', id: '1') + it "routes to #edit" do + get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") end - it 'routes to #create' do - post('/scientific_names').should route_to('scientific_names#create') + it "routes to #create" do + post("/scientific_names").should route_to("scientific_names#create") end - it 'routes to #update' do - put('/scientific_names/1').should route_to('scientific_names#update', id: '1') + it "routes to #update" do + put("/scientific_names/1").should route_to("scientific_names#update", id: "1") end - it 'routes to #destroy' do - delete('/scientific_names/1').should route_to('scientific_names#destroy', id: '1') + it "routes to #destroy" do + delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index ad8615cc4..74f4aff64 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe SeedsController do - describe 'routing' do - it 'routes to #index' do - get('/seeds').should route_to('seeds#index') + describe "routing" do + it "routes to #index" do + get("/seeds").should route_to("seeds#index") end - it 'routes to #new' do - get('/seeds/new').should route_to('seeds#new') + it "routes to #new" do + get("/seeds/new").should route_to("seeds#new") end - it 'routes to #show' do - get('/seeds/1').should route_to('seeds#show', id: '1') + it "routes to #show" do + get("/seeds/1").should route_to("seeds#show", id: "1") end - it 'routes to #edit' do - get('/seeds/1/edit').should route_to('seeds#edit', id: '1') + it "routes to #edit" do + get("/seeds/1/edit").should route_to("seeds#edit", id: "1") end - it 'routes to #create' do - post('/seeds').should route_to('seeds#create') + it "routes to #create" do + post("/seeds").should route_to("seeds#create") end - it 'routes to #update' do - put('/seeds/1').should route_to('seeds#update', id: '1') + it "routes to #update" do + put("/seeds/1").should route_to("seeds#update", id: "1") end - it 'routes to #destroy' do - delete('/seeds/1').should route_to('seeds#destroy', id: '1') + it "routes to #destroy" do + delete("/seeds/1").should route_to("seeds#destroy", id: "1") end end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 1b3c8ea59..966647515 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PostsController do - describe 'routing' do - it 'routes to #index' do - get('/posts').should route_to('posts#index') + describe "routing" do + it "routes to #index" do + get("/posts").should route_to("posts#index") end - it 'routes to #new' do - get('/posts/new').should route_to('posts#new') + it "routes to #new" do + get("/posts/new").should route_to("posts#new") end - it 'routes to #show' do - get('/posts/1').should route_to('posts#show', id: '1') + it "routes to #show" do + get("/posts/1").should route_to("posts#show", id: "1") end - it 'routes to #edit' do - get('/posts/1/edit').should route_to('posts#edit', id: '1') + it "routes to #edit" do + get("/posts/1/edit").should route_to("posts#edit", id: "1") end - it 'routes to #create' do - post('/posts').should route_to('posts#create') + it "routes to #create" do + post("/posts").should route_to("posts#create") end - it 'routes to #update' do - put('/posts/1').should route_to('posts#update', id: '1') + it "routes to #update" do + put("/posts/1").should route_to("posts#update", id: "1") end - it 'routes to #destroy' do - delete('/posts/1').should route_to('posts#destroy', id: '1') + it "routes to #destroy" do + delete("/posts/1").should route_to("posts#destroy", id: "1") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 300bca74d..9a0b542df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,5 +87,5 @@ RSpec.configure do |config| Kernel.srand config.seed # Remember which tests failed, so you can run rspec with the `--only-failures` flag. - config.example_status_persistence_file_path = 'tmp/examples.txt' + config.example_status_persistence_file_path = "tmp/examples.txt" end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index b8236e95f..354c64069 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,7 +3,7 @@ module ControllerMacros def login_member(member_factory = :member) let(:member) { FactoryBot.create(member_factory || :member) } before(:each) do - @request.env['devise.mapping'] = Devise.mappings[:member] + @request.env["devise.mapping"] = Devise.mappings[:member] sign_in member end end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 5b73b5b0c..aaa4fd689 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,6 +1,6 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) - return unless ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + return unless ENV['GROWSTUFF_ELASTICSEARCH'] == "true" crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end @@ -10,6 +10,6 @@ RSpec.configure do |config| config.include ElasticsearchHelpers config.before(:all, elasticsearch: true) do - Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" end end diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index fb24eaa02..e1a590b30 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,4 +1,4 @@ -shared_examples 'it is likeable' do +shared_examples "it is likeable" do before(:each) do # Possibly a horrible hack. # Will fail if factory name does not match the model name.. @@ -9,7 +9,7 @@ shared_examples 'it is likeable' do @like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable) end - it 'has many likes' do + it "has many likes" do expect(@likeable.likes.length).to eq 2 end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index e8f934358..1bd22be03 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/edit' do +describe "account_types/edit" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false)) end - it 'renders the edit account_type form' do + it "renders the edit account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path(@account_type), method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path(@account_type), method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index 94f19d072..56020fc35 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/index' do +describe "account_types/index" do before(:each) do @type = FactoryBot.create(:account_type) assign(:account_types, [@type, @type]) end - it 'renders a list of account_types' do + it "renders a list of account_types" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @type.name.to_s, count: 2 + assert_select "tr>td", text: @type.name.to_s, count: 2 end end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index db7cec061..027a1b7c1 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/new' do +describe "account_types/new" do before(:each) do assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false).as_new_record) end - it 'renders new account_type form' do + it "renders new account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path, method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path, method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 6bb888f1a..a31d4bc33 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/show' do +describe "account_types/show" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'Name', + name: "Name", is_paid: false, is_permanent_paid: false)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index d77edd8c8..bc5c3b5a3 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/edit' do +describe "accounts/edit" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it 'renders the edit account form' do + it "renders the edit account form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: accounts_path(@account), method: 'post' do - assert_select 'input#account_member_id', name: 'account[member_id]' - assert_select 'input#account_account_type', name: 'account[account_type]' + assert_select "form", action: accounts_path(@account), method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 7e54347fb..4ec76151e 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'accounts/index' do +describe "accounts/index" do before(:each) do @member = FactoryBot.create(:member) @account = @member.account assign(:accounts, [@account, @account]) end - it 'renders a list of accounts' do + it "renders a list of accounts" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @account.member_id.to_s, count: 2 + assert_select "tr>td", text: @account.member_id.to_s, count: 2 end end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 5bc6ba812..77f6ff20f 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/new' do +describe "accounts/new" do before(:each) do @member = FactoryBot.create(:member) assign(:account, @member.account) end - it 'renders new account form' do + it "renders new account form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: accounts_path, method: 'post' do - assert_select 'input#account_member_id', name: 'account[member_id]' - assert_select 'input#account_account_type', name: 'account[account_type]' + assert_select "form", action: accounts_path, method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb index b852b12d1..d96fbbd96 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'accounts/show' do +describe "accounts/show" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @account.member_id.to_s diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 442a0c36c..beb0eacbd 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/index.html.haml', type: 'view' do +describe 'admin/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,14 +8,14 @@ describe 'admin/index.html.haml', type: 'view' do render end - it 'includes links to manage various things' do - assert_select 'a', href: account_types_path - assert_select 'a', href: products_path - assert_select 'a', href: roles_path - assert_select 'a', href: forums_path + it "includes links to manage various things" do + assert_select "a", href: account_types_path + assert_select "a", href: products_path + assert_select "a", href: roles_path + assert_select "a", href: forums_path end - it 'has a link to newsletter subscribers' do - rendered.should have_content 'Newsletter subscribers' + it "has a link to newsletter subscribers" do + rendered.should have_content "Newsletter subscribers" end end diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 8faca4e18..384833034 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/newsletter.html.haml', type: 'view' do +describe 'admin/newsletter.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -10,7 +10,7 @@ describe 'admin/newsletter.html.haml', type: 'view' do render end - it 'lists newsletter subscribers by email' do + it "lists newsletter subscribers by email" do rendered.should have_content @subscriber.email end end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index 905b6a3ff..8d80dc3ef 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/orders/index.html.haml', type: 'view' do +describe 'admin/orders/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,13 +8,13 @@ describe 'admin/orders/index.html.haml', type: 'view' do render end - it 'includes a search form for orders' do - assert_select 'form' - assert_select 'input#search_text' - assert_select 'select#search_by' + it "includes a search form for orders" do + assert_select "form" + assert_select "input#search_text" + assert_select "select#search_by" end - it 'lets you search by referral code' do - assert_select 'option[value=referral_code]', text: 'Referral code' + it "lets you search by referral code" do + assert_select "option[value=referral_code]", text: "Referral code" end end diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index 41a46858d..2ef7d480f 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'comments/edit' do +describe "comments/edit" do before(:each) do controller.stub(:current_user) { nil } assign(:comment, FactoryBot.create(:comment)) end - it 'renders the edit comment form' do + it "renders the edit comment form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: comments_path(@comment), method: 'post' do - assert_select 'textarea#comment_body', name: 'comment[body]' + assert_select "form", action: comments_path(@comment), method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end end diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 3677782e2..91ed15a88 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/index' do +describe "comments/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -16,13 +16,13 @@ describe 'comments/index' do render end - it 'renders a list of comments' do + it "renders a list of comments" do render rendered.should have_content 'OMG LOL' rendered.should have_content 'ROFL' end - it 'contains an RSS feed link' do - assert_select 'a', href: comments_path(format: 'rss') + it "contains an RSS feed link" do + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index 6d0db9169..672658bac 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -13,7 +13,7 @@ describe 'comments/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent comments on all posts' + rendered.should have_content "Recent comments on all posts" end it 'shows item title' do @@ -26,6 +26,6 @@ describe 'comments/index.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index e5bdcfb39..e0533ea5b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/new' do +describe "comments/new" do before(:each) do controller.stub(:current_user) { nil } @post = FactoryBot.create(:post) @@ -10,21 +10,21 @@ describe 'comments/new' do render end - it 'shows the text of the post under discussion' do + it "shows the text of the post under discussion" do rendered.should have_content @post.body end - it 'shows previous comments' do + it "shows previous comments" do rendered.should have_content @comment.body end - it 'shows the correct comment count' do - rendered.should have_content '1 comment' + it "shows the correct comment count" do + rendered.should have_content "1 comment" end - it 'renders new comment form' do - assert_select 'form', action: comments_path, method: 'post' do - assert_select 'textarea#comment_body', name: 'comment[body]' + it "renders new comment form" do + assert_select "form", action: comments_path, method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index 91e045359..6315b4f69 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'comments/show' do +describe "comments/show" do before(:each) do controller.stub(:current_user) { nil } @comment = assign(:comment, FactoryBot.create(:comment)) render end - it 'renders the comment' do + it "renders the comment" do rendered.should have_content @comment.author.login_name rendered.should have_content @comment.body end diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index deb541bb4..c378c296c 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_grown_for' do +describe "crops/_grown_for" do let(:crop) { FactoryBot.create(:crop) } let(:plant_path) { FactoryBot.create(:plant_part) } let!(:harvest) do @@ -12,6 +12,6 @@ describe 'crops/_grown_for' do it 'shows plant parts' do render partial: 'crops/grown_for', locals: { crop: crop } rendered.should have_content plant_path.name - assert_select 'a', href: plant_part_path(plant_path) + assert_select "a", href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 4cb5aa0a2..12064a1b8 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,62 +1,62 @@ require 'rails_helper' -describe 'crops/_planting_advice' do +describe "crops/_planting_advice" do subject { rendered } let(:planting) { FactoryBot.create(:planting) } - shared_examples 'render planting_advice' do + shared_examples "render planting_advice" do before { render 'crops/planting_advice', crop: planting.crop } end - describe 'sunniness' do - context 'with no sunniness set' do - include_examples 'render planting_advice' + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" it "doesn't show sunniness" do - is_expected.to have_content 'Plant in: not known.' + is_expected.to have_content "Plant in: not known." end end - context 'with sunniness frequencies' do + context "with sunniness frequencies" do before { FactoryBot.create(:sunny_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - context 'with multiple sunniness frequencies' do + context "with multiple sunniness frequencies" do before do FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) FactoryBot.create(:shady_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (2), shade (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - describe 'planted from' do - context 'when none are set' do - include_examples 'render planting_advice' + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" it "doesn't show planted_from " do - is_expected.to have_content 'Plant from: not known.' + is_expected.to have_content "Plant from: not known." end end - context 'with planted_from frequencies' do + context "with planted_from frequencies" do before { FactoryBot.create(:seed_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - context 'with multiple planted_from frequencies' do + context "with multiple planted_from frequencies" do before do FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) FactoryBot.create(:cutting_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (2), cutting (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index e5f1f92ac..dde4a893f 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_popover' do +describe "crops/_popover" do before(:each) do @tomato = FactoryBot.create(:tomato) @sn = FactoryBot.create(:solanum_lycopersicum, crop: @tomato) diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index eeadf603d..19fac21af 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/edit' do +describe "crops/edit" do before(:each) do controller.stub(:current_user) do FactoryBot.create(:crop_wrangling_member) @@ -13,7 +13,7 @@ describe 'crops/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@crop.creator} less than a minute ago." end end diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index 0740142bb..833bb2b98 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/hierarchy' do +describe "crops/hierarchy" do before(:each) do controller.stub(:current_user) { nil } @tomato = FactoryBot.create(:tomato) @@ -9,7 +9,7 @@ describe 'crops/hierarchy' do render end - it 'shows crop hierarchy' do - assert_select 'ul>li>ul>li', text: @roma.name + it "shows crop hierarchy" do + assert_select "ul>li>ul>li", text: @roma.name end end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index ef7081444..9f2985035 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/index' do +describe "crops/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -15,20 +15,20 @@ describe 'crops/index' do assign(:crops, crops) end - it 'shows photos where available' do + it "shows photos where available" do @planting = FactoryBot.create(:planting, crop: @tomato) @photo = FactoryBot.create(:photo) @planting.photos << @photo render - assert_select 'img', src: @photo.thumbnail_url + assert_select "img", src: @photo.thumbnail_url end - it 'linkifies crop images' do + it "linkifies crop images" do render - assert_select 'img', src: :tomato + assert_select "img", src: :tomato end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member @@ -36,18 +36,18 @@ describe 'crops/index' do render end - it 'shows a new crop link' do - rendered.should have_content 'New Crop' + it "shows a new crop link" do + rendered.should have_content "New Crop" end end - context 'downloads' do - it 'offers data downloads' do + context "downloads" do + it "offers data downloads" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: crops_path(format: 'csv') - assert_select 'a', href: crops_path(format: 'json') - assert_select 'a', href: crops_path(format: 'rss') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: crops_path(format: 'csv') + assert_select "a", href: crops_path(format: 'json') + assert_select "a", href: crops_path(format: 'rss') end end end diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index cb218b9cd..72a8bbdff 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -11,7 +11,7 @@ describe 'crops/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recently added crops' + rendered.should have_content "Recently added crops" end it 'shows names of crops' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index 229474cac..5ce7eefdc 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/new' do +describe "crops/new" do before(:each) do @crop = FactoryBot.create(:maize) 3.times do @@ -13,7 +13,7 @@ describe 'crops/new' do render end - it 'shows a link to crop wrangling guidelines' do - assert_select "a[href^='http://wiki.growstuff.org']", 'crop wrangling guide' + it "shows a link to crop wrangling guidelines" do + assert_select "a[href^='http://wiki.growstuff.org']", "crop wrangling guide" end end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index d97eab036..085060570 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/wrangle' do +describe "crops/wrangle" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) controller.stub(:current_user) { @member } @@ -18,18 +18,18 @@ describe 'crops/wrangle' do it 'contains handy links for wranglers' do render - rendered.should have_content 'Crop wrangler guidelines' - rendered.should have_content 'mailing list' + rendered.should have_content "Crop wrangler guidelines" + rendered.should have_content "mailing list" end it 'has a link to add a crop' do render - assert_select 'a', href: new_crop_path + assert_select "a", href: new_crop_path end - it 'renders a list of crops' do + it "renders a list of crops" do render - assert_select 'a', text: @maize.name - assert_select 'a', text: @tomato.name + assert_select "a", text: @maize.name + assert_select "a", text: @tomato.name end end diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb index 3dd70cd20..720822083 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,13 +1,13 @@ -describe 'devise/confirmations/new.html.haml', type: 'view' do +describe 'devise/confirmations/new.html.haml', type: "view" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render end it 'should contain a login field' do - rendered.should have_content 'Enter either your login name or your email address' + rendered.should have_content "Enter either your login name or your email address" end end diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index b2dcf645a..d2cce98c4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'devise/mailer/confirmation_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index d64dbc30d..fc2ad1bbe 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'devise/mailer/reset_password_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = mock_model(Member) - @resource.stub(:email).and_return('example@example.com') - @resource.stub(:reset_password_token).and_return('joe') + @resource.stub(:email).and_return("example@example.com") + @resource.stub(:reset_password_token).and_return("joe") render end diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index bafbb484c..633545cf3 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'devise/mailer/unlock_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render end it "should explain what's happened" do - rendered.should have_content 'account has been locked' + rendered.should have_content "account has been locked" end - it 'should have an unlock link' do - rendered.should have_content 'Unlock my account' + it "should have an unlock link" do + rendered.should have_content "Unlock my account" end end end diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 52999595f..3d9dae906 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'devise/registrations/edit.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/edit.html.haml', type: "view" do + context "logged in" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) controller.stub(:current_member) { @member } @view.stub(:resource).and_return(@member) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) end @@ -23,11 +23,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'has a checkbox for email notifications' do - assert_select 'input[id=member_send_notification_email][type=checkbox]' + assert_select "input[id=member_send_notification_email][type=checkbox]" end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end @@ -37,23 +37,23 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'shows show_email checkbox' do - assert_select 'input[id=member_show_email][type=checkbox]' + assert_select "input[id=member_show_email][type=checkbox]" end - it 'contains a gravatar icon' do - assert_select 'img', src: /gravatar\.com\/avatar/ + it "contains a gravatar icon" do + assert_select "img", src: /gravatar\.com\/avatar/ end it 'contains a link to gravatar.com' do - assert_select 'a', href: /gravatar\.com/ + assert_select "a", href: /gravatar\.com/ end it 'shows bio field' do - assert_select 'textarea[id=member_bio]' + assert_select "textarea[id=member_bio]" end it 'shows location field' do - assert_select 'input[id=member_location][type=text]' + assert_select "input[id=member_location][type=text]" end end @@ -61,7 +61,7 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do context 'not connected to twitter' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Twitter' + assert_select "a", "Connect to Twitter" end end context 'connected to twitter' do @@ -70,18 +70,18 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do render end it 'has a link to twitter profile' do - assert_select 'a', href: "http://twitter.com/#{@twitter_auth.name}" + assert_select "a", href: "http://twitter.com/#{@twitter_auth.name}" end it 'has a link to disconnect' do render - assert_select 'a', href: @twitter_auth, text: 'Disconnect' + assert_select "a", href: @twitter_auth, text: "Disconnect" end end context 'not connected to flickr' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Flickr' + assert_select "a", "Connect to Flickr" end end context 'connected to flickr' do @@ -90,11 +90,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do render end it 'has a link to flickr photostream' do - assert_select 'a', href: "http://flickr.com/photos/#{@flickr_auth.uid}" + assert_select "a", href: "http://flickr.com/photos/#{@flickr_auth.uid}" end it 'has a link to disconnect' do render - assert_select 'a', href: @flickr_auth, text: 'Disconnect' + assert_select "a", href: @flickr_auth, text: "Disconnect" end end end diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 3424fbef9..48805b806 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/registrations/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render @@ -15,7 +15,7 @@ describe 'devise/registrations/new.html.haml', type: 'view' do end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end end diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 9d83e51b3..dfe91af2a 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/sessions/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/sessions/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index 63f2fd52d..39147113f 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,6 +1,6 @@ -describe 'devise/shared/_links.haml', type: 'view' do +describe 'devise/shared/_links.haml', type: "view" do def devise_mapping(register, recover, confirm, lock, oauth) - dm = double('mappings') + dm = double("mappings") dm.stub(registerable?: register) dm.stub(recoverable?: recover) dm.stub(confirmable?: confirm) @@ -10,15 +10,15 @@ describe 'devise/shared/_links.haml', type: 'view' do end it 'should have a sign-in link if not in sessions' do - @view.stub(:controller_name).and_return('anything but sessions') - @view.stub(:resource_name).and_return('member') + @view.stub(:controller_name).and_return("anything but sessions") + @view.stub(:resource_name).and_return("member") @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end it "shouldn't have a sign-in link if in sessions" do - @view.stub(:controller_name).and_return('sessions') - @view.stub(:resource_name).and_return('member') + @view.stub(:controller_name).and_return("sessions") + @view.stub(:resource_name).and_return("member") @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 5fd755cce..60d056d72 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/unlocks/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/unlocks/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 152a34418..44151170a 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'forums/edit' do +describe "forums/edit" do before(:each) do @forum = assign(:forum, stub_model(Forum, - name: 'MyString', - description: 'MyText', + name: "MyString", + description: "MyText", owner_id: 1)) end - it 'renders the edit forum form' do + it "renders the edit forum form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: forums_path(@forum), method: 'post' do - assert_select 'input#forum_name', name: 'forum[name]' - assert_select 'textarea#forum_description', name: 'forum[description]' - assert_select 'select#forum_owner_id', name: 'forum[owner_id]' + assert_select "form", action: forums_path(@forum), method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 279a365fc..02b265e85 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'forums/index' do +describe "forums/index" do before(:each) do @admin = FactoryBot.create(:admin_member) controller.stub(:current_user) { @admin } @@ -9,31 +9,31 @@ describe 'forums/index' do assign(:forums, [@forum1, @forum2]) end - it 'renders a list of forums' do + it "renders a list of forums" do render - assert_select 'h2', text: @forum1.name, count: 2 + assert_select "h2", text: @forum1.name, count: 2 end it "doesn't display posts for empty forums" do render - assert_select 'table', false + assert_select "table", false end - context 'posts' do + context "posts" do before(:each) do @post = FactoryBot.create(:forum_post, forum: @forum1) @comment = FactoryBot.create(:comment, post: @post) render end - it 'displays posts' do - assert_select 'table' + it "displays posts" do + assert_select "table" rendered.should have_content @post.subject rendered.should have_content Time.zone.today.to_s(:short) end - it 'displays comment count' do - assert_select 'td', text: '1' + it "displays comment count" do + assert_select "td", text: "1" end end end diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 58278ee18..72cd7ae45 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'forums/new' do +describe "forums/new" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) render end - it 'renders new forum form' do - assert_select 'form', action: forums_path, method: 'post' do - assert_select 'input#forum_name', name: 'forum[name]' - assert_select 'textarea#forum_description', name: 'forum[description]' - assert_select 'select#forum_owner_id', name: 'forum[owner_id]' + it "renders new forum form" do + assert_select "form", action: forums_path, method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 6e67b8c59..08892df58 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -describe 'forums/show' do +describe "forums/show" do before(:each) do controller.stub(:current_user) { nil } @forum = assign(:forum, FactoryBot.create(:forum)) end - it 'renders attributes' do + it "renders attributes" do render - rendered.should have_content 'Everything about permaculture' + rendered.should have_content "Everything about permaculture" rendered.should have_content @forum.owner.to_s end - it 'parses markdown description into html' do + it "parses markdown description into html" do render - assert_select 'em', 'Everything' + assert_select "em", "Everything" end it 'links to new post with the forum id' do @@ -24,13 +24,13 @@ describe 'forums/show' do it 'has no posts' do render - rendered.should have_content 'No posts yet.' + rendered.should have_content "No posts yet." end it 'shows posts' do @post = FactoryBot.create(:post, forum: @forum) render - assert_select 'table' + assert_select "table" rendered.should have_content @post.subject rendered.should have_content @post.author.to_s end diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index c725af57e..1326f1544 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'gardens/edit' do - context 'logged in' do +describe "gardens/edit" do + context "logged in" do before(:each) do @owner = FactoryBot.create(:member) sign_in @owner @@ -10,17 +10,17 @@ describe 'gardens/edit' do render end - it 'renders the edit garden form' do + it "renders the edit garden form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: gardens_path(@garden), method: 'post' do - assert_select 'input#garden_name', name: 'garden[name]' - assert_select 'textarea#garden_description', name: 'garden[description]' - assert_select 'input#garden_location', name: 'garden[location]' - assert_select 'input#garden_area', name: 'garden[area]' - assert_select 'select#garden_area_unit', name: 'garden[area_unit]' - assert_select 'input#garden_active', name: 'garden[active]' + assert_select "form", action: gardens_path(@garden), method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 39b659b7e..7346997dc 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/new' do +describe "gardens/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -10,14 +10,14 @@ describe 'gardens/new' do render end - it 'renders new garden form' do - assert_select 'form', action: gardens_path, method: 'post' do - assert_select 'input#garden_name', name: 'garden[name]' - assert_select 'textarea#garden_description', name: 'garden[description]' - assert_select 'input#garden_location', name: 'garden[location]' - assert_select 'input#garden_area', name: 'garden[area]' - assert_select 'select#garden_area_unit', name: 'garden[area_unit]' - assert_select 'input#garden_active', name: 'garden[active]' + it "renders new garden form" do + assert_select "form", action: gardens_path, method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fa03c5856..7130e2e4f 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/show' do +describe "gardens/show" do before(:each) do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @@ -21,11 +21,11 @@ describe 'gardens/show' do end it 'should show the description' do - rendered.should have_content 'totally cool garden' + rendered.should have_content "totally cool garden" end it 'renders markdown in the description' do - assert_select 'strong', 'totally' + assert_select "strong", "totally" end it 'should show plantings on the garden page' do @@ -33,7 +33,7 @@ describe 'gardens/show' do end it "doesn't show the note about random plantings" do - rendered.should_not have_content 'Note: these are a random selection' + rendered.should_not have_content "Note: these are a random selection" end context 'signed in' do @@ -47,14 +47,14 @@ describe 'gardens/show' do end it "shows a 'plant something' button" do - rendered.should have_content 'Plant something' + rendered.should have_content "Plant something" end it "shows an 'add photo' button" do - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - it 'links to the right crop in the planting link' do + it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 6d4c55b7e..1193b4284 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'harvests/edit' do +describe "harvests/edit" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it 'renders new harvest form' do - assert_select 'form', action: harvests_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' - assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' - assert_select 'input#harvest_quantity', name: 'harvest[quantity]' - assert_select 'input#harvest_weight_quantity', name: 'harvest[quantity]' - assert_select 'select#harvest_unit', name: 'harvest[unit]' - assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' - assert_select 'textarea#harvest_description', name: 'harvest[description]' + it "renders new harvest form" do + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + assert_select "input#harvest_quantity", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index 62ef81d15..fe205cda6 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/index' do +describe "harvests/index" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @@ -25,11 +25,11 @@ describe 'harvests/index' do render end - it 'provides data links' do + it "provides data links" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: harvests_path(format: 'csv') - assert_select 'a', href: harvests_path(format: 'json') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: harvests_path(format: 'csv') + assert_select "a", href: harvests_path(format: 'json') end it "displays member's name in title" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 4e6050625..d79055a38 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'harvests/new' do +describe "harvests/new" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render end - it 'renders new harvest form' do - assert_select 'form', action: harvests_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#harvest_crop_id', name: 'harvest[crop_id]' - assert_select 'select#harvest_plant_part_id', name: 'harvest[plant_part_id]' + it "renders new harvest form" do + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" # some browsers interpret without a step as "integer" - assert_select 'input#harvest_quantity[step=any]', name: 'harvest[quantity]' - assert_select 'input#harvest_weight_quantity[step=any]', name: 'harvest[quantity]' - assert_select 'select#harvest_unit', name: 'harvest[unit]' - assert_select 'select#harvest_weight_unit', name: 'harvest[unit]' - assert_select 'textarea#harvest_description', name: 'harvest[description]' + assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index a182b5269..4aec453ff 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/show' do +describe "harvests/show" do subject { render } let!(:harvest) { FactoryBot.create(:harvest) } @@ -11,7 +11,7 @@ describe 'harvests/show' do render end - describe 'renders attributes' do + describe "renders attributes" do it { is_expected.to have_content harvest.crop.name } it { is_expected.to have_content harvest.harvested_at.to_s } it { is_expected.to have_content harvest.plant_part.to_s } diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 5e661b19d..47244a445 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_blurb.html.haml', type: 'view' do +describe 'home/_blurb.html.haml', type: "view" do context 'signed out' do before :each do controller.stub(:current_user) { nil } @@ -12,13 +12,13 @@ describe 'home/_blurb.html.haml', type: 'view' do end it 'has signup section' do - assert_select 'div.signup' - assert_select 'a', href: new_member_registration_path + assert_select "div.signup" + assert_select "a", href: new_member_registration_path end it 'has a link to sign in' do - rendered.should have_content 'Or sign in if you already have an account' - assert_select 'a', href: new_member_session_path + rendered.should have_content "Or sign in if you already have an account" + assert_select "a", href: new_member_session_path end end end diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index 37dcbd05b..3ed655438 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_crops.html.haml', type: 'view' do +describe 'home/_crops.html.haml', type: "view" do let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } let(:planting) { crop.plantings.first } diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 3d75ea692..76aa434b6 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_members.html.haml', type: 'view' do +describe 'home/_members.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago @@ -11,7 +11,7 @@ describe 'home/_members.html.haml', type: 'view' do end it 'Has a heading' do - rendered.should have_content 'Some of our members' + rendered.should have_content "Some of our members" end it 'Shows members' do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index a551e97f8..7b8d6156c 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', type: 'view' do +describe 'home/_seeds.html.haml', type: "view" do before(:each) do @owner = FactoryBot.create(:london_member) @seed = FactoryBot.create(:tradable_seed, owner: @owner) diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index dc5a0e8a5..a9979190c 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'home/_stats.html.haml', type: 'view' do +describe 'home/_stats.html.haml', type: "view" do it 'has activity stats' do render - rendered.should have_content 'So far, 0 members have planted 0 crops' + rendered.should have_content "So far, 0 members have planted 0 crops" end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5eeae7ff4..5e11882fd 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/index.html.haml', type: 'view' do +describe 'home/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 60f27ca80..5060fc30d 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'layouts/_header.html.haml', type: 'view' do - context 'when not logged in' do +describe 'layouts/_header.html.haml', type: "view" do + context "when not logged in" do before(:each) do controller.stub(:current_user) { nil } render end it 'shows the brand logo in the navbar' do - assert_select('a.navbar-brand img[src]', href: root_path) + assert_select("a.navbar-brand img[src]", href: root_path) end it 'should have signup/signin links' do @@ -17,19 +17,19 @@ describe 'layouts/_header.html.haml', type: 'view' do end it 'has a Crops link' do - rendered.should have_content 'Crops' + rendered.should have_content "Crops" end it 'has a Seeds link' do - rendered.should have_content 'Seeds' + rendered.should have_content "Seeds" end it 'has a Places link' do - rendered.should have_content 'Community Map' + rendered.should have_content "Community Map" end it 'has a Community section' do - rendered.should have_content 'Community' + rendered.should have_content "Community" end it 'links to members' do @@ -46,11 +46,11 @@ describe 'layouts/_header.html.haml', type: 'view' do it 'has a crop search' do assert_select("form[action='#{crops_search_path}']") - assert_select('input#term') + assert_select("input#term") end end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -58,21 +58,21 @@ describe 'layouts/_header.html.haml', type: 'view' do render end - context 'login name' do + context "login name" do it 'should have member login name' do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", 'Gardens') + assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", 'Plantings') + assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", 'Seeds') + assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", "Seeds") end it "should show link to member's posts" do - assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", 'Posts') + assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", "Posts") end end diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 42d4704ad..151c6fe19 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/_meta.html.haml', type: 'view' do +describe 'layouts/_meta.html.haml', type: "view" do before(:each) do render end @@ -21,6 +21,6 @@ describe 'layouts/_meta.html.haml', type: 'view' do end it 'should have a title' do - assert_select 'head>title' + assert_select "head>title" end end diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index 265a0b572..f094ae2c2 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/application.html.haml', type: 'view' do +describe 'layouts/application.html.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } end @@ -8,7 +8,7 @@ describe 'layouts/application.html.haml', type: 'view' do it 'includes the analytics code' do Growstuff::Application.config.analytics_code = '' render - assert_select 'script', text: 'alert("foo!")' + assert_select "script", text: 'alert("foo!")' rendered.should_not have_content 'script' end end diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index d15d69538..50d7b675f 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'members/_location' do - context 'member with location' do +describe "members/_location" do + context "member with location" do let(:member) { FactoryBot.create(:london_member) } before(:each) { render partial: 'members/location', locals: { member: member } } @@ -10,23 +10,23 @@ describe 'members/_location' do expect(rendered).to have_content member.location end - it 'links to the places page' do - assert_select 'a', href: place_path(member.location) + it "links to the places page" do + assert_select "a", href: place_path(member.location) end end - context 'member with no location' do + context "member with no location" do before(:each) do member = FactoryBot.create(:member) render partial: 'members/location', locals: { member: member } end it 'shows unknown location' do - expect(rendered).to have_content 'unknown location' + expect(rendered).to have_content "unknown location" end it "doesn't link anywhere" do - assert_select 'a', false + assert_select "a", false end end end diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 24308bd0e..87dd3a285 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/index' do +describe "members/index" do let(:member) { FactoryBot.create(:london_member) } before(:each) do @@ -15,8 +15,8 @@ describe 'members/index' do render end - it 'contains two gravatar icons' do - assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 + it "contains two gravatar icons" do + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end it 'contains member locations' do diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index 79ea04078..23366a9a8 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/show.rss.haml', type: 'view' do +describe 'members/show.rss.haml', type: "view" do before(:each) do @member = assign(:member, FactoryBot.create(:member)) @post1 = FactoryBot.create(:post, id: 1, author: @member) @@ -16,13 +16,13 @@ describe 'members/show.rss.haml', type: 'view' do end it 'shows content of posts' do - is_expected.to have_content 'This is some text.' + is_expected.to have_content "This is some text." end it 'renders post bodies to HTML and XML-escapes them' do # The variable "rendered" has been entity-replaced and tag-stripped # The literal string output contains "<strong>" etc. - is_expected.to have_content 'strong' + is_expected.to have_content "strong" end it 'gives the author in the item title' do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 76d96f3eb..2c8195069 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'notifications/index' do +describe "notifications/index" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } end - context 'ordinary notifications' do + context "ordinary notifications" do before(:each) do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member) @@ -14,34 +14,34 @@ describe 'notifications/index' do render end - it 'renders a list of notifications' do - assert_select 'table' - assert_select 'tr>td', text: @notification.sender.to_s, count: 2 - assert_select 'tr>td', text: @notification.subject, count: 2 + it "renders a list of notifications" do + assert_select "table" + assert_select "tr>td", text: @notification.sender.to_s, count: 2 + assert_select "tr>td", text: @notification.subject, count: 2 end it "links to sender's profile" do - assert_select 'a', href: member_path(@notification.sender) + assert_select "a", href: member_path(@notification.sender) end end - context 'no subject' do - it 'shows (no subject)' do + context "no subject" do + it "shows (no subject)" do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member, subject: nil) assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content '(no subject)' + rendered.should have_content "(no subject)" end end - context 'whitespace-only subject' do - it 'shows (no subject)' do + context "whitespace-only subject" do + it "shows (no subject)" do @notification = FactoryBot.create(:notification, - sender: @member, recipient: @member, subject: ' ') + sender: @member, recipient: @member, subject: " ") assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content '(no subject)' + rendered.should have_content "(no subject)" end end end diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 091e13cc1..a7f030f47 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/new' do +describe "notifications/new" do before(:each) do @recipient = FactoryBot.create(:member) @sender = FactoryBot.create(:member) @@ -9,38 +9,38 @@ describe 'notifications/new' do controller.stub(:current_user) { @sender } end - it 'renders new message form' do + it "renders new message form" do render - assert_select 'form', action: notifications_path, method: 'notification' do - assert_select 'input#notification_subject', name: 'notification[subject]' - assert_select 'textarea#notification_body', name: 'notification[body]' + assert_select "form", action: notifications_path, method: "notification" do + assert_select "input#notification_subject", name: "notification[subject]" + assert_select "textarea#notification_body", name: "notification[body]" end end - it 'tells you who the recipient is' do + it "tells you who the recipient is" do render rendered.should have_content @recipient.login_name end - it 'puts the recipient in a hidden field' do + it "puts the recipient in a hidden field" do render - assert_select 'input#notification_recipient_id[type=hidden]', name: 'notification[recipient_id]' + assert_select "input#notification_recipient_id[type=hidden]", name: "notification[recipient_id]" end - it 'fills in the subject if provided' do + it "fills in the subject if provided" do assign(:subject, 'Foo') render - assert_select 'input#notification_subject', value: 'Foo' + assert_select "input#notification_subject", value: "Foo" end - it 'leaves the subject empty if not provided' do + it "leaves the subject empty if not provided" do render - assert_select 'input#notification_subject', value: '' + assert_select "input#notification_subject", value: "" end - it 'Tells you to write your message here' do + it "Tells you to write your message here" do render - rendered.should have_content 'Type your message here' + rendered.should have_content "Type your message here" end it 'shows markdown help' do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 1376f7c18..14db0448c 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/show' do +describe "notifications/show" do before(:each) do @member = FactoryBot.create(:member) @notification = FactoryBot.create(:notification, recipient: @member) @@ -10,16 +10,16 @@ describe 'notifications/show' do render end - it 'renders attributes' do + it "renders attributes" do rendered.should have_content @notification.sender.to_s rendered.should have_content @notification.body.to_s end - it 'includes a delete button' do - assert_select 'a', 'Delete' + it "includes a delete button" do + assert_select "a", "Delete" end - it 'includes a reply button' do - assert_select 'a', { href: @reply_link }, 'Reply' + it "includes a reply button" do + assert_select "a", { href: @reply_link }, "Reply" end end diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 2979e6985..913ea10d2 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'notifier/notify.html.haml', type: 'view' do +describe 'notifier/notify.html.haml', type: "view" do before(:each) do @notification = FactoryBot.create(:notification) - @reply_link = 'http://example.com' - @signed_message = 'EncryptedMessage' + @reply_link = "http://example.com" + @signed_message = "EncryptedMessage" assign(:reply_link, @reply_link) render end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 9660b44fb..c95f204e2 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'orders/index' do +describe "orders/index" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,15 +9,15 @@ describe 'orders/index' do assign(:orders, [@order1, @order2]) end - it 'shows your current account status' do + it "shows your current account status" do render - rendered.should have_content 'Your current account status' + rendered.should have_content "Your current account status" end - it 'renders a list of orders' do + it "renders a list of orders" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td a/@href', text: "/orders/#{@order1.id}" - assert_select 'tr>td a/@href', text: "/orders/#{@order2.id}" + assert_select "tr>td a/@href", text: "/orders/#{@order1.id}" + assert_select "tr>td a/@href", text: "/orders/#{@order2.id}" end end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index 233616b9e..a9f662de9 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'orders/show' do +describe "orders/show" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } end - context 'current order' do + context "current order" do before(:each) do @order = assign(:order, FactoryBot.create(:order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -17,38 +17,38 @@ describe 'orders/show' do render end - it 'displays order number' do - rendered.should have_content 'Order number' + it "displays order number" do + rendered.should have_content "Order number" end - it 'shows order items in a table' do - assert_select 'table>tr>th', text: 'Product' + it "shows order items in a table" do + assert_select "table>tr>th", text: "Product" end - it 'shows the total' do - rendered.should have_content 'Total:' - assert_select 'strong', /198.00/ + it "shows the total" do + rendered.should have_content "Total:" + assert_select "strong", /198.00/ end - it 'shows a foreign exchange link for the total' do + it "shows a foreign exchange link for the total" do currency = Growstuff::Application.config.currency assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") end - it 'asks for a referral code' do + it "asks for a referral code" do assert_select "input[id='referral_code']" end - it 'shows a checkout button' do + it "shows a checkout button" do assert_select "input[value='Checkout with PayPal']" end - it 'shows a delete order button' do - assert_select 'a', text: 'Delete this order' + it "shows a delete order button" do + assert_select "a", text: "Delete this order" end end - context 'completed order' do + context "completed order" do before(:each) do @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -59,11 +59,11 @@ describe 'orders/show' do end it "doesn't show a checkout button" do - assert_select 'a', text: 'Checkout', count: 0 + assert_select "a", text: "Checkout", count: 0 end it "doesn't show delete order button" do - assert_select 'a', text: 'Delete this order', count: 0 + assert_select "a", text: "Delete this order", count: 0 end end end diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index 7376ad759..a52b51a79 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'photos/edit' do +describe "photos/edit" do before(:each) do @photo = assign(:photo, stub_model(Photo, owner_id: 1, flickr_photo_id: 1, - thumbnail_url: 'MyString', - fullsize_url: 'MyString')) + thumbnail_url: "MyString", + fullsize_url: "MyString")) end end diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index b99eb8309..b603de1e6 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/index' do +describe "photos/index" do before(:each) do page = 1 per_page = 2 @@ -14,9 +14,9 @@ describe 'photos/index' do assign(:photos, photos) end - it 'renders a gallery of photos' do + it "renders a gallery of photos" do render - assert_select '.thumbnail', count: 2 - assert_select 'img', count: 2 + assert_select ".thumbnail", count: 2 + assert_select "img", count: 2 end end diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 3ae91e1a3..e4f24f9e4 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/new' do +describe "photos/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -14,27 +14,27 @@ describe 'photos/new' do assign(:flickr_auth, FactoryBot.create(:flickr_authentication, member: @member)) end - context 'user has no photosets' do + context "user has no photosets" do it "doesn't show a dropdown with sets from Flickr" do render - assert_select 'select#set', false + assert_select "select#set", false end end - context 'user has photosets' do + context "user has photosets" do before(:each) do - assign(:sets, 'foo' => 'bar') # Hash of names => IDs + assign(:sets, "foo" => "bar") # Hash of names => IDs end - it 'shows a dropdown with sets from Flickr' do + it "shows a dropdown with sets from Flickr" do render - assert_select 'select#set' + assert_select "select#set" end - it 'shows the current photoset' do - assign(:current_set, 'bar') # the ID of the set + it "shows the current photoset" do + assign(:current_set, "bar") # the ID of the set render - assert_select 'h2', 'foo' # the name of the set + assert_select "h2", "foo" # the name of the set end end end diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index ce60a0b47..cecb0008b 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/show' do +describe "photos/show" do let(:photo) { FactoryBot.create :photo, owner: member } before { @photo = photo } @@ -11,70 +11,70 @@ describe 'photos/show' do let(:seed) { FactoryBot.create :seed, owner: member } let(:garden) { FactoryBot.create :garden, owner: member } - shared_examples 'photo data renders' do - it 'shows the image' do + shared_examples "photo data renders" do + it "shows the image" do assert_select "img[src='#{@photo.fullsize_url}']" end it "links to the owner's profile" do - assert_select 'a', href: @photo.owner + assert_select "a", href: @photo.owner end - it 'shows a link to the original image' do - assert_select 'a', href: @photo.link_url, text: 'View on Flickr' + it "shows a link to the original image" do + assert_select "a", href: @photo.link_url, text: "View on Flickr" end - it 'links to harvest' do - assert_select 'a', href: harvest_path(harvest) + it "links to harvest" do + assert_select "a", href: harvest_path(harvest) end - it 'links to planting' do - assert_select 'a', href: planting_path(planting) + it "links to planting" do + assert_select "a", href: planting_path(planting) end - it 'links to garden' do - assert_select 'a', href: garden_path(garden) + it "links to garden" do + assert_select "a", href: garden_path(garden) end - it 'links to seeds' do - assert_select 'a', href: seed_path(seed) + it "links to seeds" do + assert_select "a", href: seed_path(seed) end end - shared_examples 'No links to change data' do - it 'does not have a delete button' do + shared_examples "No links to change data" do + it "does not have a delete button" do assert_select "a[href='#{photo_path(@photo)}']", false end end - context 'signed in as owner' do + context "signed in as owner" do before(:each) do controller.stub(:current_user) { member } render end - include_examples 'photo data renders' + include_examples "photo data renders" - it 'has a delete button' do + it "has a delete button" do assert_select "a[href='#{photo_path(@photo)}']" end end - context 'signed in as another member' do + context "signed in as another member" do before(:each) do controller.stub(:current_user) { FactoryBot.create :member } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'not signed in' do + context "not signed in" do before(:each) do controller.stub(:current_user) { nil } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'CC-licensed photo' do + context "CC-licensed photo" do before(:each) do controller.stub(:current_user) { nil } # @photo = assign(:photo, FactoryBot.create(:photo, owner: @member)) @@ -84,13 +84,13 @@ describe 'photos/show' do @photo.gardens << garden render end - it 'links to the CC license' do - assert_select 'a', href: @photo.license_url, + it "links to the CC license" do + assert_select "a", href: @photo.license_url, text: @photo.license_name end end - context 'unlicensed photo' do + context "unlicensed photo" do before(:each) do controller.stub(:current_user) { nil } @photo = assign(:photo, FactoryBot.create(:unlicensed_photo)) @@ -98,7 +98,7 @@ describe 'photos/show' do end it "contains the phrase 'All rights reserved'" do - rendered.should have_content 'All rights reserved' + rendered.should have_content "All rights reserved" end end end diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index 62022a303..7082290c8 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'places/_map_attribution.html.haml', type: :view do +describe "places/_map_attribution.html.haml", type: :view do before(:each) do render end - it 'links to OpenStreetMap' do - assert_select 'a', href: 'http://openstreetmap.org', - text: 'OpenStreetMap' + it "links to OpenStreetMap" do + assert_select "a", href: "http://openstreetmap.org", + text: "OpenStreetMap" end - it 'links to the ODbL' do - assert_select 'a', href: 'http://www.openstreetmap.org/copyright', - text: 'ODbL' + it "links to the ODbL" do + assert_select "a", href: "http://www.openstreetmap.org/copyright", + text: "ODbL" end - it 'links to CloudMade' do - assert_select 'a', href: 'http://cloudmade.com', text: 'CloudMade' + it "links to CloudMade" do + assert_select "a", href: "http://cloudmade.com", text: "CloudMade" end end diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 3639719d2..f3a3661ae 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'places/index' do +describe "places/index" do before(:each) do render end - it 'shows a map' do - assert_select 'div#placesmap' + it "shows a map" do + assert_select "div#placesmap" end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 463134684..635d06ab9 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'places/show' do +describe "places/show" do before(:each) do @member = FactoryBot.create(:london_member) @nearby_members = [FactoryBot.create(:member)] @@ -10,15 +10,15 @@ describe 'places/show' do render end - it 'shows the selected place' do + it "shows the selected place" do view.content_for(:title).should match @place end - it 'shows the selected place in the textbox' do - assert_select '#new_place', value: @place + it "shows the selected place in the textbox" do + assert_select "#new_place", value: @place end - it 'shows the names of nearby members' do + it "shows the names of nearby members" do @nearby_members.each do |m| rendered.should have_content m.login_name end diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index 33dab3bc8..683dd6ab0 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/edit' do +describe "plant_parts/edit" do before(:each) do @plant_part = assign(:plant_part, stub_model(PlantPart, - name: 'MyString')) + name: "MyString")) end - it 'renders the edit plant_part form' do + it "renders the edit plant_part form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: plant_parts_path(@plant_part), method: 'post' do - assert_select 'input#plant_part_name', name: 'plant_part[name]' + assert_select "form", action: plant_parts_path(@plant_part), method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index ff1955637..65ecf2d63 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'plant_parts/index' do +describe "plant_parts/index" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) assign(:plant_parts, [@pp]) end - it 'renders a list of plant_parts' do + it "renders a list of plant_parts" do render rendered.should have_content @pp.name - assert_select 'a', href: plant_part_path(@pp) + assert_select "a", href: plant_part_path(@pp) end end diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index 476987a98..b1b3f12ae 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/new' do +describe "plant_parts/new" do before(:each) do assign(:plant_part, stub_model(PlantPart, - name: 'MyString').as_new_record) + name: "MyString").as_new_record) end - it 'renders new plant_part form' do + it "renders new plant_part form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: plant_parts_path, method: 'post' do - assert_select 'input#plant_part_name', name: 'plant_part[name]' + assert_select "form", action: plant_parts_path, method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index a725121fa..b367a723b 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plant_parts/show' do +describe "plant_parts/show" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) @@ -8,11 +8,11 @@ describe 'plant_parts/show' do assign(:plant_part, @pp) end - it 'renders a list of crops harvested for this part' do + it "renders a list of crops harvested for this part" do render @pp.crops.each do |c| rendered.should have_content c.name - assert_select 'a', href: crop_path(c) + assert_select "a", href: crop_path(c) end end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 36e4aaeab..6371311ae 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/_form' do +describe "plantings/_form" do before(:each) do @member = FactoryBot.create(:member) @garden = FactoryBot.create(:garden, owner: @member) @@ -18,7 +18,7 @@ describe 'plantings/_form' do render end - it 'has a free-form text field containing the planting date in ISO format' do + it "has a free-form text field containing the planting date in ISO format" do assert_select "input#planting_planted_at[type='text'][value='2013-03-01']" end end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index 1de078e4a..b83af0028 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/edit' do +describe "plantings/edit" do before(:each) do @member = FactoryBot.create(:member, login_name: 'right', @@ -19,32 +19,32 @@ describe 'plantings/edit' do FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member controller.stub(:current_user) { @member } render end - it 'renders the edit planting form' do - assert_select 'form', action: plantings_path(@planting), method: 'post' do - assert_select 'input#planting_quantity', name: 'planting[quantity]' - assert_select 'textarea#planting_description', name: 'planting[description]' - assert_select 'select#planting_sunniness', name: 'planting[sunniness]' - assert_select 'select#planting_planted_from', name: 'planting[planted_from]' + it "renders the edit planting form" do + assert_select "form", action: plantings_path(@planting), method: "post" do + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select "a[href='#{new_garden_path}']", text: 'Add a garden.' + assert_select "a[href='#{new_garden_path}']", text: "Add a garden." end - it 'chooses the right crop' do - assert_select 'input#crop[value=?]', 'tomato' + it "chooses the right crop" do + assert_select "input#crop[value=?]", "tomato" end - it 'chooses the right garden' do - assert_select 'select#planting_garden_id', + it "chooses the right garden" do + assert_select "select#planting_garden_id", html: /option selected value="#{@garden.id}"/ end end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index eed256f87..a3a713100 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/index' do +describe "plantings/index" do let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -36,27 +36,27 @@ describe 'plantings/index' do render end - it 'renders a list of plantings' do + it "renders a list of plantings" do rendered.should have_content tomato.name rendered.should have_content maize.name rendered.should have_content member.login_name rendered.should have_content garden.name end - it 'displays planting time' do + it "displays planting time" do rendered.should have_content 'January 13, 2013' end - it 'displays finished time' do + it "displays finished time" do rendered.should have_content 'January 20, 2013' end - it 'provides data links' do + it "provides data links" do render - rendered.should have_content 'The data on this page is available in the following formats:' - assert_select 'a', href: plantings_path(format: 'csv') - assert_select 'a', href: plantings_path(format: 'json') - assert_select 'a', href: plantings_path(format: 'rss') + rendered.should have_content "The data on this page is available in the following formats:" + assert_select "a", href: plantings_path(format: 'csv') + assert_select "a", href: plantings_path(format: 'json') + assert_select "a", href: plantings_path(format: 'rss') end it "displays member's name in title" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index bed19f685..c4a394561 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -15,7 +15,7 @@ describe 'plantings/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent plantings from all members' + rendered.should have_content "Recent plantings from all members" end it 'item title shows owner and location' do @@ -23,7 +23,7 @@ describe 'plantings/index.rss.haml' do end it 'shows formatted content of posts' do - rendered.should have_content 'This is a really good plant.' + rendered.should have_content "This is a really good plant." end it 'shows sunniness' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 46971c706..6667a05ee 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/new' do +describe "plantings/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -17,7 +17,7 @@ describe 'plantings/new' do owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member assign(:planting, Planting.new) @@ -26,24 +26,24 @@ describe 'plantings/new' do render end - it 'renders new planting form' do - assert_select 'form', action: plantings_path, method: 'post' do - assert_select 'select#planting_garden_id', name: 'planting[garden_id]' - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#planting_crop_id', name: 'planting[crop_id]' - assert_select 'input#planting_quantity', name: 'planting[quantity]' - assert_select 'textarea#planting_description', name: 'planting[description]' - assert_select 'select#planting_sunniness', name: 'planting[sunniness]' - assert_select 'select#planting_planted_from', name: 'planting[planted_from]' + it "renders new planting form" do + assert_select "form", action: plantings_path, method: "post" do + assert_select "select#planting_garden_id", name: "planting[garden_id]" + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#planting_crop_id", name: "planting[crop_id]" + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select 'a', href: new_garden_path, text: 'Add a garden.' + assert_select "a", href: new_garden_path, text: "Add a garden." end - it 'selects a garden given in a param' do - assert_select 'select#planting_garden_id', + it "selects a garden given in a param" do + assert_select "select#planting_garden_id", html: /option selected value="#{@garden_z.id}"/ end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 748ceee3d..899724ac7 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/show' do +describe "plantings/show" do let(:crop) { FactoryBot.create(:tomato) } let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -19,7 +19,7 @@ describe 'plantings/show' do context 'sunniness' do let(:planting) { FactoryBot.create(:sunny_planting) } - it 'shows the sunniness' do + it "shows the sunniness" do render rendered.should have_content 'Sun or shade?' rendered.should have_content 'sun' @@ -29,7 +29,7 @@ describe 'plantings/show' do context 'planted from' do let(:planting) { FactoryBot.create(:cutting_planting) } - it 'shows planted_from' do + it "shows planted_from" do render rendered.should have_content 'Planted from:' rendered.should have_content 'cutting' @@ -43,41 +43,41 @@ describe 'plantings/show' do end end - it 'shows photos' do + it "shows photos" do photo = FactoryBot.create(:photo, owner: member) planting.photos << photo render assert_select "img[src='#{photo.thumbnail_url}']" end - it 'shows a link to add photos' do + it "shows a link to add photos" do render - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - context 'no location set' do + context "no location set" do before(:each) do render end - it 'renders the quantity planted' do + it "renders the quantity planted" do rendered.should match(/3/) end - it 'renders the description' do + it "renders the description" do rendered.should match(/This is a/) end - it 'renders markdown in the description' do - assert_select 'em', 'really' + it "renders markdown in the description" do + assert_select "em", "really" end it "doesn't contain a () if no location is set" do - rendered.should_not have_content '()' + rendered.should_not have_content "()" end end - context 'location set' do + context "location set" do before(:each) do planting.owner.update(location: 'Greenwich, UK') render diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 9217d6729..a153995c5 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'posts/_single' do +describe "posts/_single" do def render_post - render partial: 'single', locals: { post: @post } + render partial: "single", locals: { post: @post } end before(:each) do @@ -15,16 +15,16 @@ describe 'posts/_single' do render_post end - it 'contains a permanent link to post' do - assert_select "a[href='#{post_path @post}']", 'Permalink' + it "contains a permanent link to post" do + assert_select "a[href='#{post_path @post}']", "Permalink" end it "doesn't contain a link to new comment" do - assert_select('a', { href: new_comment_path(post_id: @post.id) }, false) + assert_select("a", { href: new_comment_path(post_id: @post.id) }, false) end end - context 'when logged in' do + context "when logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -32,16 +32,16 @@ describe 'posts/_single' do render_post end - it 'contains link to new comment' do - assert_select('a', { href: new_comment_path(post_id: @post.id) }, 'Reply') + it "contains link to new comment" do + assert_select("a", { href: new_comment_path(post_id: @post.id) }, "Reply") end - it 'does not contain an edit link' do + it "does not contain an edit link" do assert_select "a[href='#{edit_post_path(@post)}']", false end end - context 'when logged in as post author' do + context "when logged in as post author" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -50,88 +50,88 @@ describe 'posts/_single' do render_post end - it 'contains an edit link' do - assert_select "a[href='#{edit_post_path(@post)}']", 'Edit' + it "contains an edit link" do + assert_select "a[href='#{edit_post_path(@post)}']", "Edit" end end - context 'when there are no comments' do + context "when there are no comments" do before(:each) do render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '0 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "0 comments" end end - context 'when there is 1 comment' do + context "when there is 1 comment" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '1 comment' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "1 comment" end end - context 'when there are 2 comments' do + context "when there are 2 comments" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) @comment2 = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '2 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "2 comments" end end - context 'when comments should be hidden' do + context "when comments should be hidden" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @comment = FactoryBot.create(:comment, post: @post) - render partial: 'single', locals: { + render partial: "single", locals: { post: @post, hide_comments: true } end - it 'renders no value of comments' do - rendered.should_not have_content '1 comment' + it "renders no value of comments" do + rendered.should_not have_content "1 comment" end - it 'does not contain link to post' do + it "does not contain link to post" do assert_select "a[href='#{post_path @post}']", false end - it 'does not contain link to new comment' do + it "does not contain link to new comment" do assert_select "a[href='#{new_comment_path(post_id: @post.id)}']", false end end - context 'when post has been edited' do + context "when post has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @post = FactoryBot.create(:post, author: @member) - @post.update(body: 'I am updated') + @post.update(body: "I am updated") render_post end - it 'shows edited at' do - rendered.should have_content 'edited at' + it "shows edited at" do + rendered.should have_content "edited at" end - it 'shows the updated time' do + it "shows the updated time" do rendered.should have_content @post.updated_at end end - context 'when comment has been edited' do + context "when comment has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -139,19 +139,19 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(body: "I've been updated") - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'shows edited at time' do - rendered.should have_content 'edited at' + it "shows edited at time" do + rendered.should have_content "edited at" end - it 'shows updated time' do + it "shows updated time" do rendered.should have_content @comment.updated_at end end - context 'when post has not been edited' do + context "when post has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -161,12 +161,12 @@ describe 'posts/_single' do render_post end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@post.updated_at}" end end - context 'when comment has not been edited' do + context "when comment has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -174,10 +174,10 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(updated_at: @comment.created_at) - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@comment.updated_at}" end end diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 6867185c3..48d64a267 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,34 +1,34 @@ require 'rails_helper' -describe 'posts/edit' do +describe "posts/edit" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @post = assign(:post, FactoryBot.create(:post, author: @author)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @author render end - it 'renders the edit post form' do - assert_select 'form', action: posts_path(@post), method: 'post' do - assert_select 'input#post_subject', name: 'post[subject]' - assert_select 'textarea#post_body', name: 'post[body]' + it "renders the edit post form" do + assert_select "form", action: posts_path(@post), method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end it 'no hidden forum field' do - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index ca924a855..eeebac8b6 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index' do +describe "posts/index" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @@ -17,19 +17,19 @@ describe 'posts/index' do render end - it 'renders a list of posts' do - assert_select 'div.post', count: 2 - assert_select 'h3', text: 'A Post'.to_s, count: 2 - assert_select 'div.post-body', - text: 'This is some text.'.to_s, count: 2 + it "renders a list of posts" do + assert_select "div.post", count: 2 + assert_select "h3", text: "A Post".to_s, count: 2 + assert_select "div.post-body", + text: "This is some text.".to_s, count: 2 end - it 'contains two gravatar icons' do - assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 + it "contains two gravatar icons" do + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end - it 'contains RSS feed links for posts and comments' do - assert_select 'a', href: posts_path(format: 'rss') - assert_select 'a', href: comments_path(format: 'rss') + it "contains RSS feed links for posts and comments" do + assert_select "a", href: posts_path(format: 'rss') + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 23fd0a4b8..3d4ec11f2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index.rss.haml', type: 'view' do +describe 'posts/index.rss.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } author = FactoryBot.create(:member) @@ -11,11 +11,11 @@ describe 'posts/index.rss.haml', type: 'view' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent posts from all members' + rendered.should have_content "Recent posts from all members" end it 'shows content of posts' do - rendered.should have_content 'This is some text.' + rendered.should have_content "This is some text." end it 'gives the author in the item title' do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 37e251bea..fa344e55b 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/new' do +describe "posts/new" do before(:each) do @author = FactoryBot.create(:member) assign(:post, FactoryBot.create(:post, author: @author)) @@ -9,22 +9,22 @@ describe 'posts/new' do controller.stub(:current_user) { @author } end - it 'renders new post form' do + it "renders new post form" do render - assert_select 'form', action: posts_path, method: 'post' do - assert_select 'input#post_subject', name: 'post[subject]' - assert_select 'textarea#post_body', name: 'post[body]' + assert_select "form", action: posts_path, method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end it 'no hidden forum field' do render - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do render - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end it "asks what's going on in your garden" do @@ -32,7 +32,7 @@ describe 'posts/new' do rendered.should have_content "What's going on in your food garden?" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, forum: @forum)) diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index e29fb3f1b..ba6921e4e 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/show' do +describe "posts/show" do subject { rendered } let(:author) { FactoryBot.create(:member) } @@ -11,7 +11,7 @@ describe 'posts/show' do describe 'render post' do before { render } - describe 'basic post' do + describe "basic post" do let(:post) { FactoryBot.create(:post, author: author) } # show the name of the member who posted the post @@ -23,17 +23,17 @@ describe 'posts/show' do it { is_expected.not_to have_text('An Update') } end - describe 'should parse markdown into html' do + describe "should parse markdown into html" do let(:post) { FactoryBot.create(:markdown_post, author: author) } - it { assert_select 'strong', 'strong' } + it { assert_select "strong", "strong" } end describe "shouldn't let html through in body" do let(:post) { FactoryBot.create(:post, author: author, body: 'EVIL') } it { is_expected.to have_content('EVIL') } - it { is_expected.not_to have_link('http://evil.com') } + it { is_expected.not_to have_link("http://evil.com") } end describe 'script tag in post body' do let(:post) { FactoryBot.create(:post, author: author, body: "") } @@ -53,7 +53,7 @@ describe 'posts/show' do end end - context 'when there is one comment' do + context "when there is one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } let!(:comment) { FactoryBot.create(:comment, post: post) } @@ -63,10 +63,10 @@ describe 'posts/show' do end it 'shows comment count only 1' do - assert_select 'div.post_comments', false + assert_select "div.post_comments", false end - it 'shows comments' do + it "shows comments" do is_expected.to have_content comment.body end @@ -75,36 +75,36 @@ describe 'posts/show' do end end - context 'when there is more than one comment' do + context "when there is more than one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } before(:each) do - @comment1 = FactoryBot.create(:comment, post: post, body: 'F1rst!!!', + @comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!", created_at: Date.new(2010, 5, 17)) - @comment3 = FactoryBot.create(:comment, post: post, body: 'Th1rd!!!', + @comment3 = FactoryBot.create(:comment, post: post, body: "Th1rd!!!", created_at: Date.new(2012, 5, 17)) - @comment4 = FactoryBot.create(:comment, post: post, body: 'F0urth!!!') - @comment2 = FactoryBot.create(:comment, post: post, body: 'S3c0nd!!1!', + @comment4 = FactoryBot.create(:comment, post: post, body: "F0urth!!!") + @comment2 = FactoryBot.create(:comment, post: post, body: "S3c0nd!!1!", created_at: Date.new(2011, 5, 17)) @comments = post.comments render end - it 'shows the oldest comments first' do + it "shows the oldest comments first" do is_expected.to have_content(/#{@comment1.body}.*#{@comment2.body}.*#{@comment3.body}.*#{@comment4.body}/m) end end - context 'forum post' do + context "forum post" do let(:post) { FactoryBot.create(:forum_post, author: author) } before { render } - it 'shows forum name' do + it "shows forum name" do is_expected.to have_content "in #{post.forum.name}" end end - context 'signed in' do + context "signed in" do let(:post) { FactoryBot.create(:post, author: author) } before(:each) do @@ -114,7 +114,7 @@ describe 'posts/show' do end it 'shows a comment button' do - is_expected.to have_link 'Comment', href: new_comment_path(post_id: post.id) + is_expected.to have_link "Comment", href: new_comment_path(post_id: post.id) end end end diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index f952c6e70..c22c4196f 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -25,6 +25,6 @@ describe 'posts/show.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index 568445d72..3d60c9e95 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'products/edit' do +describe "products/edit" do before(:each) do @product = assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99')) + name: "MyString", + description: "MyString", + min_price: "9.99")) end - it 'renders the edit product form' do + it "renders the edit product form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: products_path(@product), method: 'post' do - assert_select 'input#product_name', name: 'product[name]' - assert_select 'textarea#product_description', name: 'product[description]' - assert_select 'input#product_min_price', name: 'product[min_price]' - assert_select 'input#product_recommended_price', name: 'product[recommended_price]' + assert_select "form", action: products_path(@product), method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" end end end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index c92e2dc02..90e08e2a3 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'products/index' do +describe "products/index" do before(:each) do @product = FactoryBot.create(:product) assign(:products, [@product, @product]) end - it 'renders a list of products' do + it "renders a list of products" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @product.name, count: 2 - assert_select 'tr>td', text: @product.description, count: 2 - assert_select 'tr>td', text: @product.min_price.to_s, count: 2 + assert_select "tr>td", text: @product.name, count: 2 + assert_select "tr>td", text: @product.description, count: 2 + assert_select "tr>td", text: @product.min_price.to_s, count: 2 end end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index f4b596eaf..336c6bac1 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -1,24 +1,24 @@ require 'rails_helper' -describe 'products/new' do +describe "products/new" do before(:each) do assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99').as_new_record) + name: "MyString", + description: "MyString", + min_price: "9.99").as_new_record) end - it 'renders new product form' do + it "renders new product form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: products_path, method: 'post' do - assert_select 'input#product_name', name: 'product[name]' - assert_select 'textarea#product_description', name: 'product[description]' - assert_select 'input#product_min_price', name: 'product[min_price]' - assert_select 'input#product_recommended_price', name: 'product[recommended_price]' - assert_select 'select#product_account_type_id', name: 'product[account_type_id]' - assert_select 'input#product_paid_months', name: 'product[paid_months]' + assert_select "form", action: products_path, method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" + assert_select "select#product_account_type_id", name: "product[account_type_id]" + assert_select "input#product_paid_months", name: "product[paid_months]" end end end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb index 243eae01b..315d9caae 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'products/show' do +describe "products/show" do before(:each) do @product = assign(:product, FactoryBot.create(:product)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should have_content @product.name diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index 28a5283f2..a86f67ceb 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/edit' do +describe "roles/edit" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText')) + name: "MyString", + description: "MyText")) end - it 'renders the edit role form' do + it "renders the edit role form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: roles_path(@role), method: 'post' do - assert_select 'input#role_name', name: 'role[name]' - assert_select 'textarea#role_description', name: 'role[description]' + assert_select "form", action: roles_path(@role), method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index 232b750df..e4b28e9ba 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'roles/index' do +describe "roles/index" do before(:each) do controller.stub(:current_user) { nil } assign(:roles, [ stub_model(Role, - name: 'Name', - description: 'MyText'), + name: "Name", + description: "MyText"), stub_model(Role, - name: 'Name', - description: 'MyText') + name: "Name", + description: "MyText") ]) end - it 'renders a list of roles' do + it "renders a list of roles" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: 'Name'.to_s, count: 2 - assert_select 'tr>td', text: 'MyText'.to_s, count: 2 + assert_select "tr>td", text: "Name".to_s, count: 2 + assert_select "tr>td", text: "MyText".to_s, count: 2 end end diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index d11424840..1cdce8c41 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/new' do +describe "roles/new" do before(:each) do assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText').as_new_record) + name: "MyString", + description: "MyText").as_new_record) end - it 'renders new role form' do + it "renders new role form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: roles_path, method: 'post' do - assert_select 'input#role_name', name: 'role[name]' - assert_select 'textarea#role_description', name: 'role[description]' + assert_select "form", action: roles_path, method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 2d3ea832f..56f1cc4fb 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'roles/show' do +describe "roles/show" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'Name', - description: 'MyText')) + name: "Name", + description: "MyText")) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 081e5a548..ecaa2056f 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'scientific_names/edit' do - context 'logged in' do +describe "scientific_names/edit" do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -11,14 +11,14 @@ describe 'scientific_names/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@scientific_name.creator} less than a minute ago." end - it 'renders the edit scientific_name form' do - assert_select 'form', action: scientific_names_path(@scientific_name), method: 'post' do - assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' - assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' + it "renders the edit scientific_name form" do + assert_select "form", action: scientific_names_path(@scientific_name), method: "post" do + assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end end diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 682b7078d..4d63ac9e1 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'scientific_names/index' do +describe "scientific_names/index" do before(:each) do controller.stub(:current_user) { nil } assign(:scientific_names, [ @@ -9,29 +9,29 @@ describe 'scientific_names/index' do ]) end - it 'renders a list of scientific_names' do + it "renders a list of scientific_names" do render - assert_select 'tr>td', text: 'Zea mays'.to_s - assert_select 'tr>td', text: 'Solanum lycopersicum'.to_s + assert_select "tr>td", text: "Zea mays".to_s + assert_select "tr>td", text: "Solanum lycopersicum".to_s end it "doesn't show edit/destroy links" do render - rendered.should_not have_content 'Edit' - rendered.should_not have_content 'Delete' + rendered.should_not have_content "Edit" + rendered.should_not have_content "Delete" end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member controller.stub(:current_user) { @member } end - it 'shows edit/destroy links' do + it "shows edit/destroy links" do render - rendered.should have_content 'Edit' - rendered.should have_content 'Delete' + rendered.should have_content "Edit" + rendered.should have_content "Delete" end end end diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index a7ad30252..0cf5a4205 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'scientific_names/new' do +describe "scientific_names/new" do before(:each) do assign(:scientific_name, FactoryBot.create(:zea_mays)) end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -13,12 +13,12 @@ describe 'scientific_names/new' do render end - it 'renders new scientific_name form' do + it "renders new scientific_name form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: scientific_names_path, method: 'post' do - assert_select 'input#scientific_name_name', name: 'scientific_name[scientific_name]' - assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' + assert_select "form", action: scientific_names_path, method: "post" do + assert_select "input#scientific_name_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end end diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index 85d3be9ba..b728df2b3 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'scientific_names/show' do +describe "scientific_names/show" do before(:each) do controller.stub(:current_user) { nil } @scientific_name = assign(:scientific_name, FactoryBot.create(:zea_mays)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Zea mays/) diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 14e604816..f450d7065 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/edit' do +describe "seeds/edit" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -8,23 +8,23 @@ describe 'seeds/edit' do @seed = FactoryBot.create(:seed, owner: @member) end - it 'renders the edit seed form' do + it "renders the edit seed form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: seeds_path(@seed), method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#seed_crop_id', name: 'seed[crop_id]' - assert_select 'textarea#seed_description', name: 'seed[description]' - assert_select 'input#seed_quantity', name: 'seed[quantity]' - assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' + assert_select "form", action: seeds_path(@seed), method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it "doesn't revert tradable_to to nowhere" do @seed = FactoryBot.create(:tradable_seed, owner: @member) - @seed.tradable_to.should_not eq 'nowhere' + @seed.tradable_to.should_not eq "nowhere" render - assert_select 'option[selected=selected]', text: @seed.tradable_to + assert_select "option[selected=selected]", text: @seed.tradable_to end end diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index bfb6e27c4..4df8e526c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -14,7 +14,7 @@ describe 'seeds/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent seeds from all members' + rendered.should have_content "Recent seeds from all members" end it 'has a useful item title' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index 0270d831c..5c5cf3ae4 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/new' do +describe "seeds/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,21 +9,21 @@ describe 'seeds/new' do assign(:seed, @seed1) end - it 'renders new seed form' do + it "renders new seed form" do render - assert_select 'form', action: seeds_path, method: 'post' do - assert_select 'input#crop', class: 'ui-autocomplete-input' - assert_select 'input#seed_crop_id', name: 'seed[crop_id]' - assert_select 'textarea#seed_description', name: 'seed[description]' - assert_select 'input#seed_quantity', name: 'seed[quantity]' - assert_select 'select#seed_tradable_to', name: 'seed[tradable_to]' + assert_select "form", action: seeds_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it 'reminds you to set your location' do render rendered.should have_content "Don't forget to set your location." - assert_select 'a', text: 'set your location' + assert_select "a", text: "set your location" end context 'member has location' do @@ -43,7 +43,7 @@ describe 'seeds/new' do it 'links to change location' do render - assert_select 'a', text: 'Change your location.' + assert_select "a", text: "Change your location." end end end diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 854b87e2c..fd2848f97 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/show' do +describe "seeds/show" do before(:each) do controller.stub(:current_user) { nil } @seed = FactoryBot.create(:seed) @@ -8,12 +8,12 @@ describe 'seeds/show' do assign(:photos, @seed.photos.paginate(page: 1)) end - it 'renders attributes in

' do + it "renders attributes in

" do render rendered.should have_content @seed.crop.name end - context 'tradable' do + context "tradable" do before(:each) do @owner = FactoryBot.create(:london_member) assign(:seed, FactoryBot.create(:tradable_seed, @@ -24,12 +24,12 @@ describe 'seeds/show' do controller.stub(:current_user) { @member } end - it 'shows tradable attributes' do + it "shows tradable attributes" do render - rendered.should have_content 'Will trade: locally' + rendered.should have_content "Will trade: locally" end - it 'shows location of seed owner' do + it "shows location of seed owner" do render rendered.should have_content @owner.location assert_select 'a', href: place_path(@owner.location) @@ -45,18 +45,18 @@ describe 'seeds/show' do it 'says "from unspecified location"' do render - rendered.should have_content '(from unspecified location)' + rendered.should have_content "(from unspecified location)" end - it 'links to profile to set location' do + it "links to profile to set location" do render - assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: 'Set Location' + assert_select "a[href='#{url_for(edit_member_registration_path)}']", text: "Set Location" end end - it 'shows button to send message' do + it "shows button to send message" do render - rendered.should have_content 'Request seeds' + rendered.should have_content "Request seeds" end end end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index a23320f44..754f05c09 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'shop/index.html.haml', type: 'view' do +describe 'shop/index.html.haml', type: "view" do before(:each) do @product1 = FactoryBot.create(:product) @product2 = FactoryBot.create(:product_with_recommended_price) @@ -8,7 +8,7 @@ describe 'shop/index.html.haml', type: 'view' do assign(:order_item, OrderItem.new) end - context 'signed in' do + context "signed in" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -16,7 +16,7 @@ describe 'shop/index.html.haml', type: 'view' do end it 'shows products' do - assert_select('h2', text: @product1.name) + assert_select("h2", text: @product1.name) end it 'shows prices in configured currency' do @@ -38,15 +38,15 @@ describe 'shop/index.html.haml', type: 'view' do end it 'displays the order form' do - assert_select 'form', count: 2 + assert_select "form", count: 2 end it 'renders markdown in product descriptions' do - assert_select 'em', text: 'hurrah', count: 2 + assert_select "em", text: 'hurrah', count: 2 end end - context 'is paid' do + context "is paid" do before(:each) do @member = FactoryBot.create(:member) @member.account.account_type = FactoryBot.create(:paid_account_type) @@ -54,29 +54,29 @@ describe 'shop/index.html.haml', type: 'view' do controller.stub(:current_member) { @member } end - it 'recognises the paid member' do + it "recognises the paid member" do @member.paid?.should be(true) end - it 'tells you you have a paid membership' do + it "tells you you have a paid membership" do render - rendered.should have_content 'You currently have a paid' + rendered.should have_content "You currently have a paid" end it "doesn't show shop" do render - assert_select 'form', false + assert_select "form", false end end - context 'signed out' do + context "signed out" do before(:each) do controller.stub(:current_user) { nil } render end - it 'tells you to sign up/sign in' do - rendered.should have_content 'sign in or sign up' + it "tells you to sign up/sign in" do + rendered.should have_content "sign in or sign up" end end end From 42de7264050f17b832a96e9474edad9f3c88f5a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 13:40:29 +1300 Subject: [PATCH 084/101] Removing shop, products, accounts, orders --- .rubocop_todo.yml | 2 - app/controllers/account_types_controller.rb | 53 ----- app/controllers/accounts_controller.rb | 31 --- app/controllers/admin/orders_controller.rb | 23 --- app/controllers/order_items_controller.rb | 36 ---- app/controllers/orders_controller.rb | 90 -------- app/controllers/products_controller.rb | 46 ----- app/controllers/shop_controller.rb | 19 -- app/models/ability.rb | 25 --- app/models/account.rb | 23 --- app/models/account_type.rb | 13 -- app/models/member.rb | 35 +--- app/models/order.rb | 90 -------- app/models/order_item.rb | 12 -- app/models/product.rb | 15 -- app/views/account_types/_form.html.haml | 21 -- app/views/account_types/edit.html.haml | 7 - app/views/account_types/index.html.haml | 23 --- app/views/account_types/new.html.haml | 5 - app/views/account_types/show.html.haml | 17 -- app/views/accounts/_form.html.haml | 21 -- app/views/accounts/edit.html.haml | 7 - app/views/accounts/index.html.haml | 23 --- app/views/accounts/new.html.haml | 5 - app/views/accounts/show.html.haml | 15 -- app/views/admin/index.html.haml | 7 - app/views/admin/orders/_searchform.html.haml | 8 - app/views/admin/orders/index.html.haml | 3 - app/views/admin/orders/search.html.haml | 41 ---- app/views/layouts/_header.html.haml | 2 - app/views/members/_account.html.haml | 24 --- app/views/members/_roles.html.haml | 9 + app/views/members/show.html.haml | 4 +- app/views/orders/complete.html.haml | 45 ---- app/views/orders/index.html.haml | 44 ---- app/views/orders/show.html.haml | 84 -------- app/views/products/_form.html.haml | 32 --- app/views/products/edit.html.haml | 7 - app/views/products/index.html.haml | 29 --- app/views/products/new.html.haml | 5 - app/views/products/show.html.haml | 25 --- app/views/shared/_account_status.html.haml | 13 -- app/views/shop/index.html.haml | 83 -------- config/application.rb | 3 - config/locales/en.yml | 10 - config/routes.rb | 17 +- db/migrate/20180205000612_remove_shop.rb | 9 + db/schema.rb | 48 +---- db/seeds.rb | 50 ----- lib/tasks/growstuff.rake | 73 ------- .../account_types_controller_spec.rb | 31 --- spec/controllers/accounts_controller_spec.rb | 18 -- .../admin/orders_controller_spec.rb | 18 -- .../order_items_controller_spec.rb | 51 ----- spec/controllers/orders_controller_spec.rb | 53 ----- spec/controllers/products_controller_spec.rb | 17 -- spec/controllers/shop_controller_spec.rb | 36 ---- spec/factories/account_types.rb | 33 --- spec/factories/accounts.rb | 7 - spec/factories/order_items.rb | 10 - spec/factories/orders.rb | 14 -- spec/factories/products.rb | 15 -- spec/features/admin/account_types_spec.rb | 58 ------ spec/features/admin/products_spec.rb | 44 ---- spec/features/member_profile_spec.rb | 5 - spec/features/members/deletion_spec.rb | 11 - spec/models/ability_spec.rb | 195 ------------------ spec/models/account_spec.rb | 27 --- spec/models/account_type_spec.rb | 4 - spec/models/member_spec.rb | 92 --------- spec/models/order_item_spec.rb | 26 --- spec/models/order_spec.rb | 133 ------------ spec/models/product_spec.rb | 8 - spec/routing/account_types_routing_spec.rb | 33 --- spec/routing/order_items_routing_spec.rb | 33 --- spec/routing/orders_routing_spec.rb | 33 --- spec/routing/products_routing_spec.rb | 33 --- .../account_types/edit.html.haml_spec.rb | 21 -- .../account_types/index.html.haml_spec.rb | 14 -- .../views/account_types/new.html.haml_spec.rb | 21 -- .../account_types/show.html.haml_spec.rb | 18 -- spec/views/accounts/edit.html.haml_spec.rb | 18 -- spec/views/accounts/index.html.haml_spec.rb | 15 -- spec/views/accounts/new.html.haml_spec.rb | 18 -- spec/views/accounts/show.html.haml_spec.rb | 16 -- spec/views/admin/index_spec.rb | 2 - spec/views/admin/orders/index_spec.rb | 20 -- spec/views/orders/index.html.haml_spec.rb | 23 --- spec/views/orders/show.html.haml_spec.rb | 69 ------- spec/views/products/edit.html.haml_spec.rb | 22 -- spec/views/products/index.html.haml_spec.rb | 16 -- spec/views/products/new.html.haml_spec.rb | 24 --- spec/views/products/show.html.haml_spec.rb | 15 -- spec/views/shop/index_spec.rb | 82 -------- 94 files changed, 22 insertions(+), 2762 deletions(-) delete mode 100644 app/controllers/account_types_controller.rb delete mode 100644 app/controllers/accounts_controller.rb delete mode 100644 app/controllers/admin/orders_controller.rb delete mode 100644 app/controllers/order_items_controller.rb delete mode 100644 app/controllers/orders_controller.rb delete mode 100644 app/controllers/products_controller.rb delete mode 100644 app/controllers/shop_controller.rb delete mode 100644 app/models/account.rb delete mode 100644 app/models/account_type.rb delete mode 100644 app/models/order.rb delete mode 100644 app/models/order_item.rb delete mode 100644 app/models/product.rb delete mode 100644 app/views/account_types/_form.html.haml delete mode 100644 app/views/account_types/edit.html.haml delete mode 100644 app/views/account_types/index.html.haml delete mode 100644 app/views/account_types/new.html.haml delete mode 100644 app/views/account_types/show.html.haml delete mode 100644 app/views/accounts/_form.html.haml delete mode 100644 app/views/accounts/edit.html.haml delete mode 100644 app/views/accounts/index.html.haml delete mode 100644 app/views/accounts/new.html.haml delete mode 100644 app/views/accounts/show.html.haml delete mode 100644 app/views/admin/orders/_searchform.html.haml delete mode 100644 app/views/admin/orders/index.html.haml delete mode 100644 app/views/admin/orders/search.html.haml delete mode 100644 app/views/members/_account.html.haml create mode 100644 app/views/members/_roles.html.haml delete mode 100644 app/views/orders/complete.html.haml delete mode 100644 app/views/orders/index.html.haml delete mode 100644 app/views/orders/show.html.haml delete mode 100644 app/views/products/_form.html.haml delete mode 100644 app/views/products/edit.html.haml delete mode 100644 app/views/products/index.html.haml delete mode 100644 app/views/products/new.html.haml delete mode 100644 app/views/products/show.html.haml delete mode 100644 app/views/shared/_account_status.html.haml delete mode 100644 app/views/shop/index.html.haml create mode 100644 db/migrate/20180205000612_remove_shop.rb delete mode 100644 spec/controllers/account_types_controller_spec.rb delete mode 100644 spec/controllers/accounts_controller_spec.rb delete mode 100644 spec/controllers/admin/orders_controller_spec.rb delete mode 100644 spec/controllers/order_items_controller_spec.rb delete mode 100644 spec/controllers/orders_controller_spec.rb delete mode 100644 spec/controllers/products_controller_spec.rb delete mode 100644 spec/controllers/shop_controller_spec.rb delete mode 100644 spec/factories/account_types.rb delete mode 100644 spec/factories/accounts.rb delete mode 100644 spec/factories/order_items.rb delete mode 100644 spec/factories/orders.rb delete mode 100644 spec/factories/products.rb delete mode 100644 spec/features/admin/account_types_spec.rb delete mode 100644 spec/features/admin/products_spec.rb delete mode 100644 spec/models/account_spec.rb delete mode 100644 spec/models/account_type_spec.rb delete mode 100644 spec/models/order_item_spec.rb delete mode 100644 spec/models/order_spec.rb delete mode 100644 spec/models/product_spec.rb delete mode 100644 spec/routing/account_types_routing_spec.rb delete mode 100644 spec/routing/order_items_routing_spec.rb delete mode 100644 spec/routing/orders_routing_spec.rb delete mode 100644 spec/routing/products_routing_spec.rb delete mode 100644 spec/views/account_types/edit.html.haml_spec.rb delete mode 100644 spec/views/account_types/index.html.haml_spec.rb delete mode 100644 spec/views/account_types/new.html.haml_spec.rb delete mode 100644 spec/views/account_types/show.html.haml_spec.rb delete mode 100644 spec/views/accounts/edit.html.haml_spec.rb delete mode 100644 spec/views/accounts/index.html.haml_spec.rb delete mode 100644 spec/views/accounts/new.html.haml_spec.rb delete mode 100644 spec/views/accounts/show.html.haml_spec.rb delete mode 100644 spec/views/admin/orders/index_spec.rb delete mode 100644 spec/views/orders/index.html.haml_spec.rb delete mode 100644 spec/views/orders/show.html.haml_spec.rb delete mode 100644 spec/views/products/edit.html.haml_spec.rb delete mode 100644 spec/views/products/index.html.haml_spec.rb delete mode 100644 spec/views/products/new.html.haml_spec.rb delete mode 100644 spec/views/products/show.html.haml_spec.rb delete mode 100644 spec/views/shop/index_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e0d899c7..9c3ccad34 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -39,7 +39,6 @@ Rails/SkipsModelValidations: # SupportedStyles: strict, flexible Rails/TimeZone: Exclude: - - 'spec/controllers/accounts_controller_spec.rb' - 'spec/factories/member.rb' - 'spec/factories/post.rb' - 'spec/models/post_spec.rb' @@ -60,7 +59,6 @@ Style/AsciiComments: # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: - - 'app/controllers/admin/orders_controller.rb' - 'lib/actions/oauth_signup_action.rb' - 'lib/haml/filters/escaped_markdown.rb' diff --git a/app/controllers/account_types_controller.rb b/app/controllers/account_types_controller.rb deleted file mode 100644 index f86892346..000000000 --- a/app/controllers/account_types_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -class AccountTypesController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /account_types - def index - @account_types = AccountType.all.order(:name) - respond_with(@account_types) - end - - # GET /account_types/1 - def show - respond_with(@account_types) - end - - # GET /account_types/new - def new - @account_type = AccountType.new - respond_with(@account_type) - end - - # GET /account_types/1/edit - def edit - respond_with(@account_type) - end - - # POST /account_types - def create - @account_type = AccountType.new(account_type_params) - flash[:notice] = I18n.t('account_types.created') if @account_type.save - respond_with(@account_type) - end - - # PUT /account_types/1 - def update - flash[:notice] = I18n.t('account_types.updated') if @account_type.update(account_type_params) - respond_with(@account_type) - end - - # DELETE /account_types/1 - def destroy - @account_type.destroy - flash[:notice] = I18n.t('account_types.deleted') - respond_with(@account_type) - end - - private - - def account_type_params - params.require(:account_type).permit(:is_paid, :is_permanent_paid, :name) - end -end diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb deleted file mode 100644 index 040092aba..000000000 --- a/app/controllers/accounts_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class AccountsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /accounts - def index - @accounts = Account.all.order(created_at: :desc) - respond_with(@accounts) - end - - # GET /accounts/1 - def show - respond_with(@account) - end - - # GET /accounts/1/edit - def edit; end - - # PUT /accounts/1 - def update - flash[:notice] = I18n.t('account.update') if @account.update(params[:account]) - respond_with(@account) - end - - private - - def account_params - params.require(:account).permit(:account_type_id, :member_id, :paid_until) - end -end diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb deleted file mode 100644 index d4f727ec0..000000000 --- a/app/controllers/admin/orders_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Admin - class OrdersController < ApplicationController - def index - authorize! :manage, :all - respond_to do |format| - format.html # index.html.haml - end - end - - def search - authorize! :manage, :all - @orders = Order.search(by: params[:search_by], for: params[:search_text]) - - if @orders.empty? - flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}" - end - - respond_to do |format| - format.html # index.html.haml - end - end - end -end diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb deleted file mode 100644 index 326cff21f..000000000 --- a/app/controllers/order_items_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -class OrderItemsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - # POST /order_items - def create - if params[:order_item][:price] - params[:order_item][:price] = params[:order_item][:price].to_f * 100 # convert to cents - end - - @order_item = OrderItem.new(order_item_params) - @order_item.order = current_member.current_order || Order.create(member_id: current_member.id) - - if @order_item.save - redirect_to @order_item.order, notice: 'Added item to your order.' - else - redirect_to shop_path, alert: errors - end - end - - private - - def errors - if @order_item.errors.empty? - "There was a problem with your order." - else - @order_item.errors.full_messages.to_sentence - end - end - - def order_item_params - params.require(:order_item).permit(:order_id, :price, :product_id, :quantity) - end -end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb deleted file mode 100644 index 3bc9fe45c..000000000 --- a/app/controllers/orders_controller.rb +++ /dev/null @@ -1,90 +0,0 @@ -class OrdersController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - - # GET /orders - def index - @orders = Order.by_member(current_member) - - respond_to do |format| - format.html # index.html.erb - end - end - - # GET /orders/1 - def show - respond_to do |format| - format.html # show.html.erb - end - end - - # GET /orders/new - def new - @order = Order.new - - respond_to do |format| - format.html # new.html.erb - end - end - - # checkout with PayPal - def checkout - respond_to do |format| - if @order.update_attributes(referral_code: params[:referral_code]) - response = EXPRESS_GATEWAY.setup_purchase( - @order.total, - items: @order.activemerchant_items, - currency: Growstuff::Application.config.currency, - no_shipping: true, - ip: request.remote_ip, - return_url: complete_order_url, - cancel_return_url: shop_url - ) - format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } - else - format.html { render action: "show" } - end - end - end - - def complete - if params[:token] && params['PayerID'] - purchase = EXPRESS_GATEWAY.purchase( - @order.total, - currency: Growstuff::Application.config.currency, - ip: request.remote_ip, - payer_id: params['PayerID'], - token: params[:token] - ) - if purchase.success? - @order.completed_at = Time.zone.now - @order.record_paypal_details(params[:token]) - else - flash[:alert] = "Could not complete your order. Please notify support." - end - else - flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." - end - - @order.update_account # apply paid account benefits, etc. - - respond_to do |format| - format.html # new.html.erb - end - end - - def cancel - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was cancelled.' } - end - end - - # DELETE /orders/1 - def destroy - @order.destroy - - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was deleted.' } - end - end -end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb deleted file mode 100644 index 8e0a1fb08..000000000 --- a/app/controllers/products_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class ProductsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - def index - @products = Product.all.order(:name) - respond_with @products - end - - def show - respond_with @product - end - - def new - @product = Product.new - respond_with @product - end - - def edit - respond_with @product - end - - def create - @product = Product.create(product_params) - respond_with @product - end - - def update - @product.update(product_params) - respond_with @product - end - - def destroy - @product.destroy - respond_with @product - end - - private - - def product_params - params.require(:product).permit(:description, :min_price, :recommended_price, :name, - :account_type_id, :paid_months) - end -end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb deleted file mode 100644 index 964511e50..000000000 --- a/app/controllers/shop_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ShopController < ApplicationController - respond_to :html - def index - @products = Product.all - @order_item = OrderItem.new - - # this is (hopefully) part of a short-term hack to prevent people from - # ordering multiple subscriptions, which would be very confusing to deal - # with. We check whether they have an order already in progress, and if - # so, point that out to them and encourage them to checkout, rather than - # letting them add more stuff to their order. - - @order = nil - @most_recent_item = nil - return unless current_member - @order = current_member.current_order - @most_recent_item = @order.order_items.first if @order - end -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 283bf45cc..89a304257 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,14 +24,9 @@ class Ability # except these, which don't make sense if you're not logged in cannot :read, Notification cannot :read, Authentication - cannot :read, Order - cannot :read, OrderItem # and nobody should be able to view this except admins cannot :read, Role - cannot :read, Product - cannot :read, Account - cannot :read, AccountType # nobody should be able to view unapproved crops unless they # are wranglers or admins @@ -120,20 +115,6 @@ class Ability can :update, Seed, owner_id: member.id can :destroy, Seed, owner_id: member.id - # orders/shop/etc - can :create, Order - can :read, Order, member_id: member.id - can :complete, Order, member_id: member.id, completed_at: nil - can :checkout, Order, member_id: member.id, completed_at: nil - can :cancel, Order, member_id: member.id, completed_at: nil - can :destroy, Order, member_id: member.id, completed_at: nil - - can :create, OrderItem - # for now, let's not let people mess with individual order items - cannot :read, OrderItem, order: { member_id: member.id } - cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil } - cannot :destroy, OrderItem, order: { member_id: member.id, completed_at: nil } - # following/unfollowing permissions can :create, Follow cannot :create, Follow, followed_id: member.id # can't follow yourself @@ -148,12 +129,6 @@ class Ability can :read, :all can :manage, :all - # can't change order history, because it's *history* - cannot :create, Order - cannot :complete, Order - cannot :destroy, Order - cannot :manage, OrderItem - # can't delete plant parts if they have harvests associated with them cannot :destroy, PlantPart can :destroy, PlantPart do |pp| diff --git a/app/models/account.rb b/app/models/account.rb deleted file mode 100644 index 646e9db78..000000000 --- a/app/models/account.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Account < ActiveRecord::Base - belongs_to :member - belongs_to :account_type - - validates :member_id, uniqueness: { - message: 'already has account details associated with it' - } - - before_create do |account| - unless account.account_type - account.account_type = AccountType.find_or_create_by(name: - Growstuff::Application.config.default_account_type) - end - end - - def paid_until_string - if account_type.is_permanent_paid - "forever" - elsif account_type.is_paid - paid_until.to_s - end - end -end diff --git a/app/models/account_type.rb b/app/models/account_type.rb deleted file mode 100644 index 06416751a..000000000 --- a/app/models/account_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AccountType < ActiveRecord::Base - # - # Relationships - has_many :products - - # - # Validations - validates :name, presence: true, uniqueness: true - - def to_s - name - end -end diff --git a/app/models/member.rb b/app/models/member.rb index 9828a005c..e7601f43d 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -7,7 +7,7 @@ class Member < ActiveRecord::Base friendly_id :login_name, use: %i(slugged finders) # - # Relationshops + # Relationships has_many :posts, foreign_key: 'author_id' has_many :comments, foreign_key: 'author_id' has_many :forums, foreign_key: 'owner_id' @@ -19,9 +19,6 @@ class Member < ActiveRecord::Base has_many :notifications, foreign_key: 'recipient_id' has_many :sent_notifications, foreign_key: 'sender_id' has_many :authentications - has_many :orders - has_one :account - has_one :account_type, through: :account has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy @@ -79,11 +76,9 @@ class Member < ActiveRecord::Base after_save :update_newsletter_subscription # Give each new member a default garden - # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } - after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address def self.find_first_by_auth_conditions(warden_conditions) @@ -101,34 +96,6 @@ class Member < ActiveRecord::Base roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end - def current_order - orders.find_by(completed_at: nil) - end - - # when purchasing a product that gives you a paid account, this method - # does all the messing around to actually make sure the account is - # updated correctly -- account type, paid until, etc. Usually this is - # called by order.update_account, which loops through all order items - # and does this for each one. - def update_account_after_purchase(product) - account.account_type = product.account_type if product.account_type - if product.paid_months - start_date = account.paid_until || Time.zone.now - account.paid_until = start_date + product.paid_months.months - end - account.save - end - - def paid? - if account.account_type.is_permanent_paid - true - elsif account.account_type.is_paid && account.paid_until >= Time.zone.now - true - else - false - end - end - def auth(provider) authentications.find_by(provider: provider) end diff --git a/app/models/order.rb b/app/models/order.rb deleted file mode 100644 index 53a309c35..000000000 --- a/app/models/order.rb +++ /dev/null @@ -1,90 +0,0 @@ -class Order < ActiveRecord::Base - # - # Relationships - belongs_to :member, with_deleted: true - has_many :order_items, dependent: :destroy - - # - # Validations - validates :referral_code, format: { - with: /\A[a-zA-Z0-9 ]*\z/, - message: "may only include letters and numbers" - } - - # - # Teiggers - before_save :standardize_referral_code - - # - # Scopes - scope :by_member, ->(member) { where(member: member) } - - # total price of an order - def total - sum = 0 - order_items.each do |i| - subtotal = i.price * i.quantity - sum += subtotal - end - sum - end - - # return items in the format ActiveMerchant/PayPal want them - def activemerchant_items - items = [] - order_items.each do |i| - items.push(name: i.product.name, - quantity: i.quantity, - amount: i.price) - end - items - end - - # record the paypal details for reference - def record_paypal_details(token) - self.paypal_express_token = token - details = EXPRESS_GATEWAY.details_for(token) - self.paypal_express_payer_id = details.payer_id - save - end - - # when an order is completed, we update the member's account to mark - # them as paid, or whatever, based on what products they ordered - def update_account - order_items.each do |i| - member.update_account_after_purchase(i.product) - end - end - - # removes whitespace and forces to uppercase (we're somewhat liberal - # in what we accept, but we clean it up anyway.) - def standardize_referral_code - self.referral_code = referral_code.upcase.gsub(/\s/, '') if referral_code - end - - # search orders (used by admin/orders) - # usage: Order.search({ :by => 'member', :for => 'Skud' }) - # can search by: member, order_id, paypal_token, paypal_payer_id, - def self.search(args = {}) - if args[:for] - case args[:by] - when "member" - member = Member.with_deleted.find_by(login_name: args[:for]) - return member.orders if member - when "order_id" - order = Order.find_by(id: args[:for]) - return [order] if order - when "paypal_token" - order = Order.find_by(paypal_express_token: args[:for]) - return [order] if order - when "paypal_payer_id" - order = Order.find_by(paypal_express_payer_id: args[:for]) - return [order] if order - when "referral_code" - # coerce to uppercase - return Order.where(referral_code: args[:for].upcase) - end - end - [] - end -end diff --git a/app/models/order_item.rb b/app/models/order_item.rb deleted file mode 100644 index 380fbff58..000000000 --- a/app/models/order_item.rb +++ /dev/null @@ -1,12 +0,0 @@ -class OrderItem < ActiveRecord::Base - belongs_to :order - belongs_to :product - - validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: "may only have one item." } - - def price_must_be_greater_than_minimum - @product = Product.find(product_id) - errors.add(:price, "must be greater than the product's minimum value") if price < @product.min_price - end -end diff --git a/app/models/product.rb b/app/models/product.rb deleted file mode 100644 index 01b5a8902..000000000 --- a/app/models/product.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Product < ActiveRecord::Base - # - # Relationships - belongs_to :account_type - has_and_belongs_to_many :orders # rubocop:disable Rails/HasAndBelongsToMany - - # - # Validations - validates :paid_months, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :min_price, presence: true - - def to_s - name - end -end diff --git a/app/views/account_types/_form.html.haml b/app/views/account_types/_form.html.haml deleted file mode 100644 index 5bfbb539a..000000000 --- a/app/views/account_types/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account_type do |f| - - if @account_type.errors.any? - #error_explanation - %h2 - = pluralize(@account_type.errors.size, "error") - prohibited this account_type from being saved: - %ul - - @account_type.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name - .field - = f.label :is_paid - = f.check_box :is_paid - .field - = f.label :is_permanent_paid - = f.check_box :is_permanent_paid - .actions - = f.submit 'Save' diff --git a/app/views/account_types/edit.html.haml b/app/views/account_types/edit.html.haml deleted file mode 100644 index c994c4ff1..000000000 --- a/app/views/account_types/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account type" - -= render 'form' - -= link_to 'Show', @account_type -\| -= link_to 'Back', account_types_path diff --git a/app/views/account_types/index.html.haml b/app/views/account_types/index.html.haml deleted file mode 100644 index 6af6d129d..000000000 --- a/app/views/account_types/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing account types" - -%table - %tr - %th Name - %th Is paid - %th Is permanent paid - %th - %th - %th - - - @account_types.each do |account_type| - %tr - %td= account_type.name - %td= account_type.is_paid - %td= account_type.is_permanent_paid - %td= link_to 'Show', account_type - %td= link_to 'Edit', edit_account_type_path(account_type) - %td= link_to 'Destroy', account_type, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account type', new_account_type_path diff --git a/app/views/account_types/new.html.haml b/app/views/account_types/new.html.haml deleted file mode 100644 index 92d309715..000000000 --- a/app/views/account_types/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account type" - -= render 'form' - -= link_to 'Back', account_types_path diff --git a/app/views/account_types/show.html.haml b/app/views/account_types/show.html.haml deleted file mode 100644 index a3f7f690b..000000000 --- a/app/views/account_types/show.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @account_type.name -%p - %b Is paid: - = @account_type.is_paid -%p - %b Is permanent paid: - = @account_type.is_permanent_paid - -= link_to 'Edit', edit_account_type_path(@account_type) -\| -= link_to 'Delete', @account_type, method: :delete, data: { confirm: 'Are you sure?' } -\| -= link_to 'Back', account_types_path diff --git a/app/views/accounts/_form.html.haml b/app/views/accounts/_form.html.haml deleted file mode 100644 index 410b717fa..000000000 --- a/app/views/accounts/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account do |f| - - if @account.errors.any? - #error_explanation - %h2 - = pluralize(@account.errors.size, "error") - prohibited this account from being saved: - %ul - - @account.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :member_id - = f.number_field :member_id - .field - = f.label :account_type - = f.text_field :account_type - .field - = f.label :paid_until - = f.datetime_select :paid_until - .actions - = f.submit 'Save' diff --git a/app/views/accounts/edit.html.haml b/app/views/accounts/edit.html.haml deleted file mode 100644 index ef8d08801..000000000 --- a/app/views/accounts/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account" - -= render 'form' - -= link_to 'Show', @account -\| -= link_to 'Back', accounts_path diff --git a/app/views/accounts/index.html.haml b/app/views/accounts/index.html.haml deleted file mode 100644 index 8d929dd0f..000000000 --- a/app/views/accounts/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing accounts" - -%table - %tr - %th Member - %th Account type - %th Paid until - %th - %th - %th - - - @accounts.each do |account| - %tr - %td= account.member_id - %td= account.account_type - %td= account.paid_until - %td= link_to 'Show', account - %td= link_to 'Edit', edit_account_path(account) - %td= link_to 'Destroy', account, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account detail', new_account_path diff --git a/app/views/accounts/new.html.haml b/app/views/accounts/new.html.haml deleted file mode 100644 index 9430cc2ed..000000000 --- a/app/views/accounts/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account" - -= render 'form' - -= link_to 'Back', accounts_path diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml deleted file mode 100644 index 5c5288674..000000000 --- a/app/views/accounts/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -%p#notice= notice - -%p - %b Member: - = @account.member_id -%p - %b Account type: - = @account.account_type.name -%p - %b Paid until: - = @account.paid_until - -= link_to 'Edit', edit_account_path(@account) -\| -= link_to 'Back', accounts_path diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index 294e16199..e7b164280 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -6,8 +6,6 @@ .col-md-4 %h2 Site admin %ul#site_admin - %li= link_to "Account types", account_types_path - %li= link_to "Products", products_path %li= link_to "Roles", roles_path %li= link_to "Forums", forums_path %li= link_to "CMS", comfy_admin_cms_path @@ -22,8 +20,3 @@ %ul %li= link_to "Newsletter subscribers", admin_newsletter_path %li= link_to "Members", admin_members_path - -.row - .col-md-12 - %h2 Orders - = render "admin/orders/searchform" diff --git a/app/views/admin/orders/_searchform.html.haml b/app/views/admin/orders/_searchform.html.haml deleted file mode 100644 index e0a4dc22c..000000000 --- a/app/views/admin/orders/_searchform.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= form_tag(url_for(controller: 'admin/orders', action: 'search'), method: :get, class: 'form-inline') do - = label_tag :distance, "Search orders:", class: 'control-label' - = text_field_tag :search_text - = select_tag :search_by, - options_for_select('Member': 'member', 'Referral code': 'referral_code', - 'Order ID': 'order_id', 'Paypal Token': 'paypal_token', - 'Paypal Payer ID': 'paypal_payer_id') - = submit_tag "Search", class: 'btn btn-primary' diff --git a/app/views/admin/orders/index.html.haml b/app/views/admin/orders/index.html.haml deleted file mode 100644 index e5f67f6c3..000000000 --- a/app/views/admin/orders/index.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :title, 'Admin Orders' - -= render "admin/orders/searchform" diff --git a/app/views/admin/orders/search.html.haml b/app/views/admin/orders/search.html.haml deleted file mode 100644 index 23c93d01a..000000000 --- a/app/views/admin/orders/search.html.haml +++ /dev/null @@ -1,41 +0,0 @@ -- content_for :title, 'Search Orders' - -= render "admin/orders/searchform" - -- unless @orders.empty? - %h2 - Found - = pluralize(@orders.size, "result") - - %table.table.table-striped - %tr - %th Member - %th Order number - %th Date completed - %th Referral code - %th Items - %th - - - @orders.each do |order| - %tr - %td - = link_to order.member.login_name, order.member - = "(deleted)" if order.member.deleted_at - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - = order.referral_code - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 3eb0d8ca0..d2b8fd01c 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -47,7 +47,6 @@ %li= link_to t('.browse_members'), members_path %li= link_to t('.posts'), posts_path %li= link_to t('.forums'), forums_path - %li= link_to t('.support_growstuff'), shop_path - if member_signed_in? %li.dropdown< @@ -64,7 +63,6 @@ %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li= link_to t('.account'), orders_path %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_account.html.haml b/app/views/members/_account.html.haml deleted file mode 100644 index cda792ace..000000000 --- a/app/views/members/_account.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%h3 Account details - -%p - %strong Member since: - = member.created_at.to_s(:date) - -%p - %strong Account type: - = member.account_type - account - -%p - %strong Last Login: - = member.last_sign_in_at - -%p - %strong Member Roles: - %br - - if member.role? :admin - Administrator - - if member.role? :crop_wrangler - Crop Wrangler - - else - Member diff --git a/app/views/members/_roles.html.haml b/app/views/members/_roles.html.haml new file mode 100644 index 000000000..cbfd0b576 --- /dev/null +++ b/app/views/members/_roles.html.haml @@ -0,0 +1,9 @@ +%p + %strong Member Roles: + %br + - if member.role? :admin + Administrator + - if member.role? :crop_wrangler + Crop Wrangler + - unless (member.role?(:admin) || member.role?(:crop_wrangler)) + Member diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index f0214a52f..478574b3b 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -10,8 +10,6 @@ - content_for :buttonbar do - if can? :update, @member = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default' - - if @member == current_member && !@member.paid? - = link_to "Upgrade account", shop_path, class: 'btn btn-default' - if can?(:create, Notification) && current_member != @member = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' @@ -33,7 +31,7 @@ = render partial: "gardens", locals: { member: @member, gardens: @gardens } .col-md-3 = render partial: "avatar", locals: { member: @member } - = render partial: "account", locals: { member: @member } + = render partial: "roles", locals: { member: @member } = render partial: "stats", locals: { member: @member } = render partial: "contact", locals: { member: @member, twitter_auth: @twitter_auth, diff --git a/app/views/orders/complete.html.haml b/app/views/orders/complete.html.haml deleted file mode 100644 index e2f4b97ad..000000000 --- a/app/views/orders/complete.html.haml +++ /dev/null @@ -1,45 +0,0 @@ -- content_for :title, "Completed order" - -%p Thank you for your order. - -%p - %strong Completed at: - = @order.completed_at - -%p - %strong Order number: - = @order.id - -= render "shared/account_status" - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - total = 0 - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - - total += subtotal - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(total) - -%p - = link_to "View other orders/order history", orders_path diff --git a/app/views/orders/index.html.haml b/app/views/orders/index.html.haml deleted file mode 100644 index b4741c44e..000000000 --- a/app/views/orders/index.html.haml +++ /dev/null @@ -1,44 +0,0 @@ -- content_for :title, "Your Account" - -= render "shared/account_status" - - -%h2 Orders - - -- if current_member.orders.present? - - %p - Your order history shows what you have bought via our - = succeed "." do - = link_to "shop", shop_path - - %table.table.table-striped - %tr - %th Order number - %th Date completed - %th Items - %th - - @orders.each do |order| - %tr - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' -- else - %p - You have not made any orders. You can place an order via our - = succeed "." do - = link_to "shop", shop_path diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml deleted file mode 100644 index 0998407f9..000000000 --- a/app/views/orders/show.html.haml +++ /dev/null @@ -1,84 +0,0 @@ -- content_for :title, @order.completed_at ? "Order details (##{@order.id})" : "Current order" - -%p - %strong Order number: - = @order.id - -%p - %strong Ordered by: - = link_to @order.member, @order.member - -%p - %strong Date begun: - = @order.created_at.to_s - -- if @order.completed_at - %p - %strong Date completed: - = @order.completed_at.to_s - -- if @order.referral_code - %p - %strong Referral code: - = @order.referral_code - -- if current_member.role? :admin - %p - %strong Paypal Express token: - = @order.paypal_express_token - %p - %strong Paypal Express payer ID: - = @order.paypal_express_payer_id - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(@order.total) - = forex_link(@order.total) - -- if @order.errors.any? - .alert - #error_explanation - %h3 - = pluralize(@order.errors.size, "error") - stopped you from checking out: - %ul - - @order.errors.full_messages.each do |msg| - %li= msg - -- if can?(:complete, @order) || can?(:destroy, @order) - = form_tag(checkout_order_path(@order), method: :get, class: 'form-inline') do - %p - - if can? :complete, @order - = label_tag :referral_code, "Do you have a referral code?" - = text_field_tag :referral_code, @order.referral_code, class: 'input-medium' - = submit_tag "Checkout with PayPal", class: 'btn btn-primary' - - if can? :destroy, @order - = link_to 'Delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default' - = link_to "View other orders/order history", orders_path, class: 'btn btn-default' - -%p diff --git a/app/views/products/_form.html.haml b/app/views/products/_form.html.haml deleted file mode 100644 index a3aa8a2f0..000000000 --- a/app/views/products/_form.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= form_for @product do |f| - - if @product.errors.any? - #error_explanation - %h2 - = pluralize(@product.errors.size, "error") - prohibited this product from being saved: - %ul - - @product.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name, class: 'form-control' - .field - = f.label :description - = f.text_area :description, class: 'form-control' - .field - = f.label :min_price, "Minimum price (in cents)" - = f.text_field :min_price - .field - = f.label :recommended_price, "Recommended price (in cents)" - = f.text_field :recommended_price - .field - = f.label :account_type - = collection_select(:product, :account_type_id, AccountType.all, :id, - :name, selected: @product.account_type_id) - .field - = f.label :paid_months - = f.text_field :paid_months - .form-group - .actions - = f.submit 'Save' diff --git a/app/views/products/edit.html.haml b/app/views/products/edit.html.haml deleted file mode 100644 index 84ebcb870..000000000 --- a/app/views/products/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing product" - -= render 'form' - -= link_to 'Show', @product -\| -= link_to 'Back', products_path diff --git a/app/views/products/index.html.haml b/app/views/products/index.html.haml deleted file mode 100644 index 4945d130e..000000000 --- a/app/views/products/index.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -- content_for :title, "Listing products" - -%table - %tr - %th Name - %th Description - %th Min price - %th Recommended price - %th Account type - %th Paid months - %th - %th - %th - - - @products.each do |product| - %tr - %td= product.name - %td= product.description - %td= product.min_price - %td= product.recommended_price - %td= product.account_type ? product.account_type.name : "" - %td= product.paid_months - %td= link_to 'Show', product - %td= link_to 'Edit', edit_product_path(product) - %td= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Product', new_product_path diff --git a/app/views/products/new.html.haml b/app/views/products/new.html.haml deleted file mode 100644 index 57b944d9a..000000000 --- a/app/views/products/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New product" - -= render 'form' - -= link_to 'Back', products_path diff --git a/app/views/products/show.html.haml b/app/views/products/show.html.haml deleted file mode 100644 index 61b35519f..000000000 --- a/app/views/products/show.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @product.name -%p - %b Description: - :growstuff_markdown - #{strip_tags(@product.description)} -%p - %b Min price: - = @product.min_price -%p - %b Recommended price: - = @product.recommended_price -%p - %b Account type: - = @product.account_type.name -%p - %b Paid months: - = @product.paid_months - -= link_to 'Edit', edit_product_path(@product) -\| -= link_to 'Back', products_path diff --git a/app/views/shared/_account_status.html.haml b/app/views/shared/_account_status.html.haml deleted file mode 100644 index a39870956..000000000 --- a/app/views/shared/_account_status.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%h2 Your current account status - -%p - %strong Account type: - = current_member.account_type.name - -- if current_member.account.paid_until_string - %p - %strong Paid until: - = current_member.account.paid_until_string - -- unless current_member.paid? - = link_to "Upgrade and support #{ENV['GROWSTUFF_SITE_NAME']}", shop_path, class: 'btn btn-primary' diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml deleted file mode 100644 index 6266050f0..000000000 --- a/app/views/shop/index.html.haml +++ /dev/null @@ -1,83 +0,0 @@ -- content_for :title, t('.title') - -%p - Growstuff relies on your support to build and run this open source - platform for food growers. We do not have outside investment, and do - not accept ads. Instead, we offer paid memberships, which give you - access to premium features, and ensure that we focus our efforts on - keeping you, our members, happy. - -%p - We are currently developing a number of advanced features for paid - members. We will announce our progress on these in our - = link_to "Feedback and Support forum", "http://www.growstuff.org/forums/growstuff-feedback-support" - as well as via other channels. - -%p - All our accounts are priced on a sliding scale. You can choose how - much you want to pay. Remember, your subscription supports an open - source, open data platform supporting home food growers and promoting - sustainable food systems! - -- if current_member && current_member.paid? - %h2 Thank you for supporting Growstuff - - %p You currently have a paid membership, and can't buy another one at this time. - - = render "shared/account_status" - -- elsif @order && !@order.order_items.empty? - %h2 Your current order - - %p - You currently have the following item in your cart: - %strong - = @most_recent_item.product - @ - = price_with_currency(@most_recent_item.price) - - %p - = link_to "View order and checkout", order_path(@order) - or - = succeed "." do - = link_to 'delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' } - -- else - - @products.each do |p| - %h2= p.name - - %div - :growstuff_markdown - #{ strip_tags p.description } - - %p - Pay what you want, starting at - = succeed "." do - = price_with_currency(p.min_price) - = forex_link(p.min_price) - - if p.recommended_price - Recommended price: - = succeed "." do - = price_with_currency(p.recommended_price) - = forex_link(p.recommended_price) - - %div - - if can? :create, Order - - = form_for @order_item do |f| - .field - = f.text_field :price, value: price_in_dollars(p.recommended_price || p.min_price) - .field - = f.hidden_field :product_id, value: p.id - .field - = f.hidden_field :quantity, value: 1 - .actions - = f.submit 'Buy', class: 'btn btn-primary' - - - else - Please - = link_to "sign in", new_member_session_path - or - = link_to "sign up", new_member_registration_path - to purchase. diff --git a/config/application.rb b/config/application.rb index 5280dce7e..ae8d6e95f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,9 +44,6 @@ module Growstuff # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" - # Configure a default account type - config.default_account_type = "Free" - # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] diff --git a/config/locales/en.yml b/config/locales/en.yml index d2848cecd..d5d3364a6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,11 +1,5 @@ --- en: - account: - update: Account detail was successfully updated. - account_types: - created: Account type was successfully created. - deleted: Account type was successfully deleted. - updated: Account type was successfully updated. activerecord: models: comment: @@ -99,7 +93,6 @@ en: open: ad_free_linktext: ad-free api_docs_linktext: API documentation - buy_account_linktext: buying a paid account creative_commons_linktext: Creative Commons license get_involved_body_html: > We believe in collaboration, and work closely with our members and the wider food-growing community. @@ -213,9 +206,6 @@ en: default: Everyone's seeds owner_seeds: "%{owner} seeds" string: "%{crop} seeds belonging to %{owner}" - shop: - index: - title: Shop unauthorized: create: all: Please sign in or sign up to create a %{subject}. diff --git a/config/routes.rb b/config/routes.rb index f1588fa17..777536e38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,17 +72,6 @@ Growstuff::Application.routes.draw do get '/places/search' => 'places#search', as: 'search_places' get '/places/:place' => 'places#show', as: 'place' - # everything for paid accounts etc - resources :account_types - resources :accounts - resources :orders - get 'orders/:id/checkout' => 'orders#checkout', as: 'checkout_order' - get 'orders/:id/complete' => 'orders#complete', as: 'complete_order' - get 'orders/:id/cancel' => 'orders#cancel', as: 'cancel_order' - - resources :order_items - resources :products - resources :likes, only: %i(create destroy) get "home/index" @@ -91,15 +80,11 @@ Growstuff::Application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - get '/shop' => 'shop#index' - get '/shop/:action' => 'shop#:action' - comfy_route :cms_admin, path: '/admin/cms' namespace :admin do resources :members end - get '/admin/orders' => 'admin/orders#index' - get '/admin/orders/:action' => 'admin/orders#:action' + get '/admin' => 'admin#index' get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter get '/admin/:action' => 'admin#:action' diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb new file mode 100644 index 000000000..fa0fc8793 --- /dev/null +++ b/db/migrate/20180205000612_remove_shop.rb @@ -0,0 +1,9 @@ +class RemoveShop < ActiveRecord::Migration + def up + drop_table :order_items + drop_table :orders + drop_table :products + drop_table :account_types + drop_table :accounts + end +end diff --git a/db/schema.rb b/db/schema.rb index be74dabfc..c38e122e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,27 +11,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180118112809) do +ActiveRecord::Schema.define(version: 20180205000612) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "account_types", force: :cascade do |t| - t.string "name", null: false - t.boolean "is_paid" - t.boolean "is_permanent_paid" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "accounts", force: :cascade do |t| - t.integer "member_id", null: false - t.integer "account_type_id" - t.datetime "paid_until" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "alternate_names", force: :cascade do |t| t.string "name", null: false t.integer "crop_id", null: false @@ -359,25 +343,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do t.datetime "updated_at" end - create_table "order_items", force: :cascade do |t| - t.integer "order_id" - t.integer "product_id" - t.integer "price" - t.integer "quantity" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "orders", force: :cascade do |t| - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "completed_at" - t.integer "member_id" - t.string "paypal_express_token" - t.string "paypal_express_payer_id" - t.string "referral_code" - end - create_table "orders_products", id: false, force: :cascade do |t| t.integer "order_id" t.integer "product_id" @@ -461,17 +426,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do add_index "posts", ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id", using: :btree add_index "posts", ["slug"], name: "index_posts_on_slug", unique: true, using: :btree - create_table "products", force: :cascade do |t| - t.string "name", null: false - t.text "description", null: false - t.integer "min_price", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "account_type_id" - t.integer "paid_months" - t.integer "recommended_price" - end - create_table "roles", force: :cascade do |t| t.string "name", null: false t.text "description" diff --git a/db/seeds.rb b/db/seeds.rb index be885a352..703113be3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,12 +7,9 @@ def load_data Crop.transaction do # for all Growstuff sites, including production ones load_roles - load_basic_account_types create_cropbot load_crops load_plant_parts - load_paid_account_types - load_products # We don't load these in an environment except development to # prevent creating users in the wild - especially admins - with @@ -44,20 +41,6 @@ def load_roles @wrangler = Role.create(name: 'Crop Wrangler') end -def load_basic_account_types - puts "Adding 'free' and 'staff' account types..." - AccountType.create!( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - AccountType.create!( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) -end - def load_test_users # rubocop:disable Metrics/AbcSize puts "Loading test users..." @@ -141,39 +124,6 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") - @cropbot_user.account.save -end - -def load_paid_account_types - puts "Adding 'paid' and 'seed' account types..." - @paid_account = AccountType.create!( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.create!( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) -end - -def load_products - puts "Adding products..." - Product.create!( - name: "Annual subscription", - description: "Paid account, 1 year", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.create!( - name: "Seed account", - description: "Paid account, in perpetuity", - min_price: 15_000, - account_type_id: @seed_account.id - ) end def load_plant_parts diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 03b2e3d0e..656330ea2 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -95,77 +95,6 @@ namespace :growstuff do end end - desc "June 2013: create account types and products." - task setup_shop: :environment do - puts "Adding account types..." - AccountType.find_or_create_by( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - @paid_account = AccountType.find_or_create_by( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.find_or_create_by( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) - @staff_account = AccountType.find_or_create_by( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) - - puts "Adding products..." - Product.find_or_create_by( - name: "Annual subscription", - description: "An annual subscription gives you access "\ - "to paid account features for one year. Does not auto-renew.", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.find_or_create_by( - name: "Seed account", - description: "A seed account helps Growstuff grow in its "\ - "early days. It gives you all the features of "\ - "a paid account, in perpetuity. This account "\ - "type never expires.", - min_price: 15_000, - account_type_id: @seed_account.id - ) - - puts "Giving each member an account record..." - Member.all.each do |m| - Account.create(member_id: m.id) unless m.account - end - - puts "Making Skud a staff account..." - @skud = Member.find_by(login_name: 'Skud') - if @skud - @skud.account.account_type = @staff_account - @skud.account.save - end - - puts "Done setting up shop." - end - - desc "June 2013: replace nil account_types with free accounts" - task nil_account_type: :environment do - free = AccountType.find_by(name: "Free") - raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ - unless free - Account.all.each do |a| - unless a.account_type - a.account_type = free - a.save - end - end - end - desc "July 2013: replace nil seed.tradable_to with nowhere" task tradable_to_nowhere: :environment do Seed.all.each do |s| @@ -187,8 +116,6 @@ namespace :growstuff do task set_default_crop_creator: :environment do cropbot = Member.find_by(login_name: "cropbot") raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot - cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice - cropbot.account.save Crop.find_each do |crop| unless crop.creator crop.creator = cropbot diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb deleted file mode 100644 index 010c8bf1f..000000000 --- a/spec/controllers/account_types_controller_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -describe AccountTypesController do - subject { response } - - context 'anon' do - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'member' do - login_member(:member) - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'admin' do - login_member(:admin_member) - describe '#index' do - let!(:aaa) { FactoryBot.create :account_type, name: 'aaa' } - let!(:zzz) { FactoryBot.create :account_type, name: 'zzz' } - - before { get :index } - it { is_expected.to be_success } - it { expect(assigns[:account_types].first).to eql(aaa) } - it { expect(assigns[:account_types].last).to eql(zzz) } - end - end -end diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb deleted file mode 100644 index 2b4222f1d..000000000 --- a/spec/controllers/accounts_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe AccountsController do - login_member(:admin_member) - - def valid_attributes - { "paid_until" => Time.now } - end - - def create_account - # account details are automatically created when you create a new - # member; creating them manually will just cause errors as only one is - # allowed. This method has been left here in case it's useful in - # future. - member = FactoryBot.create(:member) - member.account - end -end diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb deleted file mode 100644 index fb475b34c..000000000 --- a/spec/controllers/admin/orders_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe Admin::OrdersController do - login_member(:admin_member) - - describe "GET search" do - it "assigns @orders" do - order = FactoryBot.create(:order) - get :search, search_by: 'order_id', search_text: order.id - assigns(:orders).should eq([order]) - end - - it "sets an error message if nothing found" do - get :search, search_by: 'order_id', search_text: 'foo' - flash[:alert].should have_text "Couldn't find order with" - end - end -end diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb deleted file mode 100644 index 4de8eb98d..000000000 --- a/spec/controllers/order_items_controller_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rails_helper' - -describe OrderItemsController do - login_member(:admin_member) - - let(:member) { FactoryBot.create(:member) } - let(:product) { FactoryBot.create(:product) } - let(:order) { FactoryBot.create(:order, member: member) } - let(:order_item) do - FactoryBot.create(:order_item, - order: order, - product: product, - price: product.min_price) - end - - context 'signed in' do - before { sign_in member } - - describe "POST create" do - describe "redirects to order" do - before do - post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } - end - it { expect(response).to redirect_to(OrderItem.last.order) } - it { expect(OrderItem.last.order).to be_an_instance_of Order } - end - - describe 'creates an order for you' do - it do - expect do - post :create, order_item: { - product_id: product.id, - price: product.min_price - } - end.to change(Order, :count).by(1) - end - end - - describe "with non-int price" do - it "converts 3.33 to 333 cents" do - order = FactoryBot.create(:order, member: member) - product = FactoryBot.create(:product, min_price: 1) - expect do - post :create, order_item: { order_id: order.id, product_id: product.id, price: 3.33 } - end.to change(OrderItem, :count).by(1) - OrderItem.last.price.should eq 333 - end - end - end - end -end diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb deleted file mode 100644 index 3c6631d8c..000000000 --- a/spec/controllers/orders_controller_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'rails_helper' - -describe OrdersController do - login_member(:admin_member) - - def valid_attributes - { "member_id" => 1 } - end - - def valid_session - {} - end - - describe "GET checkout" do - it 'sets the referral_code' do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param, referral_code: 'FOOBAR' - order.reload - order.referral_code.should eq 'FOOBAR' - end - - it "redirects to Paypal" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param - response.status.should eq 302 - response.redirect_url.should match(/paypal\.com/) - end - end - - describe "GET complete" do - it "assigns the requested order as @order" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :complete, id: order.to_param - assigns(:order).should eq(order) - end - end - - describe "DELETE destroy" do - it "redirects to the shop" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - delete :destroy, id: order.id - response.should redirect_to(shop_url) - end - end -end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb deleted file mode 100644 index 173ef9ba4..000000000 --- a/spec/controllers/products_controller_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -describe ProductsController do - login_member(:admin_member) - - def valid_attributes - { - name: "product name", - description: 'some description', - min_price: 9.99 - } - end - - def valid_session - {} - end -end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb deleted file mode 100644 index 2fc6b77f7..000000000 --- a/spec/controllers/shop_controller_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -describe ShopController do - let!(:product1) { FactoryBot.create(:product, name: 'aaa') } - let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - - describe "GET index" do - describe 'not logged in' do - before { get :index, {} } - - describe "assigns all products as @products ordered by name" do - it { expect(assigns(:products)).to eq([product1, product2]) } - end - - describe "assigns a new @order_item to build forms" do - it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } - end - - describe "assigns @order as nil if the user doesn't have one" do - it { expect(assigns(:order)).to be_nil } - end - end - describe 'logged in' do - describe "assigns @order as current_order if there is one" do - let(:member) { FactoryBot.create(:member) } - let!(:order) { FactoryBot.create(:order, member: member) } - - before do - sign_in member - get :index, {} - end - it { expect(assigns(:order)).to eq order } - end - end - end -end diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb deleted file mode 100644 index 66717492f..000000000 --- a/spec/factories/account_types.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :account_type do - name { Faker::Name.unique.name } - is_paid false - is_permanent_paid false - - factory :free_account_type do - name "Free" - is_paid false - is_permanent_paid false - end - - factory :paid_account_type do - name "Paid" - is_paid true - is_permanent_paid false - end - - factory :permanent_paid_account_type do - name "Permanent paid" - is_paid true - is_permanent_paid true - end - - factory :staff_account_type do - name "Staff" - is_paid true - is_permanent_paid true - end - end -end diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb deleted file mode 100644 index fb4805964..000000000 --- a/spec/factories/accounts.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - # never do this directly. - # create a member then look at member.account_detail instead. - # (because it's auto-created, and there can only be one.) -end diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb deleted file mode 100644 index 5dfba00ab..000000000 --- a/spec/factories/order_items.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order_item do - order - product - price "999" - quantity 42 - end -end diff --git a/spec/factories/orders.rb b/spec/factories/orders.rb deleted file mode 100644 index 514eb4a22..000000000 --- a/spec/factories/orders.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order do - member - factory :completed_order do - completed_at '2013-05-08 01:01:01' - end - - factory :referred_order do - referral_code 'CAMPAIGN1' - end - end -end diff --git a/spec/factories/products.rb b/spec/factories/products.rb deleted file mode 100644 index 444c8597d..000000000 --- a/spec/factories/products.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :product do - name "annual subscription" - description "paid membership, renewing yearly, *hurrah*" - min_price "999" - account_type - paid_months 12 - - factory :product_with_recommended_price do - recommended_price "1200" - end - end -end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb deleted file mode 100644 index dac241586..000000000 --- a/spec/features/admin/account_types_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rails_helper' - -feature "account types", js: true do - context "admin user" do - let(:member) { create :admin_member } - let(:account_type) { create :account_type } - - background do - login_as member - end - - scenario "navigating to account type admin with JavaScript on" do - visit root_path - # Extra click for the expandable login menu - click_link member.login_name - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "navigating to account type admin without JavaScript - Accessility version", js: false do - visit root_path - # Extra link not needed as menu is already expanded - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "adding an account type" do - visit account_types_path - click_link "New Account type" - expect(current_path).to eq new_account_type_path - fill_in 'Name', with: 'Guest' - click_button 'Save' - expect(current_path).to eq account_type_path(AccountType.last) - expect(page).to have_content 'Account type was successfully created' - end - - scenario 'editing account type' do - visit account_type_path account_type - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq account_type_path(account_type) - expect(page).to have_content 'Account type was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting account type' do - visit account_type_path account_type - click_link 'Delete' - expect(current_path).to eq account_types_path - expect(page).to have_content 'Account type was successfully deleted' - end - end -end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb deleted file mode 100644 index ca24daf83..000000000 --- a/spec/features/admin/products_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'rails_helper' - -feature "products" do - context "admin user" do - let(:member) { create :admin_member } - let(:product) { create :product } - - background do - login_as member - end - - scenario "navigating to product admin" do - visit admin_path - click_link "Products" - expect(current_path).to eq products_path - end - - scenario "adding a product" do - visit products_path - click_link "New Product" - expect(current_path).to eq new_product_path - fill_in 'Name', with: 'Special offer' - # note that failing to fill in a mandatory field has a messy error. - # This is not a priority defect but should be raised at some point. - fill_in 'Minimum price', with: '150' - click_button 'Save' - expect(current_path).to eq product_path(Product.last) - expect(page).to have_content 'Product was successfully created' - end - - scenario 'editing product' do - visit product_path product - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq product_path(product) - expect(page).to have_content 'Product was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting product' - # this isn't possible. Should it be? - end -end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 32b11bda1..9f1005894 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -9,7 +9,6 @@ feature "member profile", js: true do expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content "Account type: Free account" expect(page).to have_content "#{member.login_name}'s gardens" expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end @@ -141,10 +140,6 @@ feature "member profile", js: true do scenario "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path end - - scenario "has a button to upgrade account" do - expect(page).to have_link "Upgrade account", href: shop_path - end end context "someone else's profile page" do diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 793a6ada5..22b91a33b 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -10,7 +10,6 @@ feature "member deletion" do let!(:harvest) { FactoryBot.create(:harvest, owner: member) } let!(:seed) { FactoryBot.create(:seed, owner: member) } let!(:secondgarden) { FactoryBot.create(:garden, owner: member) } - let!(:order) { FactoryBot.create(:order, member: member, completed_at: Time.zone.now) } let(:admin) { FactoryBot.create(:admin_member) } background do @@ -115,16 +114,6 @@ feature "member deletion" do expect(page).to have_content "Member Deleted" end - scenario "leaves a record of orders and payments intact" do - login_as(admin) - visit admin_path - fill_in "search_text", with: member.login_name.to_s - find("#maincontainer").click_button("Search", exact: true) - expect(page).to have_content member.login_name.to_s - expect(page).to have_content "Found 1 result" - logout - end - scenario "can't be interesting" do expect(Member.interesting).not_to include(member) expect(Planting.interesting).not_to include(planting) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index ef746c8bc..e95dfbdc6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -71,201 +71,6 @@ describe Ability do end end - context "products" do - let(:product) { FactoryBot.create(:product) } - - context "standard member" do - it "can't read or manage products" do - ability.should_not be_able_to(:read, product) - ability.should_not be_able_to(:create, Product) - ability.should_not be_able_to(:update, product) - ability.should_not be_able_to(:destroy, product) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read products" do - ability.should be_able_to(:read, product) - end - it "can create products" do - ability.should be_able_to(:create, Product) - end - it "can update products" do - ability.should be_able_to(:update, product) - end - it "can destroy products" do - ability.should be_able_to(:destroy, product) - end - end - end - - context "orders" do - let(:order) { FactoryBot.create(:order, member: member) } - let(:strangers_order) do - FactoryBot.create(:order, - member: FactoryBot.create(:member)) - end - let(:completed_order) do - FactoryBot.create(:completed_order, - member: member) - end - let(:order_item) { FactoryBot.create(:order_item, order: order) } - let(:strangers_order_item) do - FactoryBot.create(:order_item, - order: strangers_order) - end - let(:completed_order_item) do - FactoryBot.create(:order_item, - order: completed_order) - end - - context "standard member" do - it "can read their own orders" do - ability.should be_able_to(:read, order) - ability.should be_able_to(:read, completed_order) - end - - it "can't read other people's orders" do - ability.should_not be_able_to(:read, strangers_order) - end - - it "can create a new order" do - ability.should be_able_to(:create, Order) - end - - it "can complete their own current order" do - ability.should be_able_to(:complete, order) - end - - it "can't complete someone else's order" do - ability.should_not be_able_to(:complete, strangers_order) - end - - it "can't complete a completed order" do - ability.should_not be_able_to(:complete, completed_order) - end - - it "can delete a current order" do - ability.should be_able_to(:destroy, order) - end - - it "can't delete someone else's order" do - ability.should_not be_able_to(:destroy, strangers_order) - end - - it "can't delete a completed order" do - ability.should_not be_able_to(:destroy, completed_order) - end - - it "can't read their own order items" do - ability.should_not be_able_to(:read, order_item) - ability.should_not be_able_to(:read, completed_order_item) - end - - it "can't read other people's order items" do - ability.should_not be_able_to(:read, strangers_order_item) - end - - it "can create a new order item" do - ability.should be_able_to(:create, OrderItem) - end - - it "can't update their own order items" do - ability.should_not be_able_to(:update, order_item) - end - - it "can't update other people's order items" do - ability.should_not be_able_to(:update, strangers_order_item) - end - - it "can't updated items in completed orders" do - ability.should_not be_able_to(:update, completed_order_item) - end - - it "can't delete their own order item" do - ability.should_not be_able_to(:destroy, order_item) - end - - it "can't delete someone else's order item" do - ability.should_not be_able_to(:destroy, strangers_order_item) - end - - it "can't delete items from completed orders" do - ability.should_not be_able_to(:destroy, completed_order_item) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read orders" do - ability.should be_able_to(:read, order) - end - - it "cannot create orders" do - ability.should_not be_able_to(:create, order) - end - - it "cannot complete orders" do - ability.should_not be_able_to(:complete, order) - end - - it "cannot delete orders" do - ability.should_not be_able_to(:destroy, order) - end - end - end - - context 'account details' do - let(:account) { member.account } - - context 'ordinary member' do - it "can't read account details" do - ability.should_not be_able_to(:read, account) - end - it "can't manage account details" do - ability.should_not be_able_to(:create, Account) - ability.should_not be_able_to(:update, account) - ability.should_not be_able_to(:destroy, account) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "can read account details" do - ability.should be_able_to(:read, account) - end - it "can manage account details" do - ability.should be_able_to(:create, Account) - ability.should be_able_to(:update, account) - ability.should be_able_to(:destroy, account) - end - end - end - context 'plant parts' do let(:plant_part) { FactoryBot.create(:plant_part) } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb deleted file mode 100644 index 15eb68084..000000000 --- a/spec/models/account_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -describe Account do - let(:member) { FactoryBot.create(:member) } - - it "auto-creates an account detail record when a member is created" do - member.account.should be_an_instance_of Account - end - - it "won't let you create two account details for the same member" do - @details = Account.new(member_id: member.id) - @details.should_not be_valid - end - - it "formats the 'paid until' date nicely" do - member.account.account_type = FactoryBot.create(:account_type) - member.account.paid_until_string.should eq nil - - member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq "forever" - - member.account.account_type = FactoryBot.create(:paid_account_type) - @time = Time.zone.now - member.account.paid_until = @time - member.account.paid_until_string.should eq @time.to_s - end -end diff --git a/spec/models/account_type_spec.rb b/spec/models/account_type_spec.rb deleted file mode 100644 index c65c113ba..000000000 --- a/spec/models/account_type_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -describe AccountType do -end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index cf7b81486..01d793ded 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -24,15 +24,6 @@ describe 'member' do member.gardens.size.should == 1 end - it 'should have a accounts entry' do - member.account.should be_an_instance_of Account - end - - it "should have a default-type account by default" do - member.account.account_type.name.should eq Growstuff::Application.config.default_account_type - member.paid?.should be(false) - end - it "doesn't show email by default" do member.show_email.should be(false) end @@ -294,89 +285,6 @@ describe 'member' do end end - context 'orders' do - it 'finds the current order' do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - order2 = FactoryBot.create(:order, member: member) - member.current_order.should eq order2 - end - - it "copes if there's no current order" do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - FactoryBot.create(:completed_order, member: member) - member.current_order.should be_nil - end - end - - context "paid accounts" do - let(:member) { FactoryBot.create(:member) } - - it "recognises a permanent paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: true) - member.account.account_type = account_type - member.paid?.should be(true) - end - - it "recognises a current paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(true) - end - - it "recognises an expired paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now - 1.minute - member.paid?.should be(false) - end - - it "recognises a free account" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.paid?.should be(false) - end - - it "recognises a free account even with paid_until set" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(false) - end - end - - context "update account" do - let(:product) do - FactoryBot.create(:product, - paid_months: 3) - end - let(:member) { FactoryBot.create(:member) } - - it "sets account_type" do - member.update_account_after_purchase(product) - member.account.account_type.should eq product.account_type - end - - it "sets paid_until" do - member.account.paid_until = nil # blank for now, as if never paid before - member.update_account_after_purchase(product) - - # stringify to avoid millisecond problems... - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months).to_s) - - # and again to make sure it works for currently paid accounts - member.update_account_after_purchase(product) - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months + 3.months).to_s) - end - end - context 'harvests' do it 'has harvests' do member = FactoryBot.create(:member) diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb deleted file mode 100644 index 7c2de24c6..000000000 --- a/spec/models/order_item_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe OrderItem do - let(:order_item) { FactoryBot.create(:order_item) } - - it "has an order and a product" do - order_item.order.should be_an_instance_of Order - order_item.product.should be_an_instance_of Product - end - - it "validates price > product.min_price" do - @product = FactoryBot.create(:product) - order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) - order_item.should_not be_valid - end - - it "doesn't let you add two items to an order" do - @product = FactoryBot.create(:product) - @order = FactoryBot.create(:order) - order_item = FactoryBot.build(:order_item, order: @order) - order_item.should be_valid - order_item.save - @order_item2 = FactoryBot.build(:order_item, order: @order) - @order_item2.should_not be_valid - end -end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb deleted file mode 100644 index 9abb381ba..000000000 --- a/spec/models/order_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'rails_helper' - -describe Order do - before(:each) do - @order = FactoryBot.create(:order) - @product = FactoryBot.create(:product) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - end - - describe '#by_member_id' do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @order1 = Order.create!(member_id: @member1.id) - @order2 = Order.create!(member_id: @member2.id) - end - - it "only returns orders belonging to member" do - Order.by_member(@member1).should eq [@order1] - end - end - - it 'has order_items' do - @order.order_items.first.should eq @order_item - end - - it 'updates the account details' do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @account_type = FactoryBot.create(:account_type, name: 'paid') - @product = FactoryBot.create(:product, - account_type: @account_type, - paid_months: 3) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - - @member.account.paid_until.should be_nil - - @order.update_account - - @member.account.account_type.should eq @account_type - @member.account.paid_until.should_not be_nil - end - - it "totals the amount due" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.total.should eq 1111 - end - - it "gives the correct total for quantities more than 1" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 2) - - @order.total.should eq 2222 - end - - it "formats order items for activemerchant" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - name: 'foo', - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.activemerchant_items.should eq [{ - name: 'foo', - quantity: 1, - amount: 1111 - }] - end - - context "referral codes" do - it "has a referral code" do - referred_order = FactoryBot.create(:referred_order) - referred_order.referral_code.should_not be nil - end - - it "validates referral codes" do - referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') - referred_order.should_not be_valid - end - - it "cleans up messy referral codes" do - referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') - referred_order.referral_code.should eq 'CAMPAIGN1' - end - end - - context 'search' do - it 'finds orders by member' do - order = FactoryBot.create(:order) - Order.search(by: 'member', for: order.member.login_name).should eq [order] - end - - it 'finds orders by order_id' do - order = FactoryBot.create(:order) - Order.search(by: 'order_id', for: order.id).should eq [order] - end - - it 'finds orders by paypal_token' do - order = FactoryBot.create(:order, paypal_express_token: 'foo') - Order.search(by: 'paypal_token', for: 'foo').should eq [order] - end - - it 'finds orders by paypal_payer_id' do - order = FactoryBot.create(:order, paypal_express_payer_id: 'bar') - Order.search(by: 'paypal_payer_id', for: 'bar').should eq [order] - end - - it 'finds orders by referral_code' do - order = FactoryBot.create(:order, referral_code: 'baz') - Order.search(by: 'referral_code', for: 'baz').should eq [order] - end - end -end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb deleted file mode 100644 index 2cc684667..000000000 --- a/spec/models/product_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rails_helper' - -describe Product do - it "stringifies using the name" do - @product = FactoryBot.create(:product) - @product.to_s.should eq @product.name - end -end diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb deleted file mode 100644 index 8402dd727..000000000 --- a/spec/routing/account_types_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe AccountTypesController do - describe "routing" do - it "routes to #index" do - get("/account_types").should route_to("account_types#index") - end - - it "routes to #new" do - get("/account_types/new").should route_to("account_types#new") - end - - it "routes to #show" do - get("/account_types/1").should route_to("account_types#show", id: "1") - end - - it "routes to #edit" do - get("/account_types/1/edit").should route_to("account_types#edit", id: "1") - end - - it "routes to #create" do - post("/account_types").should route_to("account_types#create") - end - - it "routes to #update" do - put("/account_types/1").should route_to("account_types#update", id: "1") - end - - it "routes to #destroy" do - delete("/account_types/1").should route_to("account_types#destroy", id: "1") - end - end -end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb deleted file mode 100644 index 7487cb9f5..000000000 --- a/spec/routing/order_items_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrderItemsController do - describe "routing" do - it "routes to #index" do - get("/order_items").should route_to("order_items#index") - end - - it "routes to #new" do - get("/order_items/new").should route_to("order_items#new") - end - - it "routes to #show" do - get("/order_items/1").should route_to("order_items#show", id: "1") - end - - it "routes to #edit" do - get("/order_items/1/edit").should route_to("order_items#edit", id: "1") - end - - it "routes to #create" do - post("/order_items").should route_to("order_items#create") - end - - it "routes to #update" do - put("/order_items/1").should route_to("order_items#update", id: "1") - end - - it "routes to #destroy" do - delete("/order_items/1").should route_to("order_items#destroy", id: "1") - end - end -end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb deleted file mode 100644 index 38184ef33..000000000 --- a/spec/routing/orders_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrdersController do - describe "routing" do - it "routes to #index" do - get("/orders").should route_to("orders#index") - end - - it "routes to #new" do - get("/orders/new").should route_to("orders#new") - end - - it "routes to #show" do - get("/orders/1").should route_to("orders#show", id: "1") - end - - it "routes to #edit" do - get("/orders/1/edit").should route_to("orders#edit", id: "1") - end - - it "routes to #create" do - post("/orders").should route_to("orders#create") - end - - it "routes to #update" do - put("/orders/1").should route_to("orders#update", id: "1") - end - - it "routes to #destroy" do - delete("/orders/1").should route_to("orders#destroy", id: "1") - end - end -end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb deleted file mode 100644 index 15166a805..000000000 --- a/spec/routing/products_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe ProductsController do - describe "routing" do - it "routes to #index" do - get("/products").should route_to("products#index") - end - - it "routes to #new" do - get("/products/new").should route_to("products#new") - end - - it "routes to #show" do - get("/products/1").should route_to("products#show", id: "1") - end - - it "routes to #edit" do - get("/products/1/edit").should route_to("products#edit", id: "1") - end - - it "routes to #create" do - post("/products").should route_to("products#create") - end - - it "routes to #update" do - put("/products/1").should route_to("products#update", id: "1") - end - - it "routes to #destroy" do - delete("/products/1").should route_to("products#destroy", id: "1") - end - end -end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb deleted file mode 100644 index 1bd22be03..000000000 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/edit" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders the edit account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path(@account_type), method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb deleted file mode 100644 index 56020fc35..000000000 --- a/spec/views/account_types/index.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -describe "account_types/index" do - before(:each) do - @type = FactoryBot.create(:account_type) - assign(:account_types, [@type, @type]) - end - - it "renders a list of account_types" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @type.name.to_s, count: 2 - end -end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb deleted file mode 100644 index 027a1b7c1..000000000 --- a/spec/views/account_types/new.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/new" do - before(:each) do - assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false).as_new_record) - end - - it "renders new account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path, method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb deleted file mode 100644 index a31d4bc33..000000000 --- a/spec/views/account_types/show.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "account_types/show" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "Name", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - rendered.should match(/false/) - rendered.should match(/false/) - end -end diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb deleted file mode 100644 index bc5c3b5a3..000000000 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "accounts/edit" do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it "renders the edit account form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path(@account), method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" - end - end -end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb deleted file mode 100644 index 4ec76151e..000000000 --- a/spec/views/accounts/index.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe "accounts/index" do - before(:each) do - @member = FactoryBot.create(:member) - @account = @member.account - assign(:accounts, [@account, @account]) - end - - it "renders a list of accounts" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @account.member_id.to_s, count: 2 - end -end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb deleted file mode 100644 index 77f6ff20f..000000000 --- a/spec/views/accounts/new.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "accounts/new" do - before(:each) do - @member = FactoryBot.create(:member) - assign(:account, @member.account) - end - - it "renders new account form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: accounts_path, method: "post" do - assert_select "input#account_member_id", name: "account[member_id]" - assert_select "input#account_account_type", name: "account[account_type]" - end - end -end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb deleted file mode 100644 index d96fbbd96..000000000 --- a/spec/views/accounts/show.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe "accounts/show" do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @account.member_id.to_s - rendered.should have_content 'Free' - rendered.should have_content @account.paid_until.to_s - end -end diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index beb0eacbd..cc8b145d3 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -9,8 +9,6 @@ describe 'admin/index.html.haml', type: "view" do end it "includes links to manage various things" do - assert_select "a", href: account_types_path - assert_select "a", href: products_path assert_select "a", href: roles_path assert_select "a", href: forums_path end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb deleted file mode 100644 index 8d80dc3ef..000000000 --- a/spec/views/admin/orders/index_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -describe 'admin/orders/index.html.haml', type: "view" do - before(:each) do - @member = FactoryBot.create(:admin_member) - sign_in @member - controller.stub(:current_user) { @member } - render - end - - it "includes a search form for orders" do - assert_select "form" - assert_select "input#search_text" - assert_select "select#search_by" - end - - it "lets you search by referral code" do - assert_select "option[value=referral_code]", text: "Referral code" - end -end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb deleted file mode 100644 index c95f204e2..000000000 --- a/spec/views/orders/index.html.haml_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe "orders/index" do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - @order1 = FactoryBot.create(:order, member: @member) - @order2 = FactoryBot.create(:completed_order, member: @member) - assign(:orders, [@order1, @order2]) - end - - it "shows your current account status" do - render - rendered.should have_content "Your current account status" - end - - it "renders a list of orders" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td a/@href", text: "/orders/#{@order1.id}" - assert_select "tr>td a/@href", text: "/orders/#{@order2.id}" - end -end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb deleted file mode 100644 index a9f662de9..000000000 --- a/spec/views/orders/show.html.haml_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'rails_helper' - -describe "orders/show" do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - controller.stub(:current_user) { @member } - end - - context "current order" do - before(:each) do - @order = assign(:order, FactoryBot.create(:order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it "displays order number" do - rendered.should have_content "Order number" - end - - it "shows order items in a table" do - assert_select "table>tr>th", text: "Product" - end - - it "shows the total" do - rendered.should have_content "Total:" - assert_select "strong", /198.00/ - end - - it "shows a foreign exchange link for the total" do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") - end - - it "asks for a referral code" do - assert_select "input[id='referral_code']" - end - - it "shows a checkout button" do - assert_select "input[value='Checkout with PayPal']" - end - - it "shows a delete order button" do - assert_select "a", text: "Delete this order" - end - end - - context "completed order" do - before(:each) do - @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it "doesn't show a checkout button" do - assert_select "a", text: "Checkout", count: 0 - end - - it "doesn't show delete order button" do - assert_select "a", text: "Delete this order", count: 0 - end - end -end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb deleted file mode 100644 index 3d60c9e95..000000000 --- a/spec/views/products/edit.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -describe "products/edit" do - before(:each) do - @product = assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99")) - end - - it "renders the edit product form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path(@product), method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" - end - end -end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb deleted file mode 100644 index 90e08e2a3..000000000 --- a/spec/views/products/index.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe "products/index" do - before(:each) do - @product = FactoryBot.create(:product) - assign(:products, [@product, @product]) - end - - it "renders a list of products" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @product.name, count: 2 - assert_select "tr>td", text: @product.description, count: 2 - assert_select "tr>td", text: @product.min_price.to_s, count: 2 - end -end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb deleted file mode 100644 index 336c6bac1..000000000 --- a/spec/views/products/new.html.haml_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -describe "products/new" do - before(:each) do - assign(:product, stub_model(Product, - name: "MyString", - description: "MyString", - min_price: "9.99").as_new_record) - end - - it "renders new product form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: products_path, method: "post" do - assert_select "input#product_name", name: "product[name]" - assert_select "textarea#product_description", name: "product[description]" - assert_select "input#product_min_price", name: "product[min_price]" - assert_select "input#product_recommended_price", name: "product[recommended_price]" - assert_select "select#product_account_type_id", name: "product[account_type_id]" - assert_select "input#product_paid_months", name: "product[paid_months]" - end - end -end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb deleted file mode 100644 index 315d9caae..000000000 --- a/spec/views/products/show.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe "products/show" do - before(:each) do - @product = assign(:product, FactoryBot.create(:product)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @product.name - rendered.should have_content @product.min_price.to_s - rendered.should have_content @product.recommended_price.to_s - end -end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb deleted file mode 100644 index 754f05c09..000000000 --- a/spec/views/shop/index_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rails_helper' - -describe 'shop/index.html.haml', type: "view" do - before(:each) do - @product1 = FactoryBot.create(:product) - @product2 = FactoryBot.create(:product_with_recommended_price) - assign(:products, [@product1, @product2]) - assign(:order_item, OrderItem.new) - end - - context "signed in" do - before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - render - end - - it 'shows products' do - assert_select("h2", text: @product1.name) - end - - it 'shows prices in configured currency' do - rendered.should have_content format('9.99 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=9.99+#{currency}']") - end - - it 'shows recommended price for products that have it' do - rendered.should have_content format('12.00 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link for recommended price' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=12.00+#{currency}']") - end - - it 'displays the order form' do - assert_select "form", count: 2 - end - - it 'renders markdown in product descriptions' do - assert_select "em", text: 'hurrah', count: 2 - end - end - - context "is paid" do - before(:each) do - @member = FactoryBot.create(:member) - @member.account.account_type = FactoryBot.create(:paid_account_type) - @member.account.paid_until = Time.zone.now + 1.year - controller.stub(:current_member) { @member } - end - - it "recognises the paid member" do - @member.paid?.should be(true) - end - - it "tells you you have a paid membership" do - render - rendered.should have_content "You currently have a paid" - end - - it "doesn't show shop" do - render - assert_select "form", false - end - end - - context "signed out" do - before(:each) do - controller.stub(:current_user) { nil } - render - end - - it "tells you to sign up/sign in" do - rendered.should have_content "sign in or sign up" - end - end -end From f5e20cd2d206e21aee7866b9562356e5b3daa542 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:38:08 +1300 Subject: [PATCH 085/101] Re-gen rubocop todo --- .rubocop_todo.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9c3ccad34..769bcb9b6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-offense-counts` -# on 2017-12-06 11:20:15 +1300 using RuboCop version 0.49.1. +# on 2018-02-05 14:37:22 +1300 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -66,24 +66,11 @@ Style/IdenticalConditionalBranches: Exclude: - 'app/controllers/follows_controller.rb' -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'spec/controllers/member_controller_spec.rb' - - 'spec/models/photo_spec.rb' - # Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - 'spec/rails_helper.rb' -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/planting.rb' - # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison @@ -94,11 +81,6 @@ Style/NumericPredicate: - 'app/helpers/plantings_helper.rb' - 'lib/tasks/growstuff.rake' -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'app/mailers/notifier.rb' - # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed From 44b2251896eedd04903bf218168ee9475e267b5e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:05 +1300 Subject: [PATCH 086/101] Re-instated the member-since text on profiles --- app/views/members/_stats.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 346d71296..8bb9613e9 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,3 +1,7 @@ +%p + %strong Member since: + = member.created_at.to_s(:date) + %h3 Activity %ul.list-inline @@ -33,4 +37,3 @@ = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else 0 followers - From 2217d87b5a3082d6c4fda5ffcdc9a3b52ca50187 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:41 +1300 Subject: [PATCH 087/101] Added back the member's last login --- app/views/members/_stats.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 8bb9613e9..a2ebab47d 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,6 +1,9 @@ %p %strong Member since: = member.created_at.to_s(:date) +%p + %strong Last Login: + = member.last_sign_in_at %h3 Activity From aab91e2fa9421c319c33212971a347dad15ff84a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 15:36:32 +1300 Subject: [PATCH 088/101] Removed active merchant --- Gemfile | 2 -- Gemfile.lock | 10 ---------- config/application.yml.example | 5 ----- config/environments/development.rb | 11 ----------- config/environments/production.rb | 11 ----------- config/environments/staging.rb | 11 ----------- config/environments/test.rb | 7 ------- 7 files changed, 57 deletions(-) diff --git a/Gemfile b/Gemfile index 488a3b9ab..f49aaa60d 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'bootstrap-kaminari-views' # bootstrap views for kaminari gem 'kaminari' # pagination gem 'active_utils' -gem 'activemerchant' gem 'sidekiq' # Markdown formatting for updates etc @@ -125,7 +124,6 @@ group :development do end group :development, :test do - gem "active_merchant-paypal-bogus-gateway" gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Gemfile.lock b/Gemfile.lock index 2101269a0..a2bd0a4ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,19 +26,12 @@ GEM addressable active_median (0.1.4) activerecord - active_merchant-paypal-bogus-gateway (0.1.0) - activemerchant active_utils (3.3.9) activesupport (>= 3.2, < 5.2.0) i18n activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.77.0) - activesupport (>= 3.2.14, < 6.x) - builder (>= 2.1.2, < 4.0.0) - i18n (>= 0.6.9) - nokogiri (~> 1.4) activemodel (4.2.10) activesupport (= 4.2.10) builder (~> 3.1) @@ -549,9 +542,7 @@ PLATFORMS DEPENDENCIES active_median - active_merchant-paypal-bogus-gateway active_utils - activemerchant acts_as_paranoid (~> 0.5.0) better_errors (~> 2.2.0) binding_of_caller @@ -636,7 +627,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 diff --git a/config/application.yml.example b/config/application.yml.example index 4aa23e439..ba343b6d0 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -57,11 +57,6 @@ GROWSTUFF_TWITTER_SECRET: "" GROWSTUFF_FLICKR_KEY: "" GROWSTUFF_FLICKR_SECRET: "" -# Paypal is used for payments, obviously. -GROWSTUFF_PAYPAL_USERNAME: "dummy" -GROWSTUFF_PAYPAL_PASSWORD: "dummy" -GROWSTUFF_PAYPAL_SIGNATURE: "dummy" - # https://developers.facebook.com/ GROWSTUFF_FACEBOOK_KEY: "" GROWSTUFF_FACEBOOK_SECRET: "" diff --git a/config/environments/development.rb b/config/environments/development.rb index d3242353e..a66a807f7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -63,17 +63,6 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2il6a' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy', - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy', - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy' - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.action_controller.action_on_unpermitted_parameters = :raise config.active_job.queue_adapter = :sidekiq diff --git a/config/environments/production.rb b/config/environments/production.rb index c931c058e..81cbddefd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -91,16 +91,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2c4ie' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :production - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index a9e242381..d4b381577 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -89,16 +89,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2hao7' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/test.rb b/config/environments/test.rb index bf4135f64..d3ad694dd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -51,13 +51,6 @@ Growstuff::Application.configure do config.analytics_code = '' config.currency = 'AUD' end - - config.after_initialize do - require "active_merchant/ext/paypal_bogus_gateway" - ActiveMerchant::Billing::Base.mode = :test - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - end end Geocoder.configure(lookup: :test) From 83bba916a44ca9adb4bbd7ca5583848fe42c24e8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 10 Feb 2018 18:39:40 +1300 Subject: [PATCH 089/101] Don't update flickr photos in migration --- .../20180118112809_add_datetaken_to_photos.rb | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb index b8cb09118..42afaf23b 100644 --- a/db/migrate/20180118112809_add_datetaken_to_photos.rb +++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb @@ -1,20 +1,5 @@ class AddDatetakenToPhotos < ActiveRecord::Migration - def up + def change add_column :photos, :date_taken, :datetime - update_flickr_metadata - end - - def down - add_column :photos, :date_taken - end - - private - - def update_flickr_metadata - # Fetch from flickr, the photos updated the longest ago will be fetched first - Photo.all.order(:updated_at).each do |photo| - say "Fetch flickr data for #{photo}" - photo.set_flickr_metadata! - end end end From f9d4e1d6aeadc76c93252357d0bd62f56cea548b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 12 Mar 2018 08:39:32 +1300 Subject: [PATCH 090/101] Ancestry of food. Seeds -> Planting -> Seeds -> Planting (#1550) * Add seed ancestry, and seeds.finished_at * Plantings and seeds produce each other * Permissions for seeds actions * View update, for seed actions, and planting ancestry * Routes for seeds * Scopes for harvests * Spec updates for seeds * Removed in-line style * Add seed ancestry, and seeds.finished_at * Plantings and seeds produce each other * Permissions for seeds actions * View update, for seed actions, and planting ancestry * Routes for seeds * Scopes for harvests * Spec updates for seeds * Moved finishable to a concern * Seeds.finished_at * rubocop fixes * Made seeds sown migration the most recent * Specs for home page * Only show current seeds on home page * Seeds appear for logged in or not * Buttons to mark seeds finished * JS for marking seeds finished * Some actions only appear if seed or planting is active * Fixed up display of home page * Fixed typo in admin members#index * Tidying up actions on all the things * Harvest description in #index * Truncate garden description if long * Updated link label in view spec * Show planted_from always, becuase it might be a parent seed * find correct link in spec adding photos to garden * fixed spec finding link to edit garden * Better harvest description truncation * Helping spec find the edit button * specs for the home page * Re-instate crops js, but in the correct file now * Fixed link to garden in actions * Tweaking mobile view --- app/assets/javascripts/crops.js.coffee | 39 ++++++++ app/assets/javascripts/finish_seed.js.coffee | 19 ++++ app/assets/javascripts/seeds.js.coffee | 38 -------- app/controllers/plantings_controller.rb | 3 + app/controllers/seeds_controller.rb | 26 +++--- app/helpers/harvests_helper.rb | 9 +- app/helpers/photos_helper.rb | 39 ++++++++ app/models/ability.rb | 7 +- app/models/concerns/finishable.rb | 12 +++ app/models/harvest.rb | 7 ++ app/models/planting.rb | 9 +- app/models/seed.rb | 5 + app/views/admin/members/index.html.haml | 2 +- app/views/crops/_actions.html.haml | 8 ++ app/views/crops/_image_with_popover.html.haml | 2 +- app/views/crops/_thumbnail.html.haml | 8 +- app/views/crops/show.html.haml | 9 +- app/views/gardens/_actions.html.haml | 55 +++++------ app/views/gardens/_nav.haml | 13 +-- app/views/gardens/_overview.html.haml | 12 +-- app/views/gardens/index.html.haml | 6 +- app/views/gardens/show.html.haml | 24 ++--- app/views/harvests/_actions.html.haml | 6 ++ app/views/harvests/_card.html.haml | 14 +-- app/views/harvests/_image_with_popover.haml | 9 ++ app/views/harvests/_list.html.haml | 11 +++ app/views/harvests/_popover.html.haml | 3 + app/views/harvests/_thumbnail.html.haml | 1 + app/views/harvests/show.html.haml | 8 +- app/views/home/_crops.html.haml | 33 +------ app/views/home/_discuss.html.haml | 2 +- app/views/home/_harvests.html.haml | 3 + app/views/home/_members.html.haml | 4 +- app/views/home/_plantings.html.haml | 3 + app/views/home/_seeds.html.haml | 34 +++---- app/views/home/index.html.haml | 26 +++++- app/views/layouts/application.html.haml | 4 +- app/views/photos/_actions.html.haml | 6 ++ app/views/photos/_item_photos.haml | 24 +++-- app/views/photos/_thumbnail.html.haml | 22 +++-- app/views/photos/show.html.haml | 10 +- app/views/plantings/_actions.html.haml | 37 +++----- app/views/plantings/_card.html.haml | 22 +---- app/views/plantings/_descendants.html.haml | 14 +++ app/views/plantings/_form.html.haml | 12 ++- app/views/plantings/_harvests.html.haml | 15 +-- .../plantings/_image_with_popover.html.haml | 4 +- app/views/plantings/_list.html.haml | 6 +- app/views/plantings/show.html.haml | 43 +++++---- app/views/seeds/_actions.html.haml | 26 +++--- app/views/seeds/_card.html.haml | 32 +++++++ app/views/seeds/_descendants.html.haml | 13 +++ app/views/seeds/_form.html.haml | 26 +++++- app/views/seeds/_thumbnail.html.haml | 45 +++------ app/views/seeds/index.html.haml | 2 +- app/views/seeds/show.html.haml | 93 ++++++++++--------- app/views/shared/buttons/_add_photo.haml | 4 + app/views/shared/buttons/_delete.haml | 4 + app/views/shared/buttons/_edit.haml | 3 + .../shared/buttons/_finish_planting.html.haml | 5 + app/views/shared/buttons/_finish_seeds.haml | 5 + .../shared/buttons/_harvest_planting.haml | 4 + app/views/shared/buttons/_save_seeds.haml | 4 + config/routes.rb | 5 +- db/migrate/20180213005731_seed_usage.rb | 22 +++++ db/schema.rb | 8 +- spec/controllers/plantings_controller_spec.rb | 8 ++ spec/controllers/seeds_controller_spec.rb | 21 ++++- spec/factories/seeds.rb | 8 ++ spec/features/gardens/actions_spec.rb | 84 +++++++++++++++++ spec/features/gardens_spec.rb | 6 +- .../features/harvests/browse_harvests_spec.rb | 17 ++-- .../harvests/harvesting_a_crop_spec.rb | 4 +- spec/features/home/home_spec.rb | 84 +++++++++++++++++ spec/features/photos/new_photo_spec.rb | 4 +- spec/features/seeds/misc_seeds_spec.rb | 4 +- spec/models/planting_spec.rb | 16 ++++ spec/models/seed_spec.rb | 34 +++++++ spec/views/gardens/show.html.haml_spec.rb | 2 +- spec/views/home/_crops.html.haml_spec.rb | 26 ------ spec/views/plantings/show.html.haml_spec.rb | 5 +- 81 files changed, 901 insertions(+), 451 deletions(-) create mode 100644 app/assets/javascripts/crops.js.coffee create mode 100644 app/assets/javascripts/finish_seed.js.coffee create mode 100644 app/helpers/photos_helper.rb create mode 100644 app/models/concerns/finishable.rb create mode 100644 app/views/crops/_actions.html.haml create mode 100644 app/views/harvests/_actions.html.haml create mode 100644 app/views/harvests/_image_with_popover.haml create mode 100644 app/views/harvests/_list.html.haml create mode 100644 app/views/harvests/_popover.html.haml create mode 100644 app/views/home/_harvests.html.haml create mode 100644 app/views/home/_plantings.html.haml create mode 100644 app/views/photos/_actions.html.haml create mode 100644 app/views/plantings/_descendants.html.haml create mode 100644 app/views/seeds/_card.html.haml create mode 100644 app/views/seeds/_descendants.html.haml create mode 100644 app/views/shared/buttons/_add_photo.haml create mode 100644 app/views/shared/buttons/_delete.haml create mode 100644 app/views/shared/buttons/_edit.haml create mode 100644 app/views/shared/buttons/_finish_planting.html.haml create mode 100644 app/views/shared/buttons/_finish_seeds.haml create mode 100644 app/views/shared/buttons/_harvest_planting.haml create mode 100644 app/views/shared/buttons/_save_seeds.haml create mode 100644 db/migrate/20180213005731_seed_usage.rb create mode 100644 spec/features/gardens/actions_spec.rb create mode 100644 spec/features/home/home_spec.rb delete mode 100644 spec/views/home/_crops.html.haml_spec.rb diff --git a/app/assets/javascripts/crops.js.coffee b/app/assets/javascripts/crops.js.coffee new file mode 100644 index 000000000..6a0a27123 --- /dev/null +++ b/app/assets/javascripts/crops.js.coffee @@ -0,0 +1,39 @@ +jQuery -> + $('#add-sci_name-row').css("display", "inline-block") + $('#remove-sci_name-row').css("display", "inline-block") + $("#add-alt_name-row").css("display", "inline-block") + $("#remove-alt_name-row").css("display", "inline-block") + +-$ -> + sci_template = "

Scientific name of crop.
" + + sci_index = $('#scientific_names .template').length + 1 + + $('#add-sci_name-row').click -> + compiled_input = $(sci_template.split("INDEX").join(sci_index)) + $('#scientific_names').append(compiled_input) + sci_index = sci_index + 1 + + $('#remove-sci_name-row').click -> + if (sci_index > 2) + sci_index = sci_index - 1 + tmp = 'sci_template[' + sci_index + ']' + element = document.getElementById(tmp) + element.remove() + + alt_template = "
Alternate name of crop.
" + + alt_index = $('#alternate_names .template').length + 1 + + $('#add-alt_name-row').click -> + compiled_input = $(alt_template.split("INDEX").join(alt_index)) + $('#alternate_names').append(compiled_input) + alt_index = alt_index + 1 + + $('#remove-alt_name-row').click -> + if (alt_index > 2) + alt_index = alt_index - 1 + tmp = 'alt_template[' + alt_index + ']' + element = document.getElementById(tmp) + console.log("%s",tmp) + element.remove() \ No newline at end of file diff --git a/app/assets/javascripts/finish_seed.js.coffee b/app/assets/javascripts/finish_seed.js.coffee new file mode 100644 index 000000000..53a878963 --- /dev/null +++ b/app/assets/javascripts/finish_seed.js.coffee @@ -0,0 +1,19 @@ +# Clears the finished at date field when +# a seed is marked unfinished, and +# repopulates the field with a cached value +# marking unfinished is undone. + +jQuery -> + previousValue = '' + $('#seed_finished').on('click', -> + finished = $('#seed_finished_at') + if @checked + if previousValue.length + date = previousValue + finished.val(date) + else + finished.trigger('focus') + else + previousValue = finished.val() + finished.val('') + ) diff --git a/app/assets/javascripts/seeds.js.coffee b/app/assets/javascripts/seeds.js.coffee index 6cbfb9eb1..ab5b73462 100644 --- a/app/assets/javascripts/seeds.js.coffee +++ b/app/assets/javascripts/seeds.js.coffee @@ -4,41 +4,3 @@ jQuery -> $('.add-datepicker').datepicker('format' : 'yyyy-mm-dd') - $('#add-sci_name-row').css("display", "inline-block") - $('#remove-sci_name-row').css("display", "inline-block") - $("#add-alt_name-row").css("display", "inline-block") - $("#remove-alt_name-row").css("display", "inline-block") - -$ -> - sci_template = "
Scientific name of crop.
" - - sci_index = $('#scientific_names .template').length + 1 - - $('#add-sci_name-row').click -> - compiled_input = $(sci_template.split("INDEX").join(sci_index)) - $('#scientific_names').append(compiled_input) - sci_index = sci_index + 1 - - $('#remove-sci_name-row').click -> - if (sci_index > 2) - sci_index = sci_index - 1 - tmp = 'sci_template[' + sci_index + ']' - element = document.getElementById(tmp) - element.remove() - - alt_template = "
Alternate name of crop.
" - - alt_index = $('#alternate_names .template').length + 1 - - $('#add-alt_name-row').click -> - compiled_input = $(alt_template.split("INDEX").join(alt_index)) - $('#alternate_names').append(compiled_input) - alt_index = alt_index + 1 - - $('#remove-alt_name-row').click -> - if (alt_index > 2) - alt_index = alt_index - 1 - tmp = 'alt_template[' + alt_index + ']' - element = document.getElementById(tmp) - console.log("%s",tmp) - element.remove() diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index f50083213..f6da9d076 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -37,6 +37,7 @@ class PlantingsController < ApplicationController def new @planting = Planting.new(planted_at: Time.zone.today) + @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new @@ -54,6 +55,7 @@ class PlantingsController < ApplicationController def create @planting = Planting.new(planting_params) @planting.owner = current_member + @planting.crop = @planting.parent_seed.crop if @planting.parent_seed.present? @planting.save! respond_with @planting end @@ -82,6 +84,7 @@ class PlantingsController < ApplicationController params[:planted_at] = parse_date(params[:planted_at]) if params[:planted_at] params.require(:planting).permit( :crop_id, :description, :garden_id, :planted_at, + :parent_seed_id, :quantity, :sunniness, :planted_from, :finished, :finished_at ) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 12445877e..b18e6090a 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -16,44 +16,37 @@ class SeedsController < ApplicationController respond_with(@seeds) end - # GET /seeds/1 - # GET /seeds/1.json def show @photos = @seed.photos.includes(:owner).order(created_at: :desc).paginate(page: params[:page]) respond_with(@seed) end - # GET /seeds/new - # GET /seeds/new.json def new @seed = Seed.new - # using find_by_id here because it returns nil, unlike find - @crop = Crop.find_or_initialize_by(id: params[:crop_id]) + if params[:planting_id] + @planting = Planting.find_by(slug: params[:planting_id]) + else + @crop = Crop.find_or_initialize_by(id: params[:crop_id]) + end respond_with(@seed) end - # GET /seeds/1/edit def edit; end - # POST /seeds - # POST /seeds.json def create @seed = Seed.new(seed_params) @seed.owner = current_member + @seed.crop = @seed.parent_planting.crop if @seed.parent_planting flash[:notice] = "Successfully added #{@seed.crop} seed to your stash." if @seed.save respond_with(@seed) end - # PUT /seeds/1 - # PUT /seeds/1.json def update flash[:notice] = 'Seed was successfully updated.' if @seed.update(seed_params) respond_with(@seed) end - # DELETE /seeds/1 - # DELETE /seeds/1.json def destroy @seed.destroy respond_with(@seed) @@ -64,8 +57,11 @@ class SeedsController < ApplicationController def seed_params params.require(:seed).permit( :crop_id, :description, :quantity, :plant_before, - :days_until_maturity_min, :days_until_maturity_max, :organic, :gmo, - :heirloom, :tradable_to, :slug + :parent_planting_id, + :days_until_maturity_min, :days_until_maturity_max, + :organic, :gmo, + :heirloom, :tradable_to, :slug, + :finished, :finished_at ) end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 14277817b..10ed30888 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -28,7 +28,12 @@ module HarvestsHelper end def display_harvest_description(harvest) - return "No description provided." if harvest.description.nil? - harvest.description + if harvest.description.nil? + "no description provided." + else + truncate(harvest.description, length: 50, separator: ' ', omission: '... ') do + link_to "Read more", harvest_path(harvest) + end + end end end diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb new file mode 100644 index 000000000..50064f328 --- /dev/null +++ b/app/helpers/photos_helper.rb @@ -0,0 +1,39 @@ +module PhotosHelper + def crop_image_path(crop) + if crop.default_photo.present? + crop.default_photo.thumbnail_url + else + default_image + end + end + + def planting_image_path(planting) + if planting.photos.present? + planting.photos.first.thumbnail_url + else + default_image + end + end + + def harvest_image_path(harvest) + if harvest.photos.present? + harvest.photos.first.thumbnail_url + else + default_image + end + end + + def seed_image_path(seed) + if seed.default_photo + seed.default_photo.thumbnail_url + else + default_image + end + end + + private + + def default_image + 'placeholder_150.png' + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 89a304257..4fd14340e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -111,9 +111,12 @@ class Ability can :update, Photo, owner_id: member.id can :destroy, Photo, owner_id: member.id - can :create, Seed - can :update, Seed, owner_id: member.id + can :create, Seed + can :update, Seed, owner_id: member.id can :destroy, Seed, owner_id: member.id + can :create, Seed, owner_id: member.id, parent_planting: { owner_id: member.id } + can :update, Seed, owner_id: member.id, parent_planting: { owner_id: member.id } + can :destroy, Seed, owner_id: member.id, parent_planting: { owner_id: member.id } # following/unfollowing permissions can :create, Follow diff --git a/app/models/concerns/finishable.rb b/app/models/concerns/finishable.rb new file mode 100644 index 000000000..42fa4e734 --- /dev/null +++ b/app/models/concerns/finishable.rb @@ -0,0 +1,12 @@ +module Finishable + extend ActiveSupport::Concern + + included do + scope :finished, -> { where(finished: true) } + scope :current, -> { where.not(finished: true) } + + def active? + !finished + end + end +end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 6bb9aa048..9bc4195b4 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -40,6 +40,13 @@ class Harvest < ActiveRecord::Base ## ## Scopes default_scope { joins(:owner) } # Ensures owner exists + scope :interesting, -> { has_photos.one_per_owner } + scope :recent, -> { order(created_at: :desc) } + scope :one_per_owner, lambda { + joins("JOIN members m ON (m.id=harvests.owner_id) + LEFT OUTER JOIN harvests h2 + ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") + } ## ## Validations diff --git a/app/models/planting.rb b/app/models/planting.rb index 6fd4aec17..e358a6bb4 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -1,6 +1,7 @@ class Planting < ActiveRecord::Base extend FriendlyId include PhotoCapable + include Finishable friendly_id :planting_slug, use: %i(slugged finders) # Constants @@ -20,11 +21,15 @@ class Planting < ActiveRecord::Base belongs_to :crop, counter_cache: true has_many :harvests, dependent: :destroy + # + # Ancestry of food + belongs_to :parent_seed, class_name: 'Seed', foreign_key: 'parent_seed_id' # parent + has_many :child_seeds, class_name: 'Seed', + foreign_key: 'parent_planting_id', dependent: :nullify # children + ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists - scope :finished, -> { where(finished: true) } - scope :current, -> { where(finished: false) } scope :interesting, -> { has_photos.one_per_owner } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { diff --git a/app/models/seed.rb b/app/models/seed.rb index 7abae922c..63c88a47c 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -1,6 +1,7 @@ class Seed < ActiveRecord::Base extend FriendlyId include PhotoCapable + include Finishable friendly_id :seed_slug, use: %i(slugged finders) TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze @@ -13,6 +14,10 @@ class Seed < ActiveRecord::Base belongs_to :crop belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id', counter_cache: true + belongs_to :parent_planting, class_name: 'Planting', foreign_key: 'parent_planting_id' # parent + has_many :child_plantings, class_name: 'Planting', + foreign_key: 'parent_seed_id', dependent: :nullify # children + # # Validations validates :crop, approved: true diff --git a/app/views/admin/members/index.html.haml b/app/views/admin/members/index.html.haml index 2408a55db..d91b1f8a1 100644 --- a/app/views/admin/members/index.html.haml +++ b/app/views/admin/members/index.html.haml @@ -11,5 +11,5 @@ %th - @members.each do |member| %tr - %td= ember.login_name + %td= member.login_name %td= member.email diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml new file mode 100644 index 000000000..26f083d7b --- /dev/null +++ b/app/views/crops/_actions.html.haml @@ -0,0 +1,8 @@ +- if can? :create, Planting + = link_to "Plant this", new_planting_path(crop_id: crop.id), class: 'btn btn-default' + +- if can? :create, Harvest + = link_to "Harvest this", new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + +- if can? :create, Seed + = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' diff --git a/app/views/crops/_image_with_popover.html.haml b/app/views/crops/_image_with_popover.html.haml index 6744ccfe1..a8ce256bd 100644 --- a/app/views/crops/_image_with_popover.html.haml +++ b/app/views/crops/_image_with_popover.html.haml @@ -1,5 +1,5 @@ - cache crop do - = link_to image_tag(crop.default_photo.present? ? crop.default_photo.thumbnail_url : 'placeholder_150.png', + = link_to image_tag(crop_image_path(crop), alt: crop.name, class: 'image-responsive crop-image'), crop.name, rel: "popover", diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 1926b31d8..c83a1a0c6 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,7 +1,7 @@ -.thumbnail - .crop-thumbnail - - if crop - - cache cache_key_for(Crop, crop.id) do +- cache cache_key_for(Crop, crop.id) do + .thumbnail + .crop-thumbnail + - if crop = link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), alt: crop.name, class: 'img'), crop diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index cd9751469..7700501fa 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -15,14 +15,7 @@ - if @crop.approved? - content_for :buttonbar do - - if can? :create, Planting - = link_to "Plant this", new_planting_path(crop_id: @crop.id), class: 'btn btn-default' - - - if can? :create, Harvest - = link_to "Harvest this", new_harvest_path(crop_id: @crop.id), class: 'btn btn-default' - - - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: @crop.id }), class: 'btn btn-default' + = render 'crops/actions', crop: @crop .row .col-md-9 diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index ecf434911..a5187991e 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,28 +1,29 @@ -- if can?(:edit, garden) || can?(:delete, garden) - - if can? :edit, garden - - if garden.active - = link_to new_planting_path(garden_id: garden.id), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-grain{ title: "Plant" } - Plant something - = link_to "Mark as inactive", garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default', - data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } - - else - = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), - method: :put, - class: 'btn btn-default' - = link_to edit_garden_path(garden), class: 'btn btn-default', id: 'edit_garden_link' do - %span.glyphicon.glyphicon-pencil{ title: "Edit garden" } - Edit +.garden-actions + - if can?(:edit, garden) + .btn-group + - if garden.active + = link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-grain{ title: "Plant" } + Plant something + = link_to "Mark as inactive", garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default btn-xs', + data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + - else + = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), + method: :put + = render 'shared/buttons/edit', path: edit_garden_path(garden) + + - if can?(:edit, garden) && can?(:create, Photo) + = link_to new_photo_path(type: "garden", id: garden.id), + class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-camera{ title: "Add photo" } + Add photo + - if can?(:destroy, garden) - = link_to garden, - method: :delete, - data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default', id: 'delete_garden_link' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete - - if can?(:edit, garden) && can?(:create, Photo) - = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-primary' do - %span.glyphicon.glyphicon-camera{ title: "Add Photo" } - Add Photo + .pull-right + = link_to garden_path(garden), + method: :delete, + data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, + class: 'btn btn-default btn-xs', id: 'delete_garden_link' do + %span.glyphicon.glyphicon-trash{ title: "Delete" } + Delete diff --git a/app/views/gardens/_nav.haml b/app/views/gardens/_nav.haml index 82ae83086..36c828b87 100644 --- a/app/views/gardens/_nav.haml +++ b/app/views/gardens/_nav.haml @@ -4,12 +4,7 @@ = link_to "Everyone's gardens", gardens_path, class: 'btn btn-default' - - = link_to gardens_active_tickbox_path(@owner, show_all) do - = check_box_tag 'active', 'all', show_all - include in-active - -- if can?(:create, Garden) - = link_to 'Add a garden', new_garden_path, class: 'btn btn-primary' -- unless current_member - = render partial: 'shared/signin_signup', locals: { to: 'add a new garden' } + - if can?(:create, Garden) + = link_to 'Add a garden', new_garden_path, class: 'btn btn-default' + - unless current_member + = render 'shared/signin_signup', to: 'add a new garden' diff --git a/app/views/gardens/_overview.html.haml b/app/views/gardens/_overview.html.haml index 644115d16..b8f9ce54a 100644 --- a/app/views/gardens/_overview.html.haml +++ b/app/views/gardens/_overview.html.haml @@ -1,9 +1,7 @@ - .panel.panel-success .panel-heading %h3.panel-title = link_to garden.name, garden_path(garden) - .panel-body .row .col-md-2.col-xs-12.garden-info @@ -11,15 +9,17 @@ .col-md-12.col-xs-6 = render 'gardens/photo', garden: garden .col-md-12.col-xs-6 - = render 'gardens/actions', garden: garden + = display_garden_description(garden) .col-md-10 .row - if garden.plantings.current.size.positive? - garden.plantings.current.includes(:crop).each do |planting| .col-md-2.col-sm-6.col-xs-6 .hover-wrapper - .text= render 'plantings/actions', planting: planting + .text + = render 'plantings/actions', planting: planting = render partial: "plantings/thumbnail", locals: { planting: planting } - else - no plantings - -# .panel-footer + .col-md-2.col-sm-6.col-xs-6 no plantings + - if can?(:edit, garden) + .panel-footer= render 'gardens/actions', garden: garden diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 4cf4f0705..a09de73ff 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -1,6 +1,10 @@ - content_for :title, @owner ? "#{@owner}'s gardens" : "Everyone's gardens" -= render 'nav', owner: @owner, show_all: @show_all += render 'nav' + += link_to gardens_active_tickbox_path(@owner, @show_all) do + = check_box_tag 'active', 'all', @show_all + include in-active .pagination = page_entries_info @gardens diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 9d4158a00..8b45b0b16 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -16,7 +16,8 @@ .row .col-md-9 - %p.btn-group= render 'gardens/actions', garden: @garden + = render 'gardens/actions', garden: @garden + - unless @garden.active .alert.alert-warning @@ -26,20 +27,21 @@ to plant something in this garden. %div - :growstuff_markdown - #{strip_tags @garden.description} - - unless @garden.description - .row-fluid - %p No description available yet. + %p + :growstuff_markdown + #{strip_tags @garden.description} + - unless @garden.description + .row-fluid + %p No description available yet. - - if can? :edit, @garden - %p - Why not - = link_to 'tell us more.', edit_garden_path(@garden) + - if can? :edit, @garden + %p + Why not + = link_to 'tell us more.', edit_garden_path(@garden) %h3 Garden timeline .row - = timeline garden_timeline_path(@garden), adapter: "google" + .col-md-12= timeline garden_timeline_path(@garden), adapter: "google" %h3 Current plantings in garden .row diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml new file mode 100644 index 000000000..5a2f1febc --- /dev/null +++ b/app/views/harvests/_actions.html.haml @@ -0,0 +1,6 @@ +- if can?(:edit, harvest) || can?(:destroy, harvest) + .btn-group.harvest-actions + - if can? :edit, harvest + = render 'shared/buttons/edit', path: edit_harvest_path(harvest) + - if can? :destroy, harvest + .pull-right= render 'shared/buttons/delete', path: harvest_path(harvest) diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index e82d53725..1a12128b0 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -21,9 +21,11 @@ %dd= display_quantity(harvest) %dt Harvest date : %dd= harvest.harvested_at - .panel-footer - %dt Description - %dd.truncate - = display_harvest_description(harvest) - = if harvest.description.present? - - link_to "Read more", harvest_path(harvest) + %dd Notes: + %dt=display_harvest_description(harvest) + - if harvest.planting.present? + %dt Harvested from + %dd= link_to(harvest.planting, planting_path(harvest.planting)) + .row + .col-md-12 + = render 'harvests/actions', harvest: harvest diff --git a/app/views/harvests/_image_with_popover.haml b/app/views/harvests/_image_with_popover.haml new file mode 100644 index 000000000..ebfb187f6 --- /dev/null +++ b/app/views/harvests/_image_with_popover.haml @@ -0,0 +1,9 @@ += link_to image_tag(harvest_image_path(harvest), + alt: harvest.to_s, + class: 'image-responsive crop-image'), + harvest, + rel: "popover", + 'data-trigger': 'hover', + 'data-title': harvest.to_s, + 'data-content': render('harvests/popover', harvest: harvest), + 'data-html': true diff --git a/app/views/harvests/_list.html.haml b/app/views/harvests/_list.html.haml new file mode 100644 index 000000000..bb0178238 --- /dev/null +++ b/app/views/harvests/_list.html.haml @@ -0,0 +1,11 @@ +- harvests.each do |h| + - cache h do + .row + .col-md-3.col-xs-4{ style: 'padding-bottom: 6px' } + = render 'harvests/image_with_popover', harvest: h + .col-md-9.col-xs-4 + = link_to h.crop, crop_path(h.crop) + %br/ + %small + %i + = h.owner.location diff --git a/app/views/harvests/_popover.html.haml b/app/views/harvests/_popover.html.haml new file mode 100644 index 000000000..508413918 --- /dev/null +++ b/app/views/harvests/_popover.html.haml @@ -0,0 +1,3 @@ +%p + %small + = harvest.harvested_at diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index 9a9beac0c..d7fec2a7a 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -7,3 +7,4 @@ .harvestinfo .harvest-name = link_to harvest, harvest + = I18n.l(harvest.harvested_at.to_date) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 2f9114084..a584389fe 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -32,13 +32,7 @@ %b Quantity: = display_quantity(@harvest) - - if can?(:edit, @harvest) || can?(:destroy, @harvest) - %p - - if can? :edit, @harvest - = link_to 'Edit', edit_harvest_path(@harvest), class: 'btn btn-default btn-xs' - - if can? :destroy, @harvest - = link_to 'Delete', @harvest, method: :delete, data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + = render 'harvests/actions', harvest: @harvest .col-md-6 = render partial: "crops/index_card", locals: { crop: @harvest.crop } diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 6f881dc32..edec779e0 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,28 +1,5 @@ -.row - .col-md-8 - - cache cache_key_for(Crop, 'interesting'), expires_in: 1.day do - %h2= t('.our_crops') - .hidden-xs - - Crop.interesting.includes(:scientific_names, :photos).first(8).each do |c| - .col-md-3 - = render partial: 'crops/thumbnail', locals: { crop: c } - .visible-xs - - Crop.interesting.includes(:scientific_names, :photos).first(3).each do |c| - .col-md-3 - = render partial: 'crops/thumbnail', locals: { crop: c } - - .col-md-4.hidden-xs - - cache cache_key_for(Planting) do - %h2= t('.recently_planted') - = render 'plantings/list', plantings: Planting.includes(:owner, :photos).interesting.recent.first(6) - -.row - .col-md-12 - - cache cache_key_for(Crop, 'recent') do - %p{ style: 'margin-top: 11.25px' } - %strong - #{t('.recently_added')}: - != Crop.recent.limit(12).map { |c| link_to(c, c) }.join(", ") - - %p.text-right - = link_to "#{t('.view_all')} »", crops_path +- cache cache_key_for(Crop, 'interesting'), expires_in: 1.day do + .row + %h2= t('.our_crops') + - Crop.interesting.includes(:scientific_names, :photos).limit(7).each do |c| + .col-md-4.col-xs-4= render 'crops/thumbnail', crop: c diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 36cc1d0f9..0ec3077e1 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -1,6 +1,6 @@ %h2= t('.discussion') -- posts = Post.limit(6) +- posts = Post.order(created_at: :desc).limit(6) - if posts = render "posts/summary", posts: posts, howmany: 6 diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml new file mode 100644 index 000000000..d4c2a1117 --- /dev/null +++ b/app/views/home/_harvests.html.haml @@ -0,0 +1,3 @@ +- cache cache_key_for(Harvest) do + %h2 Recently Harvested + = render 'harvests/list', harvests: Harvest.includes(:crop, :owner, :photos).has_photos.recent.first(5) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index 0c786ca7b..c3a4392ba 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,13 +1,13 @@ - cache cache_key_for(Member) do .hidden-xs - - members = Member.interesting.first(6) + - members = Member.includes(plantings: :crop).interesting.first(6) - if members.present? %section %h2= t('.title') .member-cards - members.each do |m| - = render partial: "members/thumbnail", locals: { member: m } + = render "members/thumbnail", member: m %p.text-right = link_to "#{t('.view_all')} »", members_path diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml new file mode 100644 index 000000000..bfaa4a422 --- /dev/null +++ b/app/views/home/_plantings.html.haml @@ -0,0 +1,3 @@ +- cache cache_key_for(Planting, 'home'), expires_in: 1.day do + %h2= t('.recently_planted') + = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.first(5) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 7469b90b0..3f018994a 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,21 +1,21 @@ - cache cache_key_for(Seed, 'interesting'), expires_in: 1.day do %h2= t('.title') .row - .col-md-8 - - Seed.includes(:owner, crop: :photos).order(created_at: :desc).interesting.first(6).each do |seed| - .col-md-3 - .thumbnail - - cache cache_key_for(Crop, seed.id) do - = link_to image_tag((seed.default_photo ? seed.default_photo.thumbnail_url : 'placeholder_150.png'), - alt: seed.crop.name, class: 'img'), - seed - .seedinfo - = link_to seed.crop.name, seed - .trade-to - %p= seed.owner.location - %p - Will trade to: - %br/ - #{seed.tradable_to} + - Seed.current.tradable.order(created_at: :desc).limit(6).each do |seed| + .col-md-2.col-xs-4 + .thumbnail + - cache cache_key_for(Crop, seed.id) do + = link_to image_tag(seed_image_path(seed), + alt: seed.crop.name, class: 'img'), + seed + .seedinfo + = link_to seed.crop.name, seed + .trade-to + %p= seed.owner.location + %p + Will trade to: + %br/ + #{seed.tradable_to} + %p.text-right - = link_to "#{t('.view_all')} »", seeds_path += link_to "#{t('.view_all')} »", seeds_path diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 655fbd3fc..80502c3f5 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -18,8 +18,26 @@ .visible-xs = render partial: 'blurb' - = render partial: 'crops' - = render partial: 'seeds' - = render partial: 'members' - = render partial: 'discuss' + .row + .col-md-6 + = render partial: 'crops' + .col-md-3 + = render partial: 'plantings' + .col-md-3 + = render partial: 'harvests' + .col-md-12 + - cache cache_key_for(Crop, 'recent') do + %p{ style: 'margin-top: 11.25px' } + %strong + #{t('.recently_added')}: + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + %p.text-right + = link_to "#{t('home.crops.view_all')} »", crops_path + .row + .col-md-12 + = render partial: 'seeds' + = render partial: 'members' + .row + .col-md-12 + = render partial: 'discuss' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3dcf02c39..2c0f6b9bb 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,9 +15,7 @@ %small= yield(:subtitle) - if content_for?(:buttonbar) - %p - .btn-group - = yield(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) = render partial: "shared/flash_messages", flash: flash = yield diff --git a/app/views/photos/_actions.html.haml b/app/views/photos/_actions.html.haml new file mode 100644 index 000000000..878d985ef --- /dev/null +++ b/app/views/photos/_actions.html.haml @@ -0,0 +1,6 @@ +- if can?(:edit, @photo) && can?(:destroy, @photo) + %p.photo-actions + - if can?(:edit, @photo) + = render 'shared/buttons/edit', path: edit_photo_path(@photo) + - if can?(:destroy, @photo) + = render 'shared/buttons/delete', path: photo_path(@photo) diff --git a/app/views/photos/_item_photos.haml b/app/views/photos/_item_photos.haml index 679871680..f0642c336 100644 --- a/app/views/photos/_item_photos.haml +++ b/app/views/photos/_item_photos.haml @@ -1,16 +1,14 @@ +%h2 Photos + - if photos.size.positive? || (can?(:edit, item) && can?(:create, Photo)) - %h2 Photos - if photos.size.positive? + = page_entries_info photos + = will_paginate photos .row - .pagination - = page_entries_info photos - = will_paginate photos - .row - - photos.each do |photo| - .col-md-2.six-across= render 'photos/thumbnail', photo: photo - - if can?(:create, Photo) && can?(:edit, item) - .col-md-2 - .thumbnail - = link_to new_photo_path(type: type, id: item.id), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + - photos.each do |photo| + .col-xs-6.col-md-3.six-across= render 'photos/thumbnail', photo: photo + +- if can?(:create, Photo) && can?(:edit, item) + = link_to new_photo_path(type: type, id: item.id), class: 'btn btn-primary' do + %span.glyphicon.glyphicon-camera{ title: "Add photo" } + Add photo diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index 03a1f0c4c..3be4a26d6 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,10 +1,12 @@ -.thumbnail.photo-thumbnail - = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive'), photo - .text - %p - = link_to photo.title, photo - %br/ - %small - %i - by - = link_to photo.owner, photo.owner +.thumbnail + .photo-thumbnail + = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive'), photo + .text + %p + = link_to photo.title, photo + %br/ + %small + %i + by + = link_to photo.owner, photo.owner + = I18n.l(photo.created_at.to_date) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 7e52a11e9..3758883b6 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -12,15 +12,7 @@ %p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'img img-responsive') .col-md-4 - %p - - if can? :destroy, @photo - = link_to @photo, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - - - if can? :edit, @photo - = link_to edit_photo_path(@photo), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } + = render 'photos/actions', photo: @photo %p %strong Posted by: = link_to @photo.owner, @photo.owner diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index b2c2d5f98..87eddc8cf 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,27 +1,12 @@ -- if can?(:edit, planting) || can?(:destroy, planting) - - if can? :edit, planting - = link_to edit_planting_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - Edit +- if can?(:edit, planting) + .btn-group.planting-actions + = render 'shared/buttons/edit', path: edit_planting_path(planting) + = render 'shared/buttons/add_photo', path: new_photo_path(id: planting.id, type: 'planting') + + - if planting.active? + = render 'shared/buttons/finish_planting', planting: planting + = render 'shared/buttons/harvest_planting', planting: planting + = render 'shared/buttons/save_seeds', planting: planting + - if can? :destroy, planting - = link_to planting, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete - - - unless planting.finished - = link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do - - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished - - - if can? :edit, planting - = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest - - - if can?(:edit, planting) && can?(:create, Photo) - = link_to new_photo_path(id: planting.id, type: 'planting'), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + = render 'shared/buttons/delete', path: planting diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index a5469461a..bb6d77347 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -35,24 +35,6 @@ %dt Finish expected: %dd= planting.finish_predicted_at if planting.finish_predicted_at.present? - %p= render 'plantings/progress', planting: planting, show_explanation: true - - = link_to 'Details', planting_path(planting), - class: 'btn btn-default btn-xs' - - - if can?(:edit, planting) && can?(:create, Harvest) - = link_to 'Harvest', new_planting_harvest_path(planting), - class: 'btn btn-default btn-xs' - - - if can?(:edit, planting) && !planting.finished - = link_to "Mark as finished", - planting_path(planting, planting: { finished: 1 }), - method: :put, - class: 'btn btn-default btn-xs append-date' - - - if can? :destroy, planting - = link_to planting, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } + .row + .col-md-12= render 'plantings/actions', planting: planting diff --git a/app/views/plantings/_descendants.html.haml b/app/views/plantings/_descendants.html.haml new file mode 100644 index 000000000..27e81c6b8 --- /dev/null +++ b/app/views/plantings/_descendants.html.haml @@ -0,0 +1,14 @@ +%h2 Seeds saved from this planting + +- if planting.child_seeds.size.positive? + .row + - planting.child_seeds.each do |seed| + .col-xs-6.col-sm-4.col-md-3 + = render 'seeds/thumbnail', seed: seed +- else + %p No seeds saved + +- if planting.active? && can?(:create, Seed) && can?(:edit, planting) + = link_to new_planting_seed_path(planting), class: 'btn btn-primary' do + %span.glyphicon.glyphicon-heart{ title: "Add photo" } + Save seeds diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 4b0d979b6..874b5329b 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -13,10 +13,14 @@ .form-group.required = f.label :crop, 'What did you plant?', class: 'control-label col-md-2' .col-md-8 - = auto_suggest @planting, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path + - if @seed.present? + = link_to @seed, seed_path(@seed) + = f.hidden_field :parent_seed_id, value: @seed.id + - else + = auto_suggest @planting, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path .form-group.required = f.label :garden_id, 'Where did you plant it?', class: 'control-label col-md-2' .col-md-8 diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml index 5edf14a3d..a845e980e 100644 --- a/app/views/plantings/_harvests.html.haml +++ b/app/views/plantings/_harvests.html.haml @@ -1,12 +1,13 @@ +%h2 Harvests - if planting.harvests.empty? - %p no harvests yet + %p No harvests - else .row - planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest| - .col-xs-6.col-md-2 + .col-xs-6.col-sm-4.col-md-3 = render 'harvests/thumbnail', harvest: harvest - - if can? :edit, planting - .col-xs-6.col-md-2 - = link_to new_planting_harvest_path(planting), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest + +- if planting.active? && can?(:edit, planting) + = link_to new_planting_harvest_path(planting), class: 'btn btn-primary' do + %span.glyphicon.glyphicon-leaf{ title: "Harvest" } + Harvest diff --git a/app/views/plantings/_image_with_popover.html.haml b/app/views/plantings/_image_with_popover.html.haml index d958a9d41..70bfc1836 100644 --- a/app/views/plantings/_image_with_popover.html.haml +++ b/app/views/plantings/_image_with_popover.html.haml @@ -1,10 +1,10 @@ - cache planting do - = link_to image_tag(planting.photos.present? ? planting.photos.first.thumbnail_url : 'placeholder_150.png', + = link_to image_tag(planting_image_path(planting), alt: planting.to_s, class: 'image-responsive crop-image'), planting, rel: "popover", 'data-trigger': 'hover', 'data-title': planting.to_s, - 'data-content': render(partial: 'plantings/popover', locals: { planting: planting }), + 'data-content': render('plantings/popover', planting: planting), 'data-html': true diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml index cf678c8a6..02901cdcd 100644 --- a/app/views/plantings/_list.html.haml +++ b/app/views/plantings/_list.html.haml @@ -1,9 +1,9 @@ - plantings.each do |p| - cache p do .row - .col-md-3{ style: 'padding-bottom: 6px' } + .col-md-3.col-xs-4{ style: 'padding-bottom: 6px' } = render partial: 'plantings/image_with_popover', locals: { planting: p } - .col-md-9 + .col-md-9.col-xs-4 = link_to p.crop, p.crop in = succeed "'s" do @@ -12,4 +12,4 @@ %br/ %small %i - = p.owner.location + = p.location diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 88789ed5a..49be10fa5 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -9,9 +9,11 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -%p= render 'plantings/actions', planting: @planting +- content_for :buttonbar do + = render 'plantings/actions', planting: @planting + .row.planting - .col-md-6 + .col-xs-12.col-sm-6 %dl.dl-horizontal.planting-attributes %dt Owner: %dd @@ -26,14 +28,17 @@ %dd = link_to "#{@planting.owner}'s", @planting.owner = link_to @planting.garden, @planting.garden - - unless @planting.owner.location.blank? + - if @planting.owner.location.present? (#{@planting.owner.location}) %dt Quantity: %dd= display_planting_quantity(@planting) - - unless @planting.planted_from.blank? - %dt Planted from: - %dd= display_planted_from(@planting) + %dt Planted from: + %dd + - if @planting.parent_seed + = link_to @planting.parent_seed, seed_path(@planting.parent_seed) + - else + = display_planted_from(@planting) %dt Sun or shade? %dd @@ -64,23 +69,23 @@ %dt Last Harvest: %dd #{@planting.days_to_last_harvest} days after planting + %dt Progress + %dd= render 'plantings/progress', planting: @planting, show_explanation: true - %h2 Progress - %p= render 'plantings/progress', planting: @planting, show_explanation: true - %h2 Harvests - %p= render 'plantings/harvests', planting: @planting - - .col-md-6 + .col-xs-12.col-sm-6 = render partial: "crops/index_card", locals: { crop: @planting.crop } - if @planting.owner.location %p %small View other plantings, members and more near = link_to @planting.owner.location, place_path(@planting.owner.location, anchor: "plantings") -- if @planting.description - %h2 Notes - - :growstuff_markdown - #{ @planting.description != "" ? strip_tags(@planting.description) : "No description given." } - -= render 'photos/item_photos', item: @planting, type: 'planting', photos: @photos +.row + .col-md-6 + - if @planting.description + %h2 Notes + :growstuff_markdown + #{ @planting.description != "" ? strip_tags(@planting.description) : "No description given." } + = render 'plantings/harvests', planting: @planting + = render 'plantings/descendants', planting: @planting + .col-md-6 + = render 'photos/item_photos', item: @planting, type: 'planting', photos: @photos diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 9584182f0..803b63b2d 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -1,11 +1,15 @@ -- if can? :edit, @seed - = link_to edit_seed_path(@seed), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - Edit - = link_to new_photo_path(id: seed.id, type: 'seed'), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo -- if can? :destroy, @seed - = link_to @seed, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + +- if can? :edit, seed + .btn-group + = render 'shared/buttons/edit', path: edit_seed_path(seed) + = render 'shared/buttons/add_photo', path: new_photo_path(id: seed.id, type: 'seed') + + - if can?(:create, Planting) && seed.active? + = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-grain{ title: "Plant seeds" } + Plant seeds + + = render 'shared/buttons/finish_seeds', seed: seed + +- if can? :destroy, seed + = render 'shared/buttons/delete', path: seed diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml new file mode 100644 index 000000000..532db8d6c --- /dev/null +++ b/app/views/seeds/_card.html.haml @@ -0,0 +1,32 @@ +.panel.panel-success + .panel-heading + %h3.panel-title + = link_to seed, seed + - if can? :edit, seed + %a.pull-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } + %span.glyphicon.glyphicon-pencil{ title: "Edit" } + .panel-body + .row + .col-md-4 + = link_to image_tag((seed.crop.default_photo ? seed.crop.default_photo.thumbnail_url : 'placeholder_150.png'), + alt: seed.crop.name, class: 'img'), + seed.crop + .col-md-8 + %dl.dl-horizontal + %dt Crop : + %dd= link_to seed.crop.name, seed.crop + - if seed.parent_planting.present? + %dt Saved from + %dd= link_to seed.parent_planting, planting_path(seed.parent_planting) + %dt Plant before : + %dd= seed.plant_before + %dt Quantity : + %dd= seed.quantity + %dt Will trade to : + %dd= seed.tradable_to + %dt From location : + %dd= seed.owner.location + %dt Owner : + %dd= link_to seed.owner.login_name, seed.owner + .col-md-12 + %p= render 'seeds/actions', seed: seed diff --git a/app/views/seeds/_descendants.html.haml b/app/views/seeds/_descendants.html.haml new file mode 100644 index 000000000..1736d0bca --- /dev/null +++ b/app/views/seeds/_descendants.html.haml @@ -0,0 +1,13 @@ +%h2 Plants grown from these seeds +- if @seed.child_plantings + .row + - seed.child_plantings.each do |planting| + .col-md-3 + = render 'plantings/thumbnail', planting: planting +- else + %p No plants grown yet. + +- if can?(:create, Planting) && can?(:edit, seed) + = link_to new_seed_planting_path(seed), class: 'btn btn-primary' do + %span.glyphicon.glyphicon-grain{ title: "Plant seeds" } + Plant seeds diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index b7cb3ea36..9bd2dd280 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -9,14 +9,17 @@ %ul - @seed.errors.full_messages.each do |msg| %li= msg - .form-group.required = f.label :crop, 'Crop:', class: 'control-label col-md-2' .col-md-8 - = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path + - if @planting + = link_to @planting, planting_path(@planting) + = f.hidden_field :parent_planting_id, value: @planting.id + - else + = auto_suggest @seed, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path .form-group = f.label :quantity, 'Quantity:', class: 'control-label col-md-2' .col-md-2 @@ -28,6 +31,19 @@ = f.text_field :plant_before, class: 'add-datepicker form-control', value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' = render partial: 'shared/form_optional' + .form-group + = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' + .col-md-8 + = f.check_box :finished + = render partial: 'shared/form_optional' + %span.help-block + = t('.finish_helper') + .form-group + = f.label :finished_at, 'Finished at:', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :finished_at, class: 'add-datepicker form-control', + value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' + = render partial: 'shared/form_optional' .form-group = f.label :days_until_maturity_min, 'Days until maturity:', class: 'control-label col-md-2' %fieldset diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index edd464e57..f985b4d16 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -1,31 +1,14 @@ -.panel.panel-success - .panel-heading - %h3.panel-title - = link_to "#{seed.owner.login_name}'s seed", seed - - if can? :edit, seed - %a.pull-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - .panel-body - .row - .col-md-4 - = link_to image_tag((seed.crop.default_photo ? seed.crop.default_photo.thumbnail_url : 'placeholder_150.png'), - alt: seed.crop.name, class: 'img'), - seed.crop - .col-md-8 - %dl.dl-horizontal - %dt Crop : - %dd= link_to seed.crop.name, seed.crop - %dt Plant before : - %dd= seed.plant_before - %dt Quantity : - %dd= seed.quantity - %dt Will trade to : - %dd= seed.tradable_to - %dt From location : - %dd= seed.owner.location - %dt Owner : - %dd= link_to seed.owner.login_name, seed.owner - .panel-footer - %dt Description - %dd - = display_seed_description(seed) +.thumbnail + .seed-thumbnail + = link_to image_tag((seed.default_photo ? seed.default_photo.thumbnail_url : 'placeholder_150.png'), + alt: seed.crop.name, class: 'img'), + seed_path(seed) + .seedinfo + .seed-name + = link_to seed, seed_path(seed) + .trade-to + %p= seed.owner.location + %p + Will trade to: + %br/ + = seed.tradable_to diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 3108bfc56..e7e1ec3e3 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -28,7 +28,7 @@ - unless @seeds.empty? - @seeds.each do |seed| .col-md-6 - = render partial: 'seeds/thumbnail', locals: { seed: seed } + = render 'seeds/card', seed: seed .pagination = page_entries_info @seeds diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index e15ffb46d..681a21324 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -9,47 +9,56 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +- content_for :buttonbar do + = render 'seeds/actions', seed: @seed + .row .col-md-6 - %p - %b Owner: - = link_to @seed.owner, @seed.owner - — - = link_to "view all #{@seed.owner}'s seeds", seeds_by_owner_path(owner: @seed.owner.slug) - %p - %b Quantity: - = @seed.quantity.blank? ? "not specified" : @seed.quantity - %p - %b Plant before: - = @seed.plant_before.to_s - %p - %b Days until maturity: - = render partial: 'days_until_maturity', locals: { seed: @seed } - %p - %b Organic? - = @seed.organic - %p - %b GMO? - = @seed.gmo - %p - %b Heirloom? - = @seed.heirloom - %p - %b Will trade: - = @seed.tradable_to - - if @seed.owner.location.blank? - (from unspecified location) - - if current_member == @seed.owner - = link_to "Set Location", edit_registration_path(current_member), class: 'btn btn-default btn-xs' - - else - (from - = succeed ")" do - = link_to @seed.owner.location, place_path(@seed.owner.location, anchor: "seeds") + %dl.dl-horizontal + %dt Owner + %dd + = link_to @seed.owner, @seed.owner + — + = link_to "view all #{@seed.owner}'s seeds", + seeds_by_owner_path(owner: @seed.owner.slug) + %dt Quantity: + %dd= @seed.quantity.blank? ? "not specified" : @seed.quantity + %dt Plant before: + %dd= @seed.plant_before.to_s + -if @seed.finished_at + %dt Finished at: + %dd= @seed.finished_at.to_s + %dt Days until maturity: + %dd= render partial: 'days_until_maturity', locals: { seed: @seed } + %dt Organic? + %dd= @seed.organic + %dt GMO? + %dd= @seed.gmo + %dt Heirloom? + %dd= @seed.heirloom + %dt Will trade: + %dd + = @seed.tradable_to + - if @seed.owner.location.blank? + (from unspecified location) + - if current_member == @seed.owner + = link_to "Set Location", edit_registration_path(current_member), class: 'btn btn-default btn-xs' + - else + (from + = succeed ")" do + = link_to @seed.owner.location, place_path(@seed.owner.location, anchor: "seeds") - %p - %b Description: - :growstuff_markdown - #{ @seed.description != "" ? strip_tags(@seed.description) : "No description given." } + %dt When? + %dd + = @seed.created_at + - if @seed.parent_planting + %dt Saved from planting: + %dd + = link_to @seed.parent_planting, planting_path(@seed.parent_planting) + %dt Description: + %dd + :growstuff_markdown + #{ @seed.description != "" ? strip_tags(@seed.description) : "No description given." } - if current_member - if @seed.tradable? && current_member != @seed.owner @@ -60,9 +69,9 @@ - else = render 'shared/signin_signup', to: 'request seeds' - - if can?(:edit, @seed) || can?(:destroy, @seed) - %p - = render 'actions', seed: @seed + = render 'seeds/descendants', seed: @seed + = render 'photos/item_photos', item: @seed, type: 'seed', photos: @photos + .col-md-6 = render partial: "crops/index_card", locals: { crop: @seed.crop } - if @seed.owner.location @@ -75,5 +84,3 @@ Or = link_to "purchase seeds via Ebay", crop_ebay_seeds_url(@seed.crop), target: "_blank", rel: "noopener noreferrer" - -= render 'photos/item_photos', item: @seed, type: 'seed', photos: @photos diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml new file mode 100644 index 000000000..71e97c0e9 --- /dev/null +++ b/app/views/shared/buttons/_add_photo.haml @@ -0,0 +1,4 @@ +- if can?(:create, Photo) + = link_to path, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-camera{ title: "Add photo" } + Add photo diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml new file mode 100644 index 000000000..b7490837b --- /dev/null +++ b/app/views/shared/buttons/_delete.haml @@ -0,0 +1,4 @@ += link_to path, method: :delete, + data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-trash{ title: "Delete" } + Delete diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml new file mode 100644 index 000000000..87d464023 --- /dev/null +++ b/app/views/shared/buttons/_edit.haml @@ -0,0 +1,3 @@ += link_to path, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-pencil{ title: "Edit" } + Edit diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml new file mode 100644 index 000000000..9a3b6ce75 --- /dev/null +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -0,0 +1,5 @@ +- unless planting.finished + = link_to planting_path(planting, planting: { finished: 1 }), + method: :put, class: 'btn btn-default btn-xs append-date' do + %span.glyphicon.glyphicon-ok{ title: "Finished" } + Mark as finished diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml new file mode 100644 index 000000000..211e3ec8b --- /dev/null +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -0,0 +1,5 @@ +- unless seed.finished + = link_to seed_path(seed, seed: { finished: 1 }), + method: :put, class: 'btn btn-default btn-xs append-date' do + %span.glyphicon.glyphicon-ok{ title: "Finished" } + Mark as finished diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml new file mode 100644 index 000000000..c90e163ad --- /dev/null +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -0,0 +1,4 @@ +- planting.active? && if can?(:create, Harvest) && can?(:edit, planting) + = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-leaf{ title: "Harvest" } + Harvest diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml new file mode 100644 index 000000000..00d5febb0 --- /dev/null +++ b/app/views/shared/buttons/_save_seeds.haml @@ -0,0 +1,4 @@ +- if planting.active? + = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-heart{ title: "Save seeds" } + Save seeds diff --git a/config/routes.rb b/config/routes.rb index 777536e38..52517f580 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,6 +23,7 @@ Growstuff::Application.routes.draw do resources :plantings do resources :harvests + resources :seeds end get '/plantings/owner/:owner' => 'plantings#index', as: 'plantings_by_owner' get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop' @@ -32,7 +33,9 @@ Growstuff::Application.routes.draw do end get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner' - resources :seeds + resources :seeds do + resources :plantings + end get '/seeds/owner/:owner' => 'seeds#index', as: 'seeds_by_owner' get '/seeds/crop/:crop' => 'seeds#index', as: 'seeds_by_crop' diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb new file mode 100644 index 000000000..f768451d2 --- /dev/null +++ b/db/migrate/20180213005731_seed_usage.rb @@ -0,0 +1,22 @@ +class SeedUsage < ActiveRecord::Migration + def change + # # seed can be all sown, meaning there is none left + add_column(:seeds, :finished, :boolean, default: false) + add_column(:seeds, :finished_at, :date, default: nil) + + # plantings can be grown from a seed + add_column(:plantings, :parent_seed_id, :integer) + add_foreign_key(:plantings, :seeds, + column: :parent_seed_id, + primary_key: :id, + name: :parent_seed, + on_delete: :nullify) + # seeds can be harvest from planting + add_column(:seeds, :parent_planting_id, :integer) + add_foreign_key(:seeds, :plantings, + column: :parent_planting_id, + primary_key: :id, + name: :parent_planting, + on_delete: :nullify) + end +end diff --git a/db/schema.rb b/db/schema.rb index c38e122e9..7e9cad2e0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180205000612) do +ActiveRecord::Schema.define(version: 20180213005731) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -409,6 +409,7 @@ ActiveRecord::Schema.define(version: 20180205000612) do t.integer "lifespan" t.integer "days_to_first_harvest" t.integer "days_to_last_harvest" + t.integer "parent_seed_id" end add_index "plantings", ["slug"], name: "index_plantings_on_slug", unique: true, using: :btree @@ -459,10 +460,15 @@ ActiveRecord::Schema.define(version: 20180205000612) do t.text "organic", default: "unknown" t.text "gmo", default: "unknown" t.text "heirloom", default: "unknown" + t.boolean "finished", default: false + t.date "finished_at" + t.integer "parent_planting_id" end add_index "seeds", ["slug"], name: "index_seeds_on_slug", unique: true, using: :btree add_foreign_key "harvests", "plantings" add_foreign_key "photographings", "photos" + add_foreign_key "plantings", "seeds", column: "parent_seed_id", name: "parent_seed", on_delete: :nullify + add_foreign_key "seeds", "plantings", column: "parent_planting_id", name: "parent_planting", on_delete: :nullify end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index abe5ea626..c4fe2396f 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -90,6 +90,14 @@ describe PlantingsController do it { expect(assigns(:planting).planted_at).to eq Time.zone.today } end + context 'with parent seed' do + let(:seed) { FactoryBot.create :seed, owner: member } + before { get :new, seed_id: seed.to_param } + it { expect(assigns(:seed)).to eq(seed) } + end + end + + describe 'POST :create' do describe "sets the owner automatically" do before { post :create, planting: valid_attributes } it { expect(assigns(:planting).owner).to eq subject.current_member } diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index c2fd699eb..a803d8688 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,11 +1,28 @@ require 'rails_helper' describe SeedsController do + let(:owner) { FactoryBot.create(:member) } + describe "GET index" do + before { get :index, owner: owner.slug } it "picks up owner from params" do - owner = FactoryBot.create(:member) - get :index, owner: owner.slug assigns(:owner).should eq(owner) end end + + describe 'GET new' do + before { sign_in owner } + + it { expect(response).to be_success } + + context 'no parent planting' do + before { get :new } + end + + context 'with parent planting' do + let(:planting) { FactoryBot.create :planting, owner: owner } + before { get :new, planting_id: planting.to_param } + it { expect(assigns(:planting)).to eq(planting) } + end + end end diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index 41b3d404f..b58193671 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -13,9 +13,17 @@ FactoryBot.define do heirloom 'unknown' days_until_maturity_min nil days_until_maturity_max nil + finished_at nil + + factory :finished_seed do + finished true + finished_at { Date.new } + end factory :tradable_seed do tradable_to "locally" + finished false + finished_at nil end factory :untradable_seed do diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb new file mode 100644 index 000000000..7342fe55e --- /dev/null +++ b/spec/features/gardens/actions_spec.rb @@ -0,0 +1,84 @@ +require 'rails_helper' +require 'custom_matchers' + +feature "Gardens" do + context 'logged in' do + let(:member) { FactoryBot.create :member } + background { login_as member } + subject { page } + let(:garden) { member.gardens.first } + + describe '#index' do + shared_examples "has buttons bar at top" do + it "has buttons bar at top" do + within '.layout-actions' do + is_expected.to have_link 'Add a garden' + is_expected.to have_link 'My Gardens' + is_expected.to have_link "Everyone's gardens" + end + end + end + + context 'my gardens' do + before { visit gardens_path(owner: member) } + include_examples "has buttons bar at top" + it "has actions on garden" do + within '.garden-actions' do + is_expected.to have_link 'Plant something' + is_expected.to have_link 'Mark as inactive' + is_expected.to have_link 'Edit' + is_expected.to have_link 'Add photo' + is_expected.to have_link 'Delete' + end + end + end + context 'all gardens' do + before { visit gardens_path } + include_examples "has buttons bar at top" + end + context "other member's garden" do + before { visit gardens_path(owner: FactoryBot.create(:member)) } + include_examples "has buttons bar at top" + it 'does not show actions on other member garden' do + is_expected.not_to have_link 'Plant something' + is_expected.not_to have_link 'Mark as inactive' + end + end + end + + describe '#show' do + end + end + + # background do + # login_as member + # visit new_garden_path + # end + + # it "has the required fields help text" do + # expect(page).to have_content "* denotes a required field" + # end + + # it "displays required and optional fields properly" do + # expect(page).to have_selector ".form-group.required", text: "Name" + # expect(page).to have_optional 'textarea#garden_description' + # expect(page).to have_optional 'input#garden_location' + # expect(page).to have_optional 'input#garden_area' + # end + + # scenario "Create new garden" do + # fill_in "Name", with: "New garden" + # click_button "Save" + # expect(page).to have_content "Garden was successfully created" + # expect(page).to have_content "New garden" + # end + + # scenario "Refuse to create new garden with negative area" do + # visit new_garden_path + # fill_in "Name", with: "Negative Garden" + # fill_in "Area", with: -5 + # click_button "Save" + # expect(page).not_to have_content "Garden was successfully created" + # expect(page).to have_content "Area must be greater than or equal to 0" + # end +end diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 0954d35eb..368389719 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -59,7 +59,7 @@ feature "Planting a crop", js: true do end scenario "button on index to edit garden" do - first(".garden-info").click_link("edit_garden_link") + click_link href: edit_garden_path(garden) expect(page).to have_content 'Edit garden' end end @@ -68,7 +68,9 @@ feature "Planting a crop", js: true do visit new_garden_path fill_in "Name", with: "New garden" click_button "Save" - click_link 'edit_garden_link' + within '.garden-actions' do + click_link 'Edit' + end fill_in "Name", with: "Different name" click_button "Save" expect(page).to have_content "Garden was successfully updated" diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 2a8400c2e..c51be9f41 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -4,19 +4,14 @@ feature "browse harvests" do let!(:member) { create :member } let!(:harvest) { create :harvest, owner: member } - background do - login_as member - end - + background { login_as member } + subject { page } feature 'blank optional fields' do let!(:harvest) { create :harvest, :no_description } - - before(:each) do - visit harvests_path - end + before { visit harvests_path } scenario 'read more' do - expect(page).not_to have_link "Read more" + is_expected.not_to have_link "Read more" end end @@ -28,11 +23,11 @@ feature "browse harvests" do end scenario 'read more' do - expect(page).to have_link "Read more" + is_expected.to have_link "Read more" end it 'links to #show' do - expect(page).to have_link harvest.crop.name, href: harvest_path(harvest) + is_expected.to have_link harvest.crop.name, href: harvest_path(harvest) end end end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 84c4b5a7f..e99c5e814 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -78,7 +78,9 @@ feature "Harvesting a crop", :js, :elasticsearch do scenario "Harvesting from planting page" do planting = create :planting, crop: maize, owner: member, garden: member.gardens.first visit planting_path(planting) - click_link "Harvest" + within ".planting-actions" do + click_link "Harvest" + end select plant_part.name, from: 'harvest[plant_part_id]' click_button "Save" diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb new file mode 100644 index 000000000..4137b5e5a --- /dev/null +++ b/spec/features/home/home_spec.rb @@ -0,0 +1,84 @@ +require 'rails_helper' + +feature "home page" do + let(:member) { FactoryBot.create :member } + # let(:seed_photo) { FactoryBot.create :photo } + let(:photo) { FactoryBot.create :photo } + let(:crop) { FactoryBot.create :crop, created_at: 1.day.ago } + + let(:planting) { FactoryBot.create :planting, owner: member, crop: crop } + let(:seed) { FactoryBot.create :tradable_seed, owner: member, crop: crop } + let(:harvest) { FactoryBot.create :harvest, owner: member, crop: crop } + + let!(:tradable_seed) { FactoryBot.create :tradable_seed, finished: false } + let!(:finished_seed) { FactoryBot.create :tradable_seed, finished: true } + let!(:untradable_seed) { FactoryBot.create :untradable_seed } + background do + # Add photos, so they can appear on home page + planting.photos << photo + seed.photos << photo + harvest.photos << photo + end + + subject { page } + before { visit root_path } + + shared_examples 'shows seeds' do + it "show tradeable seed" do + is_expected.to have_link href: seed_path(tradable_seed) + end + it "does not show finished seeds" do + is_expected.not_to have_link href: seed_path(finished_seed) + end + it "does not show untradable seeds" do + is_expected.not_to have_link href: seed_path(untradable_seed) + end + + it { is_expected.to have_text 'View all seeds' } + end + + shared_examples 'show plantings' do + it 'shows plantings section' do + is_expected.to have_text 'Recently Planted' + is_expected.to have_link href: planting_path(planting) + end + end + shared_examples 'show harvests' do + it 'shows harvests section' do + is_expected.to have_text 'Recently Harvested' + is_expected.to have_link href: harvest_path(harvest) + end + end + + shared_examples "show crops" do + describe 'shows crops section' do + it { is_expected.to have_text 'Some of our crops' } + it { is_expected.to have_link href: crop_path(crop) } + end + describe 'shows recently added crops' do + it { is_expected.to have_text 'Recently Added' } + it 'link to newest crops' do + is_expected.to have_link crop.name, href: crop_path(crop) + end + end + it 'includes a link to all crops' do + is_expected.to have_link 'View all crops' + end + end + + context 'when anonymous' do + include_examples 'show crops' + include_examples 'show plantings' + include_examples 'show harvests' + include_examples 'shows seeds' + it { is_expected.to have_text 'community of food gardeners' } + end + + context "when signed in" do + background { login_as member } + include_examples 'show crops' + include_examples 'show plantings' + include_examples 'show harvests' + include_examples 'shows seeds' + end +end diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 1c13b2793..ee2a50691 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -33,7 +33,9 @@ feature "new photo page" do scenario "add photo" do visit garden_path(garden) - click_link "Add photo" + within '.garden-actions' do + click_link "Add photo" + end expect(page).to have_text garden.name end end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 1db053a80..ec1946d2c 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -5,9 +5,7 @@ feature "seeds", js: true do let(:member) { create :member } let(:crop) { create :crop } - background do - login_as member - end + background { login_as member } scenario "button on index to edit seed" do seed = create :seed, owner: member diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 60a95c245..6948caa75 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -426,6 +426,22 @@ describe Planting do expect(Planting.joins(:owner).all).not_to include(planting) end + context 'ancestry' do + let(:parent_seed) { FactoryBot.create :seed } + let(:planting) { FactoryBot.create :planting, parent_seed: parent_seed } + it "planting has a parent seed" do + expect(planting.parent_seed).to eq(parent_seed) + end + it "seed has a child planting" do + expect(parent_seed.child_plantings).to eq [planting] + end + describe 'grandchildren' do + let(:grandchild_seed) { FactoryBot.create :seed, parent_planting: planting } + it { expect(grandchild_seed.parent_planting).to eq planting } + it { expect(grandchild_seed.parent_planting.parent_seed).to eq parent_seed } + end + end + # it 'predicts harvest times' do # crop = FactoryBot.create :crop # 10.times do diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index e45d0e240..269cb888f 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -157,4 +157,38 @@ describe Seed do Seed.has_photos.should include(seed) end end + + context 'ancestry' do + let(:parent_planting) { FactoryBot.create :planting } + let(:seed) { FactoryBot.create :seed, parent_planting: parent_planting } + it "seed has a parent planting" do + expect(seed.parent_planting).to eq(parent_planting) + end + it "planting has a child seed" do + expect(parent_planting.child_seeds).to eq [seed] + end + end + + context "finished" do + describe 'has finished fields' do + let(:seed) { FactoryBot.create(:finished_seed) } + it { expect(seed.finished).to eq true } + it { expect(seed.finished_at).to be_an_instance_of Date } + end + + describe 'scopes' do + let!(:seed) { FactoryBot.create(:seed) } + let!(:finished_seed) { FactoryBot.create(:finished_seed) } + + describe 'has finished scope' do + it { expect(Seed.finished).to include finished_seed } + it { expect(Seed.finished).not_to include seed } + end + + describe 'has current scope' do + it { expect(Seed.current).to include seed } + it { expect(Seed.current).not_to include finished_seed } + end + end + end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 7130e2e4f..5594c6755 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -43,7 +43,7 @@ describe "gardens/show" do end it 'should have an edit button' do - rendered.should have_link 'edit_garden_link' + rendered.should have_link 'Edit' end it "shows a 'plant something' button" do diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb deleted file mode 100644 index 3ed655438..000000000 --- a/spec/views/home/_crops.html.haml_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe 'home/_crops.html.haml', type: "view" do - let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } - let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } - let(:planting) { crop.plantings.first } - - before(:each) { render } - it 'shows crops section' do - assert_select 'h2', text: 'Some of our crops' - assert_select "a[href='#{crop_path(crop)}']" - end - - it 'shows plantings section' do - assert_select 'h2', text: 'Recently planted' - rendered.should have_content planting.location - end - - it 'shows recently added crops' do - assert_select 'h2', text: 'Recently planted' - end - - it 'includes a link to all crops' do - assert_select "a[href='#{crops_path}']", text: /View all crops/ - end -end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 899724ac7..47a742c58 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -35,11 +35,10 @@ describe "plantings/show" do rendered.should have_content 'cutting' end - it "doesn't show planted_from if blank" do + it "shows planted_from if blank" do planting.update(planted_from: '') render - rendered.should_not have_content 'Planted from:' - rendered.should_not have_content 'cutting' + rendered.should have_content 'Planted from: not specified' end end From 2f45041f8c244df6bf918ce3240df8dfef650772 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 12 Mar 2018 08:56:39 +1300 Subject: [PATCH 091/101] Fixed ordering of photos on crops#show --- app/views/crops/_photos.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 927bf97c8..b799876a9 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -8,7 +8,7 @@ - unless crop.photos.empty? %h3 Photos of #{crop.name} plants .row - - crop.photos.first(6).each do |p| + - crop.photos.order(date_taken: :desc).first(6).each do |p| .col-xs-6.col-md-2 = render "photos/thumbnail", photo: p .row From 8906fd38ae56e455318806175e44f849c691846e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 14 Mar 2018 15:21:40 +1300 Subject: [PATCH 092/101] For seeds, use planting photo if no seeds photo --- app/helpers/photos_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index 50064f328..0e8985dd7 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -24,8 +24,10 @@ module PhotosHelper end def seed_image_path(seed) - if seed.default_photo + if seed.default_photo.present? seed.default_photo.thumbnail_url + elsif seed.crop.default_photo.present? + seed.crop.default_photo else default_image end From 1bf10760764fd61413abec44c72115e5cb907580 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 14 Mar 2018 15:28:00 +1300 Subject: [PATCH 093/101] Photos helper --- app/helpers/photos_helper.rb | 22 ++++++++++++++++------ app/views/crops/_index_card.html.haml | 2 +- app/views/crops/_thumbnail.html.haml | 2 +- app/views/gardens/_photo.html.haml | 2 +- app/views/gardens/_thumbnail.html.haml | 2 +- app/views/harvests/_card.html.haml | 2 +- app/views/harvests/_thumbnail.html.haml | 2 +- app/views/plantings/_card.html.haml | 2 +- app/views/plantings/_thumbnail.html.haml | 2 +- app/views/seeds/_card.html.haml | 2 +- app/views/seeds/_thumbnail.html.haml | 2 +- 11 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index 0e8985dd7..b77f35bd9 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -3,7 +3,15 @@ module PhotosHelper if crop.default_photo.present? crop.default_photo.thumbnail_url else - default_image + placeholder_image + end + end + + def garden_image_path(garden) + if garden.default_photo.present? + garden.default_photo.thumbnail_url + else + placeholder_image end end @@ -11,15 +19,17 @@ module PhotosHelper if planting.photos.present? planting.photos.first.thumbnail_url else - default_image + placeholder_image end end def harvest_image_path(harvest) if harvest.photos.present? harvest.photos.first.thumbnail_url + elsif harvest.planting.present? && harvest.planting.photos.present? + harvest.planting.photos.first.thumbnail_url else - default_image + placeholder_image end end @@ -27,15 +37,15 @@ module PhotosHelper if seed.default_photo.present? seed.default_photo.thumbnail_url elsif seed.crop.default_photo.present? - seed.crop.default_photo + seed.crop.default_photo.thumbnail_url else - default_image + placeholder_image end end private - def default_image + def placeholder_image 'placeholder_150.png' end end diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 39b9e8da4..99b4a1a7e 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -1,7 +1,7 @@ .well .row .col-md-4 - = link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(crop_image_path(crop), alt: '', class: 'img crop-image'), crop diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index c83a1a0c6..77793ef22 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -2,7 +2,7 @@ .thumbnail .crop-thumbnail - if crop - = link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(crop_image_path(crop), alt: crop.name, class: 'img'), crop .cropinfo diff --git a/app/views/gardens/_photo.html.haml b/app/views/gardens/_photo.html.haml index caf5c04d1..b6d301d2e 100644 --- a/app/views/gardens/_photo.html.haml +++ b/app/views/gardens/_photo.html.haml @@ -1,3 +1,3 @@ -= link_to image_tag((garden.default_photo ? garden.default_photo.thumbnail_url : 'placeholder_150.png'), += link_to image_tag(garden_image_path(garden), alt: garden.name, class: 'img-responsive'), garden_path(garden) diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index 56c8c9614..a2e4ea7eb 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -8,7 +8,7 @@ .panel-body{ id: "gardens_panel_body" } .row .col-md-4 - = link_to image_tag((garden.default_photo ? garden.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(garden_image_path(garden), alt: garden.name, class: 'img'), garden_path(garden) .col-md-8 diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 1a12128b0..52cfb3627 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -8,7 +8,7 @@ .panel-body .row .col-md-4 - = link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(harvest_image_path(harvest), alt: harvest.crop.name, class: 'img'), harvest .col-md-8 diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index d7fec2a7a..4344aed7d 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -1,7 +1,7 @@ .thumbnail .harvest-thumbnail - if harvest - = link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(harvest_image_path(harvest), alt: harvest.crop.name, class: 'img'), harvest .harvestinfo diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index bb6d77347..0f9518e6c 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -8,7 +8,7 @@ .panel-body .row .col-xs-12.col-md-5 - = link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(planting_image_path(planting), alt: planting.crop_id, class: 'img img-responsive'), planting .col-xs-12.col-md-7 diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index 15ff2553e..e34c653da 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,7 +1,7 @@ .thumbnail .planting-thumbnail - if planting - = link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(planting_image_path(planting), alt: planting.crop.name, class: 'img'), planting .plantinginfo diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 532db8d6c..8cb70f64f 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -8,7 +8,7 @@ .panel-body .row .col-md-4 - = link_to image_tag((seed.crop.default_photo ? seed.crop.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(seed_image_path(seed), alt: seed.crop.name, class: 'img'), seed.crop .col-md-8 diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index f985b4d16..38aa66d65 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -1,6 +1,6 @@ .thumbnail .seed-thumbnail - = link_to image_tag((seed.default_photo ? seed.default_photo.thumbnail_url : 'placeholder_150.png'), + = link_to image_tag(seed_image_path(seed), alt: seed.crop.name, class: 'img'), seed_path(seed) .seedinfo From 8941c577e4474663fd64cf782e02b8e09d3efdc8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 14 Mar 2018 22:25:30 +1300 Subject: [PATCH 094/101] Specs for photos helper --- app/models/crop.rb | 11 ++-- spec/helpers/photos_helper_spec.rb | 88 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 spec/helpers/photos_helper_spec.rb diff --git a/app/models/crop.rb b/app/models/crop.rb index 15787f6f1..682610436 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -120,12 +120,7 @@ class Crop < ActiveRecord::Base # later we can choose a default photo based on different criteria, # eg. popularity def default_photo - # most recent photo - return photos.order(created_at: :desc).first if photos.any? - - # Crop has no photos? Look for the most recent harvest with a photo. - harvest_with_photo = Harvest.where(crop_id: id).joins(:photos).order('harvests.id DESC').limit(1).first - harvest_with_photo.photos.first if harvest_with_photo + first_photo(:plantings) || first_photo(:harvests) || first_photo(:seeds) end # returns hash indicating whether this crop is grown in @@ -242,4 +237,8 @@ class Crop < ActiveRecord::Base return unless reason_for_rejection == "other" && rejection_notes.blank? errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") end + + def first_photo(type) + Photo.joins(type).where("#{type}": { crop_id: id }).order("photos.created_at DESC").first + end end diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb new file mode 100644 index 000000000..60ba61fb4 --- /dev/null +++ b/spec/helpers/photos_helper_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +describe PhotosHelper do + let(:crop) { FactoryBot.create :crop } + let(:crop_photo) { FactoryBot.create :photo, thumbnail_url: 'crop.jpg' } + let(:garden) { FactoryBot.create :garden } + let(:garden_photo) { FactoryBot.create(:photo, thumbnail_url: 'garden.jpg') } + let(:planting) { FactoryBot.create :planting } + let(:planting_photo) { FactoryBot.create(:photo, thumbnail_url: 'planting.jpg') } + let(:harvest) { FactoryBot.create :harvest } + let(:harvest_photo) { FactoryBot.create(:photo, thumbnail_url: 'harvest.jpg') } + let(:seed) { FactoryBot.create :seed } + let(:seed_photo) { FactoryBot.create(:photo, thumbnail_url: 'seed.jpg') } + + describe "crops" do + subject { crop_image_path(crop) } + + it { is_expected.to eq 'placeholder_150.png' } + + describe "with a planting" do + before do + planting.photos << planting_photo + crop.plantings << planting + end + it "uses planting photos" do + is_expected.to eq planting_photo.thumbnail_url + end + end + + describe "with a harvest photos" do + before do + harvest.photos << harvest_photo + crop.harvests << harvest + end + it "uses harvest photos" do + is_expected.to eq harvest_photo.thumbnail_url + end + end + + describe "uses seed photo" do + before do + seed.photos << seed_photo + crop.seeds << seed + end + it "uses seed photos" do + is_expected.to eq seed_photo.thumbnail_url + end + end + end + + describe "gardens" do + subject { garden_image_path(garden) } + it { is_expected.to eq 'placeholder_150.png' } + + describe "uses garden's own photo" do + before { garden.photos << garden_photo } + it { is_expected.to eq garden_photo.thumbnail_url } + end + end + + describe 'plantings' do + subject { planting_image_path(planting) } + it { is_expected.to eq 'placeholder_150.png' } + describe "uses planting's own photo" do + before { planting.photos << planting_photo } + it { is_expected.to eq planting_photo.thumbnail_url } + end + end + + describe 'harvests' do + subject { harvest_image_path(harvest) } + it { is_expected.to eq 'placeholder_150.png' } + describe "uses harvest's own photo" do + before { harvest.photos << harvest_photo } + it { is_expected.to eq harvest_photo.thumbnail_url } + end + end + + describe 'seeds' do + subject { seed_image_path(seed) } + it { is_expected.to eq 'placeholder_150.png' } + + describe "uses seed's own photo" do + before { seed.photos << seed_photo } + it { is_expected.to eq seed_photo.thumbnail_url } + end + end +end From ece7113c89c6d6639f6312a619d4ea4ab4abf960 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 15 Mar 2018 22:56:32 +1300 Subject: [PATCH 095/101] DRY photo helper spec --- spec/helpers/photos_helper_spec.rb | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb index 60ba61fb4..589cf8104 100644 --- a/spec/helpers/photos_helper_spec.rb +++ b/spec/helpers/photos_helper_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' describe PhotosHelper do let(:crop) { FactoryBot.create :crop } - let(:crop_photo) { FactoryBot.create :photo, thumbnail_url: 'crop.jpg' } + let(:garden) { FactoryBot.create :garden } let(:garden_photo) { FactoryBot.create(:photo, thumbnail_url: 'garden.jpg') } - let(:planting) { FactoryBot.create :planting } + let(:planting) { FactoryBot.create :planting, crop: crop } let(:planting_photo) { FactoryBot.create(:photo, thumbnail_url: 'planting.jpg') } - let(:harvest) { FactoryBot.create :harvest } + let(:harvest) { FactoryBot.create :harvest, crop: crop } let(:harvest_photo) { FactoryBot.create(:photo, thumbnail_url: 'harvest.jpg') } - let(:seed) { FactoryBot.create :seed } + let(:seed) { FactoryBot.create :seed, crop: crop } let(:seed_photo) { FactoryBot.create(:photo, thumbnail_url: 'seed.jpg') } describe "crops" do @@ -18,30 +18,21 @@ describe PhotosHelper do it { is_expected.to eq 'placeholder_150.png' } describe "with a planting" do - before do - planting.photos << planting_photo - crop.plantings << planting - end + before { planting.photos << planting_photo } it "uses planting photos" do is_expected.to eq planting_photo.thumbnail_url end end describe "with a harvest photos" do - before do - harvest.photos << harvest_photo - crop.harvests << harvest - end + before { harvest.photos << harvest_photo } it "uses harvest photos" do is_expected.to eq harvest_photo.thumbnail_url end end describe "uses seed photo" do - before do - seed.photos << seed_photo - crop.seeds << seed - end + before { seed.photos << seed_photo } it "uses seed photos" do is_expected.to eq seed_photo.thumbnail_url end From 2f81d6c78d25a654c3b2e7183a2201e619209e91 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 15 Mar 2018 22:51:10 +1300 Subject: [PATCH 096/101] Layout fixes for mobile and smaller screens --- app/assets/stylesheets/overrides.sass | 74 +++++++++++++++------------ app/views/home/_crops.html.haml | 4 +- app/views/home/_plantings.html.haml | 2 +- app/views/home/_seeds.html.haml | 13 ++--- app/views/home/index.html.haml | 26 +++++----- app/views/plantings/_list.html.haml | 4 +- 6 files changed, 66 insertions(+), 57 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index bdeb64d0d..338a2dbc5 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -94,21 +94,6 @@ p.stats dd margin-left: auto -@media (min-width: $screen-md-min) - .planting-thumbnail - dl.planting-attributes - width: 100% - - dt - text-align: left - width: 120px - dd - padding-left: 120px - margin-left: auto - - .navbar .navbar-form - width: 250px - #placesmap, #cropmap height: 500px @@ -254,24 +239,6 @@ html, body a font-weight: 800 -// Overrides applying only to mobile view. This must be at the end of the overrides file. - -@media only screen and (max-width: 767px) - .sidebar - margin-left: 0 - border-left: none - padding-left: 0 - - #map - height: 300px - - .navbar .nav > li - display: block - - .navbar .navbar-form - width: 185px - padding-left: 0 - padding-right: 0 /* override "info" alert boxes to be green, not blue, on Growstuff */ $state-info-text: darken($green, 10%) @@ -326,3 +293,44 @@ ul.thumbnail-buttons .hover-wrapper:hover .text visibility: visible + +.homepage-listing + padding-bottom: 6px + +@media (min-width: $screen-md-min) + .planting-thumbnail + dl.planting-attributes + width: 100% + + dt + text-align: left + width: 120px + dd + padding-left: 120px + margin-left: auto + + .navbar .navbar-form + width: 250px + +// Overrides applying only to mobile view. This must be at the end of the overrides file. +@media only screen and (max-width: 767px) + .sidebar + margin-left: 0 + border-left: none + padding-left: 0 + + #map + height: 300px + + .navbar .nav > li + display: block + + .navbar .navbar-form + width: 185px + padding-left: 0 + padding-right: 0 + .homepage + .thumbnail + height: 180px + .seed-thumbnail + height: 220px diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index edec779e0..bfcbc9a71 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Crop, 'interesting'), expires_in: 1.day do .row %h2= t('.our_crops') - - Crop.interesting.includes(:scientific_names, :photos).limit(7).each do |c| - .col-md-4.col-xs-4= render 'crops/thumbnail', crop: c + - Crop.interesting.includes(:scientific_names, :photos).limit(8).each do |c| + .col-md-4.col-sm-3.col-xs-6= render 'crops/thumbnail', crop: c diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index bfaa4a422..595ad4586 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -1,3 +1,3 @@ - cache cache_key_for(Planting, 'home'), expires_in: 1.day do %h2= t('.recently_planted') - = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.first(5) + = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.limit(5) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 3f018994a..d53759738 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -2,8 +2,8 @@ %h2= t('.title') .row - Seed.current.tradable.order(created_at: :desc).limit(6).each do |seed| - .col-md-2.col-xs-4 - .thumbnail + .col-md-2.col-sm-2.col-xs-6 + .thumbnail.seed-thumbnail - cache cache_key_for(Crop, seed.id) do = link_to image_tag(seed_image_path(seed), alt: seed.crop.name, class: 'img'), @@ -13,9 +13,10 @@ .trade-to %p= seed.owner.location %p - Will trade to: - %br/ - #{seed.tradable_to} + %small + Will trade to: + %br/ + %em= seed.tradable_to %p.text-right -= link_to "#{t('.view_all')} »", seeds_path + = link_to "#{t('.view_all')} »", seeds_path diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 80502c3f5..c28a8985b 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,9 +1,9 @@ -.row +.homepage.row .col-md-12 - if member_signed_in? %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) - = render partial: 'stats' + = render 'stats' %p .btn-group = link_to t('.plant'), new_planting_path, class: 'btn btn-default' @@ -14,17 +14,17 @@ - else .hidden-xs .jumbotron - = render partial: 'blurb' + = render 'blurb' .visible-xs - = render partial: 'blurb' + = render 'blurb' .row - .col-md-6 - = render partial: 'crops' - .col-md-3 - = render partial: 'plantings' - .col-md-3 - = render partial: 'harvests' + .col-md-6.col-sm-12 + = render 'crops' + .col-md-3.col-sm-6 + = render 'plantings' + .col-md-3.col-sm-6 + = render 'harvests' .col-md-12 - cache cache_key_for(Crop, 'recent') do %p{ style: 'margin-top: 11.25px' } @@ -36,8 +36,8 @@ = link_to "#{t('home.crops.view_all')} »", crops_path .row .col-md-12 - = render partial: 'seeds' - = render partial: 'members' + = render 'seeds' + = render 'members' .row .col-md-12 - = render partial: 'discuss' + = render 'discuss' diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml index 02901cdcd..aa7dcf9fa 100644 --- a/app/views/plantings/_list.html.haml +++ b/app/views/plantings/_list.html.haml @@ -1,8 +1,8 @@ - plantings.each do |p| - cache p do .row - .col-md-3.col-xs-4{ style: 'padding-bottom: 6px' } - = render partial: 'plantings/image_with_popover', locals: { planting: p } + .col-md-3.col-xs-4.homepage-listing + = render 'plantings/image_with_popover', planting: p .col-md-9.col-xs-4 = link_to p.crop, p.crop in From 64a8cfb59f7d3e65c497b5487b20fc54516fa3c5 Mon Sep 17 00:00:00 2001 From: deppbot Date: Fri, 16 Mar 2018 09:54:36 +0800 Subject: [PATCH 097/101] Security Update on 2018-03-16 (#1593) --- Gemfile | 1 + Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index f49aaa60d..c5c074891 100644 --- a/Gemfile +++ b/Gemfile @@ -155,3 +155,4 @@ end group :travis do gem 'platform-api' end +gem 'rack-protection', '>= 2.0.1' diff --git a/Gemfile.lock b/Gemfile.lock index a2bd0a4ed..48837e792 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -378,8 +378,8 @@ GEM public_suffix (3.0.1) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.8) - rack-protection (2.0.0) + rack (1.6.9) + rack-protection (2.0.1) rack rack-test (0.6.3) rack (>= 1.0) @@ -606,6 +606,7 @@ DEPENDENCIES poltergeist pry quiet_assets + rack-protection (>= 2.0.1) rails (~> 4.2.8) rails-assets-leaflet.markercluster! rails_12factor @@ -629,6 +630,5 @@ DEPENDENCIES RUBY VERSION ruby 2.4.1p111 - BUNDLED WITH 1.16.1 From c80685bf0d9d201fa608b4e7a773bc5150016c99 Mon Sep 17 00:00:00 2001 From: deppbot Date: Thu, 22 Mar 2018 09:14:19 +0800 Subject: [PATCH 098/101] Security Update on 2018-03-20 (#1597) * Security Update on 2018-03-20 * Ordered gems, to please rubocop --- Gemfile | 1 + Gemfile.lock | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c5c074891..55be65010 100644 --- a/Gemfile +++ b/Gemfile @@ -155,4 +155,5 @@ end group :travis do gem 'platform-api' end +gem 'loofah', '>= 2.2.1' gem 'rack-protection', '>= 2.0.1' diff --git a/Gemfile.lock b/Gemfile.lock index 48837e792..b15ea0120 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -300,7 +300,7 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.1.1) + loofah (2.2.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.12) @@ -595,6 +595,7 @@ DEPENDENCIES kaminari leaflet-rails letter_opener + loofah (>= 2.2.1) memcachier newrelic_rpm omniauth (~> 1.3) From 61468b3587193ba5b4226ac4b1cd47e8561f86eb Mon Sep 17 00:00:00 2001 From: deppbot Date: Thu, 22 Mar 2018 13:13:48 +0800 Subject: [PATCH 099/101] Bundle Update on 2018-03-22 --- Gemfile.lock | 74 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b15ea0120..a2a05afac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,8 +26,8 @@ GEM addressable active_median (0.1.4) activerecord - active_utils (3.3.9) - activesupport (>= 3.2, < 5.2.0) + active_utils (3.3.11) + activesupport (>= 3.2, < 6.0) i18n activejob (4.2.10) activesupport (= 4.2.10) @@ -51,7 +51,7 @@ GEM public_suffix (>= 2.0.2, < 4.0) arel (6.0.4) ast (2.4.0) - autoprefixer-rails (7.2.5) + autoprefixer-rails (8.2.0) execjs bcrypt (3.1.11) better_errors (2.2.0) @@ -74,12 +74,12 @@ GEM sass (>= 3.3.4) bootstrap_form (2.7.0) builder (3.2.3) - bullet (5.7.2) + bullet (5.7.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11.0) - byebug (10.0.0) + byebug (10.0.1) cancancan (2.1.3) - capybara (2.17.0) + capybara (2.18.0) addressable mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) @@ -92,13 +92,11 @@ GEM capybara-screenshot (1.0.18) capybara (>= 1.0, < 3) launchy - chartkick (2.2.5) - childprocess (0.8.0) + chartkick (2.3.2) + childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) climate_control (0.2.0) cliver (0.3.2) - cocaine (0.5.8) - climate_control (>= 0.0.3, < 1.0) codeclimate-test-reporter (1.0.8) simplecov (<= 0.13) codemirror-rails (5.16.0) @@ -137,13 +135,13 @@ GEM crass (1.0.3) csv_shaper (1.3.0) activesupport (>= 3.0.0) - dalli (2.7.6) + dalli (2.7.7) database_cleaner (1.6.2) debug_inspector (0.0.3) - devise (4.4.1) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) diff-lcs (1.3) @@ -165,7 +163,7 @@ GEM faraday multi_json erubis (2.7.0) - excon (0.60.0) + excon (0.61.0) execjs (2.7.0) factory_bot (4.8.2) activesupport (>= 3.0.0) @@ -176,16 +174,16 @@ GEM i18n (>= 0.7) faraday (0.12.2) multipart-post (>= 1.2, < 3) - ffi (1.9.21) + ffi (1.9.23) figaro (1.1.1) thor (~> 0.14) flickraw (0.9.9) - font-awesome-sass (4.7.0) + font-awesome-sass (5.0.6.2) sass (>= 3.2) formatador (0.2.5) friendly_id (5.2.3) activerecord (>= 4.0.0) - geocoder (1.4.5) + geocoder (1.4.7) gibbon (1.2.1) httparty multi_json (>= 1.9.0) @@ -241,9 +239,9 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - httparty (0.15.6) + httparty (0.16.1) multi_xml (>= 0.5.2) - i18n (0.9.3) + i18n (0.9.5) concurrent-ruby (~> 1.0) i18n-tasks (0.9.12) activesupport (>= 4.0.2) @@ -255,12 +253,12 @@ GEM parser (>= 2.2.3.0) term-ansicolor (>= 1.3.2) terminal-table (>= 1.5.1) - jasmine (2.9.0) - jasmine-core (>= 2.9.0, < 3.0.0) + jasmine (3.1.0) + jasmine-core (= 3.1.0) phantomjs rack (>= 1.2.1) rake - jasmine-core (2.99.0) + jasmine-core (3.1.0) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -351,15 +349,15 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - paperclip (5.2.1) + paperclip (6.0.0) activemodel (>= 4.2.0) activesupport (>= 4.2.0) - cocaine (~> 0.5.5) mime-types mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) parallel (1.12.1) - parser (2.4.0.2) - ast (~> 2.3) + parser (2.5.0.4) + ast (~> 2.4.0) pg (0.21.0) phantomjs (2.1.1.0) platform-api (2.1.0) @@ -375,7 +373,7 @@ GEM pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) - public_suffix (3.0.1) + public_suffix (3.0.2) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.9) @@ -420,8 +418,8 @@ GEM thor (>= 0.18.1, < 2.0) rainbow (2.1.0) raindrops (0.19.0) - rake (12.3.0) - rb-fsevent (0.10.2) + rake (12.3.1) + rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (4.0.1) @@ -461,9 +459,9 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) - ruby-units (2.2.1) + ruby-units (2.3.0) ruby_dep (1.5.0) - ruby_parser (3.10.1) + ruby_parser (3.11.0) sexp_processor (~> 4.9) rubyzip (1.2.1) sass (3.5.5) @@ -477,16 +475,16 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.9.0) + selenium-webdriver (3.11.0) childprocess (~> 0.5) rubyzip (~> 1.2) - sexp_processor (4.10.0) + sexp_processor (4.10.1) shellany (0.0.1) - sidekiq (5.1.0) + sidekiq (5.1.1) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) - redis (>= 3.3.4, < 5) + redis (>= 3.3.5, < 5) simplecov (0.12.0) docile (~> 1.1.0) json (>= 1.8, < 3) @@ -507,6 +505,8 @@ GEM tins (~> 1.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) thor (0.19.4) thread (0.2.2) thread_safe (0.3.6) @@ -516,7 +516,7 @@ GEM trollop (1.16.2) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.5) + uglifier (4.1.8) execjs (>= 0.3.0, < 3) unicode-display_width (1.3.0) unicorn (5.4.0) @@ -629,7 +629,9 @@ DEPENDENCIES will_paginate xmlrpc + RUBY VERSION ruby 2.4.1p111 + BUNDLED WITH 1.16.1 From 31d2aa052a1cd38bff36ea1f117550339ac1a89c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 1 Apr 2018 14:16:50 +1200 Subject: [PATCH 100/101] More bundle updates --- Gemfile.lock | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a2a05afac..02e9937ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,10 +61,8 @@ GEM binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bluecloth (2.2.0) - bonsai-elasticsearch-rails (0.2.0) - elasticsearch-model (~> 0) - elasticsearch-rails (~> 0) - bootstrap-datepicker-rails (1.7.1.1) + bonsai-elasticsearch-rails (0.0.4) + bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) bootstrap-kaminari-views (0.0.5) kaminari (>= 0.13) @@ -77,7 +75,7 @@ GEM bullet (5.7.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11.0) - byebug (10.0.1) + byebug (10.0.2) cancancan (2.1.3) capybara (2.18.0) addressable @@ -92,7 +90,7 @@ GEM capybara-screenshot (1.0.18) capybara (>= 1.0, < 3) launchy - chartkick (2.3.2) + chartkick (2.3.3) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) climate_control (0.2.0) @@ -154,16 +152,16 @@ GEM elasticsearch-transport (= 2.0.2) elasticsearch-api (2.0.2) multi_json - elasticsearch-model (0.1.9) + elasticsearch-model (5.0.0) activesupport (> 3) - elasticsearch (> 0.4) + elasticsearch (> 1) hashie - elasticsearch-rails (0.1.9) + elasticsearch-rails (5.0.2) elasticsearch-transport (2.0.2) faraday multi_json erubis (2.7.0) - excon (0.61.0) + excon (0.62.0) execjs (2.7.0) factory_bot (4.8.2) activesupport (>= 3.0.0) @@ -178,7 +176,7 @@ GEM figaro (1.1.1) thor (~> 0.14) flickraw (0.9.9) - font-awesome-sass (5.0.6.2) + font-awesome-sass (5.0.9) sass (>= 3.2) formatador (0.2.5) friendly_id (5.2.3) @@ -239,7 +237,7 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - httparty (0.16.1) + httparty (0.16.2) multi_xml (>= 0.5.2) i18n (0.9.5) concurrent-ruby (~> 1.0) @@ -298,10 +296,10 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.2.1) + loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.12) + lumberjack (1.0.13) mail (2.7.0) mini_mime (>= 0.1.1) memcachier (0.0.2) @@ -318,7 +316,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (4.8.0.341) + newrelic_rpm (5.0.0.342) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) notiffany (0.1.1) @@ -356,7 +354,7 @@ GEM mimemagic (~> 0.3.0) terrapin (~> 0.6.0) parallel (1.12.1) - parser (2.5.0.4) + parser (2.5.0.5) ast (~> 2.4.0) pg (0.21.0) phantomjs (2.1.1.0) @@ -401,8 +399,8 @@ GEM activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) rails-i18n (4.0.9) i18n (~> 0.7) railties (~> 4.0) @@ -464,7 +462,7 @@ GEM ruby_parser (3.11.0) sexp_processor (~> 4.9) rubyzip (1.2.1) - sass (3.5.5) + sass (3.5.6) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -480,7 +478,7 @@ GEM rubyzip (~> 1.2) sexp_processor (4.10.1) shellany (0.0.1) - sidekiq (5.1.1) + sidekiq (5.1.2) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) @@ -629,7 +627,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 From 2d309b76457e9e533e80ab4496f021b4c0f59900 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 2 Apr 2018 09:58:02 +1200 Subject: [PATCH 101/101] Removing jasmine, we have no jasmine specs --- .travis.yml | 1 - Gemfile | 1 - Gemfile.lock | 8 - spec/javascripts/support/jasmine.css | 13 - spec/javascripts/support/jasmine.yml | 123 --- spec/javascripts/support/jasmine_helper.rb | 19 - .../support/vendor/jasmine-jquery.js | 813 ------------------ 7 files changed, 978 deletions(-) delete mode 100644 spec/javascripts/support/jasmine.css delete mode 100644 spec/javascripts/support/jasmine.yml delete mode 100644 spec/javascripts/support/jasmine_helper.rb delete mode 100644 spec/javascripts/support/vendor/jasmine-jquery.js diff --git a/.travis.yml b/.travis.yml index 5d94d6a86..65db1b3f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,6 @@ script: else bundle exec rake db:migrate --trace; bundle exec rspec --tag $RSPEC_TAG spec/; - bundle exec rake jasmine:ci; fi; - set +e before_deploy: diff --git a/Gemfile b/Gemfile index 55be65010..bc3d45a34 100644 --- a/Gemfile +++ b/Gemfile @@ -137,7 +137,6 @@ group :development, :test do gem 'haml-rails' # HTML templating language gem 'haml_lint' # Checks haml files for goodness gem 'i18n-tasks' # adds tests for finding missing and unused translations - gem 'jasmine' # javascript unit testing gem 'poltergeist' # for headless JS testing gem 'rainbow', '< 2.2.0' # See https://github.com/sickill/rainbow/issues/44 gem 'rspec-activemodel-mocks' diff --git a/Gemfile.lock b/Gemfile.lock index 02e9937ed..8f7585851 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -251,12 +251,6 @@ GEM parser (>= 2.2.3.0) term-ansicolor (>= 1.3.2) terminal-table (>= 1.5.1) - jasmine (3.1.0) - jasmine-core (= 3.1.0) - phantomjs - rack (>= 1.2.1) - rake - jasmine-core (3.1.0) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -357,7 +351,6 @@ GEM parser (2.5.0.5) ast (~> 2.4.0) pg (0.21.0) - phantomjs (2.1.1.0) platform-api (2.1.0) heroics (~> 0.0.23) moneta (~> 0.8.1) @@ -585,7 +578,6 @@ DEPENDENCIES haml_lint hashie (>= 3.5.3) i18n-tasks - jasmine jquery-rails jquery-ui-rails (~> 5.0.2) js-routes diff --git a/spec/javascripts/support/jasmine.css b/spec/javascripts/support/jasmine.css deleted file mode 100644 index 4736015b6..000000000 --- a/spec/javascripts/support/jasmine.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - padding-top: 0; -} - -#jasmine_content { - width: 1000px; - height: 1000px; - position: absolute; - -webkit-transform: rotateY(-90deg); - -moz-transform: rotateY(-90deg); - -ms-transform: rotateY(-90deg); - transform: rotateY(-90deg); -} \ No newline at end of file diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml deleted file mode 100644 index 41a71db95..000000000 --- a/spec/javascripts/support/jasmine.yml +++ /dev/null @@ -1,123 +0,0 @@ -# src_files -# -# Return an array of filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# src_files: -# - lib/source1.js -# - lib/source2.js -# - dist/**/*.js -# -src_files: - - assets/application.js - -# stylesheets -# -# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# stylesheets: -# - css/style.css -# - stylesheets/*.css -# -stylesheets: - - assets/application.css - - spec/javascripts/support/jasmine.css -# helpers -# -# Return an array of filepaths relative to spec_dir to include before jasmine specs. -# Default: ["helpers/**/*.js"] -# -# EXAMPLE: -# -# helpers: -# - helpers/**/*.js -# -helpers: - - 'support/**/*.js' - -# spec_files -# -# Return an array of filepaths relative to spec_dir to include. -# Default: ["**/*[sS]pec.js"] -# -# EXAMPLE: -# -# spec_files: -# - **/*[sS]pec.js -# -spec_files: - - '**/*[sS]pec.js' - -# src_dir -# -# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. -# Default: project root -# -# EXAMPLE: -# -# src_dir: public -# -src_dir: - -# spec_dir -# -# Spec directory path. Your spec_files must be returned relative to this path. -# Default: spec/javascripts -# -# EXAMPLE: -# -# spec_dir: spec/javascripts -# -spec_dir: - -# spec_helper -# -# Ruby file that Jasmine server will require before starting. -# Returned relative to your root path -# Default spec/javascripts/support/jasmine_helper.rb -# -# EXAMPLE: -# -# spec_helper: spec/javascripts/support/jasmine_helper.rb -# -spec_helper: spec/javascripts/support/jasmine_helper.rb - -# boot_dir -# -# Boot directory path. Your boot_files must be returned relative to this path. -# Default: Built in boot file -# -# EXAMPLE: -# -# boot_dir: spec/javascripts/support/boot -# -boot_dir: - -# boot_files -# -# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine -# Default: Built in boot file -# -# EXAMPLE -# -# boot_files: -# - '**/*.js' -# -boot_files: - -# rack_options -# -# Extra options to be passed to the rack server -# by default, Port and AccessLog are passed. -# -# This is an advanced options, and left empty by default -# -# EXAMPLE -# -# rack_options: -# server: 'thin' diff --git a/spec/javascripts/support/jasmine_helper.rb b/spec/javascripts/support/jasmine_helper.rb deleted file mode 100644 index 35ec28327..000000000 --- a/spec/javascripts/support/jasmine_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Use this file to set/override Jasmine configuration options -# You can remove it if you don't need it. -# This file is loaded *after* jasmine.yml is interpreted. -# -# Example: using a different boot file. -# Jasmine.configure do |config| -# config.boot_dir = '/absolute/path/to/boot_dir' -# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } -# end -# -# Example: prevent PhantomJS auto install, uses PhantomJS already on your path. -# Jasmine.configure do |config| -# config.prevent_phantom_js_auto_install = true -# end - -Jasmine.configure do |config| - # Enable console.log for debugging - config.show_console_log = true -end diff --git a/spec/javascripts/support/vendor/jasmine-jquery.js b/spec/javascripts/support/vendor/jasmine-jquery.js deleted file mode 100644 index 89071b063..000000000 --- a/spec/javascripts/support/vendor/jasmine-jquery.js +++ /dev/null @@ -1,813 +0,0 @@ -/*! -Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - -Version 2.0.5 - -https://github.com/velesin/jasmine-jquery - -Copyright (c) 2010-2014 Wojciech Zawistowski, Travis Jeffery - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -+function (window, jasmine, $) { "use strict"; - - jasmine.spiedEventsKey = function (selector, eventName) { - return [$(selector).selector, eventName].toString() - } - - jasmine.getFixtures = function () { - return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() - } - - jasmine.getStyleFixtures = function () { - return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() - } - - jasmine.Fixtures = function () { - this.containerId = 'jasmine-fixtures' - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures' - } - - jasmine.Fixtures.prototype.set = function (html) { - this.cleanUp() - return this.createContainer_(html) - } - - jasmine.Fixtures.prototype.appendSet= function (html) { - this.addToContainer_(html) - } - - jasmine.Fixtures.prototype.preload = function () { - this.read.apply(this, arguments) - } - - jasmine.Fixtures.prototype.load = function () { - this.cleanUp() - this.createContainer_(this.read.apply(this, arguments)) - } - - jasmine.Fixtures.prototype.appendLoad = function () { - this.addToContainer_(this.read.apply(this, arguments)) - } - - jasmine.Fixtures.prototype.read = function () { - var htmlChunks = [] - , fixtureUrls = arguments - - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) - } - - return htmlChunks.join('') - } - - jasmine.Fixtures.prototype.clearCache = function () { - this.fixturesCache_ = {} - } - - jasmine.Fixtures.prototype.cleanUp = function () { - $('#' + this.containerId).remove() - } - - jasmine.Fixtures.prototype.sandbox = function (attributes) { - var attributesToSet = attributes || {} - return $('
').attr(attributesToSet) - } - - jasmine.Fixtures.prototype.createContainer_ = function (html) { - var container = $('
') - .attr('id', this.containerId) - .html(html) - - $(document.body).append(container) - return container - } - - jasmine.Fixtures.prototype.addToContainer_ = function (html){ - var container = $(document.body).find('#'+this.containerId).append(html) - - if (!container.length) { - this.createContainer_(html) - } - } - - jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) { - if (typeof this.fixturesCache_[url] === 'undefined') { - this.loadFixtureIntoCache_(url) - } - return this.fixturesCache_[url] - } - - jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { - var self = this - , url = this.makeFixtureUrl_(relativeUrl) - , htmlText = '' - , request = $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - url: url, - success: function (data, status, $xhr) { - htmlText = $xhr.responseText - } - }).fail(function ($xhr, status, err) { - throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') - }) - - var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || []; - - scripts.each(function(){ - $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - dataType: 'script', - url: $(this).attr('src'), - success: function (data, status, $xhr) { - htmlText += '' - }, - error: function ($xhr, status, err) { - throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + err.message + ')') - } - }); - }) - - self.fixturesCache_[relativeUrl] = htmlText; - } - - jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ - return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl - } - - jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) - } - - - jasmine.StyleFixtures = function () { - this.fixturesCache_ = {} - this.fixturesNodes_ = [] - this.fixturesPath = 'spec/javascripts/fixtures' - } - - jasmine.StyleFixtures.prototype.set = function (css) { - this.cleanUp() - this.createStyle_(css) - } - - jasmine.StyleFixtures.prototype.appendSet = function (css) { - this.createStyle_(css) - } - - jasmine.StyleFixtures.prototype.preload = function () { - this.read_.apply(this, arguments) - } - - jasmine.StyleFixtures.prototype.load = function () { - this.cleanUp() - this.createStyle_(this.read_.apply(this, arguments)) - } - - jasmine.StyleFixtures.prototype.appendLoad = function () { - this.createStyle_(this.read_.apply(this, arguments)) - } - - jasmine.StyleFixtures.prototype.cleanUp = function () { - while(this.fixturesNodes_.length) { - this.fixturesNodes_.pop().remove() - } - } - - jasmine.StyleFixtures.prototype.createStyle_ = function (html) { - var styleText = $('
').html(html).text() - , style = $('') - - this.fixturesNodes_.push(style) - $('head').append(style) - } - - jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache - jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read - jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ - jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ - jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ - jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ - - jasmine.getJSONFixtures = function () { - return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() - } - - jasmine.JSONFixtures = function () { - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures/json' - } - - jasmine.JSONFixtures.prototype.load = function () { - this.read.apply(this, arguments) - return this.fixturesCache_ - } - - jasmine.JSONFixtures.prototype.read = function () { - var fixtureUrls = arguments - - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - this.getFixtureData_(fixtureUrls[urlIndex]) - } - - return this.fixturesCache_ - } - - jasmine.JSONFixtures.prototype.clearCache = function () { - this.fixturesCache_ = {} - } - - jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { - if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url) - return this.fixturesCache_[url] - } - - jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { - var self = this - , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl - - $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - dataType: 'json', - url: url, - success: function (data) { - self.fixturesCache_[relativeUrl] = data - }, - error: function ($xhr, status, err) { - throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') - } - }) - } - - jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) - } - - jasmine.jQuery = function () {} - - jasmine.jQuery.browserTagCaseIndependentHtml = function (html) { - return $('
').append(html).html() - } - - jasmine.jQuery.elementToString = function (element) { - return $(element).map(function () { return this.outerHTML; }).toArray().join(', ') - } - - var data = { - spiedEvents: {} - , handlers: [] - } - - jasmine.jQuery.events = { - spyOn: function (selector, eventName) { - var handler = function (e) { - data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments) - } - - $(selector).on(eventName, handler) - data.handlers.push(handler) - - return { - selector: selector, - eventName: eventName, - handler: handler, - reset: function (){ - delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - } - } - }, - - args: function (selector, eventName) { - var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - - if (!actualArgs) { - throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." - } - - return actualArgs - }, - - wasTriggered: function (selector, eventName) { - return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) - }, - - wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) { - var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1) - - if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') - actualArgs = actualArgs[0] - - return util.equals(expectedArgs, actualArgs, customEqualityTesters) - }, - - wasPrevented: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , e = args ? args[0] : undefined - - return e && e.isDefaultPrevented() - }, - - wasStopped: function (selector, eventName) { - var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , e = args ? args[0] : undefined - return e && e.isPropagationStopped() - }, - - cleanUp: function () { - data.spiedEvents = {} - data.handlers = [] - } - } - - var hasProperty = function (actualValue, expectedValue) { - if (expectedValue === undefined) - return actualValue !== undefined - - return actualValue === expectedValue - } - - beforeEach(function () { - jasmine.addMatchers({ - toHaveClass: function () { - return { - compare: function (actual, className) { - return { pass: $(actual).hasClass(className) } - } - } - }, - - toHaveCss: function () { - return { - compare: function (actual, css) { - for (var prop in css){ - var value = css[prop] - // see issue #147 on gh - ;if (value === 'auto' && $(actual).get(0).style[prop] === 'auto') continue - if ($(actual).css(prop) !== value) return { pass: false } - } - return { pass: true } - } - } - }, - - toBeVisible: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':visible') } - } - } - }, - - toBeHidden: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':hidden') } - } - } - }, - - toBeSelected: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':selected') } - } - } - }, - - toBeChecked: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':checked') } - } - } - }, - - toBeEmpty: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':empty') } - } - } - }, - - toBeInDOM: function () { - return { - compare: function (actual) { - return { pass: $.contains(document.documentElement, $(actual)[0]) } - } - } - }, - - toExist: function () { - return { - compare: function (actual) { - return { pass: $(actual).length } - } - } - }, - - toHaveLength: function () { - return { - compare: function (actual, length) { - return { pass: $(actual).length === length } - } - } - }, - - toHaveAttr: function () { - return { - compare: function (actual, attributeName, expectedAttributeValue) { - return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) } - } - } - }, - - toHaveProp: function () { - return { - compare: function (actual, propertyName, expectedPropertyValue) { - return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) } - } - } - }, - - toHaveId: function () { - return { - compare: function (actual, id) { - return { pass: $(actual).attr('id') == id } - } - } - }, - - toHaveHtml: function () { - return { - compare: function (actual, html) { - return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) } - } - } - }, - - toContainHtml: function () { - return { - compare: function (actual, html) { - var actualHtml = $(actual).html() - , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html) - - return { pass: (actualHtml.indexOf(expectedHtml) >= 0) } - } - } - }, - - toHaveText: function () { - return { - compare: function (actual, text) { - var actualText = $(actual).text() - var trimmedText = $.trim(actualText) - - if (text && $.isFunction(text.test)) { - return { pass: text.test(actualText) || text.test(trimmedText) } - } else { - return { pass: (actualText == text || trimmedText == text) } - } - } - } - }, - - toContainText: function () { - return { - compare: function (actual, text) { - var trimmedText = $.trim($(actual).text()) - - if (text && $.isFunction(text.test)) { - return { pass: text.test(trimmedText) } - } else { - return { pass: trimmedText.indexOf(text) != -1 } - } - } - } - }, - - toHaveValue: function () { - return { - compare: function (actual, value) { - return { pass: $(actual).val() === value } - } - } - }, - - toHaveData: function () { - return { - compare: function (actual, key, expectedValue) { - return { pass: hasProperty($(actual).data(key), expectedValue) } - } - } - }, - - toContainElement: function () { - return { - compare: function (actual, selector) { - if (window.debug) debugger - return { pass: $(actual).find(selector).length } - } - } - }, - - toBeMatchedBy: function () { - return { - compare: function (actual, selector) { - return { pass: $(actual).filter(selector).length } - } - } - }, - - toBeDisabled: function () { - return { - compare: function (actual, selector) { - return { pass: $(actual).is(':disabled') } - } - } - }, - - toBeFocused: function (selector) { - return { - compare: function (actual, selector) { - return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement } - } - } - }, - - toHandle: function () { - return { - compare: function (actual, event) { - var events = $._data($(actual).get(0), "events") - - if (!events || !event || typeof event !== "string") { - return { pass: false } - } - - var namespaces = event.split(".") - , eventType = namespaces.shift() - , sortedNamespaces = namespaces.slice(0).sort() - , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") - - if (events[eventType] && namespaces.length) { - for (var i = 0; i < events[eventType].length; i++) { - var namespace = events[eventType][i].namespace - - if (namespaceRegExp.test(namespace)) - return { pass: true } - } - } else { - return { pass: (events[eventType] && events[eventType].length > 0) } - } - - return { pass: false } - } - } - }, - - toHandleWith: function () { - return { - compare: function (actual, eventName, eventHandler) { - var normalizedEventName = eventName.split('.')[0] - , stack = $._data($(actual).get(0), "events")[normalizedEventName] - - for (var i = 0; i < stack.length; i++) { - if (stack[i].handler == eventHandler) return { pass: true } - } - - return { pass: false } - } - } - }, - - toHaveBeenTriggeredOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) } - - result.message = result.pass ? - "Expected event " + $(actual) + " not to have been triggered on " + selector : - "Expected event " + $(actual) + " to have been triggered on " + selector - - return result; - } - } - }, - - toHaveBeenTriggered: function (){ - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been triggered on " + selector : - "Expected event " + eventName + " to have been triggered on " + selector - - return result - } - } - }, - - toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) { - return { - compare: function (actual, selector, expectedArgs) { - var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual) - , result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) } - - if (wasTriggered) { - var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1] - result.message = result.pass ? - "Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) : - "Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) - - } else { - // todo check on this - result.message = result.pass ? - "Expected event " + actual + " not to have been triggered on " + selector : - "Expected event " + actual + " to have been triggered on " + selector - } - - return result - } - } - }, - - toHaveBeenPreventedOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) } - - result.message = result.pass ? - "Expected event " + actual + " not to have been prevented on " + selector : - "Expected event " + actual + " to have been prevented on " + selector - - return result - } - } - }, - - toHaveBeenPrevented: function () { - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been prevented on " + selector : - "Expected event " + eventName + " to have been prevented on " + selector - - return result - } - } - }, - - toHaveBeenStoppedOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) } - - result.message = result.pass ? - "Expected event " + actual + " not to have been stopped on " + selector : - "Expected event " + actual + " to have been stopped on " + selector - - return result; - } - } - }, - - toHaveBeenStopped: function () { - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been stopped on " + selector : - "Expected event " + eventName + " to have been stopped on " + selector - - return result - } - } - } - }) - - jasmine.getEnv().addCustomEqualityTester(function(a, b) { - if (a && b) { - if (a instanceof $ || jasmine.isDomNode(a)) { - var $a = $(a) - - if (b instanceof $) - return $a.length == b.length && a.is(b) - - return $a.is(b); - } - - if (b instanceof $ || jasmine.isDomNode(b)) { - var $b = $(b) - - if (a instanceof $) - return a.length == $b.length && $b.is(a) - - return $(b).is(a); - } - } - }) - - jasmine.getEnv().addCustomEqualityTester(function (a, b) { - if (a instanceof $ && b instanceof $ && a.size() == b.size()) - return a.is(b) - }) - }) - - afterEach(function () { - jasmine.getFixtures().cleanUp() - jasmine.getStyleFixtures().cleanUp() - jasmine.jQuery.events.cleanUp() - }) - - window.readFixtures = function () { - return jasmine.getFixtures().proxyCallTo_('read', arguments) - } - - window.preloadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('preload', arguments) - } - - window.loadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('load', arguments) - } - - window.appendLoadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) - } - - window.setFixtures = function (html) { - return jasmine.getFixtures().proxyCallTo_('set', arguments) - } - - window.appendSetFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendSet', arguments) - } - - window.sandbox = function (attributes) { - return jasmine.getFixtures().sandbox(attributes) - } - - window.spyOnEvent = function (selector, eventName) { - return jasmine.jQuery.events.spyOn(selector, eventName) - } - - window.preloadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) - } - - window.loadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('load', arguments) - } - - window.appendLoadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) - } - - window.setStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('set', arguments) - } - - window.appendSetStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) - } - - window.loadJSONFixtures = function () { - return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) - } - - window.getJSONFixture = function (url) { - return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] - } -}(window, window.jasmine, window.jQuery);