Skip to content
This repository was archived by the owner on Feb 20, 2022. It is now read-only.

Commit 8c0090f

Browse files
committed
campaign name validation
1 parent bb23a0c commit 8c0090f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docker/app/jobs/lib/loader/asset/loaders/aws_loader/support.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Load Support assets into RedisGraph
35
#

docker/app/models/campaign.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Campaign
5+
#
16
class Campaign < ApplicationRecord
27
belongs_to :user
38
before_save :update_control_count
49

10+
validates :name, presence: true, length: { maximum: 120 }
11+
512
#
613
# Return the Controls that match this Campaign's filters
714
#
@@ -24,9 +31,7 @@ def controls
2431
# filters MAY have a Tags filter
2532
controls = controls.where(tags: { name: tags_filter }) if tags_filter && !tags_filter.empty?
2633
# filters MAY have "all" tags flag set
27-
if must_have_all_tags
28-
controls = controls.having('json_agg(tags.name)::jsonb @> ?::jsonb', tags_filter.to_s)
29-
end
34+
controls = controls.having('json_agg(tags.name)::jsonb @> ?::jsonb', tags_filter.to_s) if must_have_all_tags
3035

3136
controls
3237
end

0 commit comments

Comments
 (0)