disco_app 0.12.7.pre.puma.pre.3 → 0.13.6.pre.puma.pre.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/components/disco_app/forms/model-form.es6.jsx +2 -7
  3. data/app/assets/javascripts/disco_app/components/custom/shop_row.js.jsx +2 -1
  4. data/app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx +16 -44
  5. data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-checkbox.es6.jsx +10 -5
  6. data/app/controllers/disco_app/admin/application_controller.rb +2 -1
  7. data/app/controllers/disco_app/admin/concerns/sources_controller.rb +51 -0
  8. data/app/controllers/disco_app/admin/sources_controller.rb +3 -0
  9. data/app/controllers/disco_app/concerns/user_authenticated_controller.rb +17 -0
  10. data/app/controllers/disco_app/user_sessions_controller.rb +57 -0
  11. data/app/jobs/disco_app/concerns/app_installed_job.rb +1 -1
  12. data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +1 -1
  13. data/app/jobs/disco_app/concerns/render_asset_group_job.rb +1 -1
  14. data/app/jobs/disco_app/concerns/shop_update_job.rb +1 -1
  15. data/app/jobs/disco_app/concerns/subscription_changed_job.rb +1 -1
  16. data/app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb +1 -1
  17. data/app/jobs/disco_app/concerns/synchronise_resources_job.rb +1 -1
  18. data/app/jobs/disco_app/concerns/synchronise_users_job.rb +15 -0
  19. data/app/jobs/disco_app/concerns/synchronise_webhooks_job.rb +1 -1
  20. data/app/jobs/disco_app/send_subscription_job.rb +1 -1
  21. data/app/jobs/disco_app/shop_job.rb +10 -3
  22. data/app/jobs/disco_app/synchronise_users_job.rb +3 -0
  23. data/app/models/disco_app/concerns/shop.rb +13 -4
  24. data/app/models/disco_app/concerns/source.rb +14 -0
  25. data/app/models/disco_app/concerns/subscription.rb +1 -1
  26. data/app/models/disco_app/concerns/synchronises.rb +9 -0
  27. data/app/models/disco_app/concerns/taggable.rb +7 -3
  28. data/app/models/disco_app/concerns/user.rb +20 -0
  29. data/app/models/disco_app/source.rb +3 -0
  30. data/app/models/disco_app/user.rb +3 -0
  31. data/app/resources/disco_app/admin/resources/concerns/shop_resource.rb +4 -4
  32. data/app/services/disco_app/subscription_service.rb +8 -2
  33. data/app/views/disco_app/admin/sources/_form.html.erb +34 -0
  34. data/app/views/disco_app/admin/sources/edit.html.erb +7 -0
  35. data/app/views/disco_app/admin/sources/index.html.erb +32 -0
  36. data/app/views/disco_app/admin/sources/new.html.erb +7 -0
  37. data/app/views/disco_app/user_sessions/new.html.erb +12 -0
  38. data/app/views/layouts/admin/_nav_items.erb +7 -0
  39. data/config/routes.rb +4 -0
  40. data/db/migrate/20170315062548_create_disco_app_sources.rb +10 -0
  41. data/db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb +14 -0
  42. data/db/migrate/20170327214540_create_disco_app_users.rb +13 -0
  43. data/db/migrate/20170606160751_fix_disco_app_users_index.rb +6 -0
  44. data/lib/disco_app/version.rb +1 -1
  45. data/lib/generators/disco_app/disco_app_generator.rb +1 -1
  46. data/lib/generators/disco_app/templates/config/database.yml.tt +1 -0
  47. data/lib/tasks/users.rake +10 -0
  48. data/test/dummy/app/jobs/carts_update_job.rb +1 -1
  49. data/test/dummy/app/jobs/disco_app/app_uninstalled_job.rb +2 -2
  50. data/test/dummy/app/jobs/products_create_job.rb +1 -1
  51. data/test/dummy/app/jobs/products_delete_job.rb +1 -1
  52. data/test/dummy/app/jobs/products_update_job.rb +1 -1
  53. data/test/dummy/app/models/cart.rb +3 -3
  54. data/test/dummy/app/models/disco_app/shop.rb +1 -1
  55. data/test/dummy/config/database.yml +1 -0
  56. data/test/dummy/db/schema.rb +23 -2
  57. data/test/fixtures/api/subscriptions/valid_request.json +1 -1
  58. data/test/fixtures/api/widget_store/users.json +42 -0
  59. data/test/fixtures/disco_app/sources.yml +3 -0
  60. data/test/integration/synchronises_test.rb +3 -3
  61. data/test/jobs/disco_app/app_installed_job_test.rb +3 -3
  62. data/test/jobs/disco_app/app_uninstalled_job_test.rb +1 -1
  63. data/test/jobs/disco_app/synchronise_users_job_test.rb +26 -0
  64. metadata +27 -3
  65. data/test/dummy/config/database.gitlab-ci.yml +0 -24
