Commit 04516027 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Project services to strong params

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 1dab1594
...@@ -16,7 +16,7 @@ class Projects::ServicesController < Projects::ApplicationController ...@@ -16,7 +16,7 @@ class Projects::ServicesController < Projects::ApplicationController
end end
def update def update
if @service.update_attributes(params[:service]) if @service.update_attributes(service_params)
redirect_to edit_project_service_path(@project, @service.to_param) redirect_to edit_project_service_path(@project, @service.to_param)
else else
render 'edit' render 'edit'
...@@ -36,4 +36,11 @@ class Projects::ServicesController < Projects::ApplicationController ...@@ -36,4 +36,11 @@ class Projects::ServicesController < Projects::ApplicationController
def service def service
@service ||= @project.services.find { |service| service.to_param == params[:id] } @service ||= @project.services.find { |service| service.to_param == params[:id] }
end end
def service_params
params.require(:service).permit(
:title, :token, :type, :active, :api_key, :subdomain,
:room, :recipients, :project_url
)
end
end end
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# #
class AssemblaService < Service class AssemblaService < Service
attr_accessible :subdomain
include HTTParty include HTTParty
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# #
class CampfireService < Service class CampfireService < Service
attr_accessible :subdomain, :room
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
def title def title
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# #
class EmailsOnPushService < Service class EmailsOnPushService < Service
attr_accessible :recipients
validates :recipients, presence: true, if: :activated? validates :recipients, presence: true, if: :activated?
def title def title
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# #
class GitlabCiService < CiService class GitlabCiService < CiService
attr_accessible :project_url
validates :project_url, presence: true, if: :activated? validates :project_url, presence: true, if: :activated?
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# #
class HipchatService < Service class HipchatService < Service
attr_accessible :room
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
def title def title
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
# #
class SlackService < Service class SlackService < Service
attr_accessible :room
attr_accessible :subdomain
validates :room, presence: true, if: :activated? validates :room, presence: true, if: :activated?
validates :subdomain, presence: true, if: :activated? validates :subdomain, presence: true, if: :activated?
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
class Service < ActiveRecord::Base class Service < ActiveRecord::Base
default_value_for :active, false default_value_for :active, false
attr_accessible :title, :token, :type, :active, :api_key
belongs_to :project belongs_to :project
has_one :service_hook has_one :service_hook
......
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