disco_app 0.12.7 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-checkbox.es6.jsx +10 -5
  3. data/app/controllers/disco_app/admin/concerns/sources_controller.rb +51 -0
  4. data/app/controllers/disco_app/admin/sources_controller.rb +3 -0
  5. data/app/controllers/disco_app/concerns/user_authenticated_controller.rb +17 -0
  6. data/app/controllers/disco_app/user_sessions_controller.rb +49 -0
  7. data/app/models/disco_app/concerns/shop.rb +4 -1
  8. data/app/models/disco_app/concerns/source.rb +14 -0
  9. data/app/models/disco_app/concerns/subscription.rb +1 -1
  10. data/app/models/disco_app/concerns/user.rb +16 -0
  11. data/app/models/disco_app/source.rb +3 -0
  12. data/app/models/disco_app/user.rb +3 -0
  13. data/app/services/disco_app/subscription_service.rb +8 -2
  14. data/app/views/disco_app/admin/sources/_form.html.erb +34 -0
  15. data/app/views/disco_app/admin/sources/edit.html.erb +7 -0
  16. data/app/views/disco_app/admin/sources/index.html.erb +32 -0
  17. data/app/views/disco_app/admin/sources/new.html.erb +7 -0
  18. data/app/views/disco_app/user_sessions/new.html.erb +12 -0
  19. data/app/views/layouts/admin/_nav_items.erb +7 -0
  20. data/config/routes.rb +4 -0
  21. data/db/migrate/20170315062548_create_disco_app_sources.rb +10 -0
  22. data/db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb +14 -0
  23. data/db/migrate/20170327214540_create_disco_app_users.rb +13 -0
  24. data/lib/disco_app/version.rb +1 -1
  25. data/test/dummy/db/schema.rb +23 -2
  26. data/test/fixtures/api/subscriptions/valid_request.json +1 -1
  27. data/test/fixtures/disco_app/sources.yml +3 -0
  28. data/test/jobs/disco_app/app_installed_job_test.rb +2 -2
  29. metadata +19 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21023f5d93c241f965421518ec230e8586692ffb52ff8fdddc660a05a6494cd6
4
- data.tar.gz: e8b82986937577901b5e4d1e1d899fd88781cad4806881607901ba84e3ae60ae
3
+ metadata.gz: 11ac38e563eec9da84822f94baad848cebf35c61f42e0da681cb655cb0c48e6b
4
+ data.tar.gz: 0d8755c4a5b7629fab63debe1a0909c9c51919d8aaf322afe827c39eb7b2a524
5
5
  SHA512:
