bookingsync-engine 3.0.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +101 -5
  3. data/app/controllers/sessions_controller.rb +1 -1
  4. data/lib/bookingsync-engine.rb +24 -1
  5. data/lib/bookingsync/engine.rb +26 -17
  6. data/lib/bookingsync/engine/application_credentials.rb +15 -0
  7. data/lib/bookingsync/engine/auth_helpers.rb +5 -2
  8. data/lib/bookingsync/engine/credentials_resolver.rb +18 -0
  9. data/lib/bookingsync/engine/models.rb +11 -0
  10. data/lib/bookingsync/engine/models/account.rb +36 -0
  11. data/lib/bookingsync/engine/models/application.rb +9 -0
  12. data/lib/bookingsync/engine/{model.rb → models/base_account.rb} +15 -27
  13. data/lib/bookingsync/engine/models/multi_applications_account.rb +47 -0
  14. data/lib/bookingsync/engine/version.rb +1 -1
  15. data/spec/controllers/authenticated_controller_spec.rb +1 -1
  16. data/spec/controllers/sessions_controller_spec.rb +28 -4
  17. data/spec/dummy/app/models/account.rb +1 -1
  18. data/spec/dummy/app/models/application.rb +3 -0
  19. data/spec/dummy/app/models/application_record.rb +3 -0
  20. data/spec/dummy/app/models/multi_applications_account.rb +3 -0
  21. data/spec/dummy/config/database.yml.docker +11 -0
  22. data/spec/dummy/config/initializers/bookingsync-engine.rb +3 -0
  23. data/spec/dummy/db/migrate/20140522110326_create_accounts.rb +1 -1
  24. data/spec/dummy/db/migrate/20140522110454_add_o_auth_fields_to_accounts.rb +1 -1
  25. data/spec/dummy/db/migrate/20181130062531_create_multi_applications_accounts.rb +8 -0
  26. data/spec/dummy/db/migrate/20181130062650_add_o_auth_fields_to_multi_applications_accounts.rb +14 -0
  27. data/spec/dummy/db/migrate/20181130063056_create_applications.rb +8 -0
  28. data/spec/dummy/db/migrate/20181130063104_add_credentials_fields_to_applications.rb +10 -0
  29. data/spec/dummy/db/schema.rb +41 -10
  30. data/spec/dummy/log/development.log +7423 -16
  31. data/spec/dummy/log/test.log +62430 -617
  32. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0A/0AkQ3CITU4KXnU7GsiDQLAWeLkJApWK8LSS1j7wEk2I.cache +0 -0
  33. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1M/1MTKfLxlwDryDP9C4ksVeuOF5FekTW5EddfnaJ4ujrA.cache +0 -0
  34. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2F/2FjAKNLL-jC6FeYfXsL0M8jItncHQcdDy239KNsTZQs.cache +1 -0
  35. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2_/2_hJriYgvh3UGtv5NMhrnkrtfpJlyTuQ4F5jYdVf8sQ.cache +1 -0
  36. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3J/3JfiofMyqvbHq3sZznFIDsFS81fHxyAWoCXJLrtrWP4.cache +0 -0
  37. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3f/3fwING3B2z9NOnWMwdXFatlVw06vge46KkOWOII0KlU.cache +1 -0
  38. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4i/4iLsjcOzC2_Y0hxnbPKuyayJABeUFDSyIh4Ed9OA8Xw.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/50/502uMBbq2ELFXg5u1vtykxQ_whhsdgQnmTwNA96niD0.cache +0 -0
  40. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5s/5sm0UHvqondwU5MMfjMuqvLW2WQ6S7ylUf9PNw2uCTc.cache +1 -0
  41. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6F/6F2x1Bu3NKSTCTwUS6iCRFhKRT_ntZMzmPIMnVGabK4.cache +1 -0
  42. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6g/6gkpMq6BGSOyooWUFJJQCs2k3-tT0WID6Vg4wknhJoM.cache +0 -0
  43. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8K/8KNXqSB0siJpEjgLM64KpfTgX1FSbkYKxWso4jP9F6U.cache +0 -0
  44. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bf/BfiLjztc-8aILuCwNaYiWOika9XKeEiGNJJJK_LCEr4.cache +0 -0
  45. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CM/CMaRV8szi0IicAXD33YjDgWpLw468X08ycoS-ndwO5o.cache +0 -0
  46. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cc/CcghYxY4f6VUjmyR9LJJi0rYn2LXCdBR9t8Qn4SroL8.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cj/CjEM6wfYwxY_zG--WNzelIKjC420AU9WpvQLgolQOPM.cache +1 -0
  48. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cj/cJJ0QWQg4eJ37I13drpPfSy27rwN7iqiQYPswqRm_Po.cache +0 -0
  49. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/E2/E2tGPoiGjrMuq9vL-ndjkozskpSFwLcGQXxJf_dl4z0.cache +0 -0
  50. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EN/ENHTZiiuQ1cqn16401VaQQBp7b0gwZOA7_I-W5CL5ig.cache +1 -0
  51. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EV/EVkLQJ6idLBSbQnkUelhejMxSOql0wh2QbtfKpdJiak.cache +1 -0
  52. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Gg/Gg6i-z0G_WiBfMUE_gmveurGXQff5_TlQi29HwQcZ-8.cache +1 -0
  53. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Go/Gohhb2B4rJ5hYmGM-VhZxS5dB_NFtsEAdbP1kTKDUeU.cache +0 -0
  54. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/IH/IHM0sjf5lujHT6BG1cYKLB0rdqCd1KYYR5SLZkxXi1k.cache +1 -0
  55. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/NS/NSFU7p8JOb9tHDvG74s3jdRt4ONYZoCTluL3HEsrPxc.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OX/OXQFRQZ5OA2i3YtnP1fZ96aWeUC3_IIqO4fAMdR9FsM.cache +2 -0
  57. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Oi/OiV2J0lyHQgXCDgtmFPNLE59EbztPsv9MNy05s943Yw.cache +2 -0
  58. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ps/PsVVU35DPe0tSyJ1zEoiPaaJiwo6NclhO2OKuFSn76A.cache +0 -0
  59. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R-/R-onhPbfjYnU6tM9fR0wZkXDSvCLrY5G1wyNCSVmKEs.cache +1 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/RR/RRXzNBrpSlU0RGhaxTSE_1GoRrV4JkWqF0ZoOf9xtzQ.cache +0 -0
  61. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rd/Rd_ZtA5c34XyxDbTpkN8_ZfF1x78s46DbRXLu0jqMgo.cache +1 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Sm/SmJRxdUchUsyyMi6zvsdwrcRR1hfQ9YeSZNKNM-n5lw.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Su/Sue46_TUXTlImzpNh2bkqDFL5cQ08rCAcaaJqlWI7qg.cache +0 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/T1/T1lVNy8C6VpxjRsI38DgOfG7yIh3OohPWTNZmJb8CPo.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Z-/Z-P7NJ7vzHin8mjLSAoWJW6FZfd6xwWS3xuoCX0DE40.cache +0 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Z9/Z9d8_EzLy9N7tx_nHmbmBF5LzFtW_0sik4AH1IFBX0Y.cache +1 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ze/ZelUAL6jLQcQiGZUfnAbvuJbU9OAqHiXV_Ccu8lToho.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Zr/Zr7RfTTM_QNQ-7MuSD-M0rF18yH25tCSI9G4H5yYjAQ.cache +1 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_S/_SxbUQwhqQU8951QbOA6ZZ41F0d9D-VhhQqUE4BCryQ.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_o/_okSFa_t7W5YJBZTW7ZitTwnmAFYgJup7tpTYum0Udo.cache +1 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aJ/aJ4EkukIrCHlOkA1WpQIasGGosjGkOKvRMsfcNQx1QQ.cache +0 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bk/bk_rOYlFWoHkh4HHsvbxeo8rSvDWRX6cCbVlO2VCVNA.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cO/cOGLhXoKF0BumBbtviyCY1xusm_WMEMhGSWY9qFekRU.cache +2 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cq/cqMX8l9XlG5jEWd0fWjA7MTlj21d6dzcnhhOq08uFHY.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cy/cyurAtFfq8D4ORO-aDATDzTKcBumJfgafhOUCbECuMw.cache +0 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eO/eOY3YH36a6yvdznpQqACMiI0e1CcTwPiEjUdhRfmm9k.cache +0 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/f3/f3VckKo5w8mrxeqmzwLfZr7f6sj0dA8xZrFq3GMF0ig.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fS/fSn1A2ssuKdsdJ-uwH_i8bXBaWmbJd0wHd-Ob6pTPi0.cache +1 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gD/gDQJ-WkVLldqzYHKOLkamKeU-sTkDscHqOQawz7a6m4.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hj/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jH/jHvwYeln0CEBatCDHIjJMF0vIdmuDmS_eTKNxFhOmlA.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jU/jUktWNbR4V7n34UAZe7uJpmEofhflF0bVtIO2BgxyJ8.cache +2 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jb/jb46fu3q3DLQ7TFyiuaXmL_CPF7cQst2RgrF0xVyGtA.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/le/lekrQ_bDFewtYzH2xoA2tovuPzYdoSwnauQ4MgDwb0U.cache +1 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m8/m8I0GZ1puWB4hISNebXEGDX3G5QkoSVWHP4SiRvN-3Y.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mn/mNEeM32MBaqiZ0_N_eheQR9oimoBpmcXRXr5puTAh3o.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mn/mNaj9zqaawn26kC4FL9ECzN5lkppnwTTQ93MIeJRKZg.cache +1 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mn/mnJy7Ei2tJLs8tfmmUHjtWmfk2yfl1opoYG7Deg2bWQ.cache +0 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oC/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +0 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oS/oS5JF4El36MylOD0SJtv4YV-fsqNzd89t1IqlBzwYes.cache +1 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oY/oYCeXuzhz0IQEBtepScpQ7HlUp5yVleUE6BOLsnhXwA.cache +1 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oZ/oZDDUJWB1xgHo4uv_iiUCtutWZ6LeJykII3cNkmd_bA.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/u-/u-Iidm4zcU2RFkiqJFQkLTBxXuEoF5gCeJM4V5-3Qyc.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uK/uKpQUG2ys9fKuyfsrw1Payh72LhuIrYJXep13nTbIIc.cache +1 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uX/uXHfYanP3WS7whlKHqs0pLBkEQwj_IGbfmktFdHfZ_A.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v9/v9HWdIdg3uuXOOqxWg8Y6aWxzqbywfxecFSDm5ilUs8.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/w2/w2izaLMTzGRpPOq1R_Yl-0Ma7hm7tej5kSjV9khvFSk.cache +1 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y4/y4-jRuYEQUuCPpXrCIiCC1lgXmW4pm12ZEla-d56noA.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yW/yWlGtA8E8Li2epEGqbxtvBeb5h0e52XZQ8xKiMXgDOY.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yZ/yZRcLaNBQxCgGewY_IaXZrXG1YmOhr1iSxfZ-4MMK9Y.cache +0 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zU/zUYxN3uLSvSCpp561lMJSJXPGanKNgxT32rw-w5jpPs.cache +0 -0
  104. data/spec/dummy/tmp/restart.txt +0 -0
  105. data/spec/helpers/auth_helpers_spec.rb +42 -0
  106. data/spec/lib/bookingsync/engine/application_credentials_spec.rb +41 -0
  107. data/spec/lib/bookingsync/engine/credentials_resolver_spec.rb +18 -0
  108. data/spec/models/account_spec.rb +130 -41
  109. data/spec/models/application_spec.rb +16 -0
  110. data/spec/models/multi_application_account_spec.rb +247 -0
  111. data/spec/spec_helper.rb +6 -4
  112. metadata +256 -34
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&id=248130233b95d71ffd59edb693b708cc46e813bffce36f7f12297f509e8eb198:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=ab2b5a31b9104fc1acbca8e9c70e4874b263ef9c2476e5cd82b925118e81b0fb:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=610bdac9a004562a9915c7e6c42034c20c0fdb786fdee0624358c07d2aa8828b:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=33f72034b6848ab549eaa43e39f091b09658b2bc61a210fb7adc9621420a5162:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css?type=text/css&id=a570ad42a70338f5369a46898cbe8ddf77efb13d38219d747d95fe43ed38a181:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css?type=text/css&pipeline=self&id=2f5b3504f5b2a560f0096b23930970c166155db72dc48653192a87a30e96d966:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css?type=text/css&pipeline=debug&id=0f57db7ea684d2779265a0e384675b885f8c518c22e73a6aed51255187048888:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=a0bd5917a0971ce3959a41aee9ca8a7c72a9520dfe94e9d76361c6a737e74f18:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=debug&id=85f5fb70de6c2b897514b508d2a2aff20513670472801c93ae3d3eb1df139b1d:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=debug&id=d1b901dee5585f7f0d4a8beb755264b8f3ca38c8a692ad5b81f5c81c96cdf6a0:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"?processors:type=text/css&file_type=text/css&pipeline=debug;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTF
@@ -0,0 +1,2 @@
1
+ "%���*�y��D_�
2
+ �+���C����]�2���
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=a5578b9f7a125192e76d4a79123068d9c108a2542c8f8f86422edd91576b86cb:ET
@@ -0,0 +1 @@
1
+ "%��c�w��jS޿5��.y����������r
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=a2d8206d4eb3819f3bf8440f7e597e7ad7939aaee6cc87ca8363814bcb3c4554:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=917abf874b7120cdbfc26ecdab3088dfc82bf58ce82ec923e0e9cc226a0ac4f5:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&pipeline=self&id=92f6f3a017e2413f6e67f5518863baee7fcc6c6cbf9340df2e9e20f70586c0aa:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&id=5a71f602ea77d1fc1dfb73a28ad42b718d52519e8ea5612695bde6f81b0e6a64:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"?processors:type=text/css&file_type=text/css&pipeline=debug;TTI"{file-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"{file-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css;TTI"/file-digest://app/assets/images/doorkeeper;TTI"=file-digest://app/assets/images/doorkeeper/bootstrap.min;TTI"4file-digest://app/assets/javascripts/doorkeeper;TTI"Bfile-digest://app/assets/javascripts/doorkeeper/bootstrap.min;TTI"4file-digest://app/assets/stylesheets/doorkeeper;TTI"Bfile-digest://app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"kfile-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper;TTI"yfile-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"nfile-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/vendor/assets/stylesheets/doorkeeper;TTI"|file-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/vendor/assets/stylesheets/doorkeeper/bootstrap.min;TTI"qfile-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin;TTI"|file-digest:///Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin/application.css;TTF
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css?type=text/css&pipeline=self&id=ae3869fc17de8fef1cb0e86807c4f8b4aa42fd29e6e146e1918fff898ae9bc96:ET
@@ -0,0 +1 @@
1
+ "%ʹ��L�#Z�v%������%�:�T)�:�(�O
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&id=57df7bf470017b3aae3e4439780d3a25c7d62e2df4fbea5dbc0be7e0c0bfcb88:ET
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"[processors:type=application/javascript&file_type=application/javascript&pipeline=debug;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI")file-digest://app/assets/javascripts;TTF
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=96141f776ce71efa0544bc36d883da7d4ac393687e7295de9b0f755c2840604e:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css?type=text/css&pipeline=self&id=6fd11bdb2121779e5511cdf40506924a1d312050c9cf4055da6841ae77c87879:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=7a94513f5acc8c29cc959d74bdd100a8adf3a1a4dbb32723e2f9f212a53c1711:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css?type=text/css&pipeline=self&id=b48be173b8c9cac5673a8cf6685188990d68fb63199eda36d4b6774cbda7aaab:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&pipeline=self&id=2bbcf5b40fbd2de4d96de52d5ff871e3fd147e24716aeb5170e36890548ddae5:ET
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -0,0 +1 @@
1
+ "%&��P�`���_������MLH���O8�~�
@@ -0,0 +1 @@
1
+ "%���%p'�&�p؀ɴֵ���8h���
@@ -0,0 +1 @@
1
+ I"}app/assets/stylesheets/application.css?type=text/css&id=d7ab78f3c2d9666687dd5865413851ed5ddbb8499ca9884f67543dfc0c96f957:ET
@@ -0,0 +1 @@
1
+ I"�/Users/marc/.rvm/gems/ruby-2.4.1/gems/doorkeeper-5.0.2/app/assets/stylesheets/doorkeeper/application.css?type=text/css&id=6a0169633bb25f5fb4dc13b9878c27bf1770539297b8d86c4d9111653eb176df:ET
@@ -0,0 +1 @@
1
+ I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=cc8e945e51a966b912e91f3f50f7681c12917f036d31dba43b09394760de63ad:ET
File without changes
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ApplicationHelper, type: :helper do
4
+ describe "#current_account" do
5
+ context "without an account_id in session" do
6
+ before { session[:account_id] = nil }
7
+
8
+ it "returns nil" do
9
+ expect(helper.current_account).to be_nil
10
+ end
11
+ end
12
+
13
+ context "with an account_id in session" do
14
+ before { session[:account_id] = 123 }
15
+
16
+ context "when using single application setup" do
17
+ before do
18
+ allow(BookingSyncEngine).to receive(:support_multi_applications?).and_return(false)
19
+ end
20
+
21
+ let!(:account) { Account.create!(synced_id: 123) }
22
+
23
+ it "finds and return the current account by synced_id" do
24
+ expect(helper.current_account).to eq account
25
+ end
26
+ end
27
+
28
+ context "when using multi application setup" do
29
+ before do
30
+ allow(BookingSyncEngine).to receive(:support_multi_applications?).and_return(true)
31
+ end
32
+
33
+ let!(:account_1) { MultiApplicationsAccount.create!(host: "example.host", synced_id: 123) }
34
+ let!(:account_2) { MultiApplicationsAccount.create!(host: "test.host", synced_id: 123) }
35
+
36
+ it "finds and return the current account by host and synced_id" do
37
+ expect(helper.current_account).to eq account_2
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe BookingSync::Engine::ApplicationCredentials do
4
+ describe "#valid" do
5
+ context "with no application given" do
6
+ subject(:application_credentials) { BookingSync::Engine::ApplicationCredentials.new }
7
+
8
+ it "returns false" do
9
+ expect(application_credentials.valid?).to eq false
10
+ end
11
+ end
12
+
13
+ context "with application given" do
14
+ subject(:application_credentials) { BookingSync::Engine::ApplicationCredentials.new(application) }
15
+
16
+ context "with client_id missing" do
17
+ let(:application) { Application.new(host: "exemple.test", client_id: nil, client_secret: "456") }
18
+
19
+ it "returns false" do
20
+ expect(application_credentials.valid?).to eq false
21
+ end
22
+ end
23
+
24
+ context "with client_secret missing" do
25
+ let(:application) { Application.new(host: "exemple.test", client_id: "123", client_secret: nil) }
26
+
27
+ it "returns false" do
28
+ expect(application_credentials.valid?).to eq false
29
+ end
30
+ end
31
+
32
+ context "with client_id and client_secret present" do
33
+ let(:application) { Application.new(host: "exemple.test", client_id: "123", client_secret: "456") }
34
+
35
+ it "returns true" do
36
+ expect(application_credentials.valid?).to eq true
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe BookingSync::Engine::CredentialsResolver do
4
+ describe "#call" do
5
+ let(:credentials_resolver) do
6
+ BookingSync::Engine::CredentialsResolver.new("example.test")
7
+ end
8
+ let!(:application) do
9
+ Application.create(host: "example.test", client_id: "123", client_secret: "456")
10
+ end
11
+
12
+ it "returns an application credentials properly initiated" do
13
+ expect(BookingSync::Engine::ApplicationCredentials).to receive(:new)
14
+ .with(application).and_return("great")
15
+ expect(credentials_resolver.call).to eq "great"
16
+ end
17
+ end
18
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  RSpec.describe Account, type: :model do
4
4
  shared_examples "it takes attributes from auth" do
