Skip to content

Commit d83e1d5

Browse files
authored
Merge pull request #1146 from AndriiMysko/oss-credit-settings-am
Implement OSS credit consumption setting
2 parents da0b257 + f6bc7b2 commit d83e1d5

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

lib/travis/api/v3/models/organization_preferences.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module Travis::API::V3
44
class Models::OrganizationPreferences < Models::JsonSlice
55
child Models::Preference
66

7+
attribute :consume_oss_credits, Boolean, default: false
8+
79
# whether to show insights about the organization's private repositories to
810
# only admins, all members of the organization, or everybody (public) (note:
911
# insights about public repositories are always public)

lib/travis/api/v3/models/user_preferences.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class Models::UserPreferences < Models::JsonSlice
66

77
attribute :build_emails, Boolean, default: true
88

9+
attribute :consume_oss_credits, Boolean, default: false
10+
911
# whether to show insights about the user's private repositories to
1012
# everybody or keep them only for the user (note: insights about public
1113
# repositories are always public)

spec/v3/services/preferences/for_organization_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
"@representation" => "standard",
4747
"preferences" => [
4848
{
49+
"@type" => "preference",
50+
"@href" => "/v3/org/#{organization.id}/preference/consume_oss_credits",
51+
"@representation" => "standard",
52+
"name" => "consume_oss_credits",
53+
"value" => false
54+
}, {
4955
"@type" => "preference",
5056
"@href" => "/v3/org/#{organization.id}/preference/private_insights_visibility",
5157
"@representation" => "standard",
@@ -60,6 +66,7 @@
6066
describe 'some preference has been set' do
6167
before do
6268
organization.preferences.update(:private_insights_visibility, 'members')
69+
organization.preferences.update(:consume_oss_credits, true)
6370
end
6471

6572
it 'returns the set value merged with the defaults' do
@@ -69,6 +76,12 @@
6976
"@representation" => "standard",
7077
"preferences" => [
7178
{
79+
"@type" => "preference",
80+
"@href" => "/v3/org/#{organization.id}/preference/consume_oss_credits",
81+
"@representation" => "standard",
82+
"name" => "consume_oss_credits",
83+
"value" => true
84+
}, {
7285
"@type" => "preference",
7386
"@href" => "/v3/org/#{organization.id}/preference/private_insights_visibility",
7487
"@representation" => "standard",

spec/v3/services/preferences/for_user_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
"@representation" => "standard",
2727
"name" => "build_emails",
2828
"value" => true
29+
}, {
30+
"@type" => "preference",
31+
"@href" => "/v3/preference/consume_oss_credits",
32+
"@representation" => "standard",
33+
"name" => "consume_oss_credits",
34+
"value" => false
2935
}, {
3036
"@type" => "preference",
3137
"@href" => "/v3/preference/private_insights_visibility",
@@ -41,6 +47,7 @@
4147
describe 'authenticated, user has prefs' do
4248
before do
4349
user.preferences.update(:build_emails, false)
50+
user.preferences.update(:consume_oss_credits, true)
4451
user.preferences.update(:private_insights_visibility, 'public')
4552
get("/v3/preferences", {}, auth_headers)
4653
end
@@ -59,6 +66,12 @@
5966
"@representation" => "standard",
6067
"name" => "build_emails",
6168
"value" => false
69+
}, {
70+
"@type" => "preference",
71+
"@href" => "/v3/preference/consume_oss_credits",
72+
"@representation" => "standard",
73+
"name" => "consume_oss_credits",
74+
"value" => true
6275
}, {
6376
"@type" => "preference",
6477
"@href" => "/v3/preference/private_insights_visibility",

0 commit comments

Comments
 (0)