diff --git a/Procfile.tunnel b/Procfile.tunnel index bf3541d..3d1da81 100755 --- a/Procfile.tunnel +++ b/Procfile.tunnel @@ -1,4 +1,5 @@ backend: DISABLE_MINI_PROFILER=true bin/rails s -p 3000 # https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695 worker: dotenv bundle exec sidekiq -C config/sidekiq.yml -vite: bin/vite build --watch +vite: bin/vite dev +tunnel: ngrok http --domain=louvenia-pseudoembryonic-joycelyn.ngrok-free.dev 3000 diff --git a/app/models/captain_tool_config.rb b/app/models/captain_tool_config.rb index 05c62e1..9d7d77b 100644 --- a/app/models/captain_tool_config.rb +++ b/app/models/captain_tool_config.rb @@ -1,3 +1,33 @@ +# == Schema Information +# +# Table name: captain_tool_configs +# +# id :bigint not null, primary key +# fallback_message :text +# is_enabled :boolean +# plug_play_token :string +# tool_key :string +# webhook_url :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# captain_assistant_id :bigint +# inbox_id :bigint +# plug_play_id :string +# +# Indexes +# +# index_captain_tool_configs_on_account_id (account_id) +# index_captain_tool_configs_on_assistant_id_and_tool_key (captain_assistant_id,tool_key) UNIQUE +# index_captain_tool_configs_on_captain_assistant_id (captain_assistant_id) +# index_captain_tool_configs_on_context (account_id,inbox_id,tool_key) UNIQUE +# index_captain_tool_configs_on_inbox_id (inbox_id) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (inbox_id => inboxes.id) +# class CaptainToolConfig < ApplicationRecord belongs_to :account belongs_to :inbox diff --git a/app/models/channel/whatsapp.rb b/app/models/channel/whatsapp.rb index 569feff..74e8d59 100755 --- a/app/models/channel/whatsapp.rb +++ b/app/models/channel/whatsapp.rb @@ -8,6 +8,10 @@ # phone_number :string not null # provider :string default("default") # provider_config :jsonb +# wuzapi_admin_token :string +# wuzapi_admin_token_iv :string +# wuzapi_user_token :string +# wuzapi_user_token_iv :string # created_at :datetime not null # updated_at :datetime not null # account_id :integer not null diff --git a/app/models/conversation.rb b/app/models/conversation.rb index c5944d7..96d8590 100755 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -2,39 +2,43 @@ # # Table name: conversations # -# id :integer not null, primary key -# additional_attributes :jsonb -# agent_last_seen_at :datetime -# assignee_last_seen_at :datetime -# cached_label_list :text -# contact_last_seen_at :datetime -# custom_attributes :jsonb -# first_reply_created_at :datetime -# identifier :string -# last_activity_at :datetime not null -# priority :integer -# snoozed_until :datetime -# status :integer default("open"), not null -# uuid :uuid not null -# waiting_since :datetime -# created_at :datetime not null -# updated_at :datetime not null -# account_id :integer not null -# assignee_agent_bot_id :bigint -# assignee_id :integer -# campaign_id :bigint -# contact_id :bigint -# contact_inbox_id :bigint -# display_id :integer not null -# inbox_id :integer not null -# sla_policy_id :bigint -# team_id :bigint +# id :integer not null, primary key +# active_scenario_expires_at :datetime +# active_scenario_key :string +# active_scenario_state :jsonb not null +# additional_attributes :jsonb +# agent_last_seen_at :datetime +# assignee_last_seen_at :datetime +# cached_label_list :text +# contact_last_seen_at :datetime +# custom_attributes :jsonb +# first_reply_created_at :datetime +# identifier :string +# last_activity_at :datetime not null +# priority :integer +# snoozed_until :datetime +# status :integer default("open"), not null +# uuid :uuid not null +# waiting_since :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# assignee_agent_bot_id :bigint +# assignee_id :integer +# campaign_id :bigint +# contact_id :bigint +# contact_inbox_id :bigint +# display_id :integer not null +# inbox_id :integer not null +# sla_policy_id :bigint +# team_id :bigint # # Indexes # # conv_acid_inbid_stat_asgnid_idx (account_id,inbox_id,status,assignee_id) # index_conversations_on_account_id (account_id) # index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE +# index_conversations_on_active_scenario_key (active_scenario_key) # index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) # index_conversations_on_campaign_id (campaign_id) # index_conversations_on_contact_id (contact_id) diff --git a/app/models/conversation_crm_insight.rb b/app/models/conversation_crm_insight.rb index 0af9792..5ae0084 100644 --- a/app/models/conversation_crm_insight.rb +++ b/app/models/conversation_crm_insight.rb @@ -1,3 +1,40 @@ +# == Schema Information +# +# Table name: conversation_crm_insights +# +# id :bigint not null, primary key +# confidence :float +# contact_sessions_count :integer default(0), not null +# error_message :text +# generated_at :datetime +# last_contact_at :datetime +# model :string +# schema_version :string +# status :string default("success") +# structured_data :jsonb +# summary_text :text +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# contact_id :bigint not null +# conversation_id :bigint not null +# range_from_message_id :bigint +# range_to_message_id :bigint +# +# Indexes +# +# idx_on_conversation_id_generated_at_44d5836366 (conversation_id,generated_at) +# index_conversation_crm_insights_on_account_id (account_id) +# index_conversation_crm_insights_on_contact_id (contact_id) +# index_conversation_crm_insights_on_conversation_id (conversation_id) +# index_conversation_crm_insights_on_status (status) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (contact_id => contacts.id) +# fk_rails_... (conversation_id => conversations.id) +# class ConversationCrmInsight < ApplicationRecord belongs_to :conversation belongs_to :contact diff --git a/app/models/frequent_question.rb b/app/models/frequent_question.rb index 57eb1d0..eab49ab 100644 --- a/app/models/frequent_question.rb +++ b/app/models/frequent_question.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: frequent_questions +# +# id :bigint not null, primary key +# cluster_date :date +# label :string +# occurrence_count :integer +# question_text :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_frequent_questions_on_account_id (account_id) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# class FrequentQuestion < ApplicationRecord belongs_to :account diff --git a/app/models/inbox.rb b/app/models/inbox.rb index a2d4ff8..6f708ee 100755 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -7,6 +7,7 @@ # id :integer not null, primary key # allow_messages_after_resolved :boolean default(TRUE) # auto_assignment_config :jsonb +# auto_resolve_duration :integer # business_name :string # channel_type :string # csat_config :jsonb not null diff --git a/app/models/installation_config.rb b/app/models/installation_config.rb index 3fac233..092ae7b 100755 --- a/app/models/installation_config.rb +++ b/app/models/installation_config.rb @@ -19,7 +19,7 @@ class InstallationConfig < ApplicationRecord # https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017 # FIX ME : fixes breakage of installation config. we need to migrate. # Fix configuration in application.rb - serialize :serialized_value, coder: YAML, type: ActiveSupport::HashWithIndifferentAccess + # serialize :serialized_value, type: ActiveSupport::HashWithIndifferentAccess before_validation :set_lock validates :name, presence: true @@ -39,7 +39,10 @@ class InstallationConfig < ApplicationRecord # It was throwing error as the default value of column '{}' was failing in deserialization. return {}.with_indifferent_access if new_record? && @attributes['serialized_value']&.value_before_type_cast == '{}' - serialized_value[:value] + data = serialized_value + data = YAML.safe_load(data, permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol]) if data.is_a?(String) + + data.with_indifferent_access[:value] end def value=(value_to_assigned) diff --git a/app/models/jasmine/collection.rb b/app/models/jasmine/collection.rb index f11d875..7bc7698 100644 --- a/app/models/jasmine/collection.rb +++ b/app/models/jasmine/collection.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: jasmine_collections +# +# id :bigint not null, primary key +# description :text +# is_active :boolean default(TRUE) +# name :string not null +# visibility :integer default("private") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# owner_inbox_id :bigint +# +# Indexes +# +# index_jasmine_collections_on_account_id (account_id) +# index_jasmine_collections_on_account_id_and_owner_inbox_id (account_id,owner_inbox_id) +# index_jasmine_collections_on_account_id_and_visibility (account_id,visibility) +# index_jasmine_collections_on_owner_inbox_id (owner_inbox_id) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (owner_inbox_id => inboxes.id) +# module Jasmine class Collection < ApplicationRecord self.table_name = 'jasmine_collections' diff --git a/app/models/jasmine/document.rb b/app/models/jasmine/document.rb index 340b11b..4b4b118 100644 --- a/app/models/jasmine/document.rb +++ b/app/models/jasmine/document.rb @@ -1,3 +1,30 @@ +# == Schema Information +# +# Table name: jasmine_documents +# +# id :bigint not null, primary key +# content :text +# error_message :text +# metadata :jsonb +# source_type :integer default("manual") +# status :integer default("pending") +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# collection_id :bigint not null +# +# Indexes +# +# index_jasmine_docs_on_acc_coll_status (account_id,collection_id,status) +# index_jasmine_documents_on_account_id (account_id) +# index_jasmine_documents_on_collection_id (collection_id) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (collection_id => jasmine_collections.id) +# module Jasmine class Document < ApplicationRecord self.table_name = 'jasmine_documents' diff --git a/app/models/jasmine/document_chunk.rb b/app/models/jasmine/document_chunk.rb index b997409..f4c97bb 100644 --- a/app/models/jasmine/document_chunk.rb +++ b/app/models/jasmine/document_chunk.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: jasmine_document_chunks +# +# id :bigint not null, primary key +# content :text +# embedding :vector(1536) +# metadata :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# collection_id :bigint not null +# document_id :bigint not null +# +# Indexes +# +# index_jasmine_chunks_on_acc_coll_doc (account_id,collection_id,document_id) +# index_jasmine_document_chunks_on_account_id (account_id) +# index_jasmine_document_chunks_on_collection_id (collection_id) +# index_jasmine_document_chunks_on_document_id (document_id) +# index_jasmine_document_chunks_on_embedding (embedding) USING hnsw +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (collection_id => jasmine_collections.id) +# fk_rails_... (document_id => jasmine_documents.id) +# module Jasmine require 'neighbor' class DocumentChunk < ApplicationRecord diff --git a/app/models/jasmine/inbox_collection.rb b/app/models/jasmine/inbox_collection.rb index 48c878b..fba8862 100644 --- a/app/models/jasmine/inbox_collection.rb +++ b/app/models/jasmine/inbox_collection.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: jasmine_inbox_collections +# +# id :bigint not null, primary key +# is_enabled :boolean default(TRUE) +# priority :integer default(0) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# collection_id :bigint not null +# inbox_id :bigint not null +# +# Indexes +# +# idx_on_account_id_collection_id_3011aaebad (account_id,collection_id) +# index_jasmine_inbox_collections_on_account_id (account_id) +# index_jasmine_inbox_collections_on_account_id_and_inbox_id (account_id,inbox_id) +# index_jasmine_inbox_collections_on_collection_id (collection_id) +# index_jasmine_inbox_collections_on_inbox_id (inbox_id) +# index_jasmine_inbox_collections_uniqueness (account_id,inbox_id,collection_id) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (collection_id => jasmine_collections.id) +# fk_rails_... (inbox_id => inboxes.id) +# module Jasmine class InboxCollection < ApplicationRecord self.table_name = 'jasmine_inbox_collections' diff --git a/app/models/jasmine/inbox_config.rb b/app/models/jasmine/inbox_config.rb index 97323bf..ea5ee01 100644 --- a/app/models/jasmine/inbox_config.rb +++ b/app/models/jasmine/inbox_config.rb @@ -1,3 +1,34 @@ +# == Schema Information +# +# Table name: jasmine_inbox_settings +# +# id :bigint not null, primary key +# intent_keywords :jsonb +# is_enabled :boolean default(FALSE) +# mode :integer default(0) +# model :string default("gpt-4o-mini") +# name :string default("Jasmine") +# playbook_prompt :text +# rag_distance_threshold :float default(0.35) +# rag_max_results :integer default(3) +# system_prompt :text +# temperature :float default(0.7) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# inbox_id :bigint not null +# +# Indexes +# +# index_jasmine_inbox_settings_on_account_id (account_id) +# index_jasmine_inbox_settings_on_account_id_and_inbox_id (account_id,inbox_id) UNIQUE +# index_jasmine_inbox_settings_on_inbox_id (inbox_id) +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (inbox_id => inboxes.id) +# module Jasmine class InboxConfig < ApplicationRecord self.table_name = 'jasmine_inbox_settings' diff --git a/app/models/jasmine/tool_config.rb b/app/models/jasmine/tool_config.rb index 6cdcd1d..40d753e 100644 --- a/app/models/jasmine/tool_config.rb +++ b/app/models/jasmine/tool_config.rb @@ -1,3 +1,33 @@ +# == Schema Information +# +# Table name: jasmine_tool_configs +# +# id :bigint not null, primary key +# is_enabled :boolean default(FALSE), not null +# last_test_duration_ms :integer +# last_test_error :text +# last_test_status :integer +# last_tested_at :datetime +# plug_play_token :text +# tool_key :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# inbox_id :bigint not null +# plug_play_id :string +# +# Indexes +# +# index_jasmine_tool_configs_on_account_id (account_id) +# index_jasmine_tool_configs_on_inbox_id (inbox_id) +# index_jasmine_tool_configs_on_tool_key (tool_key) +# index_jasmine_tools_on_account_inbox_key (account_id,inbox_id,tool_key) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (inbox_id => inboxes.id) +# module Jasmine class ToolConfig < ApplicationRecord self.table_name = 'jasmine_tool_configs' diff --git a/app/models/super_admin.rb b/app/models/super_admin.rb index 9bcee9b..316d60c 100755 --- a/app/models/super_admin.rb +++ b/app/models/super_admin.rb @@ -19,7 +19,7 @@ # message_signature :text # name :string not null # otp_backup_codes :text -# otp_required_for_login :boolean default(FALSE) +# otp_required_for_login :boolean default(FALSE), not null # otp_secret :string # provider :string default("email"), not null # pubsub_token :string diff --git a/app/models/user.rb b/app/models/user.rb index cc25357..4923d0a 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,7 @@ # message_signature :text # name :string not null # otp_backup_codes :text -# otp_required_for_login :boolean default(FALSE) +# otp_required_for_login :boolean default(FALSE), not null # otp_secret :string # provider :string default("email"), not null # pubsub_token :string diff --git a/enterprise/app/views/api/v1/models/captain/_unit.json.jbuilder b/enterprise/app/views/api/v1/models/captain/_unit.json.jbuilder new file mode 100644 index 0000000..3273738 --- /dev/null +++ b/enterprise/app/views/api/v1/models/captain/_unit.json.jbuilder @@ -0,0 +1,7 @@ +json.id unit.id +json.name unit.name +json.status unit.status +json.captain_brand_id unit.captain_brand_id +json.account_id unit.account_id +json.created_at unit.created_at.to_i +json.updated_at unit.updated_at.to_i diff --git a/progresso/resolucao-ruby34-chatwoot.md b/progresso/resolucao-ruby34-chatwoot.md new file mode 100644 index 0000000..6bba182 --- /dev/null +++ b/progresso/resolucao-ruby34-chatwoot.md @@ -0,0 +1,38 @@ +# Nota de Resolução: Configuração de Ambiente Ruby 3.4.4 e Correção de Serialização + +## Objetivo + +Configurar o ambiente de desenvolvimento do Chatwoot para a versão de Ruby exigida e resolver impedimentos de inicialização do banco de dados e servidor. + +## Contexto + +O projeto Chatwoot exige Ruby 3.4.4 e Rails 7.1. Versões anteriores do Ruby ou ferramentas ausentes (Overmind) impossibilitavam a execução de lints e do servidor. Além disso, uma incompatibilidade no modelo `InstallationConfig` causava erros de tipo durante o parse de YAML no Ruby 3.4. + +## Passos Realizados + +1. **Instalação de Ferramentas**: + - `brew install ruby-install chruby overmind` + - `ruby-install ruby 3.4.4` +2. **Configuração de Shell**: + - Adicionado `source /opt/homebrew/opt/chruby/share/chruby/chruby.sh` e `source /opt/homebrew/opt/chruby/share/chruby/auto.sh` ao `~/.zshrc` e `~/.bash_profile`. +3. **Dependências**: + - `gem install bundler:2.5.11` + - `bundle install` +4. **Correção de Código**: + - Alterado [InstallationConfig.rb](file:///Users/user/Dev/Produtos/Chatwoot/chatwoot-develop/app/models/installation_config.rb) para lidar com a coluna `serialized_value` (JSONB) de forma resiliente, permitindo parse de YAML legado caso necessário, mas evitando falhas de tipo no Rails 7.1. + +## Principais Arquivos Alterados + +- [InstallationConfig.rb](file:///Users/user/Dev/Produtos/Chatwoot/chatwoot-develop/app/models/installation_config.rb): Ajuste nos métodos `value` e remoção da macro `serialize` redundante. +- `~/.zshrc` / `~/.bash_profile`: Atualização de paths e scripts de ambiente. + +## Como Validar + +1. Execute `source ~/.zshrc`. +2. Rode `bundle exec rails db:chatwoot_prepare`. +3. Inicie o stack com `make run`. + +## Como Reverter + +1. Remover os `source` do `~/.zshrc`. +2. Restaurar o modelo `InstallationConfig.rb` para o estado original (utilizando `serialize ... coder: YAML`). diff --git a/spec/factories/account_users.rb b/spec/factories/account_users.rb index e2bc52e..142c29b 100755 --- a/spec/factories/account_users.rb +++ b/spec/factories/account_users.rb @@ -1,5 +1,30 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: account_users +# +# id :bigint not null, primary key +# active_at :datetime +# auto_offline :boolean default(TRUE), not null +# availability :integer default("online"), not null +# role :integer default("agent") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# agent_capacity_policy_id :bigint +# custom_role_id :bigint +# inviter_id :bigint +# user_id :bigint +# +# Indexes +# +# index_account_users_on_account_id (account_id) +# index_account_users_on_agent_capacity_policy_id (agent_capacity_policy_id) +# index_account_users_on_custom_role_id (custom_role_id) +# index_account_users_on_user_id (user_id) +# uniq_user_id_per_account_id (account_id,user_id) UNIQUE +# FactoryBot.define do factory :account_user do account diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb index 1089740..4f6e5a6 100755 --- a/spec/factories/accounts.rb +++ b/spec/factories/accounts.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: accounts +# +# id :integer not null, primary key +# auto_resolve_duration :integer +# custom_attributes :jsonb +# domain :string(100) +# feature_flags :bigint default(0), not null +# internal_attributes :jsonb not null +# limits :jsonb +# locale :integer default("en") +# name :string not null +# settings :jsonb +# status :integer default("active") +# support_email :string(100) +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_accounts_on_status (status) +# FactoryBot.define do factory :account do sequence(:name) { |n| "Account #{n}" } diff --git a/spec/factories/agent_bot_inboxes.rb b/spec/factories/agent_bot_inboxes.rb index df687d7..ba2bacd 100755 --- a/spec/factories/agent_bot_inboxes.rb +++ b/spec/factories/agent_bot_inboxes.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: agent_bot_inboxes +# +# id :bigint not null, primary key +# status :integer default("active") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# agent_bot_id :integer +# inbox_id :integer +# FactoryBot.define do factory :agent_bot_inbox do inbox diff --git a/spec/factories/agent_bots.rb b/spec/factories/agent_bots.rb index 286f70b..1716a78 100755 --- a/spec/factories/agent_bots.rb +++ b/spec/factories/agent_bots.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: agent_bots +# +# id :bigint not null, primary key +# bot_config :jsonb +# bot_type :integer default("webhook") +# description :string +# name :string +# outgoing_url :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# index_agent_bots_on_account_id (account_id) +# FactoryBot.define do factory :agent_bot do name { 'MyString' } diff --git a/spec/factories/articles.rb b/spec/factories/articles.rb index b86e422..9dbe8b6 100755 --- a/spec/factories/articles.rb +++ b/spec/factories/articles.rb @@ -1,3 +1,36 @@ +# == Schema Information +# +# Table name: articles +# +# id :bigint not null, primary key +# content :text +# description :text +# locale :string default("en"), not null +# meta :jsonb +# position :integer +# slug :string not null +# status :integer +# title :string +# views :integer +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# associated_article_id :bigint +# author_id :bigint +# category_id :integer +# folder_id :integer +# portal_id :integer not null +# +# Indexes +# +# index_articles_on_account_id (account_id) +# index_articles_on_associated_article_id (associated_article_id) +# index_articles_on_author_id (author_id) +# index_articles_on_portal_id (portal_id) +# index_articles_on_slug (slug) UNIQUE +# index_articles_on_status (status) +# index_articles_on_views (views) +# FactoryBot.define do factory :article, class: 'Article' do account diff --git a/spec/factories/assignment_policies.rb b/spec/factories/assignment_policies.rb index 6a696ca..62bead7 100755 --- a/spec/factories/assignment_policies.rb +++ b/spec/factories/assignment_policies.rb @@ -1,3 +1,25 @@ +# == Schema Information +# +# Table name: assignment_policies +# +# id :bigint not null, primary key +# assignment_order :integer default("round_robin"), not null +# conversation_priority :integer default("earliest_created"), not null +# description :text +# enabled :boolean default(TRUE), not null +# fair_distribution_limit :integer default(100), not null +# fair_distribution_window :integer default(3600), not null +# name :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_assignment_policies_on_account_id (account_id) +# index_assignment_policies_on_account_id_and_name (account_id,name) UNIQUE +# index_assignment_policies_on_enabled (enabled) +# FactoryBot.define do factory :assignment_policy do account diff --git a/spec/factories/automation_rules.rb b/spec/factories/automation_rules.rb index 4a70456..a4c5710 100755 --- a/spec/factories/automation_rules.rb +++ b/spec/factories/automation_rules.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: automation_rules +# +# id :bigint not null, primary key +# actions :jsonb not null +# active :boolean default(TRUE), not null +# conditions :jsonb not null +# description :text +# event_name :string not null +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_automation_rules_on_account_id (account_id) +# FactoryBot.define do factory :automation_rule do account diff --git a/spec/factories/campaigns.rb b/spec/factories/campaigns.rb index c3c32d1..6a17abe 100755 --- a/spec/factories/campaigns.rb +++ b/spec/factories/campaigns.rb @@ -1,5 +1,36 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: campaigns +# +# id :bigint not null, primary key +# audience :jsonb +# campaign_status :integer default("active"), not null +# campaign_type :integer default("ongoing"), not null +# description :text +# enabled :boolean default(TRUE) +# message :text not null +# scheduled_at :datetime +# template_params :jsonb +# title :string not null +# trigger_only_during_business_hours :boolean default(FALSE) +# trigger_rules :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# display_id :integer not null +# inbox_id :bigint not null +# sender_id :integer +# +# Indexes +# +# index_campaigns_on_account_id (account_id) +# index_campaigns_on_campaign_status (campaign_status) +# index_campaigns_on_campaign_type (campaign_type) +# index_campaigns_on_inbox_id (inbox_id) +# index_campaigns_on_scheduled_at (scheduled_at) +# FactoryBot.define do factory :campaign do sequence(:title) { |n| "Campaign #{n}" } diff --git a/spec/factories/canned_responses.rb b/spec/factories/canned_responses.rb index 0790047..476d9d7 100755 --- a/spec/factories/canned_responses.rb +++ b/spec/factories/canned_responses.rb @@ -1,5 +1,16 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: canned_responses +# +# id :integer not null, primary key +# content :text +# short_code :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# FactoryBot.define do factory :canned_response do content { 'Content' } diff --git a/spec/factories/categories.rb b/spec/factories/categories.rb index f9685b8..9a00484 100755 --- a/spec/factories/categories.rb +++ b/spec/factories/categories.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: categories +# +# id :bigint not null, primary key +# description :text +# icon :string default("") +# locale :string default("en") +# name :string +# position :integer +# slug :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# associated_category_id :bigint +# parent_category_id :bigint +# portal_id :integer not null +# +# Indexes +# +# index_categories_on_associated_category_id (associated_category_id) +# index_categories_on_locale (locale) +# index_categories_on_locale_and_account_id (locale,account_id) +# index_categories_on_parent_category_id (parent_category_id) +# index_categories_on_slug_and_locale_and_portal_id (slug,locale,portal_id) UNIQUE +# FactoryBot.define do factory :category, class: 'Category' do portal diff --git a/spec/factories/channel/facebook_pages.rb b/spec/factories/channel/facebook_pages.rb index a30fb56..1882514 100755 --- a/spec/factories/channel/facebook_pages.rb +++ b/spec/factories/channel/facebook_pages.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_facebook_pages +# +# id :integer not null, primary key +# page_access_token :string not null +# user_access_token :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# instagram_id :string +# page_id :string not null +# +# Indexes +# +# index_channel_facebook_pages_on_page_id (page_id) +# index_channel_facebook_pages_on_page_id_and_account_id (page_id,account_id) UNIQUE +# FactoryBot.define do factory :channel_facebook_page, class: 'Channel::FacebookPage' do page_access_token { SecureRandom.uuid } diff --git a/spec/factories/channel/twilio_sms.rb b/spec/factories/channel/twilio_sms.rb index 1963a4f..26192d1 100755 --- a/spec/factories/channel/twilio_sms.rb +++ b/spec/factories/channel/twilio_sms.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: channel_twilio_sms +# +# id :bigint not null, primary key +# account_sid :string not null +# api_key_sid :string +# auth_token :string not null +# content_templates :jsonb +# content_templates_last_updated :datetime +# medium :integer default("sms") +# messaging_service_sid :string +# phone_number :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_twilio_sms_on_account_sid_and_phone_number (account_sid,phone_number) UNIQUE +# index_channel_twilio_sms_on_messaging_service_sid (messaging_service_sid) UNIQUE +# index_channel_twilio_sms_on_phone_number (phone_number) UNIQUE +# FactoryBot.define do factory :channel_twilio_sms, class: 'Channel::TwilioSms' do auth_token { SecureRandom.uuid } diff --git a/spec/factories/channel/twitter_profiles.rb b/spec/factories/channel/twitter_profiles.rb index 1de6557..4ddfc8d 100755 --- a/spec/factories/channel/twitter_profiles.rb +++ b/spec/factories/channel/twitter_profiles.rb @@ -1,5 +1,22 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_twitter_profiles +# +# id :bigint not null, primary key +# tweets_enabled :boolean default(TRUE) +# twitter_access_token :string not null +# twitter_access_token_secret :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# profile_id :string not null +# +# Indexes +# +# index_channel_twitter_profiles_on_account_id_and_profile_id (account_id,profile_id) UNIQUE +# FactoryBot.define do factory :channel_twitter_profile, class: 'Channel::TwitterProfile' do twitter_access_token { SecureRandom.uuid } diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb index 5867c3f..78f9171 100755 --- a/spec/factories/contacts.rb +++ b/spec/factories/contacts.rb @@ -1,5 +1,43 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: contacts +# +# id :integer not null, primary key +# additional_attributes :jsonb +# blocked :boolean default(FALSE), not null +# contact_type :integer default("visitor") +# country_code :string default("") +# custom_attributes :jsonb +# email :string +# identifier :string +# last_activity_at :datetime +# last_name :string default("") +# location :string default("") +# middle_name :string default("") +# name :string default("") +# phone_number :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# company_id :bigint +# +# Indexes +# +# index_contacts_on_account_id (account_id) +# index_contacts_on_account_id_and_contact_type (account_id,contact_type) +# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST) +# index_contacts_on_blocked (blocked) +# index_contacts_on_company_id (company_id) +# index_contacts_on_lower_email_account_id (lower((email)::text), account_id) +# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin +# index_contacts_on_nonempty_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# index_contacts_on_phone_number_and_account_id (phone_number,account_id) +# index_resolved_contact_account_id (account_id) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# uniq_email_per_account_contact (email,account_id) UNIQUE +# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE +# FactoryBot.define do factory :contact do sequence(:name) { |n| "Contact #{n}" } diff --git a/spec/factories/conversation_participants.rb b/spec/factories/conversation_participants.rb index 9b10d2f..cf18ddd 100755 --- a/spec/factories/conversation_participants.rb +++ b/spec/factories/conversation_participants.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: conversation_participants +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# conversation_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_conversation_participants_on_account_id (account_id) +# index_conversation_participants_on_conversation_id (conversation_id) +# index_conversation_participants_on_user_id (user_id) +# index_conversation_participants_on_user_id_and_conversation_id (user_id,conversation_id) UNIQUE +# FactoryBot.define do factory :conversation_participant do conversation diff --git a/spec/factories/conversations.rb b/spec/factories/conversations.rb index c552e6c..6e2a0c6 100755 --- a/spec/factories/conversations.rb +++ b/spec/factories/conversations.rb @@ -1,5 +1,61 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: conversations +# +# id :integer not null, primary key +# active_scenario_expires_at :datetime +# active_scenario_key :string +# active_scenario_state :jsonb not null +# additional_attributes :jsonb +# agent_last_seen_at :datetime +# assignee_last_seen_at :datetime +# cached_label_list :text +# contact_last_seen_at :datetime +# custom_attributes :jsonb +# first_reply_created_at :datetime +# identifier :string +# last_activity_at :datetime not null +# priority :integer +# snoozed_until :datetime +# status :integer default("open"), not null +# uuid :uuid not null +# waiting_since :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# assignee_agent_bot_id :bigint +# assignee_id :integer +# campaign_id :bigint +# contact_id :bigint +# contact_inbox_id :bigint +# display_id :integer not null +# inbox_id :integer not null +# sla_policy_id :bigint +# team_id :bigint +# +# Indexes +# +# conv_acid_inbid_stat_asgnid_idx (account_id,inbox_id,status,assignee_id) +# index_conversations_on_account_id (account_id) +# index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE +# index_conversations_on_active_scenario_key (active_scenario_key) +# index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) +# index_conversations_on_campaign_id (campaign_id) +# index_conversations_on_contact_id (contact_id) +# index_conversations_on_contact_inbox_id (contact_inbox_id) +# index_conversations_on_first_reply_created_at (first_reply_created_at) +# index_conversations_on_id_and_account_id (account_id,id) +# index_conversations_on_identifier_and_account_id (identifier,account_id) +# index_conversations_on_inbox_id (inbox_id) +# index_conversations_on_priority (priority) +# index_conversations_on_status_and_account_id (status,account_id) +# index_conversations_on_status_and_priority (status,priority) +# index_conversations_on_team_id (team_id) +# index_conversations_on_uuid (uuid) UNIQUE +# index_conversations_on_waiting_since (waiting_since) +# FactoryBot.define do factory :conversation do status { 'open' } diff --git a/spec/factories/csat_survey_responses.rb b/spec/factories/csat_survey_responses.rb index 92a8bdb..3f22339 100755 --- a/spec/factories/csat_survey_responses.rb +++ b/spec/factories/csat_survey_responses.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: csat_survey_responses +# +# id :bigint not null, primary key +# feedback_message :text +# rating :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# assigned_agent_id :bigint +# contact_id :bigint not null +# conversation_id :bigint not null +# message_id :bigint not null +# +# Indexes +# +# index_csat_survey_responses_on_account_id (account_id) +# index_csat_survey_responses_on_assigned_agent_id (assigned_agent_id) +# index_csat_survey_responses_on_contact_id (contact_id) +# index_csat_survey_responses_on_conversation_id (conversation_id) +# index_csat_survey_responses_on_message_id (message_id) UNIQUE +# FactoryBot.define do factory :csat_survey_response do rating { 1 } diff --git a/spec/factories/custom_attribute_definitions.rb b/spec/factories/custom_attribute_definitions.rb index 9ac6df4..bf69934 100755 --- a/spec/factories/custom_attribute_definitions.rb +++ b/spec/factories/custom_attribute_definitions.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: custom_attribute_definitions +# +# id :bigint not null, primary key +# attribute_description :text +# attribute_display_name :string +# attribute_display_type :integer default("text") +# attribute_key :string +# attribute_model :integer default("conversation_attribute") +# attribute_values :jsonb +# default_value :integer +# regex_cue :string +# regex_pattern :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# attribute_key_model_index (attribute_key,attribute_model,account_id) UNIQUE +# index_custom_attribute_definitions_on_account_id (account_id) +# FactoryBot.define do factory :custom_attribute_definition do sequence(:attribute_display_name) { |n| "Custom Attribute Definition #{n}" } diff --git a/spec/factories/custom_filters.rb b/spec/factories/custom_filters.rb index 009e409..f0e358e 100755 --- a/spec/factories/custom_filters.rb +++ b/spec/factories/custom_filters.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: custom_filters +# +# id :bigint not null, primary key +# filter_type :integer default("conversation"), not null +# name :string not null +# query :jsonb not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_custom_filters_on_account_id (account_id) +# index_custom_filters_on_user_id (user_id) +# FactoryBot.define do factory :custom_filter do sequence(:name) { |n| "Custom Filter #{n}" } diff --git a/spec/factories/folders.rb b/spec/factories/folders.rb index 62be3d2..8963365 100755 --- a/spec/factories/folders.rb +++ b/spec/factories/folders.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: folders +# +# id :bigint not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# category_id :integer not null +# FactoryBot.define do factory :folder, class: 'Folder' do account_id { 1 } diff --git a/spec/factories/inbox_assignment_policies.rb b/spec/factories/inbox_assignment_policies.rb index 80bcae2..fbc5edf 100755 --- a/spec/factories/inbox_assignment_policies.rb +++ b/spec/factories/inbox_assignment_policies.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: inbox_assignment_policies +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# assignment_policy_id :bigint not null +# inbox_id :bigint not null +# +# Indexes +# +# index_inbox_assignment_policies_on_assignment_policy_id (assignment_policy_id) +# index_inbox_assignment_policies_on_inbox_id (inbox_id) UNIQUE +# FactoryBot.define do factory :inbox_assignment_policy do inbox diff --git a/spec/factories/inbox_members.rb b/spec/factories/inbox_members.rb index 14bf5ed..723bfd3 100755 --- a/spec/factories/inbox_members.rb +++ b/spec/factories/inbox_members.rb @@ -1,5 +1,20 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: inbox_members +# +# id :integer not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# inbox_id :integer not null +# user_id :integer not null +# +# Indexes +# +# index_inbox_members_on_inbox_id (inbox_id) +# index_inbox_members_on_inbox_id_and_user_id (inbox_id,user_id) UNIQUE +# FactoryBot.define do factory :inbox_member do user { create(:user, :with_avatar) } diff --git a/spec/factories/inboxes.rb b/spec/factories/inboxes.rb index e8ca502..35c5ade 100755 --- a/spec/factories/inboxes.rb +++ b/spec/factories/inboxes.rb @@ -1,5 +1,44 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: inboxes +# +# id :integer not null, primary key +# allow_messages_after_resolved :boolean default(TRUE) +# auto_assignment_config :jsonb +# auto_resolve_duration :integer +# business_name :string +# channel_type :string +# csat_config :jsonb not null +# csat_survey_enabled :boolean default(FALSE) +# email_address :string +# enable_auto_assignment :boolean default(TRUE) +# enable_email_collect :boolean default(TRUE) +# greeting_enabled :boolean default(FALSE) +# greeting_message :string +# lock_to_single_conversation :boolean default(FALSE), not null +# name :string not null +# out_of_office_message :string +# sender_name_type :integer default("friendly"), not null +# timezone :string default("UTC") +# working_hours_enabled :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# channel_id :integer not null +# portal_id :bigint +# +# Indexes +# +# index_inboxes_on_account_id (account_id) +# index_inboxes_on_channel_id_and_channel_type (channel_id,channel_type) +# index_inboxes_on_portal_id (portal_id) +# +# Foreign Keys +# +# fk_rails_... (portal_id => portals.id) +# FactoryBot.define do factory :inbox do account diff --git a/spec/factories/integrations/hooks.rb b/spec/factories/integrations/hooks.rb index 8551733..8f2bbc0 100755 --- a/spec/factories/integrations/hooks.rb +++ b/spec/factories/integrations/hooks.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: integrations_hooks +# +# id :bigint not null, primary key +# access_token :string +# hook_type :integer default("account") +# settings :jsonb +# status :integer default("enabled") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# app_id :string +# inbox_id :integer +# reference_id :string +# FactoryBot.define do factory :integrations_hook, class: 'Integrations::Hook' do app_id { 'slack' } diff --git a/spec/factories/labels.rb b/spec/factories/labels.rb index 67d4d57..0d2a4cd 100755 --- a/spec/factories/labels.rb +++ b/spec/factories/labels.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: labels +# +# id :bigint not null, primary key +# color :string default("#1f93ff"), not null +# description :text +# show_on_sidebar :boolean +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# index_labels_on_account_id (account_id) +# index_labels_on_title_and_account_id (title,account_id) UNIQUE +# FactoryBot.define do factory :label do account diff --git a/spec/factories/macros.rb b/spec/factories/macros.rb index 1730f58..a1dc8c7 100755 --- a/spec/factories/macros.rb +++ b/spec/factories/macros.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: macros +# +# id :bigint not null, primary key +# actions :jsonb not null +# name :string not null +# visibility :integer default("personal") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# created_by_id :bigint +# updated_by_id :bigint +# +# Indexes +# +# index_macros_on_account_id (account_id) +# FactoryBot.define do factory :macro do account diff --git a/spec/factories/mentions.rb b/spec/factories/mentions.rb index 623102e..2998df3 100755 --- a/spec/factories/mentions.rb +++ b/spec/factories/mentions.rb @@ -1,5 +1,24 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: mentions +# +# id :bigint not null, primary key +# mentioned_at :datetime not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# conversation_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_mentions_on_account_id (account_id) +# index_mentions_on_conversation_id (conversation_id) +# index_mentions_on_user_id (user_id) +# index_mentions_on_user_id_and_conversation_id (user_id,conversation_id) UNIQUE +# FactoryBot.define do factory :mention do mentioned_at { Time.current } diff --git a/spec/factories/messages.rb b/spec/factories/messages.rb index 99a2c7c..86a2a59 100755 --- a/spec/factories/messages.rb +++ b/spec/factories/messages.rb @@ -1,5 +1,44 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: messages +# +# id :integer not null, primary key +# additional_attributes :jsonb +# content :text +# content_attributes :json +# content_type :integer default("text"), not null +# external_source_ids :jsonb +# message_type :integer not null +# private :boolean default(FALSE), not null +# processed_message_content :text +# sender_type :string +# sentiment :jsonb +# status :integer default("sent") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# conversation_id :integer not null +# inbox_id :integer not null +# sender_id :bigint +# source_id :text +# +# Indexes +# +# idx_messages_account_content_created (account_id,content_type,created_at) +# index_messages_on_account_created_type (account_id,created_at,message_type) +# index_messages_on_account_id (account_id) +# index_messages_on_account_id_and_inbox_id (account_id,inbox_id) +# index_messages_on_additional_attributes_campaign_id (((additional_attributes -> 'campaign_id'::text))) USING gin +# index_messages_on_content (content) USING gin +# index_messages_on_conversation_account_type_created (conversation_id,account_id,message_type,created_at) +# index_messages_on_conversation_id (conversation_id) +# index_messages_on_created_at (created_at) +# index_messages_on_inbox_id (inbox_id) +# index_messages_on_sender_type_and_sender_id (sender_type,sender_id) +# index_messages_on_source_id (source_id) +# FactoryBot.define do factory :message do content { 'Incoming Message' } diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index be65001..2d3789e 100755 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: notes +# +# id :bigint not null, primary key +# content :text not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# contact_id :bigint not null +# user_id :bigint +# +# Indexes +# +# index_notes_on_account_id (account_id) +# index_notes_on_contact_id (contact_id) +# index_notes_on_user_id (user_id) +# FactoryBot.define do factory :note do content { 'Hey welcome to chatwoot' } diff --git a/spec/factories/notification_subscriptions.rb b/spec/factories/notification_subscriptions.rb index c886a12..109f5b8 100755 --- a/spec/factories/notification_subscriptions.rb +++ b/spec/factories/notification_subscriptions.rb @@ -1,5 +1,22 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: notification_subscriptions +# +# id :bigint not null, primary key +# identifier :text +# subscription_attributes :jsonb not null +# subscription_type :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# user_id :bigint not null +# +# Indexes +# +# index_notification_subscriptions_on_identifier (identifier) UNIQUE +# index_notification_subscriptions_on_user_id (user_id) +# FactoryBot.define do factory :notification_subscription do user diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 1c3a8fb..95646c0 100755 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -1,5 +1,33 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: notifications +# +# id :bigint not null, primary key +# last_activity_at :datetime +# meta :jsonb +# notification_type :integer not null +# primary_actor_type :string not null +# read_at :datetime +# secondary_actor_type :string +# snoozed_until :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# primary_actor_id :bigint not null +# secondary_actor_id :bigint +# user_id :bigint not null +# +# Indexes +# +# idx_notifications_performance (user_id,account_id,snoozed_until,read_at) +# index_notifications_on_account_id (account_id) +# index_notifications_on_last_activity_at (last_activity_at) +# index_notifications_on_user_id (user_id) +# uniq_primary_actor_per_account_notifications (primary_actor_type,primary_actor_id) +# uniq_secondary_actor_per_account_notifications (secondary_actor_type,secondary_actor_id) +# FactoryBot.define do factory :notification do primary_actor { create(:conversation, account: account) } diff --git a/spec/factories/platform_apps.rb b/spec/factories/platform_apps.rb index 3c0fb19..96b2a9d 100755 --- a/spec/factories/platform_apps.rb +++ b/spec/factories/platform_apps.rb @@ -1,3 +1,12 @@ +# == Schema Information +# +# Table name: platform_apps +# +# id :bigint not null, primary key +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# FactoryBot.define do factory :platform_app do name { Faker::Book.name } diff --git a/spec/factories/portals.rb b/spec/factories/portals.rb index d49de09..1881352 100755 --- a/spec/factories/portals.rb +++ b/spec/factories/portals.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: portals +# +# id :bigint not null, primary key +# archived :boolean default(FALSE) +# color :string +# config :jsonb +# custom_domain :string +# header_text :text +# homepage_link :string +# name :string not null +# page_title :string +# slug :string not null +# ssl_settings :jsonb not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# channel_web_widget_id :bigint +# +# Indexes +# +# index_portals_on_channel_web_widget_id (channel_web_widget_id) +# index_portals_on_custom_domain (custom_domain) UNIQUE +# index_portals_on_slug (slug) UNIQUE +# FactoryBot.define do factory :portal, class: 'Portal' do account diff --git a/spec/factories/related_categories.rb b/spec/factories/related_categories.rb index 492cfa0..4fd0cb7 100755 --- a/spec/factories/related_categories.rb +++ b/spec/factories/related_categories.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: related_categories +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# category_id :bigint +# related_category_id :bigint +# +# Indexes +# +# index_related_categories_on_category_id_and_related_category_id (category_id,related_category_id) UNIQUE +# index_related_categories_on_related_category_id_and_category_id (related_category_id,category_id) UNIQUE +# FactoryBot.define do factory :related_category do category diff --git a/spec/factories/reporting_events.rb b/spec/factories/reporting_events.rb index aff731b..07b2132 100755 --- a/spec/factories/reporting_events.rb +++ b/spec/factories/reporting_events.rb @@ -1,3 +1,30 @@ +# == Schema Information +# +# Table name: reporting_events +# +# id :bigint not null, primary key +# event_end_time :datetime +# event_start_time :datetime +# name :string +# value :float +# value_in_business_hours :float +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# conversation_id :integer +# inbox_id :integer +# user_id :integer +# +# Indexes +# +# index_reporting_events_on_account_id (account_id) +# index_reporting_events_on_conversation_id (conversation_id) +# index_reporting_events_on_created_at (created_at) +# index_reporting_events_on_inbox_id (inbox_id) +# index_reporting_events_on_name (name) +# index_reporting_events_on_user_id (user_id) +# reporting_events__account_id__name__created_at (account_id,name,created_at) +# FactoryBot.define do factory :reporting_event do name { 'first_response' } diff --git a/spec/factories/super_admins.rb b/spec/factories/super_admins.rb index fbb821c..27a28ce 100755 --- a/spec/factories/super_admins.rb +++ b/spec/factories/super_admins.rb @@ -1,3 +1,49 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# availability :integer default("online") +# confirmation_sent_at :datetime +# confirmation_token :string +# confirmed_at :datetime +# consumed_timestep :integer +# current_sign_in_at :datetime +# current_sign_in_ip :string +# custom_attributes :jsonb +# display_name :string +# email :string +# encrypted_password :string default(""), not null +# last_sign_in_at :datetime +# last_sign_in_ip :string +# message_signature :text +# name :string not null +# otp_backup_codes :text +# otp_required_for_login :boolean default(FALSE), not null +# otp_secret :string +# provider :string default("email"), not null +# pubsub_token :string +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# sign_in_count :integer default(0), not null +# tokens :json +# type :string +# ui_settings :jsonb +# uid :string default(""), not null +# unconfirmed_email :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) +# index_users_on_otp_required_for_login (otp_required_for_login) +# index_users_on_otp_secret (otp_secret) UNIQUE +# index_users_on_pubsub_token (pubsub_token) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# index_users_on_uid_and_provider (uid,provider) UNIQUE +# FactoryBot.define do factory :super_admin do name { Faker::Name.name } diff --git a/spec/factories/team_members.rb b/spec/factories/team_members.rb index 2c499e8..aff2071 100755 --- a/spec/factories/team_members.rb +++ b/spec/factories/team_members.rb @@ -1,5 +1,21 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: team_members +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# team_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_team_members_on_team_id (team_id) +# index_team_members_on_team_id_and_user_id (team_id,user_id) UNIQUE +# index_team_members_on_user_id (user_id) +# FactoryBot.define do factory :team_member do user diff --git a/spec/factories/teams.rb b/spec/factories/teams.rb index f51269a..560c3b5 100755 --- a/spec/factories/teams.rb +++ b/spec/factories/teams.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: teams +# +# id :bigint not null, primary key +# allow_auto_assign :boolean default(TRUE) +# description :text +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_teams_on_account_id (account_id) +# index_teams_on_name_and_account_id (name,account_id) UNIQUE +# FactoryBot.define do factory :team do sequence(:name) { |n| "Team #{n}" } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 89ee680..2f6e8b9 100755 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,5 +1,51 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# availability :integer default("online") +# confirmation_sent_at :datetime +# confirmation_token :string +# confirmed_at :datetime +# consumed_timestep :integer +# current_sign_in_at :datetime +# current_sign_in_ip :string +# custom_attributes :jsonb +# display_name :string +# email :string +# encrypted_password :string default(""), not null +# last_sign_in_at :datetime +# last_sign_in_ip :string +# message_signature :text +# name :string not null +# otp_backup_codes :text +# otp_required_for_login :boolean default(FALSE), not null +# otp_secret :string +# provider :string default("email"), not null +# pubsub_token :string +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# sign_in_count :integer default(0), not null +# tokens :json +# type :string +# ui_settings :jsonb +# uid :string default(""), not null +# unconfirmed_email :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) +# index_users_on_otp_required_for_login (otp_required_for_login) +# index_users_on_otp_secret (otp_secret) UNIQUE +# index_users_on_pubsub_token (pubsub_token) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# index_users_on_uid_and_provider (uid,provider) UNIQUE +# FactoryBot.define do factory :user do transient do diff --git a/spec/factories/webhooks.rb b/spec/factories/webhooks.rb index a4a875c..9f57951 100755 --- a/spec/factories/webhooks.rb +++ b/spec/factories/webhooks.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: webhooks +# +# id :bigint not null, primary key +# name :string +# subscriptions :jsonb +# url :string +# webhook_type :integer default("account_type") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# inbox_id :integer +# +# Indexes +# +# index_webhooks_on_account_id_and_url (account_id,url) UNIQUE +# FactoryBot.define do factory :webhook do account_id { 1 } diff --git a/spec/factories/working_hours.rb b/spec/factories/working_hours.rb index 156caed..863a79f 100755 --- a/spec/factories/working_hours.rb +++ b/spec/factories/working_hours.rb @@ -1,5 +1,27 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: working_hours +# +# id :bigint not null, primary key +# close_hour :integer +# close_minutes :integer +# closed_all_day :boolean default(FALSE) +# day_of_week :integer not null +# open_all_day :boolean default(FALSE) +# open_hour :integer +# open_minutes :integer +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# inbox_id :bigint +# +# Indexes +# +# index_working_hours_on_account_id (account_id) +# index_working_hours_on_inbox_id (inbox_id) +# FactoryBot.define do factory :working_hour do inbox diff --git a/spec/fixtures/accounts.yml b/spec/fixtures/accounts.yml index 56066c6..2f391cc 100755 --- a/spec/fixtures/accounts.yml +++ b/spec/fixtures/accounts.yml @@ -1,5 +1,28 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: accounts +# +# id :integer not null, primary key +# auto_resolve_duration :integer +# custom_attributes :jsonb +# domain :string(100) +# feature_flags :bigint default(0), not null +# internal_attributes :jsonb not null +# limits :jsonb +# locale :integer default("en") +# name :string not null +# settings :jsonb +# status :integer default("active") +# support_email :string(100) +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_accounts_on_status (status) +# one: name: MyString diff --git a/spec/fixtures/attachments.yml b/spec/fixtures/attachments.yml index 80aed36..22c6b3e 100755 --- a/spec/fixtures/attachments.yml +++ b/spec/fixtures/attachments.yml @@ -4,6 +4,28 @@ # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # +# == Schema Information +# +# Table name: attachments +# +# id :integer not null, primary key +# coordinates_lat :float default(0.0) +# coordinates_long :float default(0.0) +# extension :string +# external_url :string +# fallback_title :string +# file_type :integer default("image") +# meta :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# message_id :integer not null +# +# Indexes +# +# index_attachments_on_account_id (account_id) +# index_attachments_on_message_id (message_id) +# one: {} # column: value # diff --git a/spec/fixtures/canned_responses.yml b/spec/fixtures/canned_responses.yml index 520874f..95973f9 100755 --- a/spec/fixtures/canned_responses.yml +++ b/spec/fixtures/canned_responses.yml @@ -1,5 +1,16 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: canned_responses +# +# id :integer not null, primary key +# content :text +# short_code :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# one: account_id: 1 short_code: MyString diff --git a/spec/fixtures/contacts.yml b/spec/fixtures/contacts.yml index 6c74048..f13dfe7 100755 --- a/spec/fixtures/contacts.yml +++ b/spec/fixtures/contacts.yml @@ -1,5 +1,43 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: contacts +# +# id :integer not null, primary key +# additional_attributes :jsonb +# blocked :boolean default(FALSE), not null +# contact_type :integer default("visitor") +# country_code :string default("") +# custom_attributes :jsonb +# email :string +# identifier :string +# last_activity_at :datetime +# last_name :string default("") +# location :string default("") +# middle_name :string default("") +# name :string default("") +# phone_number :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# company_id :bigint +# +# Indexes +# +# index_contacts_on_account_id (account_id) +# index_contacts_on_account_id_and_contact_type (account_id,contact_type) +# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST) +# index_contacts_on_blocked (blocked) +# index_contacts_on_company_id (company_id) +# index_contacts_on_lower_email_account_id (lower((email)::text), account_id) +# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin +# index_contacts_on_nonempty_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# index_contacts_on_phone_number_and_account_id (phone_number,account_id) +# index_resolved_contact_account_id (account_id) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# uniq_email_per_account_contact (email,account_id) UNIQUE +# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE +# one: name: MyString email: MyString diff --git a/spec/fixtures/conversations.yml b/spec/fixtures/conversations.yml index d8889ad..3f34fdb 100755 --- a/spec/fixtures/conversations.yml +++ b/spec/fixtures/conversations.yml @@ -1,5 +1,61 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: conversations +# +# id :integer not null, primary key +# active_scenario_expires_at :datetime +# active_scenario_key :string +# active_scenario_state :jsonb not null +# additional_attributes :jsonb +# agent_last_seen_at :datetime +# assignee_last_seen_at :datetime +# cached_label_list :text +# contact_last_seen_at :datetime +# custom_attributes :jsonb +# first_reply_created_at :datetime +# identifier :string +# last_activity_at :datetime not null +# priority :integer +# snoozed_until :datetime +# status :integer default("open"), not null +# uuid :uuid not null +# waiting_since :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# assignee_agent_bot_id :bigint +# assignee_id :integer +# campaign_id :bigint +# contact_id :bigint +# contact_inbox_id :bigint +# display_id :integer not null +# inbox_id :integer not null +# sla_policy_id :bigint +# team_id :bigint +# +# Indexes +# +# conv_acid_inbid_stat_asgnid_idx (account_id,inbox_id,status,assignee_id) +# index_conversations_on_account_id (account_id) +# index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE +# index_conversations_on_active_scenario_key (active_scenario_key) +# index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) +# index_conversations_on_campaign_id (campaign_id) +# index_conversations_on_contact_id (contact_id) +# index_conversations_on_contact_inbox_id (contact_inbox_id) +# index_conversations_on_first_reply_created_at (first_reply_created_at) +# index_conversations_on_id_and_account_id (account_id,id) +# index_conversations_on_identifier_and_account_id (identifier,account_id) +# index_conversations_on_inbox_id (inbox_id) +# index_conversations_on_priority (priority) +# index_conversations_on_status_and_account_id (status,account_id) +# index_conversations_on_status_and_priority (status,priority) +# index_conversations_on_team_id (team_id) +# index_conversations_on_uuid (uuid) UNIQUE +# index_conversations_on_waiting_since (waiting_since) +# one: account_id: 1 channel_id: 1 diff --git a/spec/fixtures/inbox_members.yml b/spec/fixtures/inbox_members.yml index 96db3f0..b05f49c 100755 --- a/spec/fixtures/inbox_members.yml +++ b/spec/fixtures/inbox_members.yml @@ -1,5 +1,20 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: inbox_members +# +# id :integer not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# inbox_id :integer not null +# user_id :integer not null +# +# Indexes +# +# index_inbox_members_on_inbox_id (inbox_id) +# index_inbox_members_on_inbox_id_and_user_id (inbox_id,user_id) UNIQUE +# one: user_id: 1 inbox_id: 1 diff --git a/spec/fixtures/inboxes.yml b/spec/fixtures/inboxes.yml index 14d0f4f..0057dee 100755 --- a/spec/fixtures/inboxes.yml +++ b/spec/fixtures/inboxes.yml @@ -1,5 +1,44 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# == Schema Information +# +# Table name: inboxes +# +# id :integer not null, primary key +# allow_messages_after_resolved :boolean default(TRUE) +# auto_assignment_config :jsonb +# auto_resolve_duration :integer +# business_name :string +# channel_type :string +# csat_config :jsonb not null +# csat_survey_enabled :boolean default(FALSE) +# email_address :string +# enable_auto_assignment :boolean default(TRUE) +# enable_email_collect :boolean default(TRUE) +# greeting_enabled :boolean default(FALSE) +# greeting_message :string +# lock_to_single_conversation :boolean default(FALSE), not null +# name :string not null +# out_of_office_message :string +# sender_name_type :integer default("friendly"), not null +# timezone :string default("UTC") +# working_hours_enabled :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# channel_id :integer not null +# portal_id :bigint +# +# Indexes +# +# index_inboxes_on_account_id (account_id) +# index_inboxes_on_channel_id_and_channel_type (channel_id,channel_type) +# index_inboxes_on_portal_id (portal_id) +# +# Foreign Keys +# +# fk_rails_... (portal_id => portals.id) +# one: channel_id: 1 account_id: 1 diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 80aed36..1b00625 100755 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -4,6 +4,52 @@ # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below # +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# availability :integer default("online") +# confirmation_sent_at :datetime +# confirmation_token :string +# confirmed_at :datetime +# consumed_timestep :integer +# current_sign_in_at :datetime +# current_sign_in_ip :string +# custom_attributes :jsonb +# display_name :string +# email :string +# encrypted_password :string default(""), not null +# last_sign_in_at :datetime +# last_sign_in_ip :string +# message_signature :text +# name :string not null +# otp_backup_codes :text +# otp_required_for_login :boolean default(FALSE), not null +# otp_secret :string +# provider :string default("email"), not null +# pubsub_token :string +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# sign_in_count :integer default(0), not null +# tokens :json +# type :string +# ui_settings :jsonb +# uid :string default(""), not null +# unconfirmed_email :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) +# index_users_on_otp_required_for_login (otp_required_for_login) +# index_users_on_otp_secret (otp_secret) UNIQUE +# index_users_on_pubsub_token (pubsub_token) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# index_users_on_uid_and_provider (uid,provider) UNIQUE +# one: {} # column: value # diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 0656870..93240b6 100755 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: accounts +# +# id :integer not null, primary key +# auto_resolve_duration :integer +# custom_attributes :jsonb +# domain :string(100) +# feature_flags :bigint default(0), not null +# internal_attributes :jsonb not null +# limits :jsonb +# locale :integer default("en") +# name :string not null +# settings :jsonb +# status :integer default("active") +# support_email :string(100) +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_accounts_on_status (status) +# require 'rails_helper' RSpec.describe Account do diff --git a/spec/models/account_user_spec.rb b/spec/models/account_user_spec.rb index e5a560f..6a3c774 100755 --- a/spec/models/account_user_spec.rb +++ b/spec/models/account_user_spec.rb @@ -1,5 +1,30 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: account_users +# +# id :bigint not null, primary key +# active_at :datetime +# auto_offline :boolean default(TRUE), not null +# availability :integer default("online"), not null +# role :integer default("agent") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# agent_capacity_policy_id :bigint +# custom_role_id :bigint +# inviter_id :bigint +# user_id :bigint +# +# Indexes +# +# index_account_users_on_account_id (account_id) +# index_account_users_on_agent_capacity_policy_id (agent_capacity_policy_id) +# index_account_users_on_custom_role_id (custom_role_id) +# index_account_users_on_user_id (user_id) +# uniq_user_id_per_account_id (account_id,user_id) UNIQUE +# require 'rails_helper' RSpec.describe AccountUser do diff --git a/spec/models/agent_bot_inbox_spec.rb b/spec/models/agent_bot_inbox_spec.rb index ef8f1d7..f02bbf8 100755 --- a/spec/models/agent_bot_inbox_spec.rb +++ b/spec/models/agent_bot_inbox_spec.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: agent_bot_inboxes +# +# id :bigint not null, primary key +# status :integer default("active") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# agent_bot_id :integer +# inbox_id :integer +# require 'rails_helper' RSpec.describe AgentBotInbox do diff --git a/spec/models/agent_bot_spec.rb b/spec/models/agent_bot_spec.rb index d3e5e2d..cddfecc 100755 --- a/spec/models/agent_bot_spec.rb +++ b/spec/models/agent_bot_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: agent_bots +# +# id :bigint not null, primary key +# bot_config :jsonb +# bot_type :integer default("webhook") +# description :string +# name :string +# outgoing_url :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# index_agent_bots_on_account_id (account_id) +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb' require Rails.root.join 'spec/models/concerns/avatarable_shared.rb' diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index 161f354..834346d 100755 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -1,3 +1,36 @@ +# == Schema Information +# +# Table name: articles +# +# id :bigint not null, primary key +# content :text +# description :text +# locale :string default("en"), not null +# meta :jsonb +# position :integer +# slug :string not null +# status :integer +# title :string +# views :integer +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# associated_article_id :bigint +# author_id :bigint +# category_id :integer +# folder_id :integer +# portal_id :integer not null +# +# Indexes +# +# index_articles_on_account_id (account_id) +# index_articles_on_associated_article_id (associated_article_id) +# index_articles_on_author_id (author_id) +# index_articles_on_portal_id (portal_id) +# index_articles_on_slug (slug) UNIQUE +# index_articles_on_status (status) +# index_articles_on_views (views) +# require 'rails_helper' RSpec.describe Article do diff --git a/spec/models/assignment_policy_spec.rb b/spec/models/assignment_policy_spec.rb index 1a97bbd..4126ef8 100755 --- a/spec/models/assignment_policy_spec.rb +++ b/spec/models/assignment_policy_spec.rb @@ -1,3 +1,25 @@ +# == Schema Information +# +# Table name: assignment_policies +# +# id :bigint not null, primary key +# assignment_order :integer default("round_robin"), not null +# conversation_priority :integer default("earliest_created"), not null +# description :text +# enabled :boolean default(TRUE), not null +# fair_distribution_limit :integer default(100), not null +# fair_distribution_window :integer default(3600), not null +# name :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_assignment_policies_on_account_id (account_id) +# index_assignment_policies_on_account_id_and_name (account_id,name) UNIQUE +# index_assignment_policies_on_enabled (enabled) +# require 'rails_helper' RSpec.describe AssignmentPolicy do diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index f668576..7f3d00e 100755 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -1,3 +1,25 @@ +# == Schema Information +# +# Table name: attachments +# +# id :integer not null, primary key +# coordinates_lat :float default(0.0) +# coordinates_long :float default(0.0) +# extension :string +# external_url :string +# fallback_title :string +# file_type :integer default("image") +# meta :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# message_id :integer not null +# +# Indexes +# +# index_attachments_on_account_id (account_id) +# index_attachments_on_message_id (message_id) +# require 'rails_helper' RSpec.describe Attachment do diff --git a/spec/models/automation_rule_spec.rb b/spec/models/automation_rule_spec.rb index 91452b8..ff587f2 100755 --- a/spec/models/automation_rule_spec.rb +++ b/spec/models/automation_rule_spec.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: automation_rules +# +# id :bigint not null, primary key +# actions :jsonb not null +# active :boolean default(TRUE), not null +# conditions :jsonb not null +# description :text +# event_name :string not null +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_automation_rules_on_account_id (account_id) +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb index 480f187..08a548e 100755 --- a/spec/models/campaign_spec.rb +++ b/spec/models/campaign_spec.rb @@ -1,5 +1,36 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: campaigns +# +# id :bigint not null, primary key +# audience :jsonb +# campaign_status :integer default("active"), not null +# campaign_type :integer default("ongoing"), not null +# description :text +# enabled :boolean default(TRUE) +# message :text not null +# scheduled_at :datetime +# template_params :jsonb +# title :string not null +# trigger_only_during_business_hours :boolean default(FALSE) +# trigger_rules :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# display_id :integer not null +# inbox_id :bigint not null +# sender_id :integer +# +# Indexes +# +# index_campaigns_on_account_id (account_id) +# index_campaigns_on_campaign_status (campaign_status) +# index_campaigns_on_campaign_type (campaign_type) +# index_campaigns_on_inbox_id (inbox_id) +# index_campaigns_on_scheduled_at (scheduled_at) +# require 'rails_helper' RSpec.describe Campaign do diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index efe7fe0..33f9c97 100755 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: categories +# +# id :bigint not null, primary key +# description :text +# icon :string default("") +# locale :string default("en") +# name :string +# position :integer +# slug :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# associated_category_id :bigint +# parent_category_id :bigint +# portal_id :integer not null +# +# Indexes +# +# index_categories_on_associated_category_id (associated_category_id) +# index_categories_on_locale (locale) +# index_categories_on_locale_and_account_id (locale,account_id) +# index_categories_on_parent_category_id (parent_category_id) +# index_categories_on_slug_and_locale_and_portal_id (slug,locale,portal_id) UNIQUE +# require 'rails_helper' RSpec.describe Category do diff --git a/spec/models/channel/api_spec.rb b/spec/models/channel/api_spec.rb index f3a5c8c..8ae7836 100755 --- a/spec/models/channel/api_spec.rb +++ b/spec/models/channel/api_spec.rb @@ -1,5 +1,24 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_api +# +# id :bigint not null, primary key +# additional_attributes :jsonb +# hmac_mandatory :boolean default(FALSE) +# hmac_token :string +# identifier :string +# webhook_url :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_api_on_hmac_token (hmac_token) UNIQUE +# index_channel_api_on_identifier (identifier) UNIQUE +# require 'rails_helper' RSpec.describe Channel::Api do diff --git a/spec/models/channel/email_spec.rb b/spec/models/channel/email_spec.rb index 939e8e1..a133496 100755 --- a/spec/models/channel/email_spec.rb +++ b/spec/models/channel/email_spec.rb @@ -1,5 +1,40 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_email +# +# id :bigint not null, primary key +# email :string not null +# forward_to_email :string not null +# imap_address :string default("") +# imap_enable_ssl :boolean default(TRUE) +# imap_enabled :boolean default(FALSE) +# imap_login :string default("") +# imap_password :string default("") +# imap_port :integer default(0) +# provider :string +# provider_config :jsonb +# smtp_address :string default("") +# smtp_authentication :string default("login") +# smtp_domain :string default("") +# smtp_enable_ssl_tls :boolean default(FALSE) +# smtp_enable_starttls_auto :boolean default(TRUE) +# smtp_enabled :boolean default(FALSE) +# smtp_login :string default("") +# smtp_openssl_verify_mode :string default("none") +# smtp_password :string default("") +# smtp_port :integer default(0) +# verified_for_sending :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_email_on_email (email) UNIQUE +# index_channel_email_on_forward_to_email (forward_to_email) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/channel/facebook_page_spec.rb b/spec/models/channel/facebook_page_spec.rb index f0f0e03..e5594d4 100755 --- a/spec/models/channel/facebook_page_spec.rb +++ b/spec/models/channel/facebook_page_spec.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_facebook_pages +# +# id :integer not null, primary key +# page_access_token :string not null +# user_access_token :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# instagram_id :string +# page_id :string not null +# +# Indexes +# +# index_channel_facebook_pages_on_page_id (page_id) +# index_channel_facebook_pages_on_page_id_and_account_id (page_id,account_id) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/channel/instagram_spec.rb b/spec/models/channel/instagram_spec.rb index a3cea9e..63ef75b 100755 --- a/spec/models/channel/instagram_spec.rb +++ b/spec/models/channel/instagram_spec.rb @@ -1,5 +1,21 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_instagram +# +# id :bigint not null, primary key +# access_token :string not null +# expires_at :datetime not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# instagram_id :string not null +# +# Indexes +# +# index_channel_instagram_on_instagram_id (instagram_id) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/channel/telegram_spec.rb b/spec/models/channel/telegram_spec.rb index dc401a1..4aa5f03 100755 --- a/spec/models/channel/telegram_spec.rb +++ b/spec/models/channel/telegram_spec.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: channel_telegram +# +# id :bigint not null, primary key +# bot_name :string +# bot_token :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_telegram_on_bot_token (bot_token) UNIQUE +# require 'rails_helper' RSpec.describe Channel::Telegram do diff --git a/spec/models/channel/twilio_sms_spec.rb b/spec/models/channel/twilio_sms_spec.rb index ac89a0f..9fa910e 100755 --- a/spec/models/channel/twilio_sms_spec.rb +++ b/spec/models/channel/twilio_sms_spec.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_twilio_sms +# +# id :bigint not null, primary key +# account_sid :string not null +# api_key_sid :string +# auth_token :string not null +# content_templates :jsonb +# content_templates_last_updated :datetime +# medium :integer default("sms") +# messaging_service_sid :string +# phone_number :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_twilio_sms_on_account_sid_and_phone_number (account_sid,phone_number) UNIQUE +# index_channel_twilio_sms_on_messaging_service_sid (messaging_service_sid) UNIQUE +# index_channel_twilio_sms_on_phone_number (phone_number) UNIQUE +# require 'rails_helper' RSpec.describe Channel::TwilioSms do diff --git a/spec/models/channel/web_widget_spec.rb b/spec/models/channel/web_widget_spec.rb index 3c7a803..e2552ab 100755 --- a/spec/models/channel/web_widget_spec.rb +++ b/spec/models/channel/web_widget_spec.rb @@ -1,5 +1,32 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_web_widgets +# +# id :integer not null, primary key +# allowed_domains :text default("") +# continuity_via_email :boolean default(TRUE), not null +# feature_flags :integer default(7), not null +# hmac_mandatory :boolean default(FALSE) +# hmac_token :string +# pre_chat_form_enabled :boolean default(FALSE) +# pre_chat_form_options :jsonb +# reply_time :integer default("in_a_few_minutes") +# website_token :string +# website_url :string +# welcome_tagline :string +# welcome_title :string +# widget_color :string default("#1f93ff") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# +# Indexes +# +# index_channel_web_widgets_on_hmac_token (hmac_token) UNIQUE +# index_channel_web_widgets_on_website_token (website_token) UNIQUE +# require 'rails_helper' RSpec.describe Channel::WebWidget do diff --git a/spec/models/channel/whatsapp_spec.rb b/spec/models/channel/whatsapp_spec.rb index b46c984..46d1c6f 100755 --- a/spec/models/channel/whatsapp_spec.rb +++ b/spec/models/channel/whatsapp_spec.rb @@ -1,5 +1,27 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: channel_whatsapp +# +# id :bigint not null, primary key +# message_templates :jsonb +# message_templates_last_updated :datetime +# phone_number :string not null +# provider :string default("default") +# provider_config :jsonb +# wuzapi_admin_token :string +# wuzapi_admin_token_iv :string +# wuzapi_user_token :string +# wuzapi_user_token_iv :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# +# Indexes +# +# index_channel_whatsapp_on_phone_number (phone_number) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/contact_inbox_spec.rb b/spec/models/contact_inbox_spec.rb index c0a2faf..1aff162 100755 --- a/spec/models/contact_inbox_spec.rb +++ b/spec/models/contact_inbox_spec.rb @@ -1,5 +1,26 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: contact_inboxes +# +# id :bigint not null, primary key +# hmac_verified :boolean default(FALSE) +# pubsub_token :string +# created_at :datetime not null +# updated_at :datetime not null +# contact_id :bigint +# inbox_id :bigint +# source_id :text not null +# +# Indexes +# +# index_contact_inboxes_on_contact_id (contact_id) +# index_contact_inboxes_on_inbox_id (inbox_id) +# index_contact_inboxes_on_inbox_id_and_source_id (inbox_id,source_id) UNIQUE +# index_contact_inboxes_on_pubsub_token (pubsub_token) UNIQUE +# index_contact_inboxes_on_source_id (source_id) +# require 'rails_helper' RSpec.describe ContactInbox do diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index f21a819..156931a 100755 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,5 +1,43 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: contacts +# +# id :integer not null, primary key +# additional_attributes :jsonb +# blocked :boolean default(FALSE), not null +# contact_type :integer default("visitor") +# country_code :string default("") +# custom_attributes :jsonb +# email :string +# identifier :string +# last_activity_at :datetime +# last_name :string default("") +# location :string default("") +# middle_name :string default("") +# name :string default("") +# phone_number :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# company_id :bigint +# +# Indexes +# +# index_contacts_on_account_id (account_id) +# index_contacts_on_account_id_and_contact_type (account_id,contact_type) +# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST) +# index_contacts_on_blocked (blocked) +# index_contacts_on_company_id (company_id) +# index_contacts_on_lower_email_account_id (lower((email)::text), account_id) +# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin +# index_contacts_on_nonempty_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# index_contacts_on_phone_number_and_account_id (phone_number,account_id) +# index_resolved_contact_account_id (account_id) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) +# uniq_email_per_account_contact (email,account_id) UNIQUE +# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/avatarable_shared.rb' diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 7a53984..86e9f33 100755 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -1,5 +1,61 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: conversations +# +# id :integer not null, primary key +# active_scenario_expires_at :datetime +# active_scenario_key :string +# active_scenario_state :jsonb not null +# additional_attributes :jsonb +# agent_last_seen_at :datetime +# assignee_last_seen_at :datetime +# cached_label_list :text +# contact_last_seen_at :datetime +# custom_attributes :jsonb +# first_reply_created_at :datetime +# identifier :string +# last_activity_at :datetime not null +# priority :integer +# snoozed_until :datetime +# status :integer default("open"), not null +# uuid :uuid not null +# waiting_since :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# assignee_agent_bot_id :bigint +# assignee_id :integer +# campaign_id :bigint +# contact_id :bigint +# contact_inbox_id :bigint +# display_id :integer not null +# inbox_id :integer not null +# sla_policy_id :bigint +# team_id :bigint +# +# Indexes +# +# conv_acid_inbid_stat_asgnid_idx (account_id,inbox_id,status,assignee_id) +# index_conversations_on_account_id (account_id) +# index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE +# index_conversations_on_active_scenario_key (active_scenario_key) +# index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) +# index_conversations_on_campaign_id (campaign_id) +# index_conversations_on_contact_id (contact_id) +# index_conversations_on_contact_inbox_id (contact_inbox_id) +# index_conversations_on_first_reply_created_at (first_reply_created_at) +# index_conversations_on_id_and_account_id (account_id,id) +# index_conversations_on_identifier_and_account_id (identifier,account_id) +# index_conversations_on_inbox_id (inbox_id) +# index_conversations_on_priority (priority) +# index_conversations_on_status_and_account_id (status,account_id) +# index_conversations_on_status_and_priority (status,priority) +# index_conversations_on_team_id (team_id) +# index_conversations_on_uuid (uuid) UNIQUE +# index_conversations_on_waiting_since (waiting_since) +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/assignment_handler_shared.rb' require Rails.root.join 'spec/models/concerns/auto_assignment_handler_shared.rb' diff --git a/spec/models/csat_survey_response_spec.rb b/spec/models/csat_survey_response_spec.rb index 09659f0..27d0a3f 100755 --- a/spec/models/csat_survey_response_spec.rb +++ b/spec/models/csat_survey_response_spec.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: csat_survey_responses +# +# id :bigint not null, primary key +# feedback_message :text +# rating :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# assigned_agent_id :bigint +# contact_id :bigint not null +# conversation_id :bigint not null +# message_id :bigint not null +# +# Indexes +# +# index_csat_survey_responses_on_account_id (account_id) +# index_csat_survey_responses_on_assigned_agent_id (assigned_agent_id) +# index_csat_survey_responses_on_contact_id (contact_id) +# index_csat_survey_responses_on_conversation_id (conversation_id) +# index_csat_survey_responses_on_message_id (message_id) UNIQUE +# require 'rails_helper' RSpec.describe CsatSurveyResponse do diff --git a/spec/models/custom_attribute_definition_spec.rb b/spec/models/custom_attribute_definition_spec.rb index 1359c29..99945c7 100755 --- a/spec/models/custom_attribute_definition_spec.rb +++ b/spec/models/custom_attribute_definition_spec.rb @@ -1,5 +1,28 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: custom_attribute_definitions +# +# id :bigint not null, primary key +# attribute_description :text +# attribute_display_name :string +# attribute_display_type :integer default("text") +# attribute_key :string +# attribute_model :integer default("conversation_attribute") +# attribute_values :jsonb +# default_value :integer +# regex_cue :string +# regex_pattern :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# attribute_key_model_index (attribute_key,attribute_model,account_id) UNIQUE +# index_custom_attribute_definitions_on_account_id (account_id) +# require 'rails_helper' RSpec.describe CustomAttributeDefinition do diff --git a/spec/models/data_import_spec.rb b/spec/models/data_import_spec.rb index 2b7429c..8978e90 100755 --- a/spec/models/data_import_spec.rb +++ b/spec/models/data_import_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: data_imports +# +# id :bigint not null, primary key +# data_type :string not null +# processed_records :integer +# processing_errors :text +# status :integer default("pending"), not null +# total_records :integer +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_data_imports_on_account_id (account_id) +# require 'rails_helper' RSpec.describe DataImport do diff --git a/spec/models/folder_spec.rb b/spec/models/folder_spec.rb index 19cfe6a..be2cdfb 100755 --- a/spec/models/folder_spec.rb +++ b/spec/models/folder_spec.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: folders +# +# id :bigint not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# category_id :integer not null +# require 'rails_helper' RSpec.describe Folder do diff --git a/spec/models/inbox_member_spec.rb b/spec/models/inbox_member_spec.rb index b081c54..bec0a7f 100755 --- a/spec/models/inbox_member_spec.rb +++ b/spec/models/inbox_member_spec.rb @@ -1,5 +1,20 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: inbox_members +# +# id :integer not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# inbox_id :integer not null +# user_id :integer not null +# +# Indexes +# +# index_inbox_members_on_inbox_id (inbox_id) +# index_inbox_members_on_inbox_id_and_user_id (inbox_id,user_id) UNIQUE +# require 'rails_helper' RSpec.describe InboxMember do diff --git a/spec/models/inbox_spec.rb b/spec/models/inbox_spec.rb index 92fddcd..249efde 100755 --- a/spec/models/inbox_spec.rb +++ b/spec/models/inbox_spec.rb @@ -1,5 +1,44 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: inboxes +# +# id :integer not null, primary key +# allow_messages_after_resolved :boolean default(TRUE) +# auto_assignment_config :jsonb +# auto_resolve_duration :integer +# business_name :string +# channel_type :string +# csat_config :jsonb not null +# csat_survey_enabled :boolean default(FALSE) +# email_address :string +# enable_auto_assignment :boolean default(TRUE) +# enable_email_collect :boolean default(TRUE) +# greeting_enabled :boolean default(FALSE) +# greeting_message :string +# lock_to_single_conversation :boolean default(FALSE), not null +# name :string not null +# out_of_office_message :string +# sender_name_type :integer default("friendly"), not null +# timezone :string default("UTC") +# working_hours_enabled :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# channel_id :integer not null +# portal_id :bigint +# +# Indexes +# +# index_inboxes_on_account_id (account_id) +# index_inboxes_on_channel_id_and_channel_type (channel_id,channel_type) +# index_inboxes_on_portal_id (portal_id) +# +# Foreign Keys +# +# fk_rails_... (portal_id => portals.id) +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/out_of_offisable_shared.rb' require Rails.root.join 'spec/models/concerns/avatarable_shared.rb' diff --git a/spec/models/installation_config_spec.rb b/spec/models/installation_config_spec.rb index 49270f2..ddaffd8 100755 --- a/spec/models/installation_config_spec.rb +++ b/spec/models/installation_config_spec.rb @@ -1,5 +1,21 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: installation_configs +# +# id :bigint not null, primary key +# locked :boolean default(TRUE), not null +# name :string not null +# serialized_value :jsonb not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_installation_configs_on_name (name) UNIQUE +# index_installation_configs_on_name_and_created_at (name,created_at) UNIQUE +# require 'rails_helper' RSpec.describe InstallationConfig do diff --git a/spec/models/integrations/hook_spec.rb b/spec/models/integrations/hook_spec.rb index 9c2eba7..ca0529b 100755 --- a/spec/models/integrations/hook_spec.rb +++ b/spec/models/integrations/hook_spec.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: integrations_hooks +# +# id :bigint not null, primary key +# access_token :string +# hook_type :integer default("account") +# settings :jsonb +# status :integer default("enabled") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# app_id :string +# inbox_id :integer +# reference_id :string +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb' diff --git a/spec/models/jasmine/inbox_collection_spec.rb b/spec/models/jasmine/inbox_collection_spec.rb index 24e62de..74098e1 100644 --- a/spec/models/jasmine/inbox_collection_spec.rb +++ b/spec/models/jasmine/inbox_collection_spec.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: jasmine_inbox_collections +# +# id :bigint not null, primary key +# is_enabled :boolean default(TRUE) +# priority :integer default(0) +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# collection_id :bigint not null +# inbox_id :bigint not null +# +# Indexes +# +# idx_on_account_id_collection_id_3011aaebad (account_id,collection_id) +# index_jasmine_inbox_collections_on_account_id (account_id) +# index_jasmine_inbox_collections_on_account_id_and_inbox_id (account_id,inbox_id) +# index_jasmine_inbox_collections_on_collection_id (collection_id) +# index_jasmine_inbox_collections_on_inbox_id (inbox_id) +# index_jasmine_inbox_collections_uniqueness (account_id,inbox_id,collection_id) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (account_id => accounts.id) +# fk_rails_... (collection_id => jasmine_collections.id) +# fk_rails_... (inbox_id => inboxes.id) +# require 'rails_helper' RSpec.describe Jasmine::InboxCollection do diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index ee5e7b1..fbcae26 100755 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: labels +# +# id :bigint not null, primary key +# color :string default("#1f93ff"), not null +# description :text +# show_on_sidebar :boolean +# title :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# +# Indexes +# +# index_labels_on_account_id (account_id) +# index_labels_on_title_and_account_id (title,account_id) UNIQUE +# require 'rails_helper' RSpec.describe Label do diff --git a/spec/models/macro_spec.rb b/spec/models/macro_spec.rb index 1b71614..68e0299 100755 --- a/spec/models/macro_spec.rb +++ b/spec/models/macro_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: macros +# +# id :bigint not null, primary key +# actions :jsonb not null +# name :string not null +# visibility :integer default("personal") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# created_by_id :bigint +# updated_by_id :bigint +# +# Indexes +# +# index_macros_on_account_id (account_id) +# require 'rails_helper' RSpec.describe Macro do diff --git a/spec/models/mention_spec.rb b/spec/models/mention_spec.rb index 773785c..b81d574 100755 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -1,5 +1,24 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: mentions +# +# id :bigint not null, primary key +# mentioned_at :datetime not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# conversation_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_mentions_on_account_id (account_id) +# index_mentions_on_conversation_id (conversation_id) +# index_mentions_on_user_id (user_id) +# index_mentions_on_user_id_and_conversation_id (user_id,conversation_id) UNIQUE +# require 'rails_helper' RSpec.describe Mention do diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index 8905f51..caa4b99 100755 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -1,5 +1,44 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: messages +# +# id :integer not null, primary key +# additional_attributes :jsonb +# content :text +# content_attributes :json +# content_type :integer default("text"), not null +# external_source_ids :jsonb +# message_type :integer not null +# private :boolean default(FALSE), not null +# processed_message_content :text +# sender_type :string +# sentiment :jsonb +# status :integer default("sent") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# conversation_id :integer not null +# inbox_id :integer not null +# sender_id :bigint +# source_id :text +# +# Indexes +# +# idx_messages_account_content_created (account_id,content_type,created_at) +# index_messages_on_account_created_type (account_id,created_at,message_type) +# index_messages_on_account_id (account_id) +# index_messages_on_account_id_and_inbox_id (account_id,inbox_id) +# index_messages_on_additional_attributes_campaign_id (((additional_attributes -> 'campaign_id'::text))) USING gin +# index_messages_on_content (content) USING gin +# index_messages_on_conversation_account_type_created (conversation_id,account_id,message_type,created_at) +# index_messages_on_conversation_id (conversation_id) +# index_messages_on_created_at (created_at) +# index_messages_on_inbox_id (inbox_id) +# index_messages_on_sender_type_and_sender_id (sender_type,sender_id) +# index_messages_on_source_id (source_id) +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/liquidable_shared.rb' diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 09049a0..6cb50fd 100755 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: notes +# +# id :bigint not null, primary key +# content :text not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# contact_id :bigint not null +# user_id :bigint +# +# Indexes +# +# index_notes_on_account_id (account_id) +# index_notes_on_contact_id (contact_id) +# index_notes_on_user_id (user_id) +# require 'rails_helper' RSpec.describe Note do diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index c4c064a..d9958bb 100755 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -1,5 +1,21 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: notification_settings +# +# id :bigint not null, primary key +# email_flags :integer default(0), not null +# push_flags :integer default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# user_id :integer +# +# Indexes +# +# by_account_user (account_id,user_id) UNIQUE +# require 'rails_helper' RSpec.describe NotificationSetting do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 3fbf4c4..1991944 100755 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -1,5 +1,33 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: notifications +# +# id :bigint not null, primary key +# last_activity_at :datetime +# meta :jsonb +# notification_type :integer not null +# primary_actor_type :string not null +# read_at :datetime +# secondary_actor_type :string +# snoozed_until :datetime +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# primary_actor_id :bigint not null +# secondary_actor_id :bigint +# user_id :bigint not null +# +# Indexes +# +# idx_notifications_performance (user_id,account_id,snoozed_until,read_at) +# index_notifications_on_account_id (account_id) +# index_notifications_on_last_activity_at (last_activity_at) +# index_notifications_on_user_id (user_id) +# uniq_primary_actor_per_account_notifications (primary_actor_type,primary_actor_id) +# uniq_secondary_actor_per_account_notifications (secondary_actor_type,secondary_actor_id) +# require 'rails_helper' RSpec.describe Notification do diff --git a/spec/models/platform_app_permissible_spec.rb b/spec/models/platform_app_permissible_spec.rb index a6c230d..fd6c3cd 100755 --- a/spec/models/platform_app_permissible_spec.rb +++ b/spec/models/platform_app_permissible_spec.rb @@ -1,5 +1,22 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: platform_app_permissibles +# +# id :bigint not null, primary key +# permissible_type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# permissible_id :bigint not null +# platform_app_id :bigint not null +# +# Indexes +# +# index_platform_app_permissibles_on_permissibles (permissible_type,permissible_id) +# index_platform_app_permissibles_on_platform_app_id (platform_app_id) +# unique_permissibles_index (platform_app_id,permissible_id,permissible_type) UNIQUE +# require 'rails_helper' RSpec.describe PlatformAppPermissible do diff --git a/spec/models/platform_app_spec.rb b/spec/models/platform_app_spec.rb index ad4202f..294b337 100755 --- a/spec/models/platform_app_spec.rb +++ b/spec/models/platform_app_spec.rb @@ -1,5 +1,14 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: platform_apps +# +# id :bigint not null, primary key +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb' diff --git a/spec/models/portal_spec.rb b/spec/models/portal_spec.rb index 1a108bb..5d7af95 100755 --- a/spec/models/portal_spec.rb +++ b/spec/models/portal_spec.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: portals +# +# id :bigint not null, primary key +# archived :boolean default(FALSE) +# color :string +# config :jsonb +# custom_domain :string +# header_text :text +# homepage_link :string +# name :string not null +# page_title :string +# slug :string not null +# ssl_settings :jsonb not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer not null +# channel_web_widget_id :bigint +# +# Indexes +# +# index_portals_on_channel_web_widget_id (channel_web_widget_id) +# index_portals_on_custom_domain (custom_domain) UNIQUE +# index_portals_on_slug (slug) UNIQUE +# require 'rails_helper' RSpec.describe Portal do diff --git a/spec/models/related_category_spec.rb b/spec/models/related_category_spec.rb index 4541809..d2ed202 100755 --- a/spec/models/related_category_spec.rb +++ b/spec/models/related_category_spec.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: related_categories +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# category_id :bigint +# related_category_id :bigint +# +# Indexes +# +# index_related_categories_on_category_id_and_related_category_id (category_id,related_category_id) UNIQUE +# index_related_categories_on_related_category_id_and_category_id (related_category_id,category_id) UNIQUE +# require 'rails_helper' RSpec.describe RelatedCategory do diff --git a/spec/models/reporting_event_spec.rb b/spec/models/reporting_event_spec.rb index e9c904a..989c6e5 100755 --- a/spec/models/reporting_event_spec.rb +++ b/spec/models/reporting_event_spec.rb @@ -1,3 +1,30 @@ +# == Schema Information +# +# Table name: reporting_events +# +# id :bigint not null, primary key +# event_end_time :datetime +# event_start_time :datetime +# name :string +# value :float +# value_in_business_hours :float +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# conversation_id :integer +# inbox_id :integer +# user_id :integer +# +# Indexes +# +# index_reporting_events_on_account_id (account_id) +# index_reporting_events_on_conversation_id (conversation_id) +# index_reporting_events_on_created_at (created_at) +# index_reporting_events_on_inbox_id (inbox_id) +# index_reporting_events_on_name (name) +# index_reporting_events_on_user_id (user_id) +# reporting_events__account_id__name__created_at (account_id,name,created_at) +# require 'rails_helper' RSpec.describe ReportingEvent do diff --git a/spec/models/team_member_spec.rb b/spec/models/team_member_spec.rb index f37f704..7da951b 100755 --- a/spec/models/team_member_spec.rb +++ b/spec/models/team_member_spec.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: team_members +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# team_id :bigint not null +# user_id :bigint not null +# +# Indexes +# +# index_team_members_on_team_id (team_id) +# index_team_members_on_team_id_and_user_id (team_id,user_id) UNIQUE +# index_team_members_on_user_id (user_id) +# require 'rails_helper' RSpec.describe TeamMember do diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb index cb55dba..e76c55a 100755 --- a/spec/models/team_spec.rb +++ b/spec/models/team_spec.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: teams +# +# id :bigint not null, primary key +# allow_auto_assign :boolean default(TRUE) +# description :text +# name :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint not null +# +# Indexes +# +# index_teams_on_account_id (account_id) +# index_teams_on_name_and_account_id (name,account_id) UNIQUE +# require 'rails_helper' RSpec.describe Team do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d263708..1f58185 100755 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,51 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# availability :integer default("online") +# confirmation_sent_at :datetime +# confirmation_token :string +# confirmed_at :datetime +# consumed_timestep :integer +# current_sign_in_at :datetime +# current_sign_in_ip :string +# custom_attributes :jsonb +# display_name :string +# email :string +# encrypted_password :string default(""), not null +# last_sign_in_at :datetime +# last_sign_in_ip :string +# message_signature :text +# name :string not null +# otp_backup_codes :text +# otp_required_for_login :boolean default(FALSE), not null +# otp_secret :string +# provider :string default("email"), not null +# pubsub_token :string +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# sign_in_count :integer default(0), not null +# tokens :json +# type :string +# ui_settings :jsonb +# uid :string default(""), not null +# unconfirmed_email :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) +# index_users_on_otp_required_for_login (otp_required_for_login) +# index_users_on_otp_secret (otp_secret) UNIQUE +# index_users_on_pubsub_token (pubsub_token) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# index_users_on_uid_and_provider (uid,provider) UNIQUE +# require 'rails_helper' require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb' require Rails.root.join 'spec/models/concerns/avatarable_shared.rb' diff --git a/spec/models/webhook_spec.rb b/spec/models/webhook_spec.rb index 81e6d95..8d99380 100755 --- a/spec/models/webhook_spec.rb +++ b/spec/models/webhook_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: webhooks +# +# id :bigint not null, primary key +# name :string +# subscriptions :jsonb +# url :string +# webhook_type :integer default("account_type") +# created_at :datetime not null +# updated_at :datetime not null +# account_id :integer +# inbox_id :integer +# +# Indexes +# +# index_webhooks_on_account_id_and_url (account_id,url) UNIQUE +# require 'rails_helper' RSpec.describe Webhook do diff --git a/spec/models/working_hour_spec.rb b/spec/models/working_hour_spec.rb index a5018a2..77fa30c 100755 --- a/spec/models/working_hour_spec.rb +++ b/spec/models/working_hour_spec.rb @@ -1,5 +1,27 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: working_hours +# +# id :bigint not null, primary key +# close_hour :integer +# close_minutes :integer +# closed_all_day :boolean default(FALSE) +# day_of_week :integer not null +# open_all_day :boolean default(FALSE) +# open_hour :integer +# open_minutes :integer +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# inbox_id :bigint +# +# Indexes +# +# index_working_hours_on_account_id (account_id) +# index_working_hours_on_inbox_id (inbox_id) +# require 'rails_helper' RSpec.describe WorkingHour do