@@ -18,20 +18,28 @@ RSpec.describe Account, type: :model do
18
18
  end
19
19
 
20
20
  describe ".from_omniauth" do
21
- before { Account.create!(provider: "bookingsync", synced_id: 456) }
22
-
23
21
  let(:auth) { OmniAuth.config.mock_auth[:bookingsync] }
24
22
 
23
+ before { Account.create!(provider: "bookingsync", synced_id: 456) }
24
+
25
25
  context "when account exists" do
26
26
  let!(:account) { Account.create!(provider: "bookingsync", synced_id: 123) }
27
27
 
28
- it "loads the existing account" do
29
- expect(Account.from_omniauth(auth)).to eql(account)
28
+ context "with host given" do
29
+ it "loads the existing account" do
30
+ expect(Account.from_omniauth(auth, "example.test")).to eql(account)
31
+ end
32
+ end
33
+
34
+ context "without host given" do
35
+ it "loads the existing account" do
36
+ expect(Account.from_omniauth(auth, nil)).to eql(account)
37
+ end
30
38
  end
31
39
 
32
40
  describe "the updated account" do
33
41
  before do
34
- Account.from_omniauth(auth)
42
+ Account.from_omniauth(auth, "example.test")
35
43
  account.reload
36
44
  end
37
45
 
@@ -42,12 +50,12 @@ RSpec.describe Account, type: :model do
42
50
  context "when account doesn't exist" do
43
51
  it "creates new account" do
44
52
  expect {
45
- Account.from_omniauth(auth)
53
+ Account.from_omniauth(auth, "example.test")
46
54
  }.to change { Account.count }.by(1)
47
55
  end
48
56
 
49
57
  describe "the newly created account" do
50
- let!(:account) { Account.from_omniauth(auth) }
58
+ let!(:account) { Account.from_omniauth(auth, "example.test") }
51
59
 
52
60
  it "sets synced_id and provider from auth" do
53
61
  expect(account.synced_id).to eq 123
@@ -59,12 +67,23 @@ RSpec.describe Account, type: :model do
59
67
  end
60
68
  end
61
69
 
70
+ describe ".find_by_host_and_synced_id" do
71
+ let!(:account_1) { Account.create!(synced_id: 1) }
72
+ let!(:account_2) { Account.create!(synced_id: 2) }
73
+ let!(:account_3) { Account.create!(synced_id: 3) }
74
+
75
+ it "returns the right account" do
76
+ expect(Account.find_by_host_and_synced_id("any_host", 3)).to eq account_3
77
+ end
78
+ end
79
+
62
80
  describe "#token" do