@@ -0,0 +1,34 @@
1
+ <section class="section">
2
+ <div class="layout-content">
3
+ <section class="layout-content__main">
4
+ <div class="next-grid">
5
+ <div class="next-grid__cell">
6
+ <div class="next-card">
7
+
8
+ <header class="next-card__header">
9
+ <h1>Source</h1>
10
+ </header>
11
+
12
+ <section class="next-card__section">
13
+ <div class="form-group">
14
+ <%= f.label(:source, 'Source code') %>
15
+ <%= f.text_field(:source, placeholder: "Enter the source name in its acronyme form (eg: Bob Dylan => bd") %>
16
+ </div>
17
+
18
+ <div class="form-group">
19
+ <%= f.label(:status, 'Full source name') %>
20
+ <%= f.text_field(:name, placeholder: "Enter the full source name") %>
21
+ </div>
22
+ </section>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <hr />
27
+ <div class="row">
28
+ <div class="col-md-12">
29
+ <%= f.submit 'Save', { class: 'btn btn-primary' } %>
30
+ </div>
31
+ </div>
32
+ </section>
33
+ </div>
34
+ </section>
@@ -0,0 +1,7 @@
1
+ <% provide(:title, 'Edit Source') %>
2
+
3
+ <%= form_for(@source, url: admin_source_path(@source)) do |f| %>
4
+ <%= render 'form', f: f %>
5
+ <% end %>
6
+
7
+ <%= link_to 'Back', admin_sources_path, { class: 'btn btn-default' } %>
@@ -0,0 +1,32 @@
1
+ <% provide(:title, 'Sources') %>
2
+
3
+ <div class="next-grid">
4
+ <div class="next-grid__cell">
5
+ <div class="next-card">
6
+ <% unless @sources.empty? %>
7
+ <table class="table">
8
+ <thead>
9
+ <tr>
10
+ <th>Source</th>
11
+ <th>Source (Full name)</th>
12
+ <th></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @sources.each do |source| %>
17
+ <tr>
18
+ <td><%= link_to(source.name, edit_admin_source_path(source)) %></td>
19
+ <td><%= source.source %></td>
20
+ <td><%= source.name %></td>
21
+ <td><%= link_to 'Delete', admin_source_path(source), action: 'destroy', method: :delete, data: {confirm: "About to delete the source: #{source.source}. Are you sure?"} %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ <% end %>
27
+ </div>
28
+ <hr/>
29
+ <%= link_to 'Create new source', new_admin_source_path, { class: 'btn btn-primary' } %>
30
+ </div>
31
+ </div>
32
+
@@ -0,0 +1,7 @@
1
+ <% provide(:title, 'New Source') %>
2
+
3
+ <%= form_for(@source, url: admin_sources_path) do |f| %>
4
+ <%= render 'form', f: f %>
5
+ <% end %>
6
+
7
+ <%= link_to 'Back', admin_sources_path, { class: 'btn btn-default' } %>
@@ -0,0 +1,12 @@
1
+ <%= form_tag user_sessions_path, method: :post do %>
2
+ <div class="ui-empty-state">
3
+ <section class="ui-empty-state__section">
4
+ <div class="ui-empty-state__subsection">
5
+ <h2 class="ui-empty-state__subtitle">Login as a Shopify User to access this page</h2>
6
+ </div>
7
+ <div class="ui-empty-state__subsection">
8
+ <button type="submit" class="btn btn-large btn-primary">Login</button>
9
+ </div>
10
+ </section>
11
+ </div>
12
+ <% end %>
@@ -12,6 +12,13 @@
12
12
  </a>
