Skip to content

Commit

Permalink
Fixing Validators
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu committed May 5, 2022
1 parent cfe63f9 commit 9a4cd75
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 16 deletions.
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/action_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class ActionLog < ApplicationRecord
)
}

validates :organization, :user
validates :action, presence: true
validates :resource, presence: true, if: ->(log) { log.action != "delete" }
validates :visibility, presence: true, inclusion: { in: %w(private-only admin-only public-only all) }
Expand Down
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/amendment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Amendment < ApplicationRecord
belongs_to :amender, foreign_key: "decidim_user_id", class_name: "Decidim::User"
belongs_to :emendation, foreign_key: "decidim_emendation_id", foreign_type: "decidim_emendation_type", polymorphic: true

validates :amendable, :amender, :emendation
validates :state, presence: true, inclusion: { in: STATES }

def draft?
Expand Down
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Area < ApplicationRecord
inverse_of: :areas,
optional: true

validates :organization
validates :name, presence: true, uniqueness: { scope: [:organization, :area_type] }

before_destroy :abort_if_dependencies
Expand Down
2 changes: 0 additions & 2 deletions decidim-core/app/models/decidim/coauthorship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class Coauthorship < ApplicationRecord

belongs_to :coauthorable, polymorphic: true, counter_cache: true

validates :coauthorable

after_commit :author_is_follower, on: [:create]

def identity
Expand Down
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/contextual_help_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ContextualHelpSection < ApplicationRecord
translatable_fields :content

belongs_to :organization, class_name: "Decidim::Organization"
validates :organization
validates :content, presence: true

# Public: Finds content given an id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class BadgeScore < ApplicationRecord
self.table_name = "decidim_gamification_badge_scores"

belongs_to :user, class_name: "Decidim::UserBaseEntity"
validates :user
validates :value, numericality: { greater_than_or_equal_to: 0 }
end
end
Expand Down
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/messaging/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Message < ApplicationRecord
foreign_key: :decidim_message_id,
inverse_of: :message

validates :sender
validates :body, presence: true, length: { maximum: ->(_message) { Decidim.config.maximum_conversation_message_length } }

default_scope { order(created_at: :asc) }
Expand Down
2 changes: 0 additions & 2 deletions decidim-core/app/models/decidim/messaging/participation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Participation < ApplicationRecord
foreign_key: :decidim_participant_id,
class_name: "Decidim::UserBaseEntity"

validates :conversation, :participant

validates :decidim_conversation_id, uniqueness: { scope: :decidim_participant_id }
end
end
Expand Down
2 changes: 0 additions & 2 deletions decidim-core/app/models/decidim/messaging/receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class Receipt < ApplicationRecord
belongs_to :recipient, foreign_key: "decidim_recipient_id", class_name: "Decidim::User"
belongs_to :message, foreign_key: "decidim_message_id", class_name: "Decidim::Messaging::Message"

validates :recipient, :message

scope :recipient, ->(recipient) { where(recipient: recipient) }
scope :unread_by, ->(user) { recipient(user).unread }
scope :unread, -> { where(read_at: nil) }
Expand Down
1 change: 0 additions & 1 deletion decidim-core/app/models/decidim/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Scope < ApplicationRecord

before_validation :update_part_of, on: :update

validates :organization
validates :name, :code, presence: true
validates :code, uniqueness: { scope: :organization }
validate :forbid_cycles
Expand Down
2 changes: 0 additions & 2 deletions decidim-core/app/models/decidim/share_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module Decidim
class ShareToken < ApplicationRecord
validates :organization
validates :user
validates :token, presence: true, uniqueness: { scope: [:decidim_organization_id, :token_for_type, :token_for_id] }

belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
Expand Down
1 change: 0 additions & 1 deletion decidim-core/lib/decidim/authorable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module Authorable
scoped_query
}

validates :author
validate :verified_user_group, :user_group_membership
validate :author_belongs_to_organization

Expand Down

0 comments on commit 9a4cd75

Please sign in to comment.