6
- metadata.gz: 2cba29ccd78c5507a1d4de5cda36abf0150f95808f69cd53b31f113fd72216c2827233e58637ef9f00d17987492f5932cacd2147b9bff144346046be708108df
7
- data.tar.gz: f75e2ee5578db73961aef1a740b771535a299d0507a587befa8eb4f8106b90374e4831fa696be8ef5b97b443c2a84b80f4b0daf2dd812833774259857f3bc17d
6
+ metadata.gz: dfdc79a378ecae13b4f9d1f19715f65dbad5d3ee89aa5aed2bf57d09129bec8327eccc3a9212d71d66f8362a0d6138d3f3329af2739b795010fc6d0efc8bb11e
7
+ data.tar.gz: 5d08032f8abf215f2d5b7704c4d042bd73742611abc80ff60ea234dfbd5630dfd05a2f7f3188d68d354d611c544389e0e76b1f8ea9cf96738a1ca60b34446f3d
@@ -1,6 +1,6 @@
1
- const InputCheckbox = ({ label, name, value, checked, inline, isLast, onChange, disabled = false }) => {
1
+ const InputCheckbox = ({ label, name, checked, inline, isLast, onChange, disabled = false }) => {
2
2
 
3
- const id = `${name}[${value}]`;
3
+ const id = name;
4
4
 
5
5
  const wrapperClassName = classNames({
6
6
  'next-input-wrapper': true,
@@ -16,14 +16,19 @@ const InputCheckbox = ({ label, name, value, checked, inline, isLast, onChange,
16
16
  });
17
17
 
18
18
  const handleChange = (e) => {
19
- onChange && onChange(e.target.value);
19
+ onChange && onChange(e.target.checked);
20
20
  };
21
21
 
22
22
  return(
23
23
  <div className={wrapperClassName}>
24
24
  <label htmlFor={id} className={labelClassName}>{label}</label>
25
- <input id={id} className="next-checkbox" type="checkbox" value={value} name={name} checked={checked} onChange={handleChange} disabled={disabled} />
26
- <span className="next-checkbox--styled" />
25
+ <input type="hidden" value="0" name={name} />
26
+ <input id={id} className="next-checkbox" type="checkbox" value="1" name={name} checked={checked} onChange={handleChange} disabled={disabled} />
27
+ <span className="next-checkbox--styled">
28
+ <svg className="next-icon next-icon--size-10 next-icon--blue checkmark">
29
+ <use xmlns="http://www.w3.org/1999/xlink" xlinkHref="#next-checkmark" />
30
+ </svg>
31
+ </span>
27
32
  </div>
28
33
  )
29
34
 
@@ -0,0 +1,51 @@
1
+ module DiscoApp::Admin::Concerns::SourcesController
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :find_source, only: [:edit, :update, :destroy]
6
+ end
7
+
8
+ def index
9
+ @sources = DiscoApp::Source.all
10
+ end
11
+
12
+ def new
13
+ @source = DiscoApp::Source.new
14
+ end
15
+
16
+ def create
17
+ @source = DiscoApp::Source.new(source_params)
18
+ if @source.save
19
+ redirect_to admin_sources_path
20
+ else
21
+ render 'new'
22
+ end
23
+ end
24
+
25
+ def edit
26
+ end
27
+
28
+ def update
29
+ if @source.update_attributes(source_params)
30
+ redirect_to edit_admin_plan_path(@source)
31
+ else
32
+ render 'edit'
33
+ end
34
+ end
35
+
36
+ def destroy
37
+ source.destroy
38
+ redirect_to admin_sources_path
39
+ end
40
+
41
+ private
42
+
43
+ def find_source
44
+ @source = DiscoApp::Source.find(params[:id])
45
+ end
46
+
47
+ def source_params
48
+ params.require(:source).permit(:source, :name)
49
+ end
50
+
51
+ end
@@ -0,0 +1,3 @@
1
+ class DiscoApp::Admin::SourcesController < DiscoApp::Admin::ApplicationController
2
+ include DiscoApp::Admin::Concerns::SourcesController
3
+ end
@@ -0,0 +1,17 @@
1
+ module DiscoApp::Concerns::UserAuthenticatedController
2
+ extend ActiveSupport::Concern
3
+ include ShopifyApp::LoginProtection
4
+
5
+ included do
6
+ before_action :shopify_user
7
+ end
8
+
9
+ private
10
+
11
+ def shopify_user
12
+ @user = DiscoApp::User.find(session[:shopify_user])
13
+ rescue ActiveRecord::RecordNotFound
14
+ redirect_to disco_app.new_user_session_path
15
+ end
16
+
17
+ end
@@ -0,0 +1,49 @@
1
+ class DiscoApp::UserSessionsController < ApplicationController
2
+ include DiscoApp::Concerns::AuthenticatedController
3
+
4
+ def new
5
+ end
6
+
7
+ def create
8
+ authenticate
9
+ end
10
+
11
+ def callback
12
+ if auth_hash
13
+ login_user
14
+ redirect_to return_address
15
+ else
16
+ redirect_to root_path
17
+ end
18
+ end
19
+
20
+ def destroy
21
+ session[:shopify_user] = nil
22
+ redirect_to root_path
23
+ end
24
+
25
+ protected
26
+
27
+ def associated_user(auth_hash)
28
+ auth_hash['extra']['associated_user']
29
+ end
30
+
31
+ def authenticate
32
+ if sanitized_shop_name.present?
33
+ fullpage_redirect_to "#{main_app.root_path}auth/shopify_user?shop=#{@shop.shopify_domain}"
34
+ else
35
+ redirect_to return_address
36
+ end
37
+ end
38
+
39
+ def login_user
40
+ @user = DiscoApp::User.create_from_auth(associated_user(auth_hash), @shop)
41
+ session[:shopify_user] = @user.id
42
+ end
43
+
44
+ def return_address
45
+ session.delete(:return_to) || main_app.root_url
46
+ end
47
+
48
+ end
49
+
@@ -9,6 +9,9 @@ module DiscoApp::Concerns::Shop
9
9
  has_many :subscriptions
10
10
  has_many :plans, through: :subscriptions
11
11
 
12
+ # Define relationship to users.
13
+ has_many :users
14
+
12
15
  # Define relationship to sessions.
13
16
  has_many :sessions, class_name: 'DiscoApp::Session', dependent: :destroy
14
17
 
@@ -27,7 +30,7 @@ module DiscoApp::Concerns::Shop
27
30
 
28
31
  # Return true if the shop is considered as in development mode.
29
32
  def development?
30
- ['staff', 'custom', 'affiliate'].include?(plan_name)
33
+ ['staff', 'affiliate'].include?(plan_name)
31
34
  end
32
35
 
33
36
  # Convenience method to check if this shop has a current subscription.
@@ -0,0 +1,14 @@
1
+ module DiscoApp::Concerns::Source
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+
6
+ has_many :subscriptions
7
+ has_many :shops, through: :subscriptions
8
+
9
+ validates_presence_of :source
10
+ validates_presence_of :name
11
+
12
+ end
13
+
14
+ end
@@ -6,7 +6,7 @@ module DiscoApp::Concerns::Subscription
6
6
  belongs_to :shop
7
7
  belongs_to :plan
8
8
  belongs_to :plan_code
9
-
9
+ belongs_to :source
10
10
  has_many :one_time_charges, class_name: 'DiscoApp::ApplicationCharge', dependent: :destroy
11
11
  has_many :recurring_charges, class_name: 'DiscoApp::RecurringApplicationCharge', dependent: :destroy
12
12
 
@@ -0,0 +1,16 @@
1
+ module DiscoApp::Concerns::User
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ belongs_to :shop
6
+
7
+ def self.create_from_auth(shopify_user, shop)
8
+ self.find_or_create_by(id: shopify_user.id, shop: shop).update(
9
+ first_name: shopify_user.first_name || '',
10
+ last_name: shopify_user.last_name || '',
11
+ email: shopify_user.email
12
+ )
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ class DiscoApp::Source < ActiveRecord::Base
2
+ include DiscoApp::Concerns::Source
3
+ end
@@ -0,0 +1,3 @@
1
+ class DiscoApp::User < ActiveRecord::Base
2
+ include DiscoApp::Concerns::User
3
+ end
@@ -2,7 +2,7 @@ class DiscoApp::SubscriptionService
2
2
 
3
3
  # Subscribe the given shop to the given plan, optionally using the given plan
4
4
  # code and optionally tracking the subscription source.
5
- def self.subscribe(shop, plan, plan_code = nil, source = nil)
5
+ def self.subscribe(shop, plan, plan_code = nil, source_name = nil)
6
6
 
7
7
  # If a plan code was provided, fetch it for the given plan.
8
8
  plan_code_instance = nil
@@ -10,6 +10,12 @@ class DiscoApp::SubscriptionService
10
10
  plan_code_instance = DiscoApp::PlanCode.available.find_by(plan: plan, code: plan_code)
11
11
  end
12
12
 
13
+ # If a source name has been provided, fetch or create it
14
+ source_instance = nil
15
+ if source_name.present?
16
+ source_instance = DiscoApp::Source.find_or_create_by(source: source_name)
17
+ end
18
+
13
19
  # Cancel any existing current subscriptions.
14
20
  shop.subscriptions.current.update_all(
15
21
  status: DiscoApp::Subscription.statuses[:cancelled],
@@ -33,7 +39,7 @@ class DiscoApp::SubscriptionService
33
39
  trial_period_days: plan.has_trial? ? subscription_trial_period_days : nil,
34
40
  trial_start_at: plan.has_trial? ? Time.now : nil,
35
41
  trial_end_at: plan.has_trial? ? subscription_trial_period_days.days.from_now : nil,
36
- source: source
42
+ source: source_instance
37
43
  )
38
44
 
39
45
  # Enqueue the subscription changed background job.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module DiscoApp
2
- VERSION = '0.12.7'
2
+ VERSION = '0.13.0'
3
3
  end
@@ -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: 20170327214540) 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", ["shop_id"], name: "index_disco_app_users_on_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,3 @@
1
+ source_1:
2
+ source: 'smp'
3
+ name: 'smpodcast'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disco_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.7
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Ballard
@@ -540,18 +540,22 @@ files:
540
540
  - app/controllers/disco_app/admin/concerns/authenticated_controller.rb
541
541
  - app/controllers/disco_app/admin/concerns/plans_controller.rb
542
542
  - app/controllers/disco_app/admin/concerns/shops_controller.rb
543
+ - app/controllers/disco_app/admin/concerns/sources_controller.rb
543
544
  - app/controllers/disco_app/admin/concerns/subscriptions_controller.rb
544
545
  - app/controllers/disco_app/admin/plans_controller.rb
545
546
  - app/controllers/disco_app/admin/resources/shops_controller.rb
546
547
  - app/controllers/disco_app/admin/shops_controller.rb
548
+ - app/controllers/disco_app/admin/sources_controller.rb
547
549
  - app/controllers/disco_app/admin/subscriptions_controller.rb
548
550
  - app/controllers/disco_app/charges_controller.rb
549
551
  - app/controllers/disco_app/concerns/app_proxy_controller.rb
550
552
  - app/controllers/disco_app/concerns/authenticated_controller.rb
551
553
  - app/controllers/disco_app/concerns/carrier_request_controller.rb
554
+ - app/controllers/disco_app/concerns/user_authenticated_controller.rb
552
555
  - app/controllers/disco_app/frame_controller.rb
553
556
  - app/controllers/disco_app/install_controller.rb
554
557
  - app/controllers/disco_app/subscriptions_controller.rb
558
+ - app/controllers/disco_app/user_sessions_controller.rb
555
559
  - app/controllers/disco_app/webhooks_controller.rb
556
560
  - app/controllers/sessions_controller.rb
557
561
  - app/helpers/disco_app/application_helper.rb
@@ -582,15 +586,19 @@ files:
582
586
  - app/models/disco_app/concerns/plan_code.rb
583
587
  - app/models/disco_app/concerns/renders_assets.rb
584
588
  - app/models/disco_app/concerns/shop.rb
589
+ - app/models/disco_app/concerns/source.rb
585
590
  - app/models/disco_app/concerns/subscription.rb
586
591
  - app/models/disco_app/concerns/synchronises.rb
587
592
  - app/models/disco_app/concerns/taggable.rb
593
+ - app/models/disco_app/concerns/user.rb
588
594
  - app/models/disco_app/plan.rb
589
595
  - app/models/disco_app/plan_code.rb
590
596
  - app/models/disco_app/recurring_application_charge.rb
591
597
  - app/models/disco_app/session_storage.rb
592
598
  - app/models/disco_app/shop.rb
599
+ - app/models/disco_app/source.rb
593
600
  - app/models/disco_app/subscription.rb
601
+ - app/models/disco_app/user.rb
594
602
  - app/resources/disco_app/admin/resources/concerns/shop_resource.rb
595
603
  - app/resources/disco_app/admin/resources/shop_resource.rb
596
604
  - app/services/disco_app/carrier_request_service.rb
@@ -606,6 +614,10 @@ files:
606
614
  - app/views/disco_app/admin/plans/index.html.erb
607
615
  - app/views/disco_app/admin/plans/new.html.erb
608
616
  - app/views/disco_app/admin/shops/index.html.erb
617
+ - app/views/disco_app/admin/sources/_form.html.erb
618
+ - app/views/disco_app/admin/sources/edit.html.erb
619
+ - app/views/disco_app/admin/sources/index.html.erb
620
+ - app/views/disco_app/admin/sources/new.html.erb
609
621
  - app/views/disco_app/admin/subscriptions/edit.html.erb
610
622
  - app/views/disco_app/charges/activate.html.erb
611
623
  - app/views/disco_app/charges/create.html.erb
@@ -618,6 +630,7 @@ files:
618
630
  - app/views/disco_app/shared/_icons.html.erb
619
631
  - app/views/disco_app/shared/_section.html.erb
620
632
  - app/views/disco_app/subscriptions/new.html.erb
633
+ - app/views/disco_app/user_sessions/new.html.erb
621
634
  - app/views/layouts/admin.html.erb
622
635
  - app/views/layouts/admin/_nav_items.erb
623
636
  - app/views/layouts/application.html.erb
@@ -626,6 +639,9 @@ files:
626
639
  - app/views/shopify_app/sessions/new.html.erb
627
640
  - config/routes.rb
628
641
  - db/migrate/20150525000000_create_shops_if_not_existent.rb
642
+ - db/migrate/20170315062548_create_disco_app_sources.rb
643
+ - db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb
644
+ - db/migrate/20170327214540_create_disco_app_users.rb
629
645
  - lib/disco_app.rb
630
646
  - lib/disco_app/configuration.rb
631
647
  - lib/disco_app/constants.rb
@@ -781,6 +797,7 @@ files:
781
797
  - test/fixtures/disco_app/plans.yml
782
798
  - test/fixtures/disco_app/recurring_application_charges.yml
783
799
  - test/fixtures/disco_app/shops.yml
800
+ - test/fixtures/disco_app/sources.yml
784
801
  - test/fixtures/disco_app/subscriptions.yml
785
802
  - test/fixtures/js_configurations.yml
786
803
  - test/fixtures/liquid/model.liquid
@@ -945,6 +962,7 @@ test_files:
945
962
  - test/fixtures/assets/test.min.js
946
963
  - test/fixtures/widget_configurations.yml
947
964
  - test/fixtures/js_configurations.yml
965
+ - test/fixtures/disco_app/sources.yml
948
966
  - test/fixtures/disco_app/plan_codes.yml
949
967
  - test/fixtures/disco_app/shops.yml
950
968
  - test/fixtures/disco_app/application_charges.yml