13
13
  </li>
14
14
 
15
+ <li class="next-nav__item">
16
+ <a href="<%= admin_sources_path %>" class="next-nav__link <%= active_link_to_class(admin_sources_path, class_active: 'next-nav__link--is-selected', active: :inclusive) %>">
17
+ <svg class="next-icon next-icon--size-16 next-icon--no-nudge" role="img" aria-labelledby="next-dashboard-16-17dbedf316126bf9bd81f6c6b7626199-title"><title id="next-dashboard-16-17dbedf316126bf9bd81f6c6b7626199-title">Home</title><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-dashboard-16"></use></svg>
18
+ <span class="next-nav__text">Sources</span>
19
+ </a>
20
+ </li>
21
+
15
22
  <li class="next-nav__item">
16
23
  <a href="<%= edit_admin_app_settings_path %>" class="next-nav__link <%= active_link_to_class(edit_admin_app_settings_path, class_active: 'next-nav__link--is-selected', active: :inclusive) %>">
17
24
  <svg class="next-icon next-icon--size-16 next-icon--no-nudge" role="img" aria-labelledby="next-dashboard-16-17dbedf316126bf9bd81f6c6b7626199-title"><title id="next-dashboard-16-17dbedf316126bf9bd81f6c6b7626199-title">Home</title><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#next-dashboard-16"></use></svg>
data/config/routes.rb CHANGED
@@ -9,6 +9,9 @@ DiscoApp::Engine.routes.draw do
9
9
  post 'webhooks' => :process_webhook, as: :webhooks
10
10
  end
11
11
 
12
+ resources :user_sessions, only: [:new, :create, :destroy]
13
+ get 'auth/shopify_user/callback' => 'user_sessions#callback'
14
+
12
15
  resources :subscriptions, only: [:new, :create] do
13
16
  resources :charges, only: [:new, :create] do
14
17
  member do
@@ -33,6 +36,7 @@ DiscoApp::Engine.routes.draw do
33
36
  resources :subscriptions, only: [:edit, :update]
34
37
  end
35
38
  resources :plans
39
+ resources :sources
36
40
  resource :app_settings, only: [:edit, :update]
37
41
 
38
42
  # JSON-API resources for admins.
@@ -0,0 +1,10 @@
1
+ class CreateDiscoAppSources < ActiveRecord::Migration
2
+ def change
3
+ create_table :disco_app_sources do |t|
4
+ t.string :source, null: true
5
+ t.string :name, null: true
6
+ t.timestamps null: false
7
+ end
8
+ add_index :disco_app_sources, :source
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class AddSourcesToShopSubscriptions < ActiveRecord::Migration
2
+ def change
3
+ add_column :disco_app_subscriptions, :source_id, :integer, limit: 8, index: true
4
+ add_foreign_key :disco_app_subscriptions, :disco_app_sources, column: :source_id
5
+
6
+ DiscoApp::Subscription.where.not(source: nil).find_each do |subscription|
7
+ DiscoApp::Source.find_or_create_by(source: subscription.source) do |new_source|
8
+ new_source.name = subscription.source
9
+ end
10
+ end
11
+
12
+ remove_column :disco_app_subscriptions, :source
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class CreateDiscoAppUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :disco_app_users do |t|
4
+ t.integer :shop_id, limit: 8
5
+ t.string :first_name
6
+ t.string :last_name
7
+ t.string :email
8
+
9
+ t.timestamps null: false
10
+ end
11
+ add_index :disco_app_users, :shop_id, unique: true
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class FixDiscoAppUsersIndex < ActiveRecord::Migration
2
+ def change
3
+ remove_index :disco_app_users, :shop_id
4
+ add_index :disco_app_users, [:id, :shop_id], unique: true
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module DiscoApp
2
- VERSION = '0.12.7-puma-3'
2
+ VERSION = '0.13.6-puma-3'
3
3
  end
@@ -9,7 +9,7 @@ class DiscoAppGenerator < Rails::Generators::Base
9
9
  # - Default simple Procfile for Heroku.
10
10
  #
11
11
  def copy_root_files
