v3: add subscription model
This commit is contained in:
parent
aeb5046298
commit
3680fcf389
9
lib/travis/api/v3/features.rb
Normal file
9
lib/travis/api/v3/features.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Travis::API::V3
|
||||||
|
module Features
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def use_subscriptions?
|
||||||
|
Models::Subscription.table_exists?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,5 @@
|
||||||
require 'gh'
|
require 'gh'
|
||||||
|
|
||||||
|
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class GitHub
|
class GitHub
|
||||||
DEFAULT_OPTIONS = {
|
DEFAULT_OPTIONS = {
|
||||||
|
|
|
@ -3,5 +3,10 @@ module Travis::API::V3
|
||||||
has_many :memberships
|
has_many :memberships
|
||||||
has_many :users, through: :memberships
|
has_many :users, through: :memberships
|
||||||
has_many :repositories, as: :owner
|
has_many :repositories, as: :owner
|
||||||
|
has_one :subscription, as: :owner
|
||||||
|
|
||||||
|
def subscription
|
||||||
|
super if Features.use_subscriptions?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
4
lib/travis/api/v3/models/subscription.rb
Normal file
4
lib/travis/api/v3/models/subscription.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module Travis::API::V3
|
||||||
|
class Models::Subscription < Model
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,13 +4,18 @@ module Travis::API::V3
|
||||||
has_many :permissions, dependent: :destroy
|
has_many :permissions, dependent: :destroy
|
||||||
has_many :emails, dependent: :destroy
|
has_many :emails, dependent: :destroy
|
||||||
has_many :tokens, dependent: :destroy
|
has_many :tokens, dependent: :destroy
|
||||||
has_many :repositories, through: :permissions
|
|
||||||
has_many :organizations, through: :memberships
|
has_many :organizations, through: :memberships
|
||||||
|
has_many :repositories, as: :owner
|
||||||
|
has_one :subscription, as: :owner
|
||||||
|
|
||||||
serialize :github_oauth_token, Extensions::EncryptedColumn.new(disable: true)
|
serialize :github_oauth_token, Extensions::EncryptedColumn.new(disable: true)
|
||||||
|
|
||||||
def token
|
def token
|
||||||
tokens.first_or_create.token
|
tokens.first_or_create.token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def subscription
|
||||||
|
super if Features.use_subscriptions?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,8 @@ class Travis::Console
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
V3 = Travis::API::V3
|
||||||
|
|
||||||
Travis::Api::App.setup
|
Travis::Api::App.setup
|
||||||
console = Travis::Console.new
|
console = Travis::Console.new
|
||||||
methods = Travis::Console.instance_methods - Object.instance_methods
|
methods = Travis::Console.instance_methods - Object.instance_methods
|
||||||
|
|
Loading…
Reference in New Issue
Block a user