Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ GEM
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
open3 (0.2.1)
parallel (1.27.0)
parser (3.3.10.0)
parallel (1.28.0)
parser (3.3.11.1)
ast (~> 2.4.1)
racc
pg (1.6.3)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
prism (1.4.0)
prism (1.9.0)
proc_to_ast (0.2.0)
parser
rouge
Expand Down Expand Up @@ -281,7 +281,7 @@ GEM
erb
psych (>= 4.0.0)
tsort
regexp_parser (2.10.0)
regexp_parser (2.12.0)
reline (0.6.3)
io-console (~> 0.5)
request_store (1.5.1)
Expand Down Expand Up @@ -324,20 +324,20 @@ GEM
rspec-support (3.13.7)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.75.8)
rubocop (1.86.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.44.1)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
prism (~> 1.7)
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand All @@ -350,9 +350,9 @@ GEM
rack (>= 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (3.6.0)
rubocop-rspec (3.9.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop (~> 1.81)
rubocop-rspec_rails (2.31.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/base_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Types
module BaseInterface
include GraphQL::Schema::Interface

edge_type_class(Types::BaseEdge)
connection_type_class(Types::CountableConnectionType)

Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/base_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Types
class BaseObject < GraphQL::Schema::Object
include Sagittarius::Graphql::HasMarkdownDocumentation

edge_type_class(Types::BaseEdge)
connection_type_class(Types::CountableConnectionType)
field_class Types::BaseField
Expand Down
7 changes: 5 additions & 2 deletions app/models/application_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ class ApplicationSetting < ApplicationRecord
include Code0::ZeroTrack::Loggable

# Custom class used for policy association
ApplicationSettings = Class.new(ActiveSupport::HashWithIndifferentAccess)
MissingApplicationSettings = Class.new(StandardError)
class ApplicationSettings < ActiveSupport::HashWithIndifferentAccess
end

class MissingApplicationSettings < StandardError
end

SETTINGS = {
user_registration_enabled: 1,
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/has_translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module HasTranslation
extend ActiveSupport::Concern

class_methods do
# rubocop:disable Naming/PredicateName -- this is like has_many from rails rather than a boolean predicate
# rubocop:disable Naming/PredicatePrefix -- this is an association macro, not a predicate
def has_translation(relation, purpose: nil)
has_many relation, -> { by_purpose(purpose) },
class_name: 'Translation',
Expand All @@ -13,6 +13,6 @@ def has_translation(relation, purpose: nil)
autosave: true,
dependent: :destroy
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Naming/PredicatePrefix
end
end
4 changes: 1 addition & 3 deletions app/models/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ def user_type?
parent_type == User.name
end

# rubocop:disable Naming/PredicateName
def has_owner?
def owner?
user_type?
end
# rubocop:enable Naming/PredicateName

def member?(user)
return false if user.nil?
Expand Down
5 changes: 3 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class User < ApplicationRecord
include NamespaceParent

has_secure_password

validates :username, length: { maximum: 50 },
Expand Down Expand Up @@ -46,9 +47,9 @@ def validate_mfa!(mfa)
case mfa_type
when :backup_code
backup_code = BackupCode.where(user: self, token: mfa_value)
mfa_passed = backup_code.count.positive?
mfa_passed = backup_code.any?
backup_code.delete_all
mfa_passed = false unless backup_code.count.zero?
mfa_passed = false unless backup_code.none?
when :totp
totp = ROTP::TOTP.new(totp_secret)
mfa_passed = totp.verify(mfa_value)
Expand Down
3 changes: 2 additions & 1 deletion app/policies/base_policy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class BasePolicy < DeclarativePolicy::Base
InvalidUserError = Class.new(StandardError)
class InvalidUserError < StandardError
end

def initialize(user, subject, opts = {})
super
Expand Down
3 changes: 2 additions & 1 deletion app/services/error_code.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class ErrorCode
InvalidErrorCode = Class.new(StandardError)
class InvalidErrorCode < StandardError
end

def self.validate_error_code!(error_code)
return unless error_code.is_a?(Symbol)
Expand Down
2 changes: 1 addition & 1 deletion app/services/namespaces/members/assign_roles_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_audit_event(new_roles, old_roles_for_audit_event, namespace)
end

def check_last_admin_user(t)
return if member.namespace.has_owner?
return if member.namespace.owner?

unless member.namespace.roles
.joins(:abilities, :member_roles)
Expand Down
2 changes: 1 addition & 1 deletion app/services/namespaces/members/delete_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def execute
private

def check_last_administrator(t)
return if namespace_member.namespace.has_owner?
return if namespace_member.namespace.owner?

unless namespace_member.namespace.roles
.joins(:abilities, :member_roles)
Expand Down
2 changes: 1 addition & 1 deletion app/services/namespaces/roles/assign_abilities_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def execute
private

def check_admin_existing(t)
return if role.namespace.has_owner?
return if role.namespace.owner?

unless role.namespace.roles.where.not(id: role.id)
.joins(:abilities)
Expand Down
2 changes: 1 addition & 1 deletion app/services/namespaces/roles/delete_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def execute
return ServiceResponse.error(message: 'Missing permissions', error_code: :missing_permission)
end

if !namespace_role.namespace.has_owner? &&
if !namespace_role.namespace.owner? &&
!namespace_role.namespace.roles.where.not(id: namespace_role.id)
.joins(:abilities)
.joins(:member_roles)
Expand Down
4 changes: 2 additions & 2 deletions app/services/runtimes/check_runtime_compatibility_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def check_versions(model, identifier_field = :identifier)
error_code: :missing_definition)
end

result = compare_version(curr_type.parsed_version, to_check.parsed_version)
result = compatible_version?(curr_type.parsed_version, to_check.parsed_version)

unless result
return ServiceResponse.error(message: "#{model} is outdated",
Expand All @@ -53,7 +53,7 @@ def check_versions(model, identifier_field = :identifier)

# true: compatible
# false: not compatible
def compare_version(primary_version, to_check_version)
def compatible_version?(primary_version, to_check_version)
return false if primary_version.segments[0] != to_check_version.segments[0]
return false if primary_version.segments[1] > to_check_version.segments[1]

Expand Down
2 changes: 1 addition & 1 deletion app/services/users/mfa/backup_codes/rotate_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def execute
transactional do |t|
old_codes = BackupCode.where(user: current_user)
old_codes.delete_all
unless old_codes.count.zero?
unless old_codes.none?
t.rollback_and_return! ServiceResponse.error(message: 'Failed to delete old backup codes',
error_code: :failed_to_invalidate_old_backup_codes)
end
Expand Down
2 changes: 1 addition & 1 deletion db/fixtures/production/01_users.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

return unless User.count.zero?
return unless User.none?

initial_root_email = ENV.fetch('INITIAL_ROOT_MAIL', nil)
initial_root_password = ENV.fetch('INITIAL_ROOT_PASSWORD', SecureRandom.hex)
Expand Down
2 changes: 1 addition & 1 deletion db/fixtures/production/02_runtimes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
initial_runtime_token = ENV.fetch('INITIAL_RUNTIME_TOKEN', nil)
return if initial_runtime_token.blank?

return unless Runtime.count.zero?
return unless Runtime.none?

runtime = Runtime.new(
name: 'Initial Runtime',
Expand Down
4 changes: 2 additions & 2 deletions lib/sagittarius/graphql/stable_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def nodes
results.slice(0, page_size)
end

# rubocop:disable Naming/PredicateName -- this is required by graphql-ruby
# rubocop:disable Naming/PredicateMethod, Naming/PredicatePrefix -- these method names are required by graphql-ruby
def has_next_page
!backward? && results.size > page_size
end

def has_previous_page
backward? && results.size > page_size
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Naming/PredicateMethod, Naming/PredicatePrefix
end
# rubocop:enable GraphQL/ObjectDescription
end
Expand Down
13 changes: 8 additions & 5 deletions lib/sagittarius/override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ module Sagittarius
module Override
extend ActiveSupport::Concern

InvalidMethodError = Class.new(StandardError)
MissingOverrideError = Class.new(StandardError)
class InvalidMethodError < StandardError
end

class MissingOverrideError < StandardError
end

class_methods do
def override(method)
Expand All @@ -23,7 +26,7 @@ def self.verify!(clazz)

def self.verify_existence!(clazz)
Override.extensions[clazz].each do |method|
unless clazz.instance_methods.include?(method)
unless clazz.method_defined?(method)
raise_error! InvalidMethodError, "Method #{method} is not defined on #{clazz}"
end
end
Expand All @@ -40,7 +43,7 @@ def self.verify_overrides!(clazz)
end

Override.extensions[clazz].each do |method|
unless valid_sources.any? { |src| src.instance_methods(false).include?(method) }
unless valid_sources.any? { |src| src.method_defined?(method, false) }
raise_error! MissingOverrideError, "Method #{method} is not defined on #{core_class} or a lower extension"
end
end
Expand Down Expand Up @@ -68,7 +71,7 @@ def self.verify_missing_overrides!(clazz, extended_modules)
lower_sources = [clazz] + extended_modules[0...index]

ext.instance_methods(false).each do |method|
source = lower_sources.find { |src| src.instance_methods(false).include?(method) }
source = lower_sources.find { |src| src.method_defined?(method, false) }
next unless source

overrides = Override.extensions[ext]
Expand Down
3 changes: 2 additions & 1 deletion lib/sagittarius/validators/json_schema_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
module Sagittarius
module Validators
class JsonSchemaValidator < ActiveModel::EachValidator
FilenameError = Class.new(StandardError)
class FilenameError < StandardError
end
BASE_DIRECTORY = %w[app models json_schemas].freeze

def initialize(options)
Expand Down
16 changes: 9 additions & 7 deletions spec/models/flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@
],
starting_node_id: starting_node.id,
settings: [
database_id: flow.flow_settings.first.id,
flow_setting_id: flow.flow_settings.first.flow_setting_id,
value: {
struct_value: {
fields: {
'url' => {
string_value: flow.flow_settings.first.object['url'],
{
database_id: flow.flow_settings.first.id,
flow_setting_id: flow.flow_settings.first.flow_setting_id,
value: {
struct_value: {
fields: {
'url' => {
string_value: flow.flow_settings.first.object['url'],
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@
id: 'gid://sagittarius/NodeFunction/1000',
functionDefinitionId: function_definition.to_global_id.to_s,
parameters: [
value: {
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
{
value: {
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
},
}
],
nextNodeId: 'gid://sagittarius/NodeFunction/1001',
Expand All @@ -112,15 +114,17 @@
id: 'gid://sagittarius/NodeFunction/1001',
functionDefinitionId: function_definition.to_global_id.to_s,
parameters: [
value: {
referenceValue: {
referencePath: [
{
arrayIndex: 0,
path: 'some.path',
}
],
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
{
value: {
referenceValue: {
referencePath: [
{
arrayIndex: 0,
path: 'some.path',
}
],
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
},
},
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@
id: 'gid://sagittarius/NodeFunction/1000',
functionDefinitionId: function_definition.to_global_id.to_s,
parameters: [
value: {
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
{
value: {
nodeFunctionId: 'gid://sagittarius/NodeFunction/2000',
},
}
],
nextNodeId: 'gid://sagittarius/NodeFunction/1001',
Expand Down
Loading