├── .editorconfig ├── .ember-cli ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .travis.yml ├── .watchmanconfig ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── addon ├── .gitkeep ├── adapters │ ├── github-blob.js │ ├── github-branch.js │ ├── github-compare.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ ├── github-user.js │ └── github.js ├── initializers │ └── github-inflector-rules.js ├── models │ ├── github-blob.js │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ └── github-user.js ├── serializers │ ├── github-blob.js │ ├── github-branch.js │ ├── github-compare.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ ├── github-user.js │ └── github.js └── services │ └── github-session.js ├── app ├── .gitkeep ├── adapters │ ├── github-blob.js │ ├── github-branch.js │ ├── github-compare.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ ├── github-user.js │ └── github.js ├── initializers │ └── github-inflector-rules.js ├── mirage-factories │ ├── github-blob.js │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository.js │ ├── github-tree.js │ └── github-user.js ├── mirage-models │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ └── github-repository.js ├── models │ ├── github-blob.js │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ └── github-user.js ├── serializers │ ├── github-blob.js │ ├── github-branch.js │ ├── github-compare.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ ├── github-user.js │ └── github.js └── services │ └── github-session.js ├── config ├── ember-try.js ├── environment.js └── release.js ├── ember-cli-build.js ├── index.js ├── mirage-support ├── factories │ ├── github-blob.js │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ ├── github-user.js │ └── tree.js ├── models │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository.js │ └── github-user.js └── serializers │ ├── ember-data-github.js │ ├── github-blob.js │ ├── github-branch.js │ ├── github-commit.js │ ├── github-compare.js │ ├── github-file.js │ ├── github-member.js │ ├── github-organization.js │ ├── github-pull.js │ ├── github-release.js │ ├── github-repository-contents.js │ ├── github-repository.js │ ├── github-tree.js │ └── github-user.js ├── package.json ├── testem.js ├── tests ├── acceptance │ ├── current-github-user-test.js │ ├── github-blob-test.js │ ├── github-branch-test.js │ ├── github-compare-test.js │ ├── github-organization-test.js │ ├── github-release-test.js │ ├── github-repository-contents-test.js │ ├── github-repository-test.js │ ├── github-tree-test.js │ ├── github-user-test.js │ └── gitub-pull-test.js ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ ├── .gitkeep │ │ │ └── models-list.js │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ ├── .gitkeep │ │ │ └── explore.js │ │ ├── styles │ │ │ └── app.scss │ │ └── templates │ │ │ ├── application.hbs │ │ │ ├── components │ │ │ ├── .gitkeep │ │ │ └── models-list.hbs │ │ │ ├── explore.hbs │ │ │ └── index.hbs │ ├── config │ │ ├── environment.js │ │ └── targets.js │ ├── mirage │ │ ├── config.js │ │ └── scenarios │ │ │ └── default.js │ └── public │ │ └── robots.txt ├── helpers │ ├── .gitkeep │ ├── custom-helpers │ │ ├── assert-github-blob-ok.js │ │ ├── assert-github-branch-ok.js │ │ ├── assert-github-compare-ok.js │ │ ├── assert-github-member-ok.js │ │ ├── assert-github-organization-ok.js │ │ ├── assert-github-pull-ok.js │ │ ├── assert-github-release-ok.js │ │ ├── assert-github-repository-contents-ok.js │ │ ├── assert-github-repository-ok.js │ │ ├── assert-github-tree-ok.js │ │ └── assert-github-user-ok.js │ ├── destroy-app.js │ ├── module-for-acceptance.js │ ├── start-app.js │ └── utils │ │ └── defined-attribute-assertion-builder.js ├── index.html ├── integration │ └── .gitkeep ├── test-helper.js └── unit │ ├── .gitkeep │ ├── adapters │ ├── github-blob-test.js │ ├── github-branch-test.js │ ├── github-compare-test.js │ ├── github-member-test.js │ ├── github-organization-test.js │ ├── github-pull-test.js │ ├── github-release-test.js │ ├── github-repository-contents-test.js │ ├── github-repository-test.js │ ├── github-test.js │ ├── github-tree-test.js │ └── github-user-test.js │ ├── models │ ├── github-blob-test.js │ ├── github-branch-test.js │ ├── github-commit-test.js │ ├── github-compare-test.js │ ├── github-file-test.js │ ├── github-member-test.js │ ├── github-organization-test.js │ ├── github-pull-test.js │ ├── github-release-test.js │ ├── github-repository-contents-test.js │ ├── github-repository-test.js │ ├── github-tree-test.js │ └── github-user-test.js │ ├── serializers │ ├── github-blob-test.js │ ├── github-branch-test.js │ ├── github-compare-test.js │ ├── github-member-test.js │ ├── github-organization-test.js │ ├── github-release-test.js │ ├── github-repository-contents-test.js │ ├── github-repository-test.js │ ├── github-test.js │ ├── github-tree-test.js │ └── github-user-test.js │ └── services │ └── github-session-test.js ├── vendor └── .gitkeep └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | globals: { 3 | server: true, 4 | }, 5 | root: true, 6 | parserOptions: { 7 | ecmaVersion: 2017, 8 | sourceType: 'module' 9 | }, 10 | plugins: [ 11 | 'ember' 12 | ], 13 | extends: [ 14 | 'eslint:recommended', 15 | 'plugin:ember/recommended' 16 | ], 17 | env: { 18 | browser: true 19 | }, 20 | rules: { 21 | }, 22 | overrides: [ 23 | // node files 24 | { 25 | files: [ 26 | 'ember-cli-build.js', 27 | 'index.js', 28 | 'testem.js', 29 | 'config/**/*.js', 30 | 'tests/dummy/config/**/*.js' 31 | ], 32 | excludedFiles: [ 33 | 'addon/**', 34 | 'addon-test-support/**', 35 | 'app/**', 36 | 'tests/dummy/app/**' 37 | ], 38 | parserOptions: { 39 | sourceType: 'script', 40 | ecmaVersion: 2015 41 | }, 42 | env: { 43 | browser: false, 44 | node: true 45 | }, 46 | plugins: ['node'], 47 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 48 | // add your custom rules and overrides for node files here 49 | }) 50 | }, 51 | // mirage files 52 | { 53 | files: ['tests/dummy/mirage/**', 'mirage-support/**'], 54 | rules: { 55 | 'ember/avoid-leaking-state-in-ember-objects': 'off' 56 | } 57 | } 58 | ] 59 | }; 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log* 17 | yarn-error.log 18 | testem.log 19 | 20 | # ember-try 21 | .node_modules.ember-try/ 22 | bower.json.ember-try 23 | package.json.ember-try 24 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /bower_components 2 | /config/ember-try.js 3 | /dist 4 | /tests 5 | /tmp 6 | **/.gitkeep 7 | .bowerrc 8 | .editorconfig 9 | .ember-cli 10 | .eslintrc.js 11 | .gitignore 12 | .watchmanconfig 13 | .travis.yml 14 | bower.json 15 | ember-cli-build.js 16 | testem.js 17 | 18 | # ember-try 19 | .node_modules.ember-try/ 20 | bower.json.ember-try 21 | package.json.ember-try 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "8" 7 | 8 | dist: trusty 9 | 10 | addons: 11 | chrome: stable 12 | 13 | cache: 14 | yarn: true 15 | 16 | env: 17 | global: 18 | # See https://git.io/vdao3 for details. 19 | - JOBS=1 20 | matrix: 21 | # we recommend new addons test the current and previous LTS 22 | # as well as latest stable release (bonus points to beta/canary) 23 | - EMBER_TRY_SCENARIO=ember-lts-2.12 24 | - EMBER_TRY_SCENARIO=ember-lts-2.16 25 | - EMBER_TRY_SCENARIO=ember-lts-2.18 26 | - EMBER_TRY_SCENARIO=ember-release 27 | - EMBER_TRY_SCENARIO=ember-beta 28 | - EMBER_TRY_SCENARIO=ember-canary 29 | - EMBER_TRY_SCENARIO=ember-default 30 | 31 | matrix: 32 | fast_finish: true 33 | allow_failures: 34 | - env: EMBER_TRY_SCENARIO=ember-canary 35 | 36 | before_install: 37 | - curl -o- -L https://yarnpkg.com/install.sh | bash 38 | - export PATH=$HOME/.yarn/bin:$PATH 39 | install: 40 | - yarn install --no-lockfile --non-interactive 41 | 42 | script: 43 | - npm run lint:js 44 | # Usually, it's ok to finish the test scenario without reverting 45 | # to the addon's original dependency state, skipping "cleanup". 46 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup 47 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v0.9.0 (2019-10-11) 2 | 3 | #### Enhancement 4 | * [#228](https://github.com/elwayman02/ember-data-github/pull/228) Upgrade to ember-cli-mirage ^1.1.0 ([@code0100fun](https://github.com/code0100fun)) 5 | 6 | #### Committers: 2 7 | - Brian Runnells ([@Dhaulagiri](https://github.com/Dhaulagiri)) 8 | - Chase McCarthy ([@code0100fun](https://github.com/code0100fun)) 9 | 10 | ## v0.8.1 (2018-09-27) 11 | 12 | #### Bug Fix 13 | * [#196](https://github.com/elwayman02/ember-data-github/pull/196) Fix `headers.link` not being parsed.. ([@jabrown85](https://github.com/jabrown85)) 14 | 15 | #### Internal 16 | * [#169](https://github.com/elwayman02/ember-data-github/pull/169) ember 3.1. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 17 | 18 | #### Committers: 2 19 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 20 | - Jesse Brown ([jabrown85](https://github.com/jabrown85)) 21 | 22 | ## v0.8.0 (2018-04-17) 23 | 24 | #### Enhancement 25 | * [#167](https://github.com/elwayman02/ember-data-github/pull/167) Add support for GitHub repository contents. ([@jmar910](https://github.com/jmar910)) 26 | 27 | #### Committers: 1 28 | - James Martinez ([jmar910](https://github.com/jmar910)) 29 | 30 | ## v0.7.1 (2018-03-20) 31 | 32 | #### Bug Fix 33 | * [#161](https://github.com/elwayman02/ember-data-github/pull/161) move mirage application serializer to addon to avoid conflicts. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 34 | 35 | #### Internal 36 | * [#162](https://github.com/elwayman02/ember-data-github/pull/162) lock ember-cli-mirage to 0.4.1. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 37 | 38 | #### Committers: 1 39 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 40 | 41 | ## v0.7.0 (2018-02-23) 42 | 43 | #### Enhancement 44 | * [#153](https://github.com/elwayman02/ember-data-github/pull/153) Retrieve Repo List By User. ([@elwayman02](https://github.com/elwayman02)) 45 | 46 | #### Committers: 1 47 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 48 | 49 | ## v0.6.0 (2018-02-14) 50 | 51 | #### Enhancement 52 | * [#142](https://github.com/elwayman02/ember-data-github/pull/142) allow consuming apps to use mirage factories/models/serializers. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 53 | * [#140](https://github.com/elwayman02/ember-data-github/pull/140) Add github-compare. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 54 | * [#148](https://github.com/elwayman02/ember-data-github/pull/148) use embeddedrecord to pull user out of payloads. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 55 | * [#143](https://github.com/elwayman02/ember-data-github/pull/143) properly deprecate removed properties. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 56 | * [#137](https://github.com/elwayman02/ember-data-github/pull/137) Setup members relationship on organizations. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 57 | * [#138](https://github.com/elwayman02/ember-data-github/pull/138) rename user property on github-release to author. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 58 | * [#133](https://github.com/elwayman02/ember-data-github/pull/133) DRY up how attributes are deserialized. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 59 | * [#132](https://github.com/elwayman02/ember-data-github/pull/132) Model updates. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 60 | * [#131](https://github.com/elwayman02/ember-data-github/pull/131) remove github from relation property names. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 61 | * [#127](https://github.com/elwayman02/ember-data-github/pull/127) add additional fields to github-branch. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 62 | * [#123](https://github.com/elwayman02/ember-data-github/pull/123) Convert test suite to use mirage. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 63 | 64 | #### Documentation 65 | * [#147](https://github.com/elwayman02/ember-data-github/pull/147) Better organize supported apis. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 66 | * [#146](https://github.com/elwayman02/ember-data-github/pull/146) generate changelog with lerna-changelog. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 67 | * [#134](https://github.com/elwayman02/ember-data-github/pull/134) Demo app. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 68 | 69 | #### Internal 70 | * [#151](https://github.com/elwayman02/ember-data-github/pull/151) ember-cli-update to 3.0. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 71 | * [#145](https://github.com/elwayman02/ember-data-github/pull/145) chore(package): update ember-data to version 3.0.1. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 72 | * [#126](https://github.com/elwayman02/ember-data-github/pull/126) add tests for github-pull. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 73 | 74 | #### Committers: 1 75 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 76 | 77 | ## 0.5.0 (2018-01-27) 78 | 79 | #### Enhancement 80 | * [#125](https://github.com/elwayman02/ember-data-github/pull/125) Support fetching resources by id. ([@joshwlewis](https://github.com/joshwlewis)) 81 | 82 | #### Documentation 83 | * [#120](https://github.com/elwayman02/ember-data-github/pull/120) use new imports in readme examples. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 84 | 85 | #### Internal 86 | * [#121](https://github.com/elwayman02/ember-data-github/pull/121) ember-cli-update to 2.18. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 87 | * [#110](https://github.com/elwayman02/ember-data-github/pull/110) Update yarn lock. ([@elwayman02](https://github.com/elwayman02)) 88 | 89 | #### Committers: 3 90 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 91 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 92 | - Josh W Lewis ([joshwlewis](https://github.com/joshwlewis)) 93 | 94 | 95 | ## v0.4.0 (2018-01-07) 96 | 97 | #### Enhancement 98 | * [#103](https://github.com/elwayman02/ember-data-github/pull/103) Add trees API support. ([@srvance](https://github.com/srvance)) 99 | 100 | #### Internal 101 | * [#108](https://github.com/elwayman02/ember-data-github/pull/108) update to 2.17. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 102 | 103 | #### Committers: 2 104 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 105 | - Stephen Vance ([srvance](https://github.com/srvance)) 106 | 107 | 108 | ## v0.3.1 (2017-03-26) 109 | 110 | #### Enhancement 111 | * [#83](https://github.com/elwayman02/ember-data-github/pull/83) Pagination support. ([@appleton](https://github.com/appleton)) 112 | * [#79](https://github.com/elwayman02/ember-data-github/pull/79) Adding `htmlUrl` attribute to `github-user`. ([@alexander-alvarez](https://github.com/alexander-alvarez)) 113 | 114 | #### Committers: 4 115 | - Alex Alvarez ([alexander-alvarez](https://github.com/alexander-alvarez)) 116 | - Andrew Appleton ([appleton](https://github.com/appleton)) 117 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 118 | - Stephen Vance ([srvance](https://github.com/srvance)) 119 | 120 | 121 | ## v0.3.0 (2016-12-19) 122 | 123 | #### Enhancement 124 | * [#73](https://github.com/elwayman02/ember-data-github/pull/73) Adapter simplification and branch query addition. ([@srvance](https://github.com/srvance)) 125 | 126 | #### Documentation 127 | * [#72](https://github.com/elwayman02/ember-data-github/pull/72) Add docs for ember-simple-auth authentication. ([@srvance](https://github.com/srvance)) 128 | 129 | #### Internal 130 | * [#69](https://github.com/elwayman02/ember-data-github/pull/69) Adapter tests. ([@srvance](https://github.com/srvance)) 131 | 132 | #### Committers: 3 133 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 134 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 135 | - Stephen Vance ([srvance](https://github.com/srvance)) 136 | 137 | 138 | ## v0.2.0 (2016-09-13) 139 | 140 | #### Enhancement 141 | * [#53](https://github.com/elwayman02/ember-data-github/pull/53) Add github releases. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 142 | 143 | #### Internal 144 | * [#54](https://github.com/elwayman02/ember-data-github/pull/54) remove ember-ajax. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 145 | * [#51](https://github.com/elwayman02/ember-data-github/pull/51) ember-cli-eslint 3.0.0. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 146 | * [#50](https://github.com/elwayman02/ember-data-github/pull/50) remove old jscs rules. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 147 | * [#52](https://github.com/elwayman02/ember-data-github/pull/52) Delete testem.json. ([@Dhaulagiri](https://github.com/Dhaulagiri)) 148 | 149 | #### Committers: 2 150 | - Brian Runnells ([Dhaulagiri](https://github.com/Dhaulagiri)) 151 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 152 | 153 | 154 | ## v0.1.1 (2016-08-12) 155 | 156 | #### Enhancement 157 | * [#31](https://github.com/elwayman02/ember-data-github/pull/31) Organization -> User link. ([@topaxi](https://github.com/topaxi)) 158 | 159 | #### Committers: 4 160 | - Chris Sedlmayr ([catchamonkey](https://github.com/catchamonkey)) 161 | - Damian Senn ([topaxi](https://github.com/topaxi)) 162 | - Greenkeeper ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) 163 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 164 | 165 | 166 | ## v0.1.0 (2016-04-12) 167 | 168 | #### Internal 169 | * [#11](https://github.com/elwayman02/ember-data-github/pull/11) Fix style issues. ([@elwayman02](https://github.com/elwayman02)) 170 | * [#10](https://github.com/elwayman02/ember-data-github/pull/10) Upgraded to Ember 2.x. ([@sivakumar-kailasam](https://github.com/sivakumar-kailasam)) 171 | 172 | #### Committers: 2 173 | - Jordan Hawker ([elwayman02](https://github.com/elwayman02)) 174 | - Sivakumar Kailasam ([sivakumar-kailasam](https://github.com/sivakumar-kailasam)) 175 | 176 | 177 | ## v0.0.6 (2015-07-20) 178 | 179 | #### Enhancement 180 | * [#8](https://github.com/elwayman02/ember-data-github/pull/8) More informations in githubRepository model & githubUser model. ([@Nainterceptor](https://github.com/Nainterceptor)) 181 | * [#7](https://github.com/elwayman02/ember-data-github/pull/7) Add branch model. ([@jimmay5469](https://github.com/jimmay5469)) 182 | 183 | #### Committers: 2 184 | - Jimmy Lauzau ([jimmay5469](https://github.com/jimmay5469)) 185 | - [Nainterceptor](https://github.com/Nainterceptor) 186 | 187 | 188 | ## v0.0.4 (2015-05-05) 189 | 190 | #### Enhancement 191 | * [#6](https://github.com/elwayman02/ember-data-github/pull/6) Add repository owner relationship. ([@jimmay5469](https://github.com/jimmay5469)) 192 | 193 | #### Committers: 1 194 | - Jimmy Lauzau ([jimmay5469](https://github.com/jimmay5469)) 195 | 196 | 197 | ## v0.0.2 (2015-05-04) 198 | 199 | #### Enhancement 200 | * [#5](https://github.com/elwayman02/ember-data-github/pull/5) Prevent extra records in the store because of id casing. ([@jimmay5469](https://github.com/jimmay5469)) 201 | 202 | #### Committers: 1 203 | - Jimmy Lauzau ([jimmay5469](https://github.com/jimmay5469)) 204 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2018 Jordan Hawker 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ember Data Github 2 | 3 | [![Build Status](https://travis-ci.org/elwayman02/ember-data-github.svg?branch=master)](https://travis-ci.org/elwayman02/ember-data-github) 4 | [![Ember Observer Score](http://emberobserver.com/badges/ember-data-github.svg)](http://emberobserver.com/addons/ember-data-github) 5 | [![Code Climate](https://codeclimate.com/github/elwayman02/ember-data-github/badges/gpa.svg)](https://codeclimate.com/github/elwayman02/ember-data-github) 6 | 7 | Ember Data abstraction for the [GitHub REST API v3](https://developer.github.com/v3/). 8 | 9 | ## Installation 10 | 11 | ``` 12 | ember install ember-data-github 13 | ``` 14 | 15 | ## Usage 16 | 17 | You need to choose how you wish to authenticate your GitHub requests using OAuth. `ember-data-github` provides a simple 18 | and direct mechanism that is specific to itself. Alternatively, you can use a more general authentication framework like 19 | `ember-simple-auth`. 20 | 21 | ### Authenticating Directly 22 | 23 | If you already have a token to use the OAuth endpoints, such as a *Personal access token*, you must set the property 24 | named `githubAccessToken` on `github-session` service with the currently logged in user's GitHub access token. 25 | 26 | ### Authenticating with `ember-simple-auth` 27 | 28 | If you are using [ember-simple-auth](http://ember-simple-auth.com/) (ESA) to authenticate, perhaps with 29 | [torii](http://vestorly.github.io/torii) and ESA's `torii-provider`, you can authenticate by creating a github 30 | authorizer and extending `ember-data-github`'s adapter for each model you use. See the respective addon docs and 31 | [GitHub's OAuth docs](https://developer.github.com/v3/oauth/) to set it up. 32 | 33 | 34 | Once you have a token, the authorizer will look like 35 | ```js 36 | // app/authorizers/github.js 37 | 38 | import { inject as service } from '@ember/service'; 39 | import { isEmpty } from '@ember/utils'; 40 | import Base from 'ember-simple-auth/authorizers/base'; 41 | 42 | export default Base.extend({ 43 | session: service(), 44 | authorize(sessionData, block) { 45 | if (this.get('session.isAuthenticated') && !isEmpty(sessionData.access_token)) { 46 | block('Authorization', `token ${sessionData.access_token}`); 47 | } 48 | } 49 | }); 50 | ``` 51 | assuming `access_token` is the name of the property containing the token. This automatically injects the `Authorization` 52 | header into the API requests using ESA mechanisms. 53 | 54 | An extended adapter for `github-user` would look like 55 | ```js 56 | // app/adapters/github-user.js 57 | 58 | import GitHubUserAdapter from 'ember-data-github/adapters/github-user'; 59 | import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; 60 | 61 | export default GitHubUserAdapter.extend(DataAdapterMixin, { 62 | authorizer: 'authorizer:github' 63 | }); 64 | ``` 65 | 66 | ### Retrieving GitHub Data 67 | 68 | #### [Users](https://developer.github.com/v3/users/) 69 | 70 | ##### [Get the current authenticated user](https://developer.github.com/v3/users/#get-the-authenticated-user) 71 | ```js 72 | this.get('store').findRecord('github-user', '#'); 73 | ``` 74 | 75 | ##### [Get a single user](https://developer.github.com/v3/users/#get-a-single-user) 76 | ```js 77 | this.get('store').findRecord('github-user', 'jimmay5469'); // get a user by user login 78 | this.get('store').findRecord('github-user', 917672); // get a user by user id 79 | ``` 80 | 81 | #### [Repositories](https://developer.github.com/v3/repos/) 82 | 83 | ##### [Get](https://developer.github.com/v3/repos/#get) 84 | ```js 85 | this.get('store').findRecord('github-repository', 'jimmay5469/old-hash'); // get a repository by repository name 86 | this.get('store').findRecord('github-repository', 34598603); // get a repository by repository id 87 | ``` 88 | 89 | ##### [Get By User](https://developer.github.com/v3/repos/#list-user-repositories) 90 | ```js 91 | this.get('store').query('github-repository', { user: 'elwayman02' }); // get repositories owned by user 92 | this.get('store').query('github-repository', { user: 'elwayman02', type: 'all' }); // get all repositories for user 93 | this.get('store').query('github-repository', { user: 'elwayman02', sort: 'updated', direction: 'asc' }); // get repositories owned by user sorted by last updated, ascending 94 | ``` 95 | 96 | ##### [Repository Contents](https://developer.github.com/v3/repos/contents/) 97 | 98 | ##### [Get](https://developer.github.com/v3/repos/contents/#get-contents) 99 | Note: At this time we only support getting file contents. 100 | ```js 101 | this.get('store').queryRecord('github-repository-contents', { repo: 'jmar910/test-repo-yay', file: 'app.json' }); // get file contents from repo 102 | 103 | ``` 104 | 105 | ##### [Branches](https://developer.github.com/v3/repos/branches/) 106 | 107 | ###### [List branches](https://developer.github.com/v3/repos/branches/#list-branches) 108 | 109 | ```js 110 | this.get('store').query('github-branch', { repo: 'jimmay5469/old-hash' }); 111 | ``` 112 | 113 | ###### [Get](https://developer.github.com/v3/repos/branches/#get-branch) 114 | ```js 115 | this.get('store').findRecord('github-branch', 'jimmay5469/old-hash/branches/master'); // get a branch 116 | this.get('store').queryRecord('github-branch', { repo: 'jimmay5469/old-hash', branch: 'master' }); // get a specific branch 117 | ``` 118 | 119 | ##### [Releases](https://developer.github.com/v3/repos/releases/) 120 | 121 | ###### [List releases for a repository](https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository) 122 | ```js 123 | this.get('store').query('github-release', { repo: 'jimmay5469/old-hash' }); 124 | ``` 125 | 126 | ###### [Get a single release](https://developer.github.com/v3/repos/releases/#get-a-single-release) 127 | ```js 128 | this.get('store').queryRecord('github-release', { repo: 'jimmay5469/old-hash', releaseId: 1 }); 129 | ``` 130 | 131 | ##### [Commits](https://developer.github.com/v3/repos/commits/) 132 | 133 | ###### [Compate two commits](https://developer.github.com/v3/repos/commits/#compare-two-commits) 134 | 135 | ```js 136 | this.get('store').queryRecord('github-compare', { repo: 'jimmay5469/old-hash', base: '1234', head: '5678' }); 137 | ``` 138 | 139 | #### [Pull Requests](https://developer.github.com/v3/pulls/) 140 | 141 | ##### [List pull requests](https://developer.github.com/v3/pulls/#list-pull-requests) 142 | ```js 143 | this.get('store').query('github-pull', { repo: 'jimmay5469/old-hash' }); 144 | ``` 145 | 146 | ##### [Get a single pull request](https://developer.github.com/v3/pulls/#get-a-single-pull-request) 147 | ```js 148 | this.get('store').queryRecord('github-pull', { repo: 'jimmay5469/old-hash', pullId: 1 }); 149 | ``` 150 | #### [GitHub Organizations](https://developer.github.com/v3/orgs/) 151 | 152 | ##### [Get an organizaton](https://developer.github.com/v3/orgs/#get-an-organization) 153 | ```js 154 | this.get('store').findRecord('github-organization', { org: 'my-org' }); 155 | ``` 156 | 157 | ##### [Get organization members](https://developer.github.com/v3/orgs/members/#members-list) 158 | ```js 159 | this.get('store').query('github-members', { org: 'my-org' }) 160 | ``` 161 | 162 | #### [Git Blobs](https://developer.github.com/v3/git/blobs/) 163 | 164 | ##### [Get a blob](https://developer.github.com/v3/git/blobs/#get-a-blob) 165 | 166 | ```js 167 | this.get('store').queryRecord('github-blob', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' }); 168 | ``` 169 | #### [Git Trees](https://developer.github.com/v3/git/trees/) 170 | 171 | ##### [Get a Tree](https://developer.github.com/v3/git/trees/#get-a-tree) 172 | 173 | ```js 174 | this.get('store').queryRecord('github-tree', { repo: 'jimmay5469/old-hash', sha: '47c5438403ca875f170db2aa07d1bfa3689406e3' }); 175 | ``` 176 | 177 | ## Testing with Mirage 178 | 179 | This addon uses [ember-cli-mirage](http://www.ember-cli-mirage.com/) in its tests. It is often beneficial for consuming apps to be able to re-use the factories and models defined in mirage, so if you would like to use these in your tests you can add the `mirage-support` object to your `ember-cli-build.js` file: 180 | 181 | ``` 182 | module.exports = function(defaults) { 183 | let app = new EmberApp(defaults, { 184 | ... 185 | 'mirage-support': { 186 | includeAll: true 187 | } 188 | ... 189 | }); 190 | 191 | return app.toTree(); 192 | }; 193 | ``` 194 | 195 | 196 | As long as `ember-cli-mirage` is not disabled, the files in this addon's `mirage-support` directory will be merged with the consuming app's namespace, and be made available to that mirage context. 197 | The `'mirage-support'` key has 3 options: 198 | 199 | Key | Type | Description 200 | --- | --- | --- 201 | `includeAll` | `Boolean` | If `true`, includes the full `mirage-support` tree, i.e. no-brainer just use it all. 202 | `exclude` | _{Array of `GlobStrings,RegExps,Functions`}_ | This value gets passed directly to `broccoli-funnel`, *only* if `includeAll` is specified. Allows for excluding certain files from import. 203 | `include` | _{Array of `GlobStrings,RegExps,Functions`}_ | Passed dirctly to `broccoli-funnel`. Allows to pick only certain files to be imported into app namespace. 204 | 205 | 206 | ## Contributing 207 | 208 | ### Installation 209 | 210 | * `git clone git@github.com:elwayman02/ember-data-github.git` 211 | * `cd ember-data-github` 212 | * `yarn` 213 | 214 | ### Running 215 | 216 | * `ember serve` 217 | * Visit your app at [http://localhost:4200](http://localhost:4200). 218 | 219 | ### Running Tests 220 | 221 | * `ember test` – Runs the test suite on the current Ember version 222 | * `ember test --server` – Runs the test suite in "watch mode" 223 | * `ember try:each` – Runs the test suite against multiple Ember versions 224 | 225 | ### Building 226 | 227 | * `ember build` 228 | 229 | For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). 230 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/addon/.gitkeep -------------------------------------------------------------------------------- /addon/adapters/github-blob.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQueryRecord(query) { 5 | const repo = query.repo; 6 | const sha = query.sha; 7 | delete query.repo; 8 | delete query.sha; 9 | 10 | return `${this.get('host')}/repos/${repo}/git/blobs/${sha}`; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /addon/adapters/github-branch.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForFindRecord(id, modelName, snapshot) { 5 | return this._super(id, modelName, snapshot) 6 | .replace('branches', 'repos') 7 | .replace(/%2F/g, '/'); 8 | }, 9 | 10 | urlForQuery(query) { 11 | const repo = query.repo; 12 | delete query.repo; 13 | 14 | return `${this.get('host')}/repos/${repo}/branches`; 15 | }, 16 | 17 | urlForQueryRecord(query) { 18 | const {repo, branch} = query; 19 | delete query.repo; 20 | delete query.branch; 21 | 22 | return `${this.get('host')}/repos/${repo}/branches/${branch}`; 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /addon/adapters/github-compare.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from 'ember-data-github/adapters/github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQueryRecord(query) { 5 | const { repo, base, head } = query; 6 | delete query.repo; 7 | delete query.base; 8 | delete query.head; 9 | 10 | return `${this.get('host')}/repos/${repo}/compare/${base}...${head}`; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /addon/adapters/github-member.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from 'ember-data-github/adapters/github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQuery(query) { 5 | const org = query.org; 6 | delete query.org; 7 | 8 | return `${this.get('host')}/orgs/${org}/members`; 9 | }, 10 | }); 11 | -------------------------------------------------------------------------------- /addon/adapters/github-organization.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | buildURL(type, id, snapshot) { 5 | let builtURL = this._super(type, id, snapshot); 6 | builtURL = builtURL.replace('organizations', 'orgs'); 7 | return builtURL; 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /addon/adapters/github-pull.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQuery(query) { 5 | const repo = query.repo; 6 | delete query.repo; 7 | return `${this.get('host')}/repos/${repo}/pulls`; 8 | }, 9 | 10 | urlForQueryRecord(query) { 11 | const repo = query.repo; 12 | const pullId = query.pullId; 13 | delete query.repo; 14 | delete query.pullId; 15 | 16 | return `${this.get('host')}/repos/${repo}/pulls/${pullId}`; 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /addon/adapters/github-release.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQuery(query) { 5 | const repo = query.repo; 6 | delete query.repo; 7 | return `${this.get('host')}/repos/${repo}/releases`; 8 | }, 9 | 10 | urlForQueryRecord(query) { 11 | const repo = query.repo; 12 | const releaseId = query.releaseId; 13 | delete query.repo; 14 | delete query.releaseId; 15 | 16 | return `${this.get('host')}/repos/${repo}/releases/${releaseId}`; 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /addon/adapters/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | import GitHubAdapter from 'ember-data-github/adapters/github'; 2 | 3 | export default GitHubAdapter.extend({ 4 | urlForQueryRecord(query) { 5 | const repo = query.repo; 6 | const file = query.file; 7 | delete query.repo; 8 | delete query.file; 9 | 10 | return `${this.get('host')}/repos/${repo}/contents/${file}`; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /addon/adapters/github-repository.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForFindRecord(id/*, modelName, snapshot*/) { 5 | const isInteger = /^\d+$/; 6 | let builtURL = this._super(...arguments); 7 | if (!isInteger.test(id)) { 8 | builtURL = builtURL.replace('repositories', 'repos'); 9 | } 10 | return builtURL.replace('%2F', '/'); 11 | }, 12 | 13 | urlForQuery(query/*, modelName */) { 14 | let builtURL = this._super(...arguments); 15 | let { user } = query; 16 | 17 | delete query.user; 18 | 19 | return builtURL.replace('repositories', `users/${user}/repos`); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /addon/adapters/github-tree.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForQueryRecord(query) { 5 | const repo = query.repo; 6 | const sha = query.sha; 7 | delete query.repo; 8 | delete query.sha; 9 | 10 | if (query.recursive) { 11 | query.recursive = 1; 12 | } 13 | 14 | return `${this.get('host')}/repos/${repo}/git/trees/${sha}`; 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /addon/adapters/github-user.js: -------------------------------------------------------------------------------- 1 | import GithubAdapter from './github'; 2 | 3 | export default GithubAdapter.extend({ 4 | urlForFindRecord(id, modelName, snapshot) { 5 | const isInteger = /^\d+$/; 6 | let builtURL = this._super(id, modelName, snapshot); 7 | if (id === '#') { 8 | builtURL = builtURL.replace('users/%23', 'user'); 9 | } else if (isInteger.test(id)) { 10 | builtURL = builtURL.replace('/users/', '/user/') 11 | } 12 | return builtURL; 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /addon/adapters/github.js: -------------------------------------------------------------------------------- 1 | import { inject as service } from '@ember/service'; 2 | import { camelize } from '@ember/string'; 3 | import { computed } from '@ember/object'; 4 | import { isNone } from '@ember/utils'; 5 | import DS from 'ember-data'; 6 | import { pluralize } from 'ember-inflector'; 7 | 8 | const { RESTAdapter } = DS; 9 | 10 | export default RESTAdapter.extend({ 11 | 12 | session: service('github-session'), 13 | 14 | host: 'https://api.github.com', 15 | 16 | headers: computed('session.githubAccessToken', function () { 17 | let headers = {}; 18 | if (this.get('session.githubAccessToken')) { 19 | headers.Authorization = `token ${this.get('session.githubAccessToken')}`; 20 | } 21 | return headers; 22 | }), 23 | 24 | pathForType(type) { 25 | return camelize(pluralize(type.replace('github', ''))); 26 | }, 27 | 28 | // Parse Link response header out into an object like: 29 | // { 30 | // first: 'https://api.github.com/resouce?page=1&per_page=5', 31 | // next: 'https://api.github.com/resouce?page=3&per_page=5', 32 | // prev: 'https://api.github.com/resouce?page=1&per_page=5', 33 | // last: 'https://api.github.com/resouce?page=4&per_page=5', 34 | // } 35 | // 36 | handleResponse(status, headers, payload, requestData) { 37 | const linkHeader = headers.link || headers.Link; 38 | const result = this._super(status, headers, payload, requestData); 39 | if (isNone(linkHeader)) { 40 | return result; 41 | } 42 | 43 | const links = linkHeader.split(', ').reduce((memo, link) => { 44 | let [url, rel] = link.split('; '); 45 | 46 | try { 47 | [, url] = url.match(/<(.+)>/); 48 | //eslint-disable-next-line no-useless-escape 49 | [, rel] = rel.match(/rel=\"(.+)\"/); 50 | } catch(error) { 51 | // Any error in parsing should not cause the application to error 52 | return; 53 | } 54 | 55 | memo[rel] = url; 56 | return memo; 57 | }, {}); 58 | 59 | result.links = links; 60 | return result; 61 | } 62 | }); 63 | -------------------------------------------------------------------------------- /addon/initializers/github-inflector-rules.js: -------------------------------------------------------------------------------- 1 | import Inflector from 'ember-inflector'; 2 | 3 | export function initialize() { 4 | const inflector = Inflector.inflector; 5 | inflector.uncountable('githubRepositoryContents'); 6 | } 7 | 8 | export default { 9 | name: 'github-inflector-rules', 10 | initialize 11 | }; 12 | -------------------------------------------------------------------------------- /addon/models/github-blob.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | 4 | export default Model.extend({ 5 | sha: attr('string'), 6 | url: attr('string'), 7 | content: attr('string'), 8 | encoding: attr('string'), 9 | size: attr('number') 10 | }); 11 | -------------------------------------------------------------------------------- /addon/models/github-branch.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | 4 | export default Model.extend({ 5 | name: attr('string'), 6 | commit: attr(), 7 | protected: attr('boolean') 8 | }); 9 | -------------------------------------------------------------------------------- /addon/models/github-commit.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | 4 | export default Model.extend({ 5 | sha: attr('string'), 6 | url: attr('string'), 7 | parents: attr(), 8 | commit: attr(), 9 | author: attr(), 10 | committer: attr() 11 | }); 12 | -------------------------------------------------------------------------------- /addon/models/github-compare.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { belongsTo, hasMany } from 'ember-data/relationships'; 4 | 5 | export default Model.extend({ 6 | aheadBy: attr('number'), 7 | behindBy: attr('number'), 8 | status: attr('string'), 9 | totalCommits: attr('number'), 10 | diffUrl: attr('string'), 11 | htmlUrl: attr('string'), 12 | patchUrl: attr('string'), 13 | permalinkUrl: attr('string'), 14 | 15 | baseCommit: belongsTo('github-commit'), 16 | mergeBaseCommit: belongsTo('github-commit'), 17 | commits: hasMany('github-commit'), 18 | files: hasMany('github-file') 19 | }); 20 | -------------------------------------------------------------------------------- /addon/models/github-file.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | 4 | export default Model.extend({ 5 | additions: attr('number'), 6 | blobUrl: attr('string'), 7 | changes: attr('number'), 8 | deletions: attr('number'), 9 | filename: attr('string'), 10 | patch: attr('string'), 11 | rawUrl: attr('string'), 12 | sha: attr('string'), 13 | status: attr('string') 14 | }); 15 | -------------------------------------------------------------------------------- /addon/models/github-member.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | 4 | export default Model.extend({ 5 | login: attr('string'), 6 | avatarUrl: attr('string'), 7 | gravatarId: attr('string'), 8 | type: attr('string'), 9 | siteAdmin: attr('boolean'), 10 | url: attr('string') 11 | }); 12 | -------------------------------------------------------------------------------- /addon/models/github-organization.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { hasMany } from 'ember-data/relationships'; 4 | import { deprecate } from '@ember/application/deprecations'; 5 | import { computed } from '@ember/object'; 6 | 7 | export default Model.extend({ 8 | login: attr('string'), 9 | name: attr('string'), 10 | avatarUrl: attr('string'), 11 | 12 | members: hasMany('github-member'), 13 | repositories: hasMany('github-repository'), 14 | 15 | githubUsers: computed('members.[]', function() { 16 | deprecate('The githubUsers property on the github-organization model has been deprecated. Please use the members property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); 17 | return this.get('members'); 18 | }), 19 | githubRepositories: computed('repositories.[]', function() { 20 | deprecate('The githubRepositories property on the github-organization model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); 21 | return this.get('repositories'); 22 | }) 23 | }); 24 | -------------------------------------------------------------------------------- /addon/models/github-pull.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { belongsTo } from 'ember-data/relationships'; 4 | 5 | export default Model.extend({ 6 | number: attr('number'), 7 | title: attr('string'), 8 | state: attr('string'), 9 | htmlUrl: attr('string'), 10 | body: attr('string'), 11 | createdAt: attr('date'), 12 | updatedAt: attr('date'), 13 | closedAt: attr('date'), 14 | mergedAt: attr('date'), 15 | userLogin: attr('string'), 16 | userAvatarUrl: attr('string'), 17 | 18 | user: belongsTo('github-user', { inverse: null }) 19 | }); 20 | -------------------------------------------------------------------------------- /addon/models/github-release.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { belongsTo } from 'ember-data/relationships'; 4 | import { deprecate } from '@ember/application/deprecations'; 5 | import { computed } from '@ember/object'; 6 | 7 | export default Model.extend({ 8 | name: attr('string'), 9 | url: attr('string'), 10 | htmlUrl: attr('string'), 11 | assetsUrl: attr('string'), 12 | uploadUrl: attr('string'), 13 | tarballUrl: attr('string'), 14 | zipballUrl: attr('string'), 15 | tagName: attr('string'), 16 | targetCommitish: attr('string'), 17 | body: attr('string'), 18 | draft: attr('boolean'), 19 | prerelease: attr('boolean'), 20 | createdAt: attr('date'), 21 | publishedAt: attr('date'), 22 | 23 | author: belongsTo('github-user', { inverse: null }), 24 | user: computed('author', function() { 25 | deprecate('The user property on the github-release model has been deprecated. Please use the author property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); 26 | return this.get('author'); 27 | }), 28 | repository: belongsTo('github-repository') 29 | }); 30 | -------------------------------------------------------------------------------- /addon/models/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | import attr from 'ember-data/attr'; 2 | import Model from 'ember-data/model'; 3 | 4 | export default Model.extend({ 5 | content: attr('string'), 6 | downloadUrl: attr('string'), 7 | encoding: attr('string'), 8 | gitUrl: attr('string'), 9 | htmlUrl: attr('string'), 10 | name: attr('string'), 11 | path: attr('string'), 12 | sha: attr('string'), 13 | size: attr('number'), 14 | type: attr('string'), 15 | url: attr('string') 16 | }); 17 | -------------------------------------------------------------------------------- /addon/models/github-repository.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { belongsTo, hasMany } from 'ember-data/relationships'; 4 | 5 | export default Model.extend({ 6 | description: attr('string'), 7 | fullName: attr('string'), 8 | homepage: attr('string'), 9 | language: attr('string'), 10 | name: attr('string'), 11 | 12 | forks: attr('number'), 13 | forksCount: attr('number'), 14 | openIssues: attr('number'), 15 | openIssuesCount: attr('number'), 16 | size: attr('number'), 17 | stargazersCount: attr('number'), 18 | watchers: attr('number'), 19 | watchersCount: attr('number'), 20 | 21 | fork: attr('boolean'), 22 | hasDownloads: attr('boolean'), 23 | hasIssues: attr('boolean'), 24 | hasPages: attr('boolean'), 25 | hasProjects: attr('boolean'), 26 | hasWiki: attr('boolean'), 27 | private: attr('boolean'), 28 | 29 | createdAt: attr('date'), 30 | updatedAt: attr('date'), 31 | pushedAt: attr('date'), 32 | 33 | cloneUrl: attr('string'), 34 | gitUrl: attr('string'), 35 | sshUrl: attr('string'), 36 | svnUrl: attr('string'), 37 | 38 | // Urls 39 | archiveUrl: attr('string'), 40 | assigneesUrl: attr('string'), 41 | blobsUrl: attr('string'), 42 | branchesUrl: attr('string'), 43 | collaboratorsUrl: attr('string'), 44 | commentsUrl: attr('string'), 45 | commitsUrl: attr('string'), 46 | compareUrl: attr('string'), 47 | contentsUrl: attr('string'), 48 | contributorsUrl: attr('string'), 49 | deploymentsUrl: attr('string'), 50 | downloadsUrl: attr('string'), 51 | eventsUrl: attr('string'), 52 | forksUrl: attr('string'), 53 | gitCommitsUrl: attr('string'), 54 | gitRefsUrl: attr('string'), 55 | gitTagsUrl: attr('string'), 56 | hooksUrl: attr('string'), 57 | htmlUrl: attr('string'), 58 | issueCommentUrl: attr('string'), 59 | issueEventsUrl: attr('string'), 60 | issuesUrl: attr('string'), 61 | keysUrl: attr('string'), 62 | labelsUrl: attr('string'), 63 | mergesUrl: attr('string'), 64 | milestonesUrl: attr('string'), 65 | notificationsUrl: attr('string'), 66 | pullsUrl: attr('string'), 67 | releasesUrl: attr('string'), 68 | statusesUrl: attr('string'), 69 | subscribersUrl: attr('string'), 70 | subscriptionUrl: attr('string'), 71 | tagsUrl: attr('string'), 72 | teamsUrl: attr('string'), 73 | treesUrl: attr('string'), 74 | url: attr('string'), 75 | 76 | // Embedded Objects 77 | branches: hasMany('github-branch'), 78 | defaultBranch: belongsTo('github-branch', { inverse: null }), 79 | license: attr(), // TODO: Make into a real model 80 | owner: belongsTo('github-user'), 81 | pulls: hasMany('github-pull'), 82 | releases: hasMany('github-release') 83 | }); 84 | -------------------------------------------------------------------------------- /addon/models/github-tree.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { hasMany } from 'ember-data/relationships'; 4 | 5 | export default Model.extend({ 6 | sha: attr('string'), 7 | url: attr('string'), 8 | files: attr(), // object 9 | directories: attr(), // object 10 | truncated: attr('boolean'), 11 | 12 | blobs: hasMany('github-blob'), 13 | trees: hasMany('github-tree') 14 | }); 15 | -------------------------------------------------------------------------------- /addon/models/github-user.js: -------------------------------------------------------------------------------- 1 | import Model from 'ember-data/model'; 2 | import attr from 'ember-data/attr'; 3 | import { hasMany } from 'ember-data/relationships'; 4 | import { deprecate } from '@ember/application/deprecations'; 5 | import { computed } from '@ember/object'; 6 | 7 | export default Model.extend({ 8 | avatarUrl: attr('string'), 9 | bio: attr('string'), 10 | blog: attr('string'), 11 | company: attr('string'), 12 | email: attr('string'), 13 | gravatarId: attr('string'), 14 | location: attr('string'), 15 | login: attr('string'), 16 | name: attr('string'), 17 | type: attr('string'), 18 | 19 | followers: attr('number'), 20 | following: attr('number'), 21 | publicGists: attr('number'), 22 | publicRepos: attr('number'), 23 | 24 | createdAt: attr('date'), 25 | updatedAt: attr('date'), 26 | 27 | hireable: attr('boolean'), 28 | siteAdmin: attr('boolean'), 29 | 30 | // Urls 31 | eventsUrl: attr('string'), 32 | followersUrl: attr('string'), 33 | followingUrl: attr('string'), 34 | gistsUrl: attr('string'), 35 | htmlUrl: attr('string'), 36 | organizationsUrl: attr('string'), 37 | receivedEventsUrl: attr('string'), 38 | reposUrl: attr('string'), 39 | starredUrl: attr('string'), 40 | subscriptionsUrl: attr('string'), 41 | url: attr('string'), 42 | 43 | // Embedded Objects 44 | repositories: hasMany('github-repository'), 45 | githubRepositories: computed('repositories.[]', function() { 46 | deprecate('The githubRepositories property on the github-user model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); 47 | return this.get('repositories'); 48 | }), 49 | }); 50 | -------------------------------------------------------------------------------- /addon/serializers/github-blob.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GithubSerializer.extend({}); 4 | -------------------------------------------------------------------------------- /addon/serializers/github-branch.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GithubSerializer.extend({ 4 | normalize(modelClass, resourceHash, prop) { 5 | resourceHash.id = resourceHash.recordId || resourceHash.commit.url.replace('https://api.github.com/repos/', '').replace(/\/commits\/.+/, `/branches/${resourceHash.name}`); 6 | 7 | return this._super(modelClass, resourceHash, prop); 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /addon/serializers/github-compare.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | import GithubSerializer from 'ember-data-github/serializers/github'; 3 | 4 | const { EmbeddedRecordsMixin } = DS; 5 | 6 | export default GithubSerializer.extend(EmbeddedRecordsMixin, { 7 | attrs: { 8 | commits: { embedded: 'always' }, 9 | files: { embedded: 'always' }, 10 | baseCommit: { embedded: 'always' }, 11 | mergeBaseCommit: { embedded: 'always' } 12 | }, 13 | 14 | normalize(modelClass, resourceHash, prop) { 15 | resourceHash.id = resourceHash.diff_url; 16 | 17 | return this._super(modelClass, resourceHash, prop); 18 | }, 19 | 20 | extractRelationships(modelClass, resourceHash) { 21 | resourceHash.base_commit.type = 'github-commit'; 22 | resourceHash.base_commit.id = resourceHash['base_commit']['sha']; 23 | 24 | resourceHash.merge_base_commit.type = 'github-commit'; 25 | resourceHash.merge_base_commit.id = resourceHash['merge_base_commit']['sha']; 26 | 27 | resourceHash.commits.forEach((commit) => { 28 | commit.type = 'github-commit'; 29 | commit.id = commit.sha; 30 | }); 31 | 32 | resourceHash.files.forEach((file) => { 33 | file.type = 'github-file'; 34 | file.id = file.sha; 35 | }); 36 | 37 | return this._super(modelClass, resourceHash); 38 | } 39 | }); 40 | -------------------------------------------------------------------------------- /addon/serializers/github-member.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from './github'; 2 | 3 | export default GithubSerializer.extend({}); 4 | -------------------------------------------------------------------------------- /addon/serializers/github-organization.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GithubSerializer.extend({ 4 | normalize(modelClass, resourceHash, prop) { 5 | resourceHash.id = resourceHash.recordId || resourceHash.login; 6 | resourceHash.links = { 7 | members: resourceHash.members_url.replace(/\{\/member\}/, ''), 8 | repositories: resourceHash.repos_url 9 | }; 10 | return this._super(modelClass, resourceHash, prop); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /addon/serializers/github-pull.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | import DS from 'ember-data'; 3 | 4 | const { EmbeddedRecordsMixin } = DS; 5 | 6 | export default GithubSerializer.extend(EmbeddedRecordsMixin, { 7 | attrs: { 8 | user: { embedded: 'always' } 9 | }, 10 | 11 | normalize(modelClass, resourceHash, prop) { 12 | resourceHash.user_avatar_url = resourceHash.user.avatar_url; 13 | resourceHash.user_login = resourceHash.user.login; 14 | 15 | return this._super(modelClass, resourceHash, prop); 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /addon/serializers/github-release.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | import DS from 'ember-data'; 3 | 4 | const { EmbeddedRecordsMixin } = DS; 5 | 6 | export default GithubSerializer.extend(EmbeddedRecordsMixin, { 7 | attrs: { 8 | author: { embedded: 'always' } 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /addon/serializers/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | import GitHubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GitHubSerializer.extend({ 4 | extractId(modelClass, resourceHash) { 5 | return resourceHash.url; 6 | }, 7 | 8 | modelNameFromPayloadKey() { 9 | return 'github-repository-contents'; 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /addon/serializers/github-repository.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | import DS from 'ember-data'; 3 | 4 | const { EmbeddedRecordsMixin } = DS; 5 | 6 | export default GithubSerializer.extend(EmbeddedRecordsMixin, { 7 | attrs: { 8 | owner: { embedded: 'always' } 9 | }, 10 | 11 | normalize(modelClass, resourceHash, prop) { 12 | resourceHash.id = resourceHash.recordId || resourceHash.full_name; 13 | resourceHash.links = { 14 | defaultBranch: `${resourceHash.url}/branches/${resourceHash.default_branch}`, 15 | branches: `${resourceHash.url}/branches`, 16 | pulls: `${resourceHash.url}/pulls`, 17 | releases: `${resourceHash.url}/releases` 18 | }; 19 | return this._super(modelClass, resourceHash, prop); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /addon/serializers/github-tree.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GithubSerializer.extend({ 4 | normalize(modelClass, resourceHash, prop) { 5 | let blobItems = resourceHash.tree 6 | .filter(item => item.type === 'blob'); 7 | let treeItems = resourceHash.tree 8 | .filter(item => item.type === 'tree'); 9 | 10 | resourceHash.id = resourceHash.sha; 11 | resourceHash.files = blobItems.reduce((files, blob) => { 12 | files[blob.path] = blob.sha; 13 | return files; 14 | }, {}); 15 | resourceHash.directories = treeItems.reduce((files, tree) => { 16 | files[tree.path] = tree.sha; 17 | return files; 18 | }, {}); 19 | resourceHash.links = { 20 | blobs: blobItems.map(blob => blob.url), 21 | trees: treeItems.map(tree => tree.url) 22 | } 23 | 24 | return this._super(modelClass, resourceHash, prop); 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /addon/serializers/github-user.js: -------------------------------------------------------------------------------- 1 | import GithubSerializer from 'ember-data-github/serializers/github'; 2 | 3 | export default GithubSerializer.extend({ 4 | normalizeResponse(store, primaryModelClass, payload, id, requestType) { 5 | if (id === '#') { 6 | payload.repos_url = payload.repos_url.replace(`users/${payload.login}`, 'user'); 7 | } 8 | return this._super(store, primaryModelClass, payload, id, requestType); 9 | }, 10 | 11 | normalize(modelClass, resourceHash, prop) { 12 | resourceHash.id = resourceHash.recordId || resourceHash.login; 13 | resourceHash.links = { 14 | repositories: resourceHash.repos_url 15 | } 16 | 17 | return this._super(modelClass, resourceHash, prop); 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /addon/serializers/github.js: -------------------------------------------------------------------------------- 1 | import { isArray } from '@ember/array'; 2 | import { get } from '@ember/object'; 3 | import { isNone } from '@ember/utils'; 4 | import { pluralize } from 'ember-inflector'; 5 | import DS from 'ember-data'; 6 | import { decamelize } from '@ember/string'; 7 | 8 | export default DS.RESTSerializer.extend({ 9 | keyForAttribute(attr) { 10 | return decamelize(attr); 11 | }, 12 | 13 | normalizeResponse(store, primaryModelClass, payload, id, requestType) { 14 | payload.recordId = id; 15 | let wrappedPayload = {}; 16 | let fieldName = primaryModelClass.modelName; 17 | if (isArray(payload)) { 18 | fieldName = pluralize(fieldName); 19 | } 20 | wrappedPayload[fieldName] = payload; 21 | return this._super(store, primaryModelClass, wrappedPayload, id, requestType); 22 | }, 23 | 24 | // Add metadata to the response for use with pagination. Formatted like: 25 | // { 26 | // first: { page: 1, per_page: 5 } 27 | // next: { page: 3, per_page: 5 }, 28 | // prev: { page: 1, per_page: 5 }, 29 | // last: { page: 3, per_page: 5 } 30 | // } 31 | // 32 | extractMeta(store, modelClass, payload) { 33 | const links = get(payload, `${pluralize(modelClass.modelName)}.links`); 34 | 35 | if (isNone(links)) { 36 | return; 37 | } 38 | 39 | return Object.keys(links).reduce((meta, name) => { 40 | const link = links[name]; 41 | const qs = link.split('?').pop(); 42 | 43 | meta[name] = qs.split('&').reduce((memo, str) => { 44 | const [key, value] = str.split('='); 45 | memo[key] = parseInt(value, 10); 46 | return memo; 47 | }, {}); 48 | 49 | return meta; 50 | }, {}); 51 | } 52 | }); 53 | -------------------------------------------------------------------------------- /addon/services/github-session.js: -------------------------------------------------------------------------------- 1 | import Service from '@ember/service'; 2 | 3 | export default Service.extend({ 4 | githubAccessToken: '' 5 | }); 6 | -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/app/.gitkeep -------------------------------------------------------------------------------- /app/adapters/github-blob.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/adapters/github-blob'; 2 | -------------------------------------------------------------------------------- /app/adapters/github-branch.js: -------------------------------------------------------------------------------- 1 | import githubBranch from 'ember-data-github/adapters/github-branch'; 2 | 3 | export default githubBranch; 4 | -------------------------------------------------------------------------------- /app/adapters/github-compare.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/adapters/github-compare'; 2 | -------------------------------------------------------------------------------- /app/adapters/github-member.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/adapters/github-member'; 2 | -------------------------------------------------------------------------------- /app/adapters/github-organization.js: -------------------------------------------------------------------------------- 1 | import githubOrganization from 'ember-data-github/adapters/github-organization'; 2 | 3 | export default githubOrganization; 4 | -------------------------------------------------------------------------------- /app/adapters/github-pull.js: -------------------------------------------------------------------------------- 1 | import githubPull from 'ember-data-github/adapters/github-pull'; 2 | 3 | export default githubPull; 4 | -------------------------------------------------------------------------------- /app/adapters/github-release.js: -------------------------------------------------------------------------------- 1 | import githubRelease from 'ember-data-github/adapters/github-release'; 2 | 3 | export default githubRelease; 4 | -------------------------------------------------------------------------------- /app/adapters/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/adapters/github-repository-contents'; 2 | -------------------------------------------------------------------------------- /app/adapters/github-repository.js: -------------------------------------------------------------------------------- 1 | import githubRepository from 'ember-data-github/adapters/github-repository'; 2 | 3 | export default githubRepository; 4 | -------------------------------------------------------------------------------- /app/adapters/github-tree.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/adapters/github-tree'; 2 | -------------------------------------------------------------------------------- /app/adapters/github-user.js: -------------------------------------------------------------------------------- 1 | import githubUser from 'ember-data-github/adapters/github-user'; 2 | 3 | export default githubUser; 4 | -------------------------------------------------------------------------------- /app/adapters/github.js: -------------------------------------------------------------------------------- 1 | import github from 'ember-data-github/adapters/github'; 2 | 3 | export default github; 4 | -------------------------------------------------------------------------------- /app/initializers/github-inflector-rules.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/initializers/github-inflector-rules'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-blob.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-blob'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-branch.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-branch'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-commit.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-commit'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-compare.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-compare'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-file.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-file'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-member.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-member'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-organization.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-organization'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-pull.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-pull'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-release.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-release'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-repository.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-repository'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-tree.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-tree'; 2 | -------------------------------------------------------------------------------- /app/mirage-factories/github-user.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-factories/github-user'; 2 | -------------------------------------------------------------------------------- /app/mirage-models/github-commit.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-models/github-commit'; 2 | -------------------------------------------------------------------------------- /app/mirage-models/github-compare.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-models/github-compare'; 2 | -------------------------------------------------------------------------------- /app/mirage-models/github-file.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-models/github-file'; 2 | -------------------------------------------------------------------------------- /app/mirage-models/github-member.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-models/github-member'; 2 | -------------------------------------------------------------------------------- /app/mirage-models/github-repository.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/mirage-models/github-repository'; 2 | -------------------------------------------------------------------------------- /app/models/github-blob.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-blob'; 2 | -------------------------------------------------------------------------------- /app/models/github-branch.js: -------------------------------------------------------------------------------- 1 | import githubBranch from 'ember-data-github/models/github-branch'; 2 | 3 | export default githubBranch; 4 | -------------------------------------------------------------------------------- /app/models/github-commit.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-commit'; 2 | -------------------------------------------------------------------------------- /app/models/github-compare.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-compare'; 2 | -------------------------------------------------------------------------------- /app/models/github-file.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-file'; 2 | -------------------------------------------------------------------------------- /app/models/github-member.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-member'; 2 | -------------------------------------------------------------------------------- /app/models/github-organization.js: -------------------------------------------------------------------------------- 1 | import githubOrganization from 'ember-data-github/models/github-organization'; 2 | 3 | export default githubOrganization; 4 | -------------------------------------------------------------------------------- /app/models/github-pull.js: -------------------------------------------------------------------------------- 1 | import githubPull from 'ember-data-github/models/github-pull'; 2 | 3 | export default githubPull; 4 | -------------------------------------------------------------------------------- /app/models/github-release.js: -------------------------------------------------------------------------------- 1 | import githubRelease from 'ember-data-github/models/github-release'; 2 | 3 | export default githubRelease; 4 | -------------------------------------------------------------------------------- /app/models/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-repository-contents'; 2 | -------------------------------------------------------------------------------- /app/models/github-repository.js: -------------------------------------------------------------------------------- 1 | import githubRepository from 'ember-data-github/models/github-repository'; 2 | 3 | export default githubRepository; 4 | -------------------------------------------------------------------------------- /app/models/github-tree.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/models/github-tree'; 2 | -------------------------------------------------------------------------------- /app/models/github-user.js: -------------------------------------------------------------------------------- 1 | import githubUser from 'ember-data-github/models/github-user'; 2 | 3 | export default githubUser; 4 | -------------------------------------------------------------------------------- /app/serializers/github-blob.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/serializers/github-blob'; 2 | -------------------------------------------------------------------------------- /app/serializers/github-branch.js: -------------------------------------------------------------------------------- 1 | import githubBranch from 'ember-data-github/serializers/github-branch'; 2 | 3 | export default githubBranch; 4 | -------------------------------------------------------------------------------- /app/serializers/github-compare.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/serializers/github-compare'; 2 | -------------------------------------------------------------------------------- /app/serializers/github-member.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/serializers/github-member'; 2 | -------------------------------------------------------------------------------- /app/serializers/github-organization.js: -------------------------------------------------------------------------------- 1 | import githubOrganization from 'ember-data-github/serializers/github-organization'; 2 | 3 | export default githubOrganization; 4 | -------------------------------------------------------------------------------- /app/serializers/github-pull.js: -------------------------------------------------------------------------------- 1 | import githubPull from 'ember-data-github/serializers/github-pull'; 2 | 3 | export default githubPull; 4 | -------------------------------------------------------------------------------- /app/serializers/github-release.js: -------------------------------------------------------------------------------- 1 | import githubRelease from 'ember-data-github/serializers/github-release'; 2 | 3 | export default githubRelease; 4 | -------------------------------------------------------------------------------- /app/serializers/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/serializers/github-repository-contents'; 2 | -------------------------------------------------------------------------------- /app/serializers/github-repository.js: -------------------------------------------------------------------------------- 1 | import githubRepository from 'ember-data-github/serializers/github-repository'; 2 | 3 | export default githubRepository; 4 | -------------------------------------------------------------------------------- /app/serializers/github-tree.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/serializers/github-tree'; 2 | -------------------------------------------------------------------------------- /app/serializers/github-user.js: -------------------------------------------------------------------------------- 1 | import githubUser from 'ember-data-github/serializers/github-user'; 2 | 3 | export default githubUser; 4 | -------------------------------------------------------------------------------- /app/serializers/github.js: -------------------------------------------------------------------------------- 1 | import github from 'ember-data-github/serializers/github'; 2 | 3 | export default github; 4 | -------------------------------------------------------------------------------- /app/services/github-session.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-data-github/services/github-session'; 2 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | useYarn: true, 13 | scenarios: [ 14 | { 15 | name: 'ember-lts-2.12', 16 | npm: { 17 | devDependencies: { 18 | 'ember-source': '~2.12.0', 19 | 'ember-data': '>=3.0.0 <=3.12' 20 | } 21 | } 22 | }, 23 | { 24 | name: 'ember-lts-2.16', 25 | npm: { 26 | devDependencies: { 27 | 'ember-source': '~2.16.0' 28 | } 29 | } 30 | }, 31 | { 32 | name: 'ember-lts-2.18', 33 | npm: { 34 | devDependencies: { 35 | 'ember-source': '~2.18.0' 36 | } 37 | } 38 | }, 39 | { 40 | name: 'ember-release', 41 | npm: { 42 | devDependencies: { 43 | 'ember-source': urls[0] 44 | } 45 | } 46 | }, 47 | { 48 | name: 'ember-beta', 49 | npm: { 50 | devDependencies: { 51 | 'ember-source': urls[1] 52 | } 53 | } 54 | }, 55 | { 56 | name: 'ember-canary', 57 | npm: { 58 | devDependencies: { 59 | 'ember-source': urls[2] 60 | } 61 | } 62 | }, 63 | { 64 | name: 'ember-default', 65 | npm: { 66 | devDependencies: {} 67 | } 68 | } 69 | ] 70 | }; 71 | }); 72 | }; 73 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { 5 | 'ember-cli-mirage': { 6 | trackRequests: true 7 | } 8 | }; 9 | }; 10 | -------------------------------------------------------------------------------- /config/release.js: -------------------------------------------------------------------------------- 1 | /* jshint node:true */ 2 | 3 | module.exports = { 4 | manifest: ['package.json', 'bower.json'], 5 | publish: true 6 | }; 7 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | 'ember-bootstrap': { 9 | 'bootstrapVersion': 4, 10 | 'importBootstrapFont': false, 11 | 'importBootstrapCSS': false 12 | } 13 | }); 14 | 15 | /* 16 | This build file specifies the options for the dummy test app of this 17 | addon, located in `/tests/dummy` 18 | This build file does *not* influence how the addon or the app using it 19 | behave. You most likely want to be modifying `./index.js` or app's build file 20 | */ 21 | 22 | return app.toTree(); 23 | }; 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | const path = require('path'); 5 | const MergeTrees = require('broccoli-merge-trees'); 6 | const Funnel = require('broccoli-funnel'); 7 | 8 | module.exports = { 9 | name: 'ember-data-github', 10 | 11 | included(app) { 12 | this.addonConfig = this.app.project.config(app.env)['ember-cli-mirage'] || {}; 13 | this.mirageSupportDirectory = path.join(this.root, 'mirage-support'); 14 | 15 | this._super.included.apply(this, arguments); 16 | }, 17 | 18 | treeForApp(appTree) { 19 | var trees = [appTree]; 20 | 21 | if (this._shouldIncludeMirageFiles()) { 22 | let mirageFolderName = 'mirage-support'; 23 | let mirageOptions = this.app.options[mirageFolderName]; 24 | let isDummyApp = this.app.name === 'dummy'; 25 | 26 | if (isDummyApp || mirageOptions) { 27 | if (isDummyApp || mirageOptions.includeAll) { 28 | trees.push(new Funnel(this.mirageSupportDirectory, { 29 | destDir: 'mirage', 30 | exclude: mirageOptions && mirageOptions.exclude || [] 31 | })); 32 | } else if (mirageOptions.include) { 33 | trees.push(new Funnel(this.mirageSupportDirectory, { 34 | destDir: 'mirage', 35 | include: mirageOptions.include 36 | })); 37 | } 38 | } 39 | } 40 | 41 | return new MergeTrees(trees, { 42 | overwrite: true 43 | }); 44 | }, 45 | 46 | _shouldIncludeMirageFiles() { 47 | if (process.env.EMBER_CLI_FASTBOOT) { 48 | return false; 49 | } 50 | 51 | let enabledInProd = this.app.env === 'production' && this.addonConfig.enabled, 52 | explicitExcludeFiles = this.addonConfig.excludeFilesFromBuild; 53 | 54 | return enabledInProd || (this.app.env !== 'production' && explicitExcludeFiles !== true);//eslint-disable-line 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /mirage-support/factories/github-blob.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | sha: '7fd1a60b01f91b314f59955a4e4d4e80d8edf11d', 5 | url() { 6 | return `https://api.github.com/repos/user1/repository1/git/blobs/${this.sha}`; 7 | }, 8 | content: 'IyBFZGl0b3JDb25maWcgaGVscHMgZGV2ZWxvcGVycyBkZWZpbmUgYW5kIG1h\naW50YWluIGNvbnNpc3RlbnQKIyBjb2Rpbmcgc3R5bGVzIGJldHdlZW4gZGlm\nZmVyZW50IGVkaXRvcnMgYW5kIElERXMKIyBlZGl0b3Jjb25maWcub3JnCgpy\nb290ID0gdHJ1ZQoKClsqXQplbmRfb2ZfbGluZSA9IGxmCmNoYXJzZXQgPSB1\ndGYtOAp0cmltX3RyYWlsaW5nX3doaXRlc3BhY2UgPSB0cnVlCmluc2VydF9m\naW5hbF9uZXdsaW5lID0gdHJ1ZQppbmRlbnRfc3R5bGUgPSBzcGFjZQppbmRl\nbnRfc2l6ZSA9IDIKClsqLmhic10KaW5zZXJ0X2ZpbmFsX25ld2xpbmUgPSBm\nYWxzZQoKWyoue2RpZmYsbWR9XQp0cmltX3RyYWlsaW5nX3doaXRlc3BhY2Ug\nPSBmYWxzZQo=\n', 9 | encoding: 'base64', 10 | size: 368 11 | }); 12 | -------------------------------------------------------------------------------- /mirage-support/factories/github-branch.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | name: function(i) { 5 | return `branch${i}`; 6 | }, 7 | commit: { 8 | url: function(i) { 9 | return `https://api.github.com/repos/octocat/Hello-World/git/commits/${i}fd1a60b01f91b314f59955a4e4d4e80d8edf11d`; 10 | } 11 | }, 12 | protected: true 13 | }); 14 | -------------------------------------------------------------------------------- /mirage-support/factories/github-commit.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | id() { 6 | return this.sha; 7 | }, 8 | sha: function(i) { 9 | return `${i}51a87a3027a3ab2asfsfb23dd24186dfd7d587` 10 | }, 11 | commit: { 12 | message: faker.random.words() 13 | }, 14 | url: 'https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e' 15 | }); 16 | -------------------------------------------------------------------------------- /mirage-support/factories/github-compare.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | ahead_by: faker.random.number(), 6 | behind_by: faker.random.number(), 7 | status: 'behind', 8 | total_commits: faker.random.number(), 9 | diff_url: 'https://github.com/octocat/Hello-World/compare/master...topic.diff', 10 | html_url: 'https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e', 11 | patch_url: 'https://github.com/octocat/Hello-World/compare/master...topic.patch', 12 | permalink_url: 'https://github.com/octocat/Hello-World/compare/octocat:bbcd538c8e72b8c175046e27cc8f907076331401...octocat:0328041d1152db8ae77652d1618a02e57f745f17', 13 | 14 | afterCreate(githubCompare, server) { 15 | // manually setup related records 16 | githubCompare.baseCommit = server.create('github-commit'); 17 | githubCompare.mergeBaseCommit = server.create('github-commit'); 18 | githubCompare.commits = server.createList('github-commit', 3); 19 | githubCompare.files = server.createList('github-file', 3); 20 | githubCompare.save(); 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /mirage-support/factories/github-file.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | id() { 6 | return this.sha; 7 | }, 8 | additions: faker.random.number(), 9 | blob_url: 'https://github.com/octocat/Hello-World/blob/7ca483543807a51b6079e54ac4cc392bc29ae284/file1.txt', 10 | changes: faker.random.number(), 11 | deletions: faker.random.number(), 12 | filename: 'file1.text', 13 | patch: '@@ -29,7 +29,7 @@\n.....', 14 | raw_url: 'https://github.com/octocat/Hello-World/raw/7ca483543807a51b6079e54ac4cc392bc29ae284/file1.txt', 15 | sha: function(i) { 16 | return `51a87a3027a3ab2asfsfb23dd24186dfd7d587${i}` 17 | }, 18 | status: 'modified' 19 | }); 20 | -------------------------------------------------------------------------------- /mirage-support/factories/github-member.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | login: function(i) { 5 | return `member${i}`; 6 | }, 7 | type: 'github-member', 8 | avatar_url: function(i) { 9 | return `member${i}-avatar.gif`; 10 | }, 11 | gravatar_id: '', 12 | site_admin: false, 13 | url: function(i) { 14 | return `https://api.github.com/users/member${i}`; 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /mirage-support/factories/github-organization.js: -------------------------------------------------------------------------------- 1 | import { Factory, trait } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | login: function(i) { 5 | return `organization${i}`; 6 | }, 7 | name: function(i) { 8 | return `Organization ${i}`; 9 | }, 10 | avatar_url: function(i) { 11 | return `organization${i}-avatar.gif`; 12 | }, 13 | members_url: function(i) { 14 | return `https://api.github.com/orgs/organization${i}/members{/member}`; 15 | }, 16 | repos_url: function(i) { 17 | return `https://api.github.com/orgs/organization${i}/repos`; 18 | }, 19 | 20 | withRepositories: trait({ 21 | afterCreate(organization) { 22 | server.createList('githubRepository', 2, { owner: organization }); 23 | } 24 | }), 25 | withMembers: trait({ 26 | afterCreate(organization) { 27 | server.createList('githubMember', 2, { organization }); 28 | } 29 | }) 30 | }); 31 | -------------------------------------------------------------------------------- /mirage-support/factories/github-pull.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | number: faker.random.number(), 6 | title: faker.lorem.words(), 7 | state: 'open', 8 | html_url: function(i) { 9 | return `https://github.com/octocat/Hello-World/pull/${i}`; 10 | }, 11 | body: faker.lorem.words(), 12 | created_at: faker.date.past(), 13 | updated_at: faker.date.past(), 14 | closed_at: faker.date.past(), 15 | merged_at: faker.date.past(), 16 | 17 | afterCreate(pull, server) { 18 | pull.update('user', server.create('github-user')); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /mirage-support/factories/github-release.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | tag_name: function(i) { 6 | return `v1.0.${i}`; 7 | }, 8 | url: function(i) { 9 | return `https://api.github.com/repos/user1/repository1/releases/${i}`; 10 | }, 11 | html_url: function(i) { 12 | return `https://github.com/repos/user1/repository1/releases/$v1.0.${i}`; 13 | }, 14 | assets_url: function(i) { 15 | return `https://api.github.com/repos/user1/repository1/releases/${i}/assets`; 16 | }, 17 | upload_url: function(i) { 18 | return `https://uploads.github.com/repos/user1/repository1/releases/${i}/assets{?name,label}`; 19 | }, 20 | tarball_url: function(i) { 21 | return `https://api.github.com/repos/user1/repository1/tarball/v1.0.${i}`; 22 | }, 23 | zipball_url: function(i) { 24 | return `https://api.github.com/repos/user1/repository1/zipball/v1.0.${i}`; 25 | }, 26 | target_commitish: 'master', 27 | name: function(i) { 28 | return `release${i}`; 29 | }, 30 | body: 'release body', 31 | draft: true, 32 | prerelease: true, 33 | created_at: faker.date.past(), 34 | published_at: faker.date.past(), 35 | 36 | afterCreate(release, server) { 37 | let author = server.create('githubUser'); 38 | release.update('authorId', author.id); 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /mirage-support/factories/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | content: "ewogICJuYW1lIjogInNhdXNhZ2V", 5 | download_url: function() { 6 | return `https://raw.githubusercontent.com/user1/repository1/master/${this.name}?token=123456`; 7 | }, 8 | git_url: function() { 9 | return `https://api.github.com/repos/user1/repository1/git/blobs/ff6447f1dd151539e92de91c9465c549f5d77829`; 10 | }, 11 | 12 | html_url: function() { 13 | return `https://github.com/user1/repository1/blob/master/${this.name}`; 14 | }, 15 | 16 | url: function() { 17 | return `https://api.github.com/repos/user1/repository1/contents/${this.file}?ref=master`; 18 | }, 19 | 20 | encoding: 'base64', 21 | name(i) { 22 | return `name${i}.extension`; 23 | }, 24 | path(i) { 25 | return `name${i}.extension`; 26 | }, 27 | sha: "ff6447f1dd151539e92de91c9465c549f5d77829", 28 | size: 377, 29 | type: 'file' 30 | }); 31 | -------------------------------------------------------------------------------- /mirage-support/factories/github-repository.js: -------------------------------------------------------------------------------- 1 | import { Factory, trait } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | name: function(i) { 6 | return `repository${i}`; 7 | }, 8 | full_name: function(i) { 9 | return `user${i}/${i}` 10 | }, 11 | description: 'This is a test repository', 12 | html_url: function(i) { 13 | return `https://github.com/repos/user1/repository${i}`; 14 | }, 15 | login: function(i) { 16 | return `user${i}`; 17 | }, 18 | fork: true, 19 | private: true, 20 | created_at: faker.date.past(), 21 | updated_at: faker.date.past(), 22 | pushed_at: faker.date.recent(), 23 | default_branch: function(i) { 24 | return `branch${i}`; 25 | }, 26 | url: function(i) { 27 | return `https://api.github.com/repos/user${i}/repository${i}`; 28 | }, 29 | 30 | afterCreate(githubRepository, server) { 31 | server.create('github-user', { repositories: [githubRepository] }); 32 | }, 33 | 34 | withBranches: trait({ 35 | afterCreate(repository) { 36 | server.createList('githubBranch', 2, { repository }); 37 | } 38 | }), 39 | 40 | withReleases: trait({ 41 | afterCreate(repository) { 42 | server.createList('githubRelease', 2, { repository }); 43 | } 44 | }), 45 | 46 | withPulls: trait({ 47 | afterCreate(repository) { 48 | server.createList('githubPull', 2, { repository }); 49 | } 50 | }) 51 | }); 52 | -------------------------------------------------------------------------------- /mirage-support/factories/github-tree.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | export default Factory.extend({ 4 | sha: '7fd1a60b01f91b314f59955a4e4d4e80d8edf11d', 5 | url() { 6 | return `https://api.github.com/user1/repository1/git/trees/${this.sha}`; 7 | }, 8 | truncated: false, 9 | 10 | afterCreate(githubTree, server) { 11 | githubTree.update('tree', server.createList('tree', 3)); 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /mirage-support/factories/github-user.js: -------------------------------------------------------------------------------- 1 | import { Factory, trait } from 'ember-cli-mirage'; 2 | import faker from 'faker'; 3 | 4 | export default Factory.extend({ 5 | login: function(i) { 6 | return `user${i}`; 7 | }, 8 | name: function(i) { 9 | return `User ${i}`; 10 | }, 11 | // needs to be the actual related model name for Ember Data reasons? 🤔 12 | type: 'github-user', 13 | avatar_url: function(i) { 14 | return `user${i}-avatar.gif`; 15 | }, 16 | public_repos: 1, 17 | public_gists: 2, 18 | followers: 3, 19 | following: 4, 20 | created_at: faker.date.past(), 21 | updated_at: faker.date.recent(), 22 | repos_url: function(i) { 23 | return `https://api.github.com/users/user${i}/repos`; 24 | }, 25 | url: function(i) { 26 | return `https://api.github.com/users/user${i}`; 27 | }, 28 | 29 | withRepositories: trait({ 30 | afterCreate(user) { 31 | server.createList('githubRepository', 2, { owner: user }); 32 | } 33 | }), 34 | }); 35 | -------------------------------------------------------------------------------- /mirage-support/factories/tree.js: -------------------------------------------------------------------------------- 1 | import { Factory } from 'ember-cli-mirage'; 2 | 3 | const types = ['blob', 'tree']; 4 | 5 | export default Factory.extend({ 6 | path: 'file.rb', 7 | mode: 100644, 8 | type(i){ 9 | return types[i % types.length]; 10 | }, 11 | sha: '44b4fc6d56897b048c772eb4087f854f46256132', 12 | url() { 13 | return `https://api.github.com/repos/user1/repository1/git/blobs/${this.sha}`; 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /mirage-support/models/github-branch.js: -------------------------------------------------------------------------------- 1 | import { Model, belongsTo } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | repository: belongsTo('github-repository') 5 | }); 6 | -------------------------------------------------------------------------------- /mirage-support/models/github-commit.js: -------------------------------------------------------------------------------- 1 | import { Model } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/models/github-compare.js: -------------------------------------------------------------------------------- 1 | import { Model, hasMany, belongsTo } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | baseCommit: belongsTo('github-commit'), 5 | mergeBaseCommit: belongsTo('github-commit'), 6 | commits: hasMany('github-commit'), 7 | files: hasMany('github-file') 8 | }); 9 | -------------------------------------------------------------------------------- /mirage-support/models/github-file.js: -------------------------------------------------------------------------------- 1 | import { Model } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/models/github-member.js: -------------------------------------------------------------------------------- 1 | import { Model, belongsTo } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | organization: belongsTo('github-organization') 5 | }); 6 | -------------------------------------------------------------------------------- /mirage-support/models/github-organization.js: -------------------------------------------------------------------------------- 1 | import { Model, hasMany } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | members: hasMany('github-member'), 5 | repositories: hasMany('github-repository') 6 | }); 7 | -------------------------------------------------------------------------------- /mirage-support/models/github-pull.js: -------------------------------------------------------------------------------- 1 | import { Model, belongsTo } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | repository: belongsTo('github-repository'), 5 | user: belongsTo('github-user') 6 | }); 7 | -------------------------------------------------------------------------------- /mirage-support/models/github-release.js: -------------------------------------------------------------------------------- 1 | import { Model, belongsTo } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | repository: belongsTo('github-repository'), 5 | author: belongsTo('github-user') 6 | }); 7 | -------------------------------------------------------------------------------- /mirage-support/models/github-repository.js: -------------------------------------------------------------------------------- 1 | import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | owner: belongsTo('githubUser', { inverse: null }), 5 | defaultBranch: belongsTo('github-branch', { inverse: null }), 6 | pulls: hasMany('github-pull'), 7 | branches: hasMany('github-branch'), 8 | releases: hasMany('github-release') 9 | }); 10 | -------------------------------------------------------------------------------- /mirage-support/models/github-user.js: -------------------------------------------------------------------------------- 1 | import { Model, hasMany } from 'ember-cli-mirage'; 2 | 3 | export default Model.extend({ 4 | repositories: hasMany('github-repository'), 5 | releases: hasMany('github-release') 6 | }); 7 | -------------------------------------------------------------------------------- /mirage-support/serializers/ember-data-github.js: -------------------------------------------------------------------------------- 1 | import { RestSerializer } from 'ember-cli-mirage'; 2 | import { underscore } from '@ember/string'; 3 | 4 | export default RestSerializer.extend({ 5 | root: false, 6 | embed: true, 7 | 8 | keyForAttribute(attr) { 9 | return underscore(attr); 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-blob.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-branch.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-commit.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-compare.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | import { underscore } from '@ember/string'; 3 | 4 | export default EmberDataGithubSerializer.extend({ 5 | include: ['mergeBaseCommit', 'baseCommit', 'files', 'commits'], 6 | 7 | keyForEmbeddedRelationship(attributeName) { 8 | return underscore(attributeName) 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-file.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-member.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-organization.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-pull.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | include: ['user'] 5 | }); 6 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-release.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | include: ['author'] 5 | }); 6 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-repository-contents.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-repository.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | include: ['owner'] 5 | }); 6 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-tree.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /mirage-support/serializers/github-user.js: -------------------------------------------------------------------------------- 1 | import EmberDataGithubSerializer from './ember-data-github'; 2 | 3 | export default EmberDataGithubSerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-data-github", 3 | "version": "0.9.0", 4 | "description": "Ember Data abstraction for the GitHub API", 5 | "keywords": [ 6 | "ember-addon", 7 | "ember-data", 8 | "github", 9 | "api" 10 | ], 11 | "license": "MIT", 12 | "author": "Jordan Hawker (http://www.JordanHawker.com)", 13 | "directories": { 14 | "doc": "doc", 15 | "test": "tests" 16 | }, 17 | "repository": "git@github.com:elwayman02/ember-data-github", 18 | "scripts": { 19 | "build": "ember build", 20 | "lint:js": "eslint ./*.js addon addon-test-support app config lib server test-support tests mirage-support", 21 | "start": "ember serve", 22 | "test": "ember test", 23 | "changelog": "lerna-changelog", 24 | "test:all": "ember try:each" 25 | }, 26 | "dependencies": { 27 | "broccoli-funnel": "^2.0.1", 28 | "broccoli-merge-trees": "^3.0.1", 29 | "ember-cli-babel": "^6.9.0", 30 | "ember-inflector": "^3.0.1" 31 | }, 32 | "devDependencies": { 33 | "bootstrap": "^4.0.0", 34 | "broccoli-asset-rev": "^2.4.5", 35 | "ember-auto-import": "^1.5.2", 36 | "ember-bootstrap": "^2.1.0", 37 | "ember-cli": "~3.1.2", 38 | "ember-cli-dependency-checker": "^2.0.0", 39 | "ember-cli-eslint": "^4.2.1", 40 | "ember-cli-htmlbars": "^4.0.7", 41 | "ember-cli-htmlbars-inline-precompile": "^2.0.0", 42 | "ember-cli-inject-live-reload": "^1.4.1", 43 | "ember-cli-mirage": "^1.1.0", 44 | "ember-cli-qunit": "^4.1.1", 45 | "ember-cli-release": "1.0.0-beta.2", 46 | "ember-cli-sass": "^7.1.4", 47 | "ember-cli-shims": "^1.2.0", 48 | "ember-cli-sri": "^2.1.0", 49 | "ember-cli-uglify": "^2.0.0", 50 | "ember-data": "^3.0.1", 51 | "ember-disable-prototype-extensions": "^1.1.2", 52 | "ember-export-application-global": "^2.0.0", 53 | "ember-load-initializers": "^1.0.0", 54 | "ember-maybe-import-regenerator": "^0.1.6", 55 | "ember-resolver": "^4.0.0", 56 | "ember-source": "~3.1.0", 57 | "ember-source-channel-url": "^1.0.1", 58 | "ember-try": "^0.2.23", 59 | "eslint-plugin-ember": "^5.0.0", 60 | "eslint-plugin-node": "^6.0.1", 61 | "faker": "^4.1.0", 62 | "lerna-changelog": "^0.8.2", 63 | "loader.js": "^4.2.3" 64 | }, 65 | "engines": { 66 | "node": ">= 8.*" 67 | }, 68 | "changelog": { 69 | "repo": "elwayman02/ember-data-github", 70 | "labels": { 71 | "breaking": "Breaking Change", 72 | "enhancement": "Enhancement", 73 | "bug": "Bug Fix", 74 | "documentation": "Documentation", 75 | "internal": "Internal" 76 | }, 77 | "ignoreCommitters": [ 78 | "greenkeeper[bot]" 79 | ] 80 | }, 81 | "ember-addon": { 82 | "configPath": "tests/dummy/config" 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_args: { 11 | Chrome: { 12 | mode: 'ci', 13 | args: [ 14 | // --no-sandbox is needed when running Chrome inside a container 15 | process.env.TRAVIS ? '--no-sandbox' : null, 16 | 17 | '--disable-gpu', 18 | '--headless', 19 | '--remote-debugging-port=0', 20 | '--window-size=1440,900' 21 | ].filter(Boolean) 22 | } 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /tests/acceptance/current-github-user-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | current github user', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 12 | server.create('github-user', 'withRepositories') 13 | } 14 | }); 15 | 16 | test('finding current user', function (assert) { 17 | assert.expect(4); 18 | 19 | return run(() => { 20 | return store.findRecord('githubUser', '#').then((user) => { 21 | assert.githubUserOk(user); 22 | assert.equal(store.peekAll('githubUser').get('length'), 1); 23 | assert.equal(server.pretender.handledRequests.length, 1); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 25 | }); 26 | }); 27 | }); 28 | 29 | test(`finding current user's repositories`, function (assert) { 30 | assert.expect(4); 31 | 32 | return run(() => { 33 | return store.findRecord('githubUser', '#').then((user) => { 34 | return user.get('repositories').then((repositories) => { 35 | assert.equal(repositories.get('length'), 2); 36 | assert.githubRepositoryOk(repositories.toArray()[0]); 37 | assert.equal(server.pretender.handledRequests.length, 2); 38 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123'); 39 | }); 40 | }); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /tests/acceptance/github-blob-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github blob', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('retrieving a blob', function(assert) { 15 | assert.expect(4); 16 | 17 | server.create('github-blob'); 18 | 19 | return run(() => { 20 | return store.queryRecord('github-blob', { 21 | repo: 'user1/repo1', 22 | sha: '1' 23 | }).then(blob => { 24 | assert.githubBlobOk(blob); 25 | assert.equal(store.peekAll('githubBlob').get('length'), 1); 26 | assert.equal(server.pretender.handledRequests.length, 1); 27 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 28 | }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/acceptance/github-branch-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github branch', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | server.create('github-branch') 12 | } 13 | }); 14 | 15 | test('finding a branch without authorization', function (assert) { 16 | assert.expect(4); 17 | 18 | return run(() => { 19 | return store.findRecord('githubBranch', 'User1/Repository1/branches/branch0').then((branch) => { 20 | assert.githubBranchOk(branch); 21 | assert.equal(store.peekAll('githubBranch').get('length'), 1); 22 | assert.equal(server.pretender.handledRequests.length, 1); 23 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 24 | }); 25 | }); 26 | }); 27 | 28 | test('finding a branch', function (assert) { 29 | assert.expect(4); 30 | 31 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 32 | 33 | return run(() => { 34 | return store.findRecord('githubBranch', 'user1/repository1/branches/branch0').then((branch) => { 35 | assert.githubBranchOk(branch); 36 | assert.equal(store.peekAll('githubBranch').get('length'), 1); 37 | assert.equal(server.pretender.handledRequests.length, 1); 38 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/acceptance/github-compare-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github compare', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('finding a comparison without authorization', function (assert) { 15 | assert.expect(3); 16 | 17 | server.create('github-compare'); 18 | 19 | return run(() => { 20 | return store.queryRecord('githubCompare', { repo: 'user1/repository1', base: '1234', 'head': '1234' }).then((compare) => { 21 | assert.githubCompareOk(compare); 22 | assert.equal(store.peekAll('githubCompare').get('length'), 1, 'loads 1 compare'); 23 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined, 'has no authorization token'); 24 | }); 25 | }); 26 | }); 27 | 28 | test('finding a comparison', function (assert) { 29 | assert.expect(3); 30 | 31 | server.create('github-compare'); 32 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 33 | 34 | return run(() => { 35 | return store.queryRecord('githubCompare', { repo: 'user1/repository1', base: '1234', 'head': '1234' }).then((compare) => { 36 | assert.githubCompareOk(compare); 37 | assert.equal(store.peekAll('githubCompare').get('length'), 1, 'loads 1 compare'); 38 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/acceptance/github-organization-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github organization', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('finding an organization without authorization', function (assert) { 15 | assert.expect(4); 16 | 17 | server.create('github-organization'); 18 | 19 | return run(() => { 20 | return store.findRecord('githubOrganization', 'organization0').then((organization) => { 21 | assert.githubOrganizationOk(organization); 22 | assert.equal(store.peekAll('githubOrganization').get('length'), 1); 23 | assert.equal(server.pretender.handledRequests.length, 1); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 25 | }); 26 | }); 27 | }); 28 | 29 | test('finding an organization', function (assert) { 30 | assert.expect(4); 31 | 32 | server.create('github-organization'); 33 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 34 | 35 | return run(() => { 36 | return store.findRecord('githubOrganization', 'organization0').then((organization) => { 37 | assert.githubOrganizationOk(organization); 38 | assert.equal(store.peekAll('githubOrganization').get('length'), 1); 39 | assert.equal(server.pretender.handledRequests.length, 1); 40 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 41 | }); 42 | }); 43 | }); 44 | 45 | test(`finding an organization's repositories`, function (assert) { 46 | assert.expect(4); 47 | server.create('github-organization', 'withRepositories'); 48 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 49 | 50 | return run(() => { 51 | return store.findRecord('githubOrganization', 'organization0').then((organization) => { 52 | return organization.get('repositories').then(function (repositories) { 53 | assert.equal(repositories.get('length'), 2); 54 | assert.githubRepositoryOk(repositories.toArray()[0]); 55 | assert.equal(server.pretender.handledRequests.length, 2); 56 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123'); 57 | }); 58 | }); 59 | }); 60 | }); 61 | 62 | test(`finding an organization's members`, function (assert) { 63 | assert.expect(4); 64 | server.create('github-organization', 'withMembers'); 65 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 66 | 67 | return run(() => { 68 | return store.findRecord('githubOrganization', 'organization0').then((organization) => { 69 | return organization.get('members').then(function (members) { 70 | assert.equal(members.get('length'), 2); 71 | assert.githubMemberOk(members.toArray()[0]); 72 | assert.equal(server.pretender.handledRequests.length, 2); 73 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123'); 74 | }); 75 | }); 76 | }); 77 | }); 78 | -------------------------------------------------------------------------------- /tests/acceptance/github-release-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github release', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('finding a release without authorization', function (assert) { 15 | assert.expect(4); 16 | 17 | server.create('github-release'); 18 | 19 | return run(() => { 20 | return store.queryRecord('githubRelease', { repo: 'user1/repository1', releaseId: '1' }).then((release) => { 21 | assert.githubReleaseOk(release); 22 | assert.equal(store.peekAll('githubRelease').get('length'), 1, 'loads 1 release'); 23 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined, 'has no authorization token'); 25 | }); 26 | }); 27 | }); 28 | 29 | test('finding a release', function (assert) { 30 | assert.expect(4); 31 | 32 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 33 | server.create('github-release'); 34 | 35 | return run(() => { 36 | return store.queryRecord('githubRelease', { repo: 'user1/repository0', releaseId: '1' }).then((release) => { 37 | assert.githubReleaseOk(release); 38 | assert.equal(store.peekAll('githubRelease').get('length'), 1, 'loads 1 release'); 39 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 40 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 41 | }); 42 | }); 43 | }); 44 | 45 | test('finding all releases', function (assert) { 46 | assert.expect(4); 47 | 48 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 49 | let repository = server.create('githubRepository'); 50 | server.createList('github-release', 2, { repository }); 51 | 52 | return run(() => { 53 | return store.query('githubRelease', { repo: 'user1/repository0' }).then((releases) => { 54 | assert.githubReleaseOk(releases.toArray()[0]); 55 | assert.equal(store.peekAll('githubRelease').get('length'), 2, 'loads 2 releases'); 56 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 57 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 58 | }); 59 | }); 60 | }); 61 | 62 | test('getting a releases\' author', function (assert) { 63 | assert.expect(4); 64 | 65 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 66 | server.create('github-release'); 67 | 68 | return run(() => { 69 | return store.queryRecord('githubRelease', { repo: 'user1/repository0', releaseId: '1' }).then((release) => { 70 | return release.get('author').then(function (user) { 71 | assert.githubUserOk(user); 72 | assert.equal(store.peekAll('githubUser').get('length'), 1, 'loads 1 user'); 73 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 requests'); 74 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 75 | }); 76 | }); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /tests/acceptance/github-repository-contents-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github repository contents', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('retrieving github repository contents', function(assert) { 15 | assert.expect(4); 16 | 17 | server.create('githubRepositoryContents', { name: 'app.json' }); 18 | 19 | return run(() => { 20 | return store.queryRecord('github-repository-contents', { 21 | repo: 'jmar910/test-repo-yay', 22 | file: 'app.json' 23 | }).then((content) => { 24 | assert.githubRepositoryContentsOk(content); 25 | assert.equal(store.peekAll('githubRepositoryContents').get('length'), 1, 'loads 1 repository contents'); 26 | assert.equal(server.pretender.handledRequests.length, 1); 27 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 28 | }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/acceptance/github-repository-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github repository', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | let owner = server.create('github-user'); 12 | server.create('github-repository', { owner }, 'withBranches'); 13 | } 14 | }); 15 | 16 | test('finding a repository without authorization', function (assert) { 17 | assert.expect(4); 18 | 19 | return run(() => { 20 | return store.findRecord('githubRepository', 'user0/repository0').then((repository) => { 21 | assert.githubRepositoryOk(repository); 22 | assert.equal(store.peekAll('githubRepository').get('length'), 1, 'loads 1 repository'); 23 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined, 'has no authorization token'); 25 | }); 26 | }); 27 | }); 28 | 29 | test('finding a repository by name', function (assert) { 30 | assert.expect(4); 31 | 32 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 33 | 34 | return run(() => { 35 | return store.findRecord('githubRepository', 'user0/repository0').then((repository) => { 36 | assert.githubRepositoryOk(repository); 37 | assert.equal(store.peekAll('githubRepository').get('length'), 1, 'loads 1 repository'); 38 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 39 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 40 | }); 41 | }); 42 | }); 43 | 44 | test('finding a repository by id', function (assert) { 45 | assert.expect(4); 46 | 47 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 48 | 49 | return run(() => { 50 | return store.findRecord('githubRepository', 1).then((repository) => { 51 | assert.githubRepositoryOk(repository); 52 | assert.equal(store.peekAll('githubRepository').get('length'), 1, 'loads 1 repository'); 53 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 54 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 55 | }); 56 | }); 57 | }); 58 | 59 | 60 | test('finding all repositories', function (assert) { 61 | assert.expect(4); 62 | 63 | let owner = server.create('github-user'); 64 | server.create('github-repository', { owner }); 65 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 66 | 67 | return run(() => { 68 | return store.findAll('githubRepository').then(function (repositories) { 69 | assert.equal(repositories.get('length'), 2, 'loads 2 repositories'); 70 | assert.githubRepositoryOk(repositories.toArray()[0]); 71 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 72 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 73 | }); 74 | }); 75 | }); 76 | 77 | test('getting a repository\'s owner', function (assert) { 78 | assert.expect(3); 79 | 80 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 81 | 82 | return run(() => { 83 | return store.findRecord('githubRepository', 'user0/repository0').then((repository) => { 84 | return repository.get('owner').then(function (owner) { 85 | assert.githubUserOk(owner); 86 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request1'); 87 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 88 | }); 89 | }); 90 | }); 91 | }); 92 | 93 | test('getting a repository\'s default branch', function (assert) { 94 | assert.expect(3); 95 | 96 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 97 | 98 | return run(() => { 99 | return store.findRecord('githubRepository', 'user0/repository0').then((repository) => { 100 | return repository.get('defaultBranch').then(function (branch) { 101 | assert.githubBranchOk(branch); 102 | assert.equal(server.pretender.handledRequests.length, 2, 'handles 2 requests'); 103 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 104 | }); 105 | }); 106 | }); 107 | }); 108 | 109 | test('finding a repository\'s branches', function (assert) { 110 | assert.expect(4); 111 | 112 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 113 | 114 | return run(() => { 115 | return store.findRecord('githubRepository', 'user0/repository0').then((repository) => { 116 | return repository.get('branches').then(function (branches) { 117 | assert.equal(branches.get('length'), 2, 'loads 2 branches'); 118 | assert.githubBranchOk(branches.toArray()[0]); 119 | assert.equal(server.pretender.handledRequests.length, 2, 'handles 2 requests'); 120 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 121 | }); 122 | }); 123 | }); 124 | }); 125 | 126 | test('finding a repository\'s releases', function (assert) { 127 | assert.expect(4); 128 | 129 | let owner = server.create('github-user'); 130 | server.create('github-repository', { owner }, 'withReleases'); 131 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 132 | 133 | return run(() => { 134 | return store.findRecord('githubRepository', 'user1/repository1').then((repository) => { 135 | return repository.get('releases').then(function (releases) { 136 | assert.equal(releases.get('length'), 2, 'loads 2 releases'); 137 | assert.githubReleaseOk(releases.toArray()[0]); 138 | assert.equal(server.pretender.handledRequests.length, 2, 'handles 2 requests'); 139 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 140 | }); 141 | }); 142 | }); 143 | }); 144 | 145 | test('finding a repository\'s pull requests', function (assert) { 146 | assert.expect(4); 147 | 148 | let owner = server.create('github-user'); 149 | server.create('github-repository', { owner }, 'withPulls'); 150 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 151 | 152 | return run(() => { 153 | return store.findRecord('githubRepository', 'user1/repository1').then((repository) => { 154 | return repository.get('pulls').then(function (pulls) { 155 | assert.equal(pulls.get('length'), 2, 'loads 2 pull requests'); 156 | assert.githubPullOk(pulls.toArray()[0]); 157 | assert.equal(server.pretender.handledRequests.length, 2, 'handles 2 requests'); 158 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 159 | }); 160 | }); 161 | }); 162 | }); 163 | -------------------------------------------------------------------------------- /tests/acceptance/github-tree-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github tree', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('retrieving a tree', function(assert) { 15 | assert.expect(4); 16 | 17 | server.create('githubTree'); 18 | 19 | return run(() => { 20 | return store.queryRecord('github-tree', { 21 | repo: 'user1/repo1', 22 | sha: '1' 23 | }).then(tree => { 24 | assert.githubTreeOk(tree); 25 | assert.equal(store.peekAll('githubTree').get('length'), 1); 26 | assert.equal(server.pretender.handledRequests.length, 1); 27 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 28 | }); 29 | }); 30 | }); 31 | 32 | test('retrieving a tree recursively', function(assert) { 33 | assert.expect(7); 34 | 35 | server.create('githubTree'); 36 | 37 | return run(() => { 38 | return store.queryRecord('github-tree', { 39 | repo: 'user1/repo1', 40 | sha: '1', 41 | recursive: true 42 | }).then(tree => { 43 | assert.githubTreeOk(tree); 44 | assert.equal(store.peekAll('githubTree').get('length'), 1); 45 | assert.equal(server.pretender.handledRequests.length, 1); 46 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 47 | assert.ok(server.pretender.handledRequests[0].queryParams); 48 | assert.ok(server.pretender.handledRequests[0].queryParams.recursive); 49 | assert.equal(server.pretender.handledRequests[0].queryParams.recursive, 1); 50 | }); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /tests/acceptance/github-user-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github user', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('finding a user without authorization', function (assert) { 15 | assert.expect(4); 16 | 17 | server.create('github-user'); 18 | 19 | return run(() => { 20 | return store.findRecord('githubUser', 'User1').then((user) => { 21 | assert.githubUserOk(user); 22 | assert.equal(store.peekAll('githubUser').get('length'), 1); 23 | assert.equal(server.pretender.handledRequests.length, 1); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined); 25 | }); 26 | }); 27 | }); 28 | 29 | test('finding a user by login', function (assert) { 30 | assert.expect(4); 31 | 32 | server.create('github-user'); 33 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 34 | 35 | return run(() => { 36 | return store.findRecord('githubUser', 'user1').then((user) => { 37 | assert.githubUserOk(user); 38 | assert.equal(store.peekAll('githubUser').get('length'), 1); 39 | assert.equal(server.pretender.handledRequests.length, 1); 40 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 41 | }); 42 | }); 43 | }); 44 | 45 | test('finding a user by id', function (assert) { 46 | assert.expect(4); 47 | 48 | server.create('github-user'); 49 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 50 | 51 | return run(() => { 52 | return store.findRecord('githubUser', 1).then((user) => { 53 | assert.githubUserOk(user); 54 | assert.equal(store.peekAll('githubUser').get('length'), 1); 55 | assert.equal(server.pretender.handledRequests.length, 1); 56 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 57 | }); 58 | }); 59 | }); 60 | 61 | test('finding all users', function (assert) { 62 | assert.expect(4); 63 | 64 | server.createList('github-user', 2); 65 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 66 | 67 | return run(() => { 68 | return store.findAll('githubUser').then((users) => { 69 | assert.equal(users.get('length'), 2); 70 | assert.githubUserOk(users.toArray()[0]); 71 | assert.equal(server.pretender.handledRequests.length, 1); 72 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123'); 73 | }); 74 | }); 75 | }); 76 | 77 | test(`finding a user's repositories`, function (assert) { 78 | assert.expect(4); 79 | 80 | server.create('githubUser', 'withRepositories'); 81 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 82 | 83 | return run(() => { 84 | return store.findRecord('githubUser', 'user1').then((user) => { 85 | return user.get('repositories').then((repositories) => { 86 | assert.equal(repositories.get('length'), 2); 87 | assert.githubRepositoryOk(repositories.toArray()[0]); 88 | assert.equal(server.pretender.handledRequests.length, 2); 89 | assert.equal(server.pretender.handledRequests[1].requestHeaders.Authorization, 'token abc123'); 90 | }); 91 | }); 92 | }); 93 | }); 94 | -------------------------------------------------------------------------------- /tests/acceptance/gitub-pull-test.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | import { test } from 'qunit'; 3 | import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; 4 | 5 | let container, store; 6 | 7 | moduleForAcceptance('Acceptance | github pull', { 8 | beforeEach() { 9 | container = this.application.__container__; 10 | store = run(container, 'lookup', 'service:store'); 11 | } 12 | }); 13 | 14 | test('finding a pull request without authorization', function (assert) { 15 | assert.expect(4); 16 | 17 | server.create('github-pull'); 18 | 19 | return run(() => { 20 | return store.queryRecord('githubPull', { repo: 'user1/repository1', pullId: '1' }).then((pull) => { 21 | assert.githubPullOk(pull); 22 | assert.equal(store.peekAll('githubPull').get('length'), 1, 'loads 1 pull'); 23 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 24 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, undefined, 'has no authorization token'); 25 | }); 26 | }); 27 | }); 28 | 29 | test('finding a pull request', function (assert) { 30 | assert.expect(4); 31 | 32 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 33 | server.create('github-pull'); 34 | 35 | return run(() => { 36 | return store.queryRecord('githubPull', { repo: 'user1/repository0', pullId: '1' }).then((pull) => { 37 | assert.githubPullOk(pull); 38 | assert.equal(store.peekAll('githubPull').get('length'), 1, 'loads 1 pull'); 39 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 40 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 41 | }); 42 | }); 43 | }); 44 | 45 | test('finding all pull requests', function (assert) { 46 | assert.expect(4); 47 | 48 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 49 | let repository = server.create('githubRepository'); 50 | server.createList('github-pull', 2, { repository }); 51 | 52 | return run(() => { 53 | return store.query('githubPull', { repo: 'user1/repository0' }).then((pulls) => { 54 | assert.githubPullOk(pulls.toArray()[0]); 55 | assert.equal(store.peekAll('githubPull').get('length'), 2, 'loads 2 pulls'); 56 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 request'); 57 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 58 | }); 59 | }); 60 | }); 61 | 62 | test('getting a pull request\'s author', function (assert) { 63 | assert.expect(4); 64 | 65 | container.lookup('service:github-session').set('githubAccessToken', 'abc123'); 66 | server.create('github-pull'); 67 | 68 | return run(() => { 69 | return store.queryRecord('githubPull', { repo: 'user1/repository0', pullId: '1' }).then((pull) => { 70 | return pull.get('user').then(function (user) { 71 | assert.githubUserOk(user); 72 | assert.equal(store.peekAll('githubUser').get('length'), 1, 'loads 1 user'); 73 | assert.equal(server.pretender.handledRequests.length, 1, 'handles 1 requests'); 74 | assert.equal(server.pretender.handledRequests[0].requestHeaders.Authorization, 'token abc123', 'has the authorization token'); 75 | }); 76 | }); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Application.extend({ 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | Resolver 10 | }); 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/components/models-list.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import layout from '../templates/components/models-list'; 3 | import { getOwner } from '@ember/application'; 4 | import { A } from '@ember/array'; 5 | 6 | export default Component.extend({ 7 | layout, 8 | 9 | init() { 10 | this._super(...arguments); 11 | 12 | this.models = []; 13 | }, 14 | 15 | didInsertElement() { 16 | this._super(...arguments); 17 | 18 | let adapter = getOwner(this).lookup('data-adapter:main'); 19 | this.set('models', adapter.getModelTypes()); 20 | 21 | this.get('models').forEach((type) => { 22 | let { klass } = type; 23 | 24 | type['keys'] = A(['id']); 25 | type['relationships'] = A(); 26 | 27 | klass.eachAttribute((key) => { 28 | type['keys'].push(key); 29 | }); 30 | 31 | klass.eachRelationship((key) => { 32 | type['relationships'].push(key); 33 | }) 34 | }) 35 | 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ember Data Github Demo 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | const Router = EmberRouter.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | this.route('explore'); 11 | }); 12 | 13 | export default Router; 14 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/routes/explore.js: -------------------------------------------------------------------------------- 1 | import Route from '@ember/routing/route'; 2 | 3 | export default Route.extend({ 4 | model() { 5 | return this.store.query('github-repository', { 6 | user: 'elwayman02', 7 | type: 'all' 8 | }); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.scss: -------------------------------------------------------------------------------- 1 | @import "ember-bootstrap/bootstrap"; 2 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Ember Data Github

4 | 5 | {{outlet}} 6 |
7 |
8 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/dummy/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/models-list.hbs: -------------------------------------------------------------------------------- 1 | {{keys.length}} 2 | {{#bs-accordion as |acc|}} 3 | {{#each models as |model|}} 4 | {{#acc.item value=model.name title=model.name}} 5 |

Properties

6 | 11 | 12 | {{#if model.relationships}} 13 |

Relationships

14 | 19 | {{/if}} 20 | {{/acc.item}} 21 | {{/each}} 22 | {{/bs-accordion}} 23 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/explore.hbs: -------------------------------------------------------------------------------- 1 | {{#each model as |repo|}} 2 | {{repo.name}} 3 | {{/each}} -------------------------------------------------------------------------------- /tests/dummy/app/templates/index.hbs: -------------------------------------------------------------------------------- 1 | {{models-list}} 2 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | ENV['ember-cli-mirage'] = { 33 | enabled: false 34 | } 35 | } 36 | 37 | if (environment === 'test') { 38 | // Testem prefers this... 39 | ENV.locationType = 'none'; 40 | 41 | // keep test console output quieter 42 | ENV.APP.LOG_ACTIVE_GENERATION = false; 43 | ENV.APP.LOG_VIEW_LOOKUPS = false; 44 | 45 | ENV.APP.rootElement = '#ember-testing'; 46 | ENV.APP.autoboot = false; 47 | } 48 | 49 | if (environment === 'production') { 50 | // here you can enable a production-specific feature 51 | } 52 | 53 | return ENV; 54 | }; 55 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions' 7 | ]; 8 | 9 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tests/dummy/mirage/config.js: -------------------------------------------------------------------------------- 1 | export default function testConfig() { 2 | this.urlPrefix = 'https://api.github.com/' 3 | 4 | this.get('/repos/:owner/:repo/branches/:branch', (schema, request) => { 5 | return schema.githubBranches.findBy({ name: request.params.branch }); 6 | }); 7 | 8 | this.get('/repos/:owner/:repo/branches', (schema, { params }) => { 9 | return schema.githubRepositories.findBy({ name: params.repo }).branches; 10 | }); 11 | 12 | this.get('/repos/:owner/:repo/releases', (schema, request) => { 13 | return schema.githubRepositories.findBy({ name: request.params.branch }).releases; 14 | }); 15 | 16 | this.get('/repos/:owner/:repo', (schema, request) => { 17 | return schema.githubRepositories.findBy({ name: request.params.repo }); 18 | }); 19 | 20 | this.get('repositories', (schema) => { 21 | return schema.githubRepositories.all(); 22 | }); 23 | 24 | this.get('repositories/:repo', (schema, request) => { 25 | return schema.githubRepositories.findBy({ id: request.params.repo }); 26 | }); 27 | 28 | this.get('user', (schema) => { 29 | return schema.githubUsers.first(); 30 | }); 31 | 32 | this.get('user/:id', (schema, request) => { 33 | return schema.githubUsers.findBy({ id: request.params.id }) 34 | }); 35 | 36 | this.get('user/repos', (schema) => { 37 | return schema.githubUsers.first().repositories; 38 | }); 39 | 40 | this.get('users/:user/repos', (schema, { params }) => { 41 | return schema.githubUsers.findBy({ login: params.user }).repositories; 42 | }); 43 | 44 | this.get('users/:user', (schema) => { 45 | return schema.githubUsers.first(); 46 | }); 47 | 48 | this.get('users', (schema) => { 49 | return schema.githubUsers.all().models; 50 | }); 51 | 52 | this.get('/repos/:user/:repo/git/blobs/:blob', (schema, { params }) => { 53 | return schema.githubBlobs.findBy({ id: params.blob }); 54 | }); 55 | 56 | this.get('repos/:user/:repo/releases/:release', (schema, { params }) => { 57 | return schema.githubReleases.findBy({ id: params.release }); 58 | }); 59 | 60 | this.get('repos/:user/:repo/releases', (schema, { params }) => { 61 | return schema.githubRepositories.findBy({ name: params.repo }).releases; 62 | }); 63 | 64 | this.get('repos/:user/:repo/pulls', (schema, { params }) => { 65 | return schema.githubRepositories.findBy({ name: params.repo }).pulls; 66 | }); 67 | 68 | this.get('repos/:user/:repo/pulls/:pull', (schema, { params }) => { 69 | return schema.githubPulls.findBy({ id: params.pull }); 70 | }); 71 | 72 | this.get('repos/:user/:repo/git/trees/:tree', (schema, { params }) => { 73 | return schema.githubTrees.findBy({ id: params.tree }); 74 | }); 75 | 76 | this.get('repos/:user/:repo/compare/:base...:head', (schema) => { 77 | return schema.githubCompares.first(); 78 | }); 79 | 80 | this.get('repos/:user/:repo/contents/:file', (schema, { params }) => { 81 | return schema.githubRepositoryContents.findBy({ name: params.file }); 82 | }); 83 | 84 | this.get('/orgs/:org', (schema, { params }) => { 85 | return schema.githubOrganizations.findBy({ login: params.org }); 86 | }); 87 | 88 | this.get('orgs/:org/repos', (schema, { params }) => { 89 | return schema.githubOrganizations.findBy({ login: params.org }).repositories; 90 | }); 91 | 92 | this.get('orgs/:org/members', (schema, { params }) => { 93 | return schema.githubOrganizations.findBy({ login: params.org }).members; 94 | }); 95 | } 96 | -------------------------------------------------------------------------------- /tests/dummy/mirage/scenarios/default.js: -------------------------------------------------------------------------------- 1 | export default function(/* server */) { 2 | 3 | /* 4 | Seed your development database using your factories. 5 | This data will not be loaded in your tests. 6 | */ 7 | 8 | // server.createList('post', 10); 9 | } 10 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-blob-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubBlobOk = assertionBuilder([ 6 | 'id', 7 | 'sha', 8 | 'url', 9 | 'content', 10 | 'size', 11 | 'encoding' 12 | ]); 13 | 14 | export default registerHelper( 15 | 'assertGithubBlobOk', 16 | function (app, assert, blob) { 17 | assert.githubBlobOk(blob); 18 | } 19 | ); 20 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-branch-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubBranchOk = assertionBuilder([ 6 | 'id', 7 | 'name', 8 | 'commit', 9 | 'protected' 10 | ]); 11 | 12 | export default registerHelper( 13 | 'assertGithubBranchOk', 14 | function (app, assert, branch) { 15 | assert.githubBranchOk(branch); 16 | } 17 | ); 18 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-compare-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubCompareOk = assertionBuilder([ 6 | 'id', 7 | 'aheadBy', 8 | 'behindBy', 9 | 'status', 10 | 'totalCommits', 11 | 'diffUrl', 12 | 'htmlUrl', 13 | 'patchUrl', 14 | 'permalinkUrl', 15 | 'baseCommit', 16 | 'mergeBaseCommit' 17 | ]); 18 | 19 | export default registerHelper( 20 | 'githubCompareOk', 21 | function (app, assert, compare) { 22 | assert.githubCompareOk(compare); 23 | } 24 | ); 25 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-member-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubMemberOk = assertionBuilder([ 6 | 'id', 7 | 'login', 8 | 'avatarUrl', 9 | 'gravatarId', 10 | 'url', 11 | 'type', 12 | 'siteAdmin' 13 | ]); 14 | 15 | export default registerHelper( 16 | 'assertGithubMemberOk', 17 | function (app, assert, member) { 18 | assert.githubMemberOk(member); 19 | } 20 | ); 21 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-organization-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubOrganizationOk = assertionBuilder([ 6 | 'id', 7 | 'login', 8 | 'name', 9 | 'avatarUrl' 10 | ]); 11 | 12 | export default registerHelper( 13 | 'assertGithubOrganizationOk', 14 | function (app, assert, organization) { 15 | assert.githubOrganizationOk(organization); 16 | } 17 | ); 18 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-pull-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubPullOk = assertionBuilder([ 6 | 'id', 7 | 'number', 8 | 'title', 9 | 'state', 10 | 'htmlUrl', 11 | 'body', 12 | 'createdAt', 13 | 'updatedAt', 14 | 'closedAt', 15 | 'mergedAt', 16 | 'userLogin', 17 | 'userAvatarUrl' 18 | ]); 19 | 20 | export default registerHelper( 21 | 'githubPullOk', 22 | function (app, assert, release) { 23 | assert.githubPullOk(release); 24 | } 25 | ); 26 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-release-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubReleaseOk = assertionBuilder([ 6 | 'id', 7 | 'url', 8 | 'htmlUrl', 9 | 'assetsUrl', 10 | 'uploadUrl', 11 | 'tarballUrl', 12 | 'zipballUrl', 13 | 'tagName', 14 | 'targetCommitish', 15 | 'name', 16 | 'body', 17 | 'draft', 18 | 'prerelease', 19 | 'createdAt', 20 | 'publishedAt' 21 | ]); 22 | 23 | export default registerHelper( 24 | 'assertGithubReleaseOk', 25 | function (app, assert, release) { 26 | assert.githubReleaseOk(release); 27 | } 28 | ); 29 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-repository-contents-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubRepositoryContentsOk = assertionBuilder([ 6 | 'id', 7 | 'content', 8 | 'downloadUrl', 9 | 'encoding', 10 | 'gitUrl', 11 | 'htmlUrl', 12 | 'name', 13 | 'path', 14 | 'sha', 15 | 'size', 16 | 'type', 17 | 'url' 18 | ]); 19 | 20 | export default registerHelper( 21 | 'assertGithubRepositoryContentsOk', 22 | function (app, assert, contents) { 23 | assert.githubRepositoryContentsOk(contents); 24 | } 25 | ); 26 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-repository-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubRepositoryOk = assertionBuilder([ 6 | 'id', 7 | 'fullName', 8 | 'name', 9 | 'description', 10 | 'fork', 11 | 'private', 12 | 'createdAt', 13 | 'updatedAt', 14 | 'pushedAt' 15 | ]); 16 | 17 | export default registerHelper( 18 | 'assertGithubRepositoryOk', 19 | function (app, assert, repository) { 20 | assert.githubRepositoryOk(repository); 21 | } 22 | ); 23 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-tree-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubTreeOk = assertionBuilder([ 6 | 'id', 7 | 'sha', 8 | 'url', 9 | 'files', 10 | 'directories', 11 | 'blobs', 12 | 'trees', 13 | 'truncated' 14 | ]); 15 | 16 | export default registerHelper( 17 | 'assertGithubTreeOk', 18 | function (app, assert, tree) { 19 | assert.githubTreeOk(tree); 20 | } 21 | ); 22 | -------------------------------------------------------------------------------- /tests/helpers/custom-helpers/assert-github-user-ok.js: -------------------------------------------------------------------------------- 1 | import { registerHelper } from '@ember/test'; 2 | import QUnit from 'qunit'; 3 | import assertionBuilder from '../utils/defined-attribute-assertion-builder'; 4 | 5 | QUnit.assert.githubUserOk = assertionBuilder([ 6 | 'id', 7 | 'login', 8 | 'name', 9 | 'type', 10 | 'avatarUrl', 11 | 'publicRepos', 12 | 'publicGists', 13 | 'followers', 14 | 'following', 15 | 'createdAt', 16 | 'updatedAt', 17 | 'url' 18 | ]); 19 | 20 | export default registerHelper( 21 | 'assertGithubUserOk', 22 | function (app, assert, user) { 23 | assert.githubUserOk(user); 24 | } 25 | ); 26 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | 3 | export default function destroyApp(application) { 4 | if (server) { 5 | server.shutdown(); 6 | } 7 | run(application, 'destroy'); 8 | } 9 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import { resolve } from 'rsvp'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | export default function(name, options = {}) { 7 | module(name, { 8 | beforeEach() { 9 | this.application = startApp(); 10 | 11 | if (options.beforeEach) { 12 | return options.beforeEach.apply(this, arguments); 13 | } 14 | }, 15 | 16 | afterEach() { 17 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 18 | return resolve(afterEach).then(() => destroyApp(this.application)); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Application from '../../app'; 2 | import config from '../../config/environment'; 3 | import { merge } from '@ember/polyfills'; 4 | import { run } from '@ember/runloop'; 5 | 6 | import './custom-helpers/assert-github-branch-ok'; 7 | import './custom-helpers/assert-github-organization-ok'; 8 | import './custom-helpers/assert-github-repository-ok'; 9 | import './custom-helpers/assert-github-user-ok'; 10 | import './custom-helpers/assert-github-release-ok'; 11 | import './custom-helpers/assert-github-blob-ok'; 12 | import './custom-helpers/assert-github-tree-ok'; 13 | import './custom-helpers/assert-github-pull-ok'; 14 | import './custom-helpers/assert-github-member-ok'; 15 | import './custom-helpers/assert-github-compare-ok'; 16 | import './custom-helpers/assert-github-repository-contents-ok'; 17 | 18 | export default function startApp(attrs) { 19 | let attributes = merge({}, config.APP); 20 | attributes.autoboot = true; 21 | attributes = merge(attributes, attrs); // use defaults, but you can override; 22 | 23 | return run(() => { 24 | let application = Application.create(attributes); 25 | application.setupForTesting(); 26 | application.injectTestHelpers(); 27 | 28 | return application; 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /tests/helpers/utils/defined-attribute-assertion-builder.js: -------------------------------------------------------------------------------- 1 | export default function(keys) { 2 | return function(object, message) { 3 | let allDefined = true; 4 | let undefinedKeys = []; 5 | 6 | keys.forEach(key => { 7 | if (object.get(key) === undefined) { 8 | allDefined = false; 9 | undefinedKeys.push(key); 10 | } 11 | }); 12 | let realMessage = message || 'Undefined keys'; 13 | this.pushResult({ 14 | result: allDefined, 15 | actual: allDefined, 16 | expected: true, 17 | message: `${realMessage}: ${undefinedKeys.join(',')}` 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ember Data Github Demo App 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/integration/.gitkeep -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/adapters/github-blob-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-blob', 'Unit | Adapter | github blob', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | // Replace this with your real tests. 8 | test('it exists', function(assert) { 9 | let adapter = this.subject(); 10 | assert.ok(adapter); 11 | }); 12 | 13 | test('it builds the URL correctly', function(assert) { 14 | let adapter = this.subject(); 15 | const host = adapter.get('host'); 16 | const repo = 'jimmay5469/old-hash'; 17 | const sha = '219985c2289f78f0a652c317ec69c2bc355ee5e9'; 18 | let query = { 19 | repo, 20 | sha 21 | }; 22 | 23 | assert.equal(adapter.buildURL('github-blob', null, null, 'queryRecord', query), `${host}/repos/${repo}/git/blobs/${sha}`); 24 | }); 25 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-branch-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-branch', 'Unit | Adapter | github branch', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function (assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the specified branch URL correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | const branch = 'jimmay5469/old-hash/branches/master'; 16 | 17 | assert.equal(adapter.buildURL('github-branch', branch, null, 'findRecord'), `${host}/repos/${branch}`); 18 | }); 19 | 20 | // TODO: The index URL doesn't work correctly 21 | 22 | test('it builds the branch index URL correctly as a query', function(assert) { 23 | let adapter = this.subject(); 24 | const host = adapter.get('host'); 25 | const repo = 'jimmay5469/old-hash'; 26 | const query = { 27 | repo: repo, 28 | }; 29 | 30 | assert.equal(adapter.buildURL('github-branch', null, null, 'query', query), `${host}/repos/${repo}/branches`); 31 | }); 32 | 33 | test('it builds the specific branch URL correctly as a query', function(assert) { 34 | let adapter = this.subject(); 35 | const host = adapter.get('host'); 36 | const repo = 'jimmay5469/old-hash'; 37 | const branch = 'master'; 38 | const query = { 39 | repo: repo, 40 | branch: branch 41 | }; 42 | 43 | assert.equal(adapter.buildURL('github-branch', null, null, 'queryRecord', query), `${host}/repos/${repo}/branches/${branch}`); 44 | }); 45 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-compare-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-compare', 'Unit | Adapter | github compare', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it builds the URL for a specific comparison query correctly', function(assert) { 8 | let adapter = this.subject(); 9 | const host = adapter.get('host'); 10 | const repo = 'jimmay5469/old-hash'; 11 | const base = 1234 12 | const head = 5678; 13 | 14 | assert.equal( 15 | adapter.buildURL('github-compare', null, null, 'queryRecord', { repo, base, head }), 16 | `${host}/repos/${repo}/compare/${base}...${head}` 17 | ); 18 | }); 19 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-member-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-member', 'Unit | Adapter | github member', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it builds the organization\'s members URL correctly', function(assert) { 8 | let adapter = this.subject(); 9 | const host = adapter.get('host'); 10 | const org = 'ember'; 11 | const query = { 12 | org, 13 | }; 14 | 15 | assert.equal(adapter.buildURL('github-member', null, null, 'query', query), `${host}/orgs/${org}/members`); 16 | }); 17 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-organization-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-organization', 'Unit | Adapter | github organization', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function (assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the index URL correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | 16 | assert.equal(adapter.buildURL('organizations', null, null), `${host}/orgs`); 17 | }); 18 | 19 | test('it builds the specified org URL correctly', function(assert) { 20 | let adapter = this.subject(); 21 | const host = adapter.get('host'); 22 | const org = 'ember'; 23 | 24 | assert.equal(adapter.buildURL('organizations', org, null), `${host}/orgs/${org}`); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-pull-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-pull', 'Unit | Adapter | github pull', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function(assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | 13 | test('it builds the index URL correctly', function(assert) { 14 | let adapter = this.subject(); 15 | const host = adapter.get('host'); 16 | 17 | assert.equal(adapter.buildURL('pulls'), `${host}/pulls`); 18 | }); 19 | 20 | test('it builds the specific pull URL correctly', function(assert) { 21 | let adapter = this.subject(); 22 | const host = adapter.get('host'); 23 | const id = 3; 24 | 25 | assert.equal(adapter.buildURL('pulls', id), `${host}/pulls/${id}`); 26 | }); 27 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-release-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-release', 'Unit | Adapter | github release', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function(assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the URL for the releases query correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | const repo = 'jimmay5469/old-hash'; 16 | 17 | assert.equal(adapter.buildURL('github-release', null, null, 'query', { repo: repo }), `${host}/repos/${repo}/releases`); 18 | }); 19 | 20 | test('it builds the URL for a specific release query correctly', function(assert) { 21 | let adapter = this.subject(); 22 | const host = adapter.get('host'); 23 | const repo = 'jimmay5469/old-hash'; 24 | const release = 1; 25 | 26 | assert.equal( 27 | adapter.buildURL('github-release', null, null, 'queryRecord', { repo: repo, releaseId: release }), 28 | `${host}/repos/${repo}/releases/${release}` 29 | ); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-repository-contents-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-repository-contents', 'Unit | Adapter | github repository contents', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it builds the repo content URL correctly', function(assert) { 8 | let adapter = this.subject(); 9 | const host = adapter.get('host'); 10 | const repo = 'jmar910/test-repo-yay'; 11 | const file = 'app.json'; 12 | const query = { 13 | repo, 14 | file 15 | }; 16 | 17 | assert.equal(adapter.buildURL('github-repository-contents', null, null, 'queryRecord', query), `${host}/repos/${repo}/contents/${file}`); 18 | }); 19 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-repository-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-repository', 'Unit | Adapter | github repository', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function (assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the index URL correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | 16 | assert.equal(adapter.buildURL('github-repository', null, null), `${host}/repositories`); 17 | }); 18 | 19 | test('it builds the specified repo name URL correctly', function(assert) { 20 | let adapter = this.subject(); 21 | let host = adapter.get('host'); 22 | let name = 'elwayman02/ember-data-github'; 23 | 24 | assert.equal(adapter.buildURL('github-repository', name, null, 'findRecord'), `${host}/repos/${name}`); 25 | }); 26 | 27 | 28 | test('it builds the specified repo list URL correctly', function(assert) { 29 | let adapter = this.subject(); 30 | let host = adapter.get('host'); 31 | let user = 'elwayman02'; 32 | 33 | assert.equal(adapter.buildURL('github-repository', null, null, 'query', { user }), `${host}/users/${user}/repos`); 34 | }); 35 | 36 | test('it builds the specified repo id URL correctly', function(assert) { 37 | let adapter = this.subject(); 38 | let host = adapter.get('host'); 39 | let id = 34598603; 40 | 41 | assert.equal(adapter.buildURL('github-repository', parseInt(id), null, 'findRecord'), `${host}/repositories/${id}`); 42 | assert.equal(adapter.buildURL('github-repository', id.toString(), null, 'findRecord'), `${host}/repositories/${id}`); 43 | }); 44 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github', 'Unit | Adapter | github', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists and has the right properties', function (assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | assert.ok(adapter.get('host')); 11 | assert.ok(adapter.get('session')); 12 | assert.ok(adapter.get('headers')); 13 | }); 14 | 15 | test('it computes headers without authorization correctly', function(assert) { 16 | let adapter = this.subject(); 17 | let session = adapter.get('session'); 18 | 19 | assert.ok(session); 20 | assert.notOk(session.get('githubAccessToken')); 21 | assert.deepEqual(adapter.get('headers'), {}); 22 | }); 23 | 24 | test('it computes headers with authorization correctly', function(assert) { 25 | let adapter = this.subject(); 26 | let session = adapter.get('session'); 27 | const token = 'asdfjkl'; 28 | 29 | session.set('githubAccessToken', token); 30 | 31 | assert.deepEqual(adapter.get('headers'), { Authorization: `token ${token}`}); 32 | }); 33 | 34 | test('it transforms type names correctly', function(assert) { 35 | let adapter = this.subject(); 36 | 37 | assert.equal(adapter.pathForType('github-user'), 'users'); 38 | assert.equal(adapter.pathForType('github-user-name'), 'userNames'); 39 | }); 40 | 41 | test('it extracts links from the Link header', function(assert) { 42 | let adapter = this.subject(); 43 | let first = '; rel="first"'; 44 | let next = '; rel="next"'; 45 | let prev = '; rel="prev"'; 46 | let last = '; rel="last"'; 47 | 48 | let headers = { 49 | Link: [first, next, prev, last].join(', ') 50 | }; 51 | 52 | assert.deepEqual(adapter.handleResponse(200, headers, {}, null).links, { 53 | first: 'https://api.github.com/resouce?page=1&per_page=5', 54 | next: 'https://api.github.com/resouce?page=3&per_page=5', 55 | prev: 'https://api.github.com/resouce?page=1&per_page=5', 56 | last: 'https://api.github.com/resouce?page=4&per_page=5' 57 | }); 58 | }); 59 | 60 | test('it extracts links from the link header', function(assert) { 61 | let adapter = this.subject(); 62 | let first = '; rel="first"'; 63 | let next = '; rel="next"'; 64 | let prev = '; rel="prev"'; 65 | let last = '; rel="last"'; 66 | 67 | let headers = { 68 | link: [first, next, prev, last].join(', ') 69 | }; 70 | 71 | assert.deepEqual(adapter.handleResponse(200, headers, {}, null).links, { 72 | first: 'https://api.github.com/resouce?page=1&per_page=5', 73 | next: 'https://api.github.com/resouce?page=3&per_page=5', 74 | prev: 'https://api.github.com/resouce?page=1&per_page=5', 75 | last: 'https://api.github.com/resouce?page=4&per_page=5' 76 | }); 77 | }); 78 | 79 | test('it handles a missing Link header', function(assert) { 80 | let adapter = this.subject(); 81 | let headers = {}; 82 | 83 | assert.equal(adapter.handleResponse(200, headers, {}, null).links, undefined); 84 | }); 85 | 86 | test('it handles a mis-formed Link header', function(assert) { 87 | let adapter = this.subject(); 88 | let headers = { 89 | Link: 'well_this-is|unexpected' 90 | } 91 | 92 | assert.equal(adapter.handleResponse(200, headers, {}, null).links, undefined); 93 | }); 94 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-tree-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-tree', 'Unit | Adapter | github tree', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function(assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the URL correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | const repo = 'jimmay5469/old-hash'; 16 | const sha = '219985c2289f78f0a652c317ec69c2bc355ee5e9'; 17 | let query = { 18 | repo, 19 | sha 20 | }; 21 | 22 | assert.equal(adapter.buildURL('github-tree', null, null, 'queryRecord', query), `${host}/repos/${repo}/git/trees/${sha}`); 23 | }); 24 | 25 | test('it builds the URL correctly with the recursive query', function(assert) { 26 | let adapter = this.subject(); 27 | const host = adapter.get('host'); 28 | const repo = 'jimmay5469/old-hash'; 29 | const sha = '219985c2289f78f0a652c317ec69c2bc355ee5e9'; 30 | const recursive = true; 31 | let query = { 32 | repo, 33 | sha, 34 | recursive 35 | }; 36 | 37 | // NOTE: Query params are handled separately from the URL, so are not part of the expected result. 38 | assert.equal(adapter.buildURL('github-tree', null, null, 'queryRecord', query), `${host}/repos/${repo}/git/trees/${sha}`); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/unit/adapters/github-user-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:github-user', 'Unit | Adapter | github user', { 4 | needs: ['service:github-session'] 5 | }); 6 | 7 | test('it exists', function (assert) { 8 | let adapter = this.subject(); 9 | assert.ok(adapter); 10 | }); 11 | 12 | test('it builds the current user URL correctly', function(assert) { 13 | let adapter = this.subject(); 14 | const host = adapter.get('host'); 15 | 16 | assert.equal(adapter.buildURL('github-user', '#', null, 'findRecord'), `${host}/user`); 17 | }); 18 | 19 | test('it builds specified user login URLs correctly', function(assert) { 20 | let adapter = this.subject(); 21 | const host = adapter.get('host'); 22 | const login = 'elwayman02'; 23 | 24 | assert.equal(adapter.buildURL('github-user', login, null, 'findRecord'), `${host}/users/${login}`); 25 | }); 26 | 27 | test('it builds specified user id URLs correctly', function(assert) { 28 | let adapter = this.subject(); 29 | const host = adapter.get('host'); 30 | const id = 917672; 31 | 32 | assert.equal(adapter.buildURL('github-user', parseInt(id), null, 'findRecord'), `${host}/user/${id}`); 33 | assert.equal(adapter.buildURL('github-user', id.toString(), null, 'findRecord'), `${host}/user/${id}`); 34 | }); 35 | -------------------------------------------------------------------------------- /tests/unit/models/github-blob-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-blob', 'Unit | Model | github blob', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-branch-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-branch', 'Unit | Model | github branch', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function (assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-commit-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-commit', 'Unit | Model | github commit', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-compare-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-compare', 'Unit | Model | github compare', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-file-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-file', 'Unit | Model | github file', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-member-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-member', 'Unit | Model | github member', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-organization-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-organization', 'Unit | Model | github organization', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'model:githubRepository', 7 | 'model:githubBranch', 8 | 'model:githubUser' 9 | ] 10 | }); 11 | 12 | test('it exists', function (assert) { 13 | let model = this.subject(); 14 | // let store = this.store(); 15 | assert.ok(!!model); 16 | }); 17 | -------------------------------------------------------------------------------- /tests/unit/models/github-pull-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-pull', 'Unit | Model | github pull', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'model:githubUser', 7 | 'model:githubBranch' 8 | ] 9 | }); 10 | 11 | test('it exists', function (assert) { 12 | let model = this.subject(); 13 | // let store = this.store(); 14 | assert.ok(!!model); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/models/github-release-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-release', 'Unit | Model | github release', { 4 | // Specify the other units that are required for this test. 5 | needs: ['model:github-user'] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-repository-contents-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-repository-contents', 'Unit | Model | github repository contents', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-repository-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-repository', 'Unit | Model | github repository', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'model:githubUser', 7 | 'model:githubBranch', 8 | 'model:githubPull', 9 | 'model:githubRelease' 10 | ] 11 | }); 12 | 13 | test('it exists', function (assert) { 14 | let model = this.subject(); 15 | // let store = this.store(); 16 | assert.ok(!!model); 17 | }); 18 | -------------------------------------------------------------------------------- /tests/unit/models/github-tree-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-tree', 'Unit | Model | github tree', { 4 | // Specify the other units that are required for this test. 5 | needs: ['model:github-blob'] 6 | }); 7 | 8 | test('it exists', function(assert) { 9 | let model = this.subject(); 10 | // let store = this.store(); 11 | assert.ok(!!model); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/models/github-user-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-user', 'Unit | Model | github user', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'model:githubRepository', 7 | 'model:githubBranch' 8 | ] 9 | }); 10 | 11 | test('it exists', function (assert) { 12 | let model = this.subject(); 13 | // let store = this.store(); 14 | assert.ok(!!model); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-blob-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-blob', 'Unit | Serializer | github blob', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-blob'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function(assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-branch-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-branch', 'Unit | Serializer | github branch', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-branch'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function (assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-compare-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-compare', 'Unit | Serializer | github compare', { 4 | needs: ['serializer:github-compare', 'model:github-commit', 'model:github-file'] 5 | }); 6 | 7 | // Replace this with your real tests. 8 | test('it serializes records', function(assert) { 9 | let record = this.subject(); 10 | 11 | let serializedRecord = record.serialize(); 12 | 13 | assert.ok(serializedRecord); 14 | }); 15 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-member-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-member', 'Unit | Serializer | github member', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-member'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function(assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-organization-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-organization', 'Unit | Serializer | github organization', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'serializer:github-organization', 7 | 'model:githubRepository', 8 | 'model:githubBranch', 9 | 'model:githubMember' 10 | ] 11 | }); 12 | 13 | // Replace this with your real tests. 14 | test('it serializes records', function (assert) { 15 | let record = this.subject(); 16 | 17 | let serializedRecord = record.serialize(); 18 | 19 | assert.ok(serializedRecord); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-release-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-release', 'Unit | Serializer | github release', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-release', 'model:github-user', 'model:github-repository'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function(assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-repository-contents-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-repository-contents', 'Unit | Serializer | github repository contents', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-repository-contents'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function(assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-repository-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-repository', 'Unit | Serializer | github repository', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'serializer:github-repository', 7 | 'model:githubBranch', 8 | 'model:githubUser', 9 | 'model:githubPull', 10 | 'model:githubRelease' 11 | ] 12 | }); 13 | 14 | // Replace this with your real tests. 15 | test('it serializes records', function (assert) { 16 | let record = this.subject(); 17 | 18 | let serializedRecord = record.serialize(); 19 | 20 | assert.ok(serializedRecord); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('serializer:github', 'Unit | Serializer | github', { 4 | // Specify the other units that are required for this test. 5 | needs: [] 6 | }); 7 | 8 | test('extracts pagination metadata from payload.links', function (assert) { 9 | let serializer = this.subject(); 10 | let modelClass = { modelName: 'my-model' }; 11 | 12 | let payload = { 13 | 'my-models': [ { id: 1 }, { id: 2 } ] 14 | }; 15 | 16 | payload['my-models'].links = { 17 | first: 'https://api.github.com/resouce?page=1&per_page=5', 18 | next: 'https://api.github.com/resouce?page=3&per_page=5', 19 | prev: 'https://api.github.com/resouce?page=1&per_page=5', 20 | last: 'https://api.github.com/resouce?page=4&per_page=5' 21 | }; 22 | 23 | assert.deepEqual(serializer.extractMeta(null, modelClass, payload), { 24 | first: { page: 1, per_page: 5 }, 25 | next: { page: 3, per_page: 5 }, 26 | prev: { page: 1, per_page: 5 }, 27 | last: { page: 4, per_page: 5 } 28 | }); 29 | }); 30 | 31 | test('it handles a missing payload.links property', function (assert) { 32 | let serializer = this.subject(); 33 | let modelClass = { modelName: 'my-model' }; 34 | 35 | let payload = { 36 | 'my-models': [ { id: 1 }, { id: 2 } ] 37 | }; 38 | 39 | assert.equal(serializer.extractMeta(null, modelClass, payload), undefined); 40 | }); 41 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-tree-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-tree', 'Unit | Serializer | github tree', { 4 | // Specify the other units that are required for this test. 5 | needs: ['serializer:github-tree', 'model:github-blob'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it serializes records', function(assert) { 10 | let record = this.subject(); 11 | 12 | let serializedRecord = record.serialize(); 13 | 14 | assert.ok(serializedRecord); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/unit/serializers/github-user-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForModel, test } from 'ember-qunit'; 2 | 3 | moduleForModel('github-user', 'Unit | Serializer | github user', { 4 | // Specify the other units that are required for this test. 5 | needs: [ 6 | 'serializer:github-user', 7 | 'model:githubRepository', 8 | 'model:githubBranch' 9 | ] 10 | }); 11 | 12 | // Replace this with your real tests. 13 | test('it serializes records', function (assert) { 14 | let record = this.subject(); 15 | 16 | let serializedRecord = record.serialize(); 17 | 18 | assert.ok(serializedRecord); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/unit/services/github-session-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('service:github-session', 'Unit | Service | github session', { 4 | // Specify the other units that are required for this test. 5 | // needs: ['service:foo'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it exists', function (assert) { 10 | let service = this.subject(); 11 | assert.ok(service); 12 | }); 13 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elwayman02/ember-data-github/27b031781141c220c0a5a9ce315c45702600473c/vendor/.gitkeep --------------------------------------------------------------------------------