12
- %w(.env .env.local .gitignore Procfile CHECKS).each do |file|
12
+ %w(.env .env.local .gitignore .rubocop.yml .codeclimate.yml Procfile CHECKS).each do |file|
13
13
  copy_file "root/#{file}", file
14
14
  end
15
15
  end
@@ -3,6 +3,7 @@ default: &default
3
3
  encoding: unicode
4
4
  pool: 5
5
5
  timeout: 5000
6
+ prepared_statements: false
6
7
 
7
8
  development:
8
9
  <<: *default
@@ -0,0 +1,10 @@
1
+ namespace :users do
2
+
3
+ desc 'Synchronise user data accross all installed shops'
4
+ task sync: :environment do
5
+ DiscoApp::Shop.installed.has_active_shopify_plan.shopify_plus.each do |shop|
6
+ DiscoApp::SynchroniseUsersJob.perform_later(shop)
7
+ end
8
+ end
9
+
10
+ end
@@ -1,6 +1,6 @@
1
1
  class CartsUpdateJob < DiscoApp::ShopJob
2
2
 
3
- def perform(shop, cart_data)
3
+ def perform(_shop, cart_data)
4
4
  Cart.synchronise(@shop, cart_data)
5
5
  end
6
6
 
@@ -3,8 +3,8 @@ class DiscoApp::AppUninstalledJob < DiscoApp::ShopJob
3
3
 
4
4
  # Extend the perform method to change the country name of the shop to
5
5
  # 'Nowhere' on uninstallation.
6
- def perform(domain, shop_data)
7
- super(domain, shop_data)
6
+ def perform(_shop, shop_data)
7
+ super
8
8
  @shop.update(data: @shop.data.merge(country_name: 'Nowhere'))
9
9
  end
10
10
 
@@ -1,6 +1,6 @@
1
1
  class ProductsCreateJob < DiscoApp::ShopJob
2
2
 
3
- def perform(shop, product_data)
3
+ def perform(_shop, product_data)
4
4
  Product.synchronise(@shop, product_data)
5
5
  end
6
6
 
@@ -1,6 +1,6 @@
1
1
  class ProductsDeleteJob < DiscoApp::ShopJob
2
2
 
3
- def perform(shop, product_data)
3
+ def perform(_shop, product_data)
4
4
  Product.synchronise_deletion(@shop, product_data)
5
5
  end
6
6
 
@@ -1,6 +1,6 @@
1
1
  class ProductsUpdateJob < DiscoApp::ShopJob
2
2
 
3
- def perform(shop, product_data)
3
+ def perform(_shop, product_data)
4
4
  Product.synchronise(@shop, product_data)
5
5
  end
6
6
 
@@ -8,17 +8,17 @@ class Cart < ActiveRecord::Base
8
8
  before_save :set_token
9
9
 
10
10
  def self.synchronise_by(shop, data)
11
- { token: data['token'] }
11
+ { token: data[:token] }
12
12
  end
13
13
 
14
14
  def total_price
15
- data['line_items'].map { |line_item| line_item['line_price'].to_f }.sum
15
+ data[:line_items].map { |line_item| line_item[:line_price].to_f }.sum
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
  def set_token
21
- self.token = data['token']
21
+ self.token = data[:token]
22
22
  end
23
23
 
24
24
  end
@@ -11,7 +11,7 @@ class DiscoApp::Shop < ActiveRecord::Base
11
11
  # Extend the Shop model to return the Shop's country as an ActiveUtils country.
12
12
  def country
13
13
  begin
14
- ActiveUtils::Country.find(data['country_name'])
14
+ ActiveUtils::Country.find(data[:country_name])
15
15
  rescue ActiveUtils::InvalidCountryCodeError
16
16
  nil
17
17
  end
@@ -3,6 +3,7 @@ default: &default
3
3
  encoding: unicode
4
4
  pool: 5
5
5
  timeout: 5000
6
+ prepared_statements: false
6
7
 
7
8
  development:
8
9
  <<: *default
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20161105054746) do
14
+ ActiveRecord::Schema.define(version: 20170606160751) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
@@ -99,6 +99,15 @@ ActiveRecord::Schema.define(version: 20161105054746) do
99
99
 
100
100
  add_index "disco_app_shops", ["shopify_domain"], name: "index_disco_app_shops_on_shopify_domain", unique: true, using: :btree
