Commit 71e6a93d authored by Kamil Trzcinski's avatar Kamil Trzcinski

Change default values

parent e3657501
...@@ -24,7 +24,12 @@ class BuildsEmailService < Service ...@@ -24,7 +24,12 @@ class BuildsEmailService < Service
boolean_accessor :notify_only_broken_builds boolean_accessor :notify_only_broken_builds
validates :recipients, presence: true, if: :activated? validates :recipients, presence: true, if: :activated?
default_value_for :notify_only_broken_builds, true def initialize_properties
if properties.nil?
self.properties = {}
self.notify_only_broken_builds = true
end
end
def title def title
'Builds emails' 'Builds emails'
......
...@@ -25,7 +25,12 @@ class HipchatService < Service ...@@ -25,7 +25,12 @@ class HipchatService < Service
boolean_accessor :notify_only_broken_builds boolean_accessor :notify_only_broken_builds
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
default_value_for :notify_only_broken_builds, true def initialize_properties
if properties.nil?
self.properties = {}
self.notify_only_broken_builds = true
end
end
def title def title
'HipChat' 'HipChat'
......
...@@ -56,12 +56,16 @@ class IssueTrackerService < Service ...@@ -56,12 +56,16 @@ class IssueTrackerService < Service
end end
def initialize_properties def initialize_properties
if new_record? if properties.nil?
if enabled_in_gitlab_config if enabled_in_gitlab_config
self.title = issues_tracker['title'] self.properties = {
self.project_url = add_issues_tracker_id(issues_tracker['project_url']) title: issues_tracker['title'],
self.issues_url = add_issues_tracker_id(issues_tracker['issues_url']) project_url: add_issues_tracker_id(issues_tracker['project_url']),
self.new_issue_url = add_issues_tracker_id(issues_tracker['new_issue_url']) issues_url: add_issues_tracker_id(issues_tracker['issues_url']),
new_issue_url: add_issues_tracker_id(issues_tracker['new_issue_url'])
}
else
self.properties = {}
end end
end end
end end
...@@ -94,8 +98,8 @@ class IssueTrackerService < Service ...@@ -94,8 +98,8 @@ class IssueTrackerService < Service
def enabled_in_gitlab_config def enabled_in_gitlab_config
Gitlab.config.issues_tracker && Gitlab.config.issues_tracker &&
Gitlab.config.issues_tracker.values.any? && Gitlab.config.issues_tracker.values.any? &&
issues_tracker issues_tracker
end end
def issues_tracker def issues_tracker
......
...@@ -23,7 +23,12 @@ class SlackService < Service ...@@ -23,7 +23,12 @@ class SlackService < Service
boolean_accessor :notify_only_broken_builds boolean_accessor :notify_only_broken_builds
validates :webhook, presence: true, if: :activated? validates :webhook, presence: true, if: :activated?
default_value_for :notify_only_broken_builds, true def initialize_properties
if properties.nil?
self.properties = {}
self.notify_only_broken_builds = true
end
end
def title def title
'Slack' 'Slack'
......
...@@ -31,7 +31,6 @@ class Service < ActiveRecord::Base ...@@ -31,7 +31,6 @@ class Service < ActiveRecord::Base
default_value_for :tag_push_events, true default_value_for :tag_push_events, true
default_value_for :note_events, true default_value_for :note_events, true
default_value_for :build_events, true default_value_for :build_events, true
default_value_for :properties, {}
after_initialize :initialize_properties after_initialize :initialize_properties
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment