refactors debate_links using an attr_accessor

refactors debate_links using an attr_accessor
This commit is contained in:
kikito
2016-02-08 15:25:51 +01:00
parent 2ee90ac76e
commit 2a55c2d94d
3 changed files with 13 additions and 18 deletions

View File

@@ -8,11 +8,11 @@ class DebateLinksController < ApplicationController
private
def create_params
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key)
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key).merge(link_required: true)
end
def debate_params
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key)
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key).merge(link_required: true)
end
def after_create_path

View File

@@ -45,6 +45,8 @@ class Debate < ActiveRecord::Base
# Ahoy setup
visitable # Ahoy will automatically assign visit_id on create
attr_accessor :link_required
def searchable_values
{ title => 'A',
author.username => 'B',
@@ -132,19 +134,11 @@ class Debate < ActiveRecord::Base
end
def description_required?
if self.external_link == nil
return true
else
return false
end
!link_required?
end
def link_required?
if self.external_link == nil
return false
else
return true
end
link_required
end
end

View File

@@ -31,6 +31,7 @@ describe Debate do
end
describe "#external_link" do
before { debate.link_required = true }
it "should not be valid without a url" do
debate.external_link = ""