101
101
 
102
+ create_table "disco_app_sources", force: :cascade do |t|
103
+ t.string "source"
104
+ t.string "name"
105
+ t.datetime "created_at", null: false
106
+ t.datetime "updated_at", null: false
107
+ end
108
+
109
+ add_index "disco_app_sources", ["source"], name: "index_disco_app_sources_on_source", using: :btree
110
+
102
111
  create_table "disco_app_subscriptions", force: :cascade do |t|
103
112
  t.integer "shop_id"
104
113
  t.integer "plan_id"
@@ -111,13 +120,24 @@ ActiveRecord::Schema.define(version: 20161105054746) do
111
120
  t.datetime "cancelled_at"
112
121
  t.integer "amount", default: 0
113
122
  t.integer "plan_code_id", limit: 8
114
- t.string "source"
115
123
  t.integer "trial_period_days"
124
+ t.integer "source_id", limit: 8
116
125
  end
117
126
 
118
127
  add_index "disco_app_subscriptions", ["plan_id"], name: "index_disco_app_subscriptions_on_plan_id", using: :btree
119
128
  add_index "disco_app_subscriptions", ["shop_id"], name: "index_disco_app_subscriptions_on_shop_id", using: :btree
120
129
 
130
+ create_table "disco_app_users", force: :cascade do |t|
131
+ t.integer "shop_id", limit: 8
132
+ t.string "first_name"
133
+ t.string "last_name"
134
+ t.string "email"
135
+ t.datetime "created_at", null: false
136
+ t.datetime "updated_at", null: false
137
+ end
138
+
139
+ add_index "disco_app_users", ["id", "shop_id"], name: "index_disco_app_users_on_id_and_shop_id", unique: true, using: :btree
140
+
121
141
  create_table "js_configurations", force: :cascade do |t|
122
142
  t.integer "shop_id", limit: 8
123
143
  t.string "label", default: "Default"
@@ -146,6 +166,7 @@ ActiveRecord::Schema.define(version: 20161105054746) do
146
166
  add_foreign_key "disco_app_recurring_application_charges", "disco_app_subscriptions", column: "subscription_id"
147
167
  add_foreign_key "disco_app_sessions", "disco_app_shops", column: "shop_id", on_delete: :cascade
148
168
  add_foreign_key "disco_app_subscriptions", "disco_app_plan_codes", column: "plan_code_id"
169
+ add_foreign_key "disco_app_subscriptions", "disco_app_sources", column: "source_id"
149
170
  add_foreign_key "js_configurations", "disco_app_shops", column: "shop_id"
150
171
  add_foreign_key "products", "disco_app_shops", column: "shop_id"
151
172
  add_foreign_key "widget_configurations", "disco_app_shops", column: "shop_id"
@@ -24,8 +24,8 @@
24
24
  "cancelled_at": null,
25
25
  "amount": 999,
26
26
  "plan_code_id": null,
27
- "source": null,
28
27
  "trial_period_days": 14,
