@@ -55,11 +55,10 @@ def update
55
55
56
56
record . update ( JSON . parse ( request . body . read ) [ singular_name ] )
57
57
if record . valid?
58
- @changes = { :"env_vars" => { created : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } }
58
+ @changes = { :"env_vars" => { created : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } } if is_env_var?
59
59
60
60
repo_settings . save
61
- run_callbacks :after_save
62
- @changes = { }
61
+ run_callbacks :after_save if is_env_var?
63
62
64
63
respond_with ( record , type : singular_name , version : :v2 )
65
64
else
@@ -73,11 +72,10 @@ def create
73
72
74
73
record = collection . create ( JSON . parse ( request . body . read ) [ singular_name ] )
75
74
if record . valid?
76
- @changes = { :"env_vars" => { created : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } }
75
+ @changes = { :"env_vars" => { created : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } } if is_env_var?
77
76
78
77
repo_settings . save
79
- run_callbacks :after_save
80
- @changes = { }
78
+ run_callbacks :after_save if is_env_var?
81
79
82
80
respond_with ( record , type : singular_name , version : :v2 )
83
81
else
@@ -90,11 +88,10 @@ def destroy
90
88
disallow_migrating! ( repo )
91
89
92
90
record = collection . destroy ( params [ :id ] ) || record_not_found
93
- @changes = { :"env_vars" => { destroyed : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } }
91
+ @changes = { :"env_vars" => { destroyed : "name: #{ record . name } , is_public: #{ record . public } , branch: #{ record . branch || 'all' } " } } if is_env_var?
94
92
95
93
repo_settings . save
96
- run_callbacks :after_save
97
- @changes = { }
94
+ run_callbacks :after_save if is_env_var?
98
95
99
96
respond_with ( record , type : singular_name , version : :v2 )
100
97
end
@@ -131,11 +128,16 @@ def changes
131
128
@changes
132
129
end
133
130
131
+ def is_env_var?
132
+ singular_name == 'env_var'
133
+ end
134
+
134
135
private
135
136
136
137
def save_audit
137
138
change_source = access_token . app_id == 2 ? 'admin-v2' : 'travis-api'
138
139
Travis ::API ::V3 ::Models ::Audit . create! ( owner : current_user , change_source : change_source , source : @repo , source_changes : { settings : self . changes } )
140
+ @changes = { }
139
141
end
140
142
end
141
143
end
0 commit comments