63
- let(:expires_at) { 1.day.from_now.to_i }
64
81
  let!(:account) { Account.create!(synced_id: 123, oauth_access_token: "token",
65
82
  oauth_refresh_token: "refresh_token", oauth_expires_at: expires_at) }
66
83
 
67
84
  context "when the stored token is fresh" do
85
+ let(:expires_at) { 1.day.from_now.to_i }
86
+
68
87
  it "returns the token" do
69
88
  expect(account.token).to be_a OAuth2::AccessToken
70
89
  expect(account.token.token).to eq "token"
@@ -72,59 +91,129 @@ RSpec.describe Account, type: :model do
72
91
  end
73
92
 
74
93
  context "when the stored token is expired" do
75
- # comparing rails version, the use_transactional_fixtures only works pre 5
76
- if Rails::VERSION::STRING.split(".").first.to_i >=5
77
- self.use_transactional_tests = false
78
- else
79
- self.use_transactional_fixtures = false
94
+ around do |test_case|
95
+ # comparing rails version, the use_transactional_fixtures only works pre 5
96
+ if Rails::VERSION::MAJOR >= 5
97
+ original_setup = self.use_transactional_tests
98
+ self.use_transactional_tests = false
99
+ test_case.run
100
+ self.use_transactional_tests = original_setup
101
+ else
102
+ original_setup = self.use_transactional_fixtures
103
+ self.use_transactional_fixtures = false
104
+ test_case.run
105
+ self.use_transactional_fixtures = original_setup
106
+ end
80
107
  end
81
108
 
82
109
  let(:expires_at) { 1.day.ago.to_i.to_s }
83
- let(:new_expires_at) { 2.days.from_now.to_i.to_s }
84
- let(:token) { double(expired?: true, refresh!: double(token: "refreshed_token",
85
- refresh_token: "refreshed_refresh_token", expires_at: new_expires_at)) }
86
- let(:client) { double }
87
110
 
88
111
  before do
89
- expect(BookingSync::Engine).to receive(:oauth_client) { client }
90
- expect(OAuth2::AccessToken).to receive(:new).with(client, "token",
91
- refresh_token: "refresh_token", expires_at: expires_at) { token }
92
- end
93
-
94
- after do
95
- Account.destroy_all
112
+ stub_request(:post, "https://some_url.com/oauth/token").with(
113
+ body: {
114
+ "client_id" => "some_client_id",
115
+ "client_secret" => "some_client_secret",
116
+ "grant_type" => "refresh_token",
117
+ "refresh_token" => "refresh_token"
118
+ },
119
+ headers: {
120
+ "Accept" => "application/vnd.api+json",
121
+ "Content-Type" => "application/x-www-form-urlencoded"
122
+ }
123
+ ).to_return(
124
+ status: 200,
125
+ body: { "access_token": "refreshed_token" }.to_json,
126
+ headers: { "Content-Type" => "application/json" }
127
+ )
96
128
  end
97
129
 
98
130
  it "refreshes the token" do
99
- expect(token).to receive(:refresh!)
100
- account.token
131
+ expect(account.token).to be_a OAuth2::AccessToken
132
+ expect(account.token.token).to eq "refreshed_token"
101
133
  end
102
134
  end
103
135
  end
104
136
 
105
- describe "#clear_token!" do
106
- it "clears token related fields on account" do
107
- account = Account.create!(oauth_access_token: "token",
108
- oauth_refresh_token: "refresh", oauth_expires_at: "expires")
137
+ describe "#application_token" do
138
+ let!(:account) { Account.create!(synced_id: 123) }
139
+ before do
140
+ stub_request(:post, "https://some_url.com/oauth/token").with(
141
+ body: {
142
+ "client_id" => "some_client_id",
143
+ "client_secret" => "some_client_secret",
144
+ "grant_type"=>"client_credentials"
145
+ },
146
+ headers: {
147
+ "Accept" => "application/vnd.api+json",
148
+ "Content-Type" => "application/x-www-form-urlencoded"
149
+ }
150
+ ).to_return(
151
+ status: 200,
152
+ body: { "access_token": "the_access_token" }.to_json,
153
+ headers: { "Content-Type" => "application/json" }
154
+ )
155
+ end
109
156
 
110
- account.clear_token!
111
- account.reload
157
+ it "returns a client credential token setup without default params" do
158
+ expect(account.application_token.token).to eq "the_access_token"
159
+ end
160
+ end
161
+
162
+ describe "#oauth_client" do
163
+ let!(:account) { Account.create!(synced_id: 123) }
164
+
165
+ it "returns a BookingSync::Engine.oauth_client setup without default params" do
166
+ expect(account.oauth_client).to be_an OAuth2::Client
167
+ expect(account.oauth_client.id).to eq "some_client_id"
168
+ expect(account.oauth_client.secret).to eq "some_client_secret"
169
+ end
170
+ end
112
171
 
113
- expect(account.oauth_access_token).to be_nil
114
- expect(account.oauth_refresh_token).to be_nil
115
- expect(account.oauth_expires_at).to be_nil
172
+ describe "#application" do
173
+ let!(:account) { Account.create!(synced_id: 123) }
174
+
175
+ it "returns nil" do
176
+ expect(account.application).to be_nil
116
177
  end
117
178
  end
118
179
 
119
180
  describe "#api" do
120
- it "returns API client initialized with OAuth token" do
121
- token = double(token: "access_token", expired?: false)
122
- allow(OAuth2::AccessToken).to receive(:new)
123
- .and_return(token)
124
- account = Account.new
181
+ let!(:account) { Account.new(oauth_access_token: "access_token") }
125
182
 
183
+ it "returns API client initialized with OAuth token" do
126
184
  expect(account.api).to be_kind_of(BookingSync::API::Client)
127
185
  expect(account.api.token).to eq("access_token")
128
186
  end
129
187
  end
188
+
189
+ describe "#clear_token!" do
190
+ let!(:account) do
191
+ Account.create!(oauth_access_token: "token", oauth_refresh_token: "refresh",
192
+ oauth_expires_at: "expires")
193
+ end
194
+ it "clears token related fields on account" do
195
+ expect { account.clear_token! }
196
+ .to change { account.reload.oauth_access_token }.from("token").to(nil)
197
+ .and change { account.oauth_refresh_token }.from("refresh").to(nil)
198
+ .and change { account.oauth_expires_at }.from("expires").to(nil)
199
+ end
200
+ end
201
+
202
+ describe "#update_token" do
203
+ let!(:account) do
204
+ Account.create!(oauth_access_token: "token", oauth_refresh_token: "refresh",
205
+ oauth_expires_at: "expires")
206
+ end
207
+ let(:token) do
208
+ double(token: "new_access_token", refresh_token: "new_refresh_token",
209
+ expires_at: "new_expires_at")
210
+ end
211
+
212
+ it "updates the token related fields on account" do
213
+ expect { account.update_token(token) }
214
+ .to change { account.oauth_access_token }.from("token").to("new_access_token")
215
+ .and change { account.oauth_refresh_token }.from("refresh").to("new_refresh_token")
216
+ .and change { account.oauth_expires_at }.from("expires").to("new_expires_at")
217
+ end
218
+ end
130
219
  end