28
+ "source_id": null,
29
29
  "active_charge": {
30
30
  "id":332186283,
31
31
  "shop_id":605094243,
@@ -0,0 +1,42 @@
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 799407056,
5
+ "first_name": "Steve",
6
+ "email": "steve@apple.com",
7
+ "url": "www.apple.com",
8
+ "im": null,
9
+ "screen_name": null,
10
+ "phone": null,
11
+ "last_name": "Jobs",
12
+ "account_owner": true,
13
+ "receive_announcements": 1,
14
+ "bio": null,
15
+ "permissions": [
16
+ "full"
17
+ ],
18
+ "user_type": "regular",
19
+ "phone_validated?": false,
20
+ "tfa_enabled?": false
21
+ },
22
+ {
23
+ "id": 930143300,
24
+ "first_name": "noaccesssteve",
25
+ "email": "noaccesssteve@jobs.com",
26
+ "url": "www.apple.com",
27
+ "im": null,
28
+ "screen_name": null,
29
+ "phone": null,
30
+ "last_name": "Jobs",
31
+ "account_owner": false,
32
+ "receive_announcements": 1,
33
+ "bio": null,
34
+ "permissions": [
35
+ "limited"
36
+ ],
37
+ "user_type": "regular",
38
+ "phone_validated?": false,
39
+ "tfa_enabled?": false
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,3 @@
1
+ source_1:
2
+ source: 'smp'
3
+ name: 'smpodcast'
@@ -18,7 +18,7 @@ class SynchronisesTest < ActionDispatch::IntegrationTest
18
18
 
19
19
  # Assert the product was created locally, with the correct attributes.
20
20
  product = Product.find(632910392)
21
- assert_equal 'IPod Nano - 8GB', product.data['title']
21
+ assert_equal 'IPod Nano - 8GB', product.data[:title]
22
22
  end
23
23
 
24
24
  test 'existing product is updated when product updated webhook is received' do
@@ -29,7 +29,7 @@ class SynchronisesTest < ActionDispatch::IntegrationTest
29
29
  # Assert the product was updated locally, with the correct attributes.
30
30
  @product.reload
31
31
  assert_equal 632910393, @product.id
32
- assert_equal 'IPod Nano - 8GB', @product.data['title']
32
+ assert_equal 'IPod Nano - 8GB', @product.data[:title]
33
33
  end
34
34
 
35
35
  test 'existing product is deleted when product deleted webhook is received' do
@@ -53,7 +53,7 @@ class SynchronisesTest < ActionDispatch::IntegrationTest
53
53
  # Assert the product was updated locally, with the correct attributes.
54
54
  @product.reload
55
55
  assert_equal 632910393, @product.id
56
- assert_equal 'IPod Nano - 8GB', @product.data['title']
56
+ assert_equal 'IPod Nano - 8GB', @product.data[:title]
57
57
  end
58
58
 
59
59
  private
@@ -27,7 +27,7 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
27
27
 
28
28
  # Assert the update shop job was performed.
29
29
  @shop.reload
30
- assert_equal 'United States', @shop.data['country_name']
30
+ assert_equal 'United States', @shop.data[:country_name]
31
31
  end
32
32
 
33
33
  test 'app installed job automatically subscribes stores to the correct default plan' do
@@ -45,13 +45,13 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
45
45
  @shop.current_subscription.destroy
46
46
 
47
47
  perform_enqueued_jobs do
48
- DiscoApp::AppInstalledJob.perform_later(@shop, 'PODCAST', 'smpodcast')
48
+ DiscoApp::AppInstalledJob.perform_later(@shop, 'PODCAST', 'smp')
49
49
  end
50
50
 
51
51
  # Assert the shop was subscribed to the development plan.
52
52
  assert_equal disco_app_plans(:development), @shop.current_subscription.plan
53
53
  assert_equal disco_app_plan_codes(:podcast_dev), @shop.current_subscription.plan_code
54
- assert_equal 'smpodcast', @shop.current_subscription.source
54
+ assert_equal 'smpodcast', @shop.current_subscription.source.name
55
55
  end
56
56
 
57
57
  end
@@ -25,6 +25,6 @@ class DiscoApp::AppUninstalledJobTest < ActionController::TestCase
25
25
  test 'app uninstalled job can be extended using concerns' do
26
26
  assert_performed_jobs 2
27
27
  @shop.reload
28
- assert_equal 'Nowhere', @shop.data['country_name'] # Assert extended method called.
28
+ assert_equal 'Nowhere', @shop.data[:country_name] # Assert extended method called.
29
29
  end
30
30
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ class DiscoApp::SynchroniseUsersJobTest < ActionController::TestCase
4
+ include ActiveJob::TestHelper
5
+
6
+ def setup
7
+ @shop = disco_app_shops(:widget_store)
8
+ stub_request(:get, "#{@shop.admin_url}/users.json").to_return(status: 200, body: api_fixture('widget_store/users').to_json)
9
+ end
10
+
11
+ def teardown
12
+ @shop = nil
13
+ WebMock.reset!
14
+ end
15
+
16
+ test 'Successfully synchronise users via background job' do
17
+ perform_enqueued_jobs do
18
+ DiscoApp::SynchroniseUsersJob.perform_later(@shop)
19
+ end
20
+ user = DiscoApp::User.first
21
+ assert_equal 'Steve', user.first_name
22
+ assert_equal 'Jobs', user.last_name
23
+ assert_equal 'steve@apple.com', user.email
24
+ end
25
+
26
+ end