DEV: Apply new Rubocop linting on services
This commit is contained in:
parent
a52b83333e
commit
cf2b4d9934
|
@ -465,7 +465,7 @@ GEM
|
||||||
parser (>= 3.3.1.0)
|
parser (>= 3.3.1.0)
|
||||||
rubocop-capybara (2.21.0)
|
rubocop-capybara (2.21.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-discourse (3.8.6)
|
rubocop-discourse (3.9.0)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
rubocop (>= 1.59.0)
|
rubocop (>= 1.59.0)
|
||||||
rubocop-capybara (>= 2.0.0)
|
rubocop-capybara (>= 2.0.0)
|
||||||
|
|
|
@ -4,12 +4,15 @@ class AdminNotices::Dismiss
|
||||||
include Service::Base
|
include Service::Base
|
||||||
|
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :id, :integer
|
attribute :id, :integer
|
||||||
|
|
||||||
validates :id, presence: true
|
validates :id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :admin_notice, optional: true
|
model :admin_notice, optional: true
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :destroy
|
step :destroy
|
||||||
step :reset_problem_check
|
step :reset_problem_check
|
||||||
|
|
|
@ -4,10 +4,12 @@ class Experiments::Toggle
|
||||||
include Service::Base
|
include Service::Base
|
||||||
|
|
||||||
policy :current_user_is_admin
|
policy :current_user_is_admin
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :setting_name, :string
|
attribute :setting_name, :string
|
||||||
validates :setting_name, presence: true
|
validates :setting_name, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
policy :setting_is_available
|
policy :setting_is_available
|
||||||
transaction { step :toggle }
|
transaction { step :toggle }
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Flags::CreateFlag
|
||||||
include Service::Base
|
include Service::Base
|
||||||
|
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :name, :string
|
attribute :name, :string
|
||||||
attribute :description, :string
|
attribute :description, :string
|
||||||
|
@ -18,8 +19,10 @@ class Flags::CreateFlag
|
||||||
validates :description, length: { maximum: Flag::MAX_DESCRIPTION_LENGTH }
|
validates :description, length: { maximum: Flag::MAX_DESCRIPTION_LENGTH }
|
||||||
validates :applies_to, inclusion: { in: -> { Flag.valid_applies_to_types } }, allow_nil: false
|
validates :applies_to, inclusion: { in: -> { Flag.valid_applies_to_types } }, allow_nil: false
|
||||||
end
|
end
|
||||||
|
|
||||||
policy :unique_name
|
policy :unique_name
|
||||||
model :flag, :instantiate_flag
|
model :flag, :instantiate_flag
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :create
|
step :create
|
||||||
step :log
|
step :log
|
||||||
|
|
|
@ -8,10 +8,12 @@ class Flags::DestroyFlag
|
||||||
|
|
||||||
validates :id, presence: true
|
validates :id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :flag
|
model :flag
|
||||||
policy :not_system
|
policy :not_system
|
||||||
policy :not_used
|
policy :not_used
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :destroy
|
step :destroy
|
||||||
step :log
|
step :log
|
||||||
|
|
|
@ -10,10 +10,12 @@ class Flags::ReorderFlag
|
||||||
validates :flag_id, presence: true
|
validates :flag_id, presence: true
|
||||||
validates :direction, inclusion: { in: %w[up down] }
|
validates :direction, inclusion: { in: %w[up down] }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :flag
|
model :flag
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
model :all_flags
|
model :all_flags
|
||||||
policy :invalid_move
|
policy :invalid_move
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :move
|
step :move
|
||||||
step :log
|
step :log
|
||||||
|
|
|
@ -4,12 +4,15 @@ class Flags::ToggleFlag
|
||||||
include Service::Base
|
include Service::Base
|
||||||
|
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :flag_id, :integer
|
attribute :flag_id, :integer
|
||||||
|
|
||||||
validates :flag_id, presence: true
|
validates :flag_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :flag
|
model :flag
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :toggle
|
step :toggle
|
||||||
step :log
|
step :log
|
||||||
|
|
|
@ -19,11 +19,13 @@ class Flags::UpdateFlag
|
||||||
validates :description, length: { maximum: Flag::MAX_DESCRIPTION_LENGTH }
|
validates :description, length: { maximum: Flag::MAX_DESCRIPTION_LENGTH }
|
||||||
validates :applies_to, inclusion: { in: -> { Flag.valid_applies_to_types } }, allow_nil: false
|
validates :applies_to, inclusion: { in: -> { Flag.valid_applies_to_types } }, allow_nil: false
|
||||||
end
|
end
|
||||||
|
|
||||||
model :flag
|
model :flag
|
||||||
policy :not_system
|
policy :not_system
|
||||||
policy :not_used
|
policy :not_used
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
policy :unique_name
|
policy :unique_name
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :update
|
step :update
|
||||||
step :log
|
step :log
|
||||||
|
|
|
@ -6,6 +6,7 @@ class SiteSetting::Update
|
||||||
options { attribute :allow_changing_hidden, :boolean, default: false }
|
options { attribute :allow_changing_hidden, :boolean, default: false }
|
||||||
|
|
||||||
policy :current_user_is_admin
|
policy :current_user_is_admin
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :setting_name
|
attribute :setting_name
|
||||||
attribute :new_value
|
attribute :new_value
|
||||||
|
@ -34,6 +35,7 @@ class SiteSetting::Update
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
policy :setting_is_visible
|
policy :setting_is_visible
|
||||||
policy :setting_is_configurable
|
policy :setting_is_configurable
|
||||||
step :save
|
step :save
|
||||||
|
|
|
@ -19,6 +19,7 @@ class User::Silence
|
||||||
validates :other_user_ids, length: { maximum: User::MAX_SIMILAR_USERS }
|
validates :other_user_ids, length: { maximum: User::MAX_SIMILAR_USERS }
|
||||||
validates :post_action, inclusion: { in: %w[delete delete_replies edit] }, allow_blank: true
|
validates :post_action, inclusion: { in: %w[delete delete_replies edit] }, allow_blank: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :user
|
model :user
|
||||||
policy :not_silenced_already, class_name: User::Policy::NotAlreadySilenced
|
policy :not_silenced_already, class_name: User::Policy::NotAlreadySilenced
|
||||||
model :users
|
model :users
|
||||||
|
|
|
@ -19,6 +19,7 @@ class User::Suspend
|
||||||
validates :other_user_ids, length: { maximum: User::MAX_SIMILAR_USERS }
|
validates :other_user_ids, length: { maximum: User::MAX_SIMILAR_USERS }
|
||||||
validates :post_action, inclusion: { in: %w[delete delete_replies edit] }, allow_blank: true
|
validates :post_action, inclusion: { in: %w[delete delete_replies edit] }, allow_blank: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :user
|
model :user
|
||||||
policy :not_suspended_already, class_name: User::Policy::NotAlreadySuspended
|
policy :not_suspended_already, class_name: User::Policy::NotAlreadySuspended
|
||||||
model :users
|
model :users
|
||||||
|
|
|
@ -24,6 +24,7 @@ module Chat
|
||||||
# @option params [Array<String>] :usernames
|
# @option params [Array<String>] :usernames
|
||||||
# @option params [Array<String>] :groups
|
# @option params [Array<String>] :groups
|
||||||
# @return [Service::Base::Context]
|
# @return [Service::Base::Context]
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :usernames, :array
|
attribute :usernames, :array
|
||||||
attribute :groups, :array
|
attribute :groups, :array
|
||||||
|
@ -36,11 +37,13 @@ module Chat
|
||||||
usernames.present? || groups.present?
|
usernames.present? || groups.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :can_add_users_to_channel
|
policy :can_add_users_to_channel
|
||||||
model :target_users, optional: true
|
model :target_users, optional: true
|
||||||
policy :satisfies_dms_max_users_limit,
|
policy :satisfies_dms_max_users_limit,
|
||||||
class_name: Chat::DirectMessageChannel::Policy::MaxUsersExcess
|
class_name: Chat::DirectMessageChannel::Policy::MaxUsersExcess
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :upsert_memberships
|
step :upsert_memberships
|
||||||
step :recompute_users_count
|
step :recompute_users_count
|
||||||
|
|
|
@ -31,6 +31,7 @@ module Chat
|
||||||
|
|
||||||
policy :public_channels_enabled
|
policy :public_channels_enabled
|
||||||
policy :can_create_channel
|
policy :can_create_channel
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :name, :string
|
attribute :name, :string
|
||||||
attribute :description, :string
|
attribute :description, :string
|
||||||
|
@ -48,12 +49,15 @@ module Chat
|
||||||
validates :category_id, presence: true
|
validates :category_id, presence: true
|
||||||
validates :name, length: { maximum: SiteSetting.max_topic_title_length }
|
validates :name, length: { maximum: SiteSetting.max_topic_title_length }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :category
|
model :category
|
||||||
policy :category_channel_does_not_exist
|
policy :category_channel_does_not_exist
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
model :channel, :create_channel
|
model :channel, :create_channel
|
||||||
model :membership, :create_membership
|
model :membership, :create_membership
|
||||||
end
|
end
|
||||||
|
|
||||||
step :auto_join_users_if_needed
|
step :auto_join_users_if_needed
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -38,6 +38,7 @@ module Chat
|
||||||
target_usernames.present? || target_groups.present?
|
target_usernames.present? || target_groups.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
model :target_users
|
model :target_users
|
||||||
policy :can_create_direct_message
|
policy :can_create_direct_message
|
||||||
policy :satisfies_dms_max_users_limit,
|
policy :satisfies_dms_max_users_limit,
|
||||||
|
|
|
@ -72,6 +72,7 @@ module Chat
|
||||||
policy :ensure_thread_matches_parent
|
policy :ensure_thread_matches_parent
|
||||||
model :uploads, optional: true
|
model :uploads, optional: true
|
||||||
model :message_instance, :instantiate_message
|
model :message_instance, :instantiate_message
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :create_excerpt
|
step :create_excerpt
|
||||||
step :update_created_by_sdk
|
step :update_created_by_sdk
|
||||||
|
@ -83,6 +84,7 @@ module Chat
|
||||||
step :update_membership_last_read
|
step :update_membership_last_read
|
||||||
step :process_direct_message_channel
|
step :process_direct_message_channel
|
||||||
end
|
end
|
||||||
|
|
||||||
step :publish_new_thread
|
step :publish_new_thread
|
||||||
step :process
|
step :process
|
||||||
step :publish_user_tracking_state
|
step :publish_user_tracking_state
|
||||||
|
|
|
@ -25,14 +25,17 @@ module Chat
|
||||||
validates :original_message_id, :channel_id, presence: true
|
validates :original_message_id, :channel_id, presence: true
|
||||||
validates :title, length: { maximum: Chat::Thread::MAX_TITLE_LENGTH }
|
validates :title, length: { maximum: Chat::Thread::MAX_TITLE_LENGTH }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
policy :threading_enabled_for_channel
|
policy :threading_enabled_for_channel
|
||||||
model :original_message
|
model :original_message
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
model :thread, :find_or_create_thread
|
model :thread, :find_or_create_thread
|
||||||
step :associate_thread_to_message
|
step :associate_thread_to_message
|
||||||
end
|
end
|
||||||
|
|
||||||
step :publish_new_thread
|
step :publish_new_thread
|
||||||
step :trigger_chat_thread_created_event
|
step :trigger_chat_thread_created_event
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Chat
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
validates :flag_type_id, inclusion: { in: -> { ::ReviewableScore.types.values } }
|
validates :flag_type_id, inclusion: { in: -> { ::ReviewableScore.types.values } }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :message
|
model :message
|
||||||
policy :can_flag_message_in_channel
|
policy :can_flag_message_in_channel
|
||||||
step :flag_message
|
step :flag_message
|
||||||
|
|
|
@ -25,6 +25,7 @@ module Chat
|
||||||
validates :user_ids, presence: true
|
validates :user_ids, presence: true
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
model :users, optional: true
|
model :users, optional: true
|
||||||
|
|
|
@ -25,6 +25,7 @@ module Chat
|
||||||
|
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
step :leave
|
step :leave
|
||||||
step :recompute_users_count
|
step :recompute_users_count
|
||||||
|
|
|
@ -40,6 +40,7 @@ module Chat
|
||||||
},
|
},
|
||||||
allow_nil: true
|
allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
model :membership, optional: true
|
model :membership, optional: true
|
||||||
|
|
|
@ -41,6 +41,7 @@ module Chat
|
||||||
},
|
},
|
||||||
allow_nil: true
|
allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :thread
|
model :thread
|
||||||
policy :can_view_thread
|
policy :can_view_thread
|
||||||
model :membership, optional: true
|
model :membership, optional: true
|
||||||
|
|
|
@ -43,6 +43,7 @@ module Chat
|
||||||
self.offset = [offset || 0, 0].max
|
self.offset = [offset || 0, 0].max
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :threading_enabled_for_channel
|
policy :threading_enabled_for_channel
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
|
|
|
@ -23,6 +23,7 @@ module Chat
|
||||||
|
|
||||||
validates :thread_id, :channel_id, presence: true
|
validates :thread_id, :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :thread
|
model :thread
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
policy :threading_enabled_for_channel
|
policy :threading_enabled_for_channel
|
||||||
|
|
|
@ -30,6 +30,7 @@ module Chat
|
||||||
self.offset = [offset || 0, 0].max
|
self.offset = [offset || 0, 0].max
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
model :threads
|
model :threads
|
||||||
step :fetch_tracking
|
step :fetch_tracking
|
||||||
step :fetch_memberships
|
step :fetch_memberships
|
||||||
|
|
|
@ -30,6 +30,7 @@ module Chat
|
||||||
|
|
||||||
validates :thread_id, :channel_id, presence: true
|
validates :thread_id, :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :thread
|
model :thread
|
||||||
policy :threading_enabled_for_channel
|
policy :threading_enabled_for_channel
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
|
|
|
@ -25,13 +25,16 @@ module Chat
|
||||||
validates :message_id, presence: true
|
validates :message_id, presence: true
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :message
|
model :message
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :restore_message
|
step :restore_message
|
||||||
step :update_last_message_ids
|
step :update_last_message_ids
|
||||||
step :update_thread_reply_cache
|
step :update_thread_reply_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
step :publish_events
|
step :publish_events
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -27,6 +27,7 @@ module Chat
|
||||||
|
|
||||||
after_validation { self.term = term&.downcase&.strip&.gsub(/^[@#]+/, "") }
|
after_validation { self.term = term&.downcase&.strip&.gsub(/^[@#]+/, "") }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :memberships, optional: true
|
model :memberships, optional: true
|
||||||
model :users, optional: true
|
model :users, optional: true
|
||||||
model :groups, optional: true
|
model :groups, optional: true
|
||||||
|
|
|
@ -41,6 +41,7 @@ module Chat
|
||||||
attribute :include_threads, default: false
|
attribute :include_threads, default: false
|
||||||
attribute :include_read, default: true
|
attribute :include_read, default: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :report
|
model :report
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -23,13 +23,16 @@ module Chat
|
||||||
|
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :prevents_slug_collision
|
step :prevents_slug_collision
|
||||||
step :soft_delete_channel
|
step :soft_delete_channel
|
||||||
step :log_channel_deletion
|
step :log_channel_deletion
|
||||||
end
|
end
|
||||||
|
|
||||||
step :enqueue_delete_channel_relations_job
|
step :enqueue_delete_channel_relations_job
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -25,8 +25,10 @@ module Chat
|
||||||
validates :message_id, presence: true
|
validates :message_id, presence: true
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :message
|
model :message
|
||||||
policy :invalid_access
|
policy :invalid_access
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :trash_message
|
step :trash_message
|
||||||
step :destroy_notifications
|
step :destroy_notifications
|
||||||
|
@ -34,6 +36,7 @@ module Chat
|
||||||
step :update_tracking_state
|
step :update_tracking_state
|
||||||
step :update_thread_reply_cache
|
step :update_thread_reply_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
step :publish_events
|
step :publish_events
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -25,8 +25,10 @@ module Chat
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
validates :message_ids, length: { minimum: 1, maximum: 200 }
|
validates :message_ids, length: { minimum: 1, maximum: 200 }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :messages
|
model :messages
|
||||||
policy :can_delete_all_chat_messages
|
policy :can_delete_all_chat_messages
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :trash_messages
|
step :trash_messages
|
||||||
step :destroy_notifications
|
step :destroy_notifications
|
||||||
|
@ -34,6 +36,7 @@ module Chat
|
||||||
step :update_tracking_states
|
step :update_tracking_states
|
||||||
step :update_thread_reply_cache
|
step :update_thread_reply_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
step :publish_events
|
step :publish_events
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -25,6 +25,7 @@ module Chat
|
||||||
|
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
step :unfollow
|
step :unfollow
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ module Chat
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
validates :status, inclusion: { in: Chat::Channel.editable_statuses.keys }
|
validates :status, inclusion: { in: Chat::Channel.editable_statuses.keys }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :check_channel_permission
|
policy :check_channel_permission
|
||||||
step :change_status
|
step :change_status
|
||||||
|
|
|
@ -44,12 +44,14 @@ module Chat
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
model :message
|
model :message
|
||||||
model :uploads, optional: true
|
model :uploads, optional: true
|
||||||
step :enforce_membership
|
step :enforce_membership
|
||||||
model :membership
|
model :membership
|
||||||
policy :can_modify_channel_message
|
policy :can_modify_channel_message
|
||||||
policy :can_modify_message
|
policy :can_modify_message
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :modify_message
|
step :modify_message
|
||||||
step :update_excerpt
|
step :update_excerpt
|
||||||
|
|
|
@ -26,6 +26,7 @@ module Chat
|
||||||
validates :thread_id, presence: true
|
validates :thread_id, presence: true
|
||||||
validates :title, length: { maximum: Chat::Thread::MAX_TITLE_LENGTH }
|
validates :title, length: { maximum: Chat::Thread::MAX_TITLE_LENGTH }
|
||||||
end
|
end
|
||||||
|
|
||||||
model :thread
|
model :thread
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
policy :can_edit_thread
|
policy :can_edit_thread
|
||||||
|
|
|
@ -37,6 +37,7 @@ module Chat
|
||||||
in: Chat::UserChatThreadMembership.notification_levels.values,
|
in: Chat::UserChatThreadMembership.notification_levels.values,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
model :thread, :fetch_thread
|
model :thread, :fetch_thread
|
||||||
policy :can_view_channel
|
policy :can_view_channel
|
||||||
policy :threading_enabled_for_channel
|
policy :threading_enabled_for_channel
|
||||||
|
|
|
@ -31,6 +31,7 @@ module Chat
|
||||||
|
|
||||||
validates :channel_id, presence: true
|
validates :channel_id, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
model :channel
|
model :channel
|
||||||
policy :can_upsert_draft
|
policy :can_upsert_draft
|
||||||
step :check_thread_exists
|
step :check_thread_exists
|
||||||
|
|
|
@ -11,15 +11,18 @@ RSpec.describe Service::StepsInspector do
|
||||||
|
|
||||||
model :model
|
model :model
|
||||||
policy :policy
|
policy :policy
|
||||||
|
|
||||||
params do
|
params do
|
||||||
attribute :parameter
|
attribute :parameter
|
||||||
|
|
||||||
validates :parameter, presence: true
|
validates :parameter, presence: true
|
||||||
end
|
end
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
step :in_transaction_step_1
|
step :in_transaction_step_1
|
||||||
step :in_transaction_step_2
|
step :in_transaction_step_2
|
||||||
end
|
end
|
||||||
|
|
||||||
try { step :might_raise }
|
try { step :might_raise }
|
||||||
step :final_step
|
step :final_step
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue