source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20251023034925_create_tariff_plans.rb
Ruby
mit
95
develop
511
class CreateTariffPlans < ActiveRecord::Migration[8.0] def change create_table :tariff_plans, id: :uuid do |t| t.references :carrier, null: false, foreign_key: { on_delete: :cascade }, type: :uuid t.citext :name, null: false t.string :category, null: false t.text :description t.bigse...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20210510073816_add_carrier_id_to_accounts.rb
Ruby
mit
95
develop
393
class AddCarrierIDToAccounts < ActiveRecord::Migration[6.1] def change add_reference(:accounts, :carrier, type: :uuid, foreign_key: true, null: false) add_reference(:accounts, :outbound_sip_trunk, type: :uuid, foreign_key: true) add_column(:accounts, :allowed_calling_codes, :string, null: false, array: tr...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20240119154859_add_default_sender_to_sms_gateways.rb
Ruby
mit
95
develop
217
class AddDefaultSenderToSMSGateways < ActiveRecord::Migration[7.1] def change add_reference(:sms_gateways, :default_sender, type: :uuid, foreign_key: { to_table: :phone_numbers, on_delete: :nullify }) end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20221003135156_remove_lock_version_and_last_channel_allocated_at_from_sip_trunks.rb
Ruby
mit
95
develop
242
class RemoveLockVersionAndLastChannelAllocatedAtFromSIPTrunks < ActiveRecord::Migration[7.0] def change remove_column(:sip_trunks, :lock_version, :integer) remove_column(:sip_trunks, :last_channel_allocated_at, :datetime) end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20251023040100_create_tariff_packages.rb
Ruby
mit
95
develop
471
class CreateTariffPackages < ActiveRecord::Migration[8.0] def change create_table :tariff_packages, id: :uuid do |t| t.references :carrier, null: false, foreign_key: { on_delete: :cascade }, type: :uuid t.citext :name, null: false t.text :description t.bigserial :sequence_number, null: fal...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20210616063149_add_carrier_id_to_phone_numbers.rb
Ruby
mit
95
develop
556
class AddCarrierIDToPhoneNumbers < ActiveRecord::Migration[6.1] def change add_reference :phone_numbers, :carrier, foreign_key: true, type: :uuid, null: false rename_column(:phone_numbers, :phone_number, :number) change_column_null(:phone_numbers, :account_id, true) change_column_null(:phone_numbers, ...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20220412071058_create_phone_number_configurations.rb
Ruby
mit
95
develop
810
class CreatePhoneNumberConfigurations < ActiveRecord::Migration[7.0] def change create_table :phone_number_configurations, id: :uuid do |t| t.references :phone_number, foreign_key: { on_delete: :cascade }, type: :uuid t.string :voice_url t.string :voice_method t.string :status_callback_url...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20231021010730_add_provider_and_engine_to_tts_events.rb
Ruby
mit
95
develop
302
class AddProviderAndEngineToTTSEvents < ActiveRecord::Migration[7.1] def change add_column(:tts_events, :tts_provider, :string, null: false) add_column(:tts_events, :tts_engine, :string, null: false) add_index(:tts_events, :tts_provider) add_index(:tts_events, :tts_engine) end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20220916053123_remove_old_sip_trunks.rb
Ruby
mit
95
develop
393
class RemoveOldSIPTrunks < ActiveRecord::Migration[7.0] def up remove_column :phone_calls, :outbound_sip_trunk_id, :uuid remove_column :phone_calls, :inbound_sip_trunk_id, :uuid remove_column :accounts, :outbound_sip_trunk_id, :uuid drop_table :outbound_sip_trunks drop_table :inbound_sip_trunks ...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20211124142522_add_price_and_price_unit_to_phone_calls.rb
Ruby
mit
95
develop
214
class AddPriceAndPriceUnitToPhoneCalls < ActiveRecord::Migration[6.1] def change add_column :phone_calls, :price, :decimal, precision: 10, scale: 4 add_column :phone_calls, :price_unit, :string end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20251026042114_create_tariff_plan_subscriptions.rb
Ruby
mit
95
develop
597
class CreateTariffPlanSubscriptions < ActiveRecord::Migration[8.1] def change create_table :tariff_plan_subscriptions, id: :uuid do |t| t.references :account, null: false, foreign_key: { on_delete: :cascade }, type: :uuid t.references :plan, null: false, foreign_key: { to_table: :tariff_plans, on_dele...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20240325170920_create_media_stream_events.rb
Ruby
mit
95
develop
495
class CreateMediaStreamEvents < ActiveRecord::Migration[7.1] def change create_table :media_stream_events, id: :uuid do |t| t.references :phone_call, type: :uuid, null: false, foreign_key: true t.references :media_stream, type: :uuid, null: false, foreign_key: true t.jsonb(:details, null: false,...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20210510072647_create_carriers.rb
Ruby
mit
95
develop
269
class CreateCarriers < ActiveRecord::Migration[6.1] def change create_table :carriers, id: :uuid do |t| t.string :name, null: false t.bigserial :sequence_number, null: false, index: { unique: true, order: :desc } t.timestamps end end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20250909091420_add_sip_profile_to_sip_trunks.rb
Ruby
mit
95
develop
296
class AddSIPProfileToSIPTrunks < ActiveRecord::Migration[8.0] def change add_column :sip_trunks, :sip_profile, :string, null: false add_index :sip_trunks, :sip_profile remove_column :sip_trunks, :outbound_symmetric_latching_supported, :boolean, null: false, default: true end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20240427000906_add_visibility_to_phone_numbers.rb
Ruby
mit
95
develop
266
class AddVisibilityToPhoneNumbers < ActiveRecord::Migration[7.1] def change add_column(:phone_numbers, :visibility, :string, null: false) add_index(:phone_numbers, :visibility) remove_column(:phone_numbers, :enabled, :boolean, default: true) end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20210603075602_add_current_account_membership_id_to_users.rb
Ruby
mit
95
develop
283
class AddCurrentAccountMembershipIDToUsers < ActiveRecord::Migration[6.1] def change add_reference( :users, :current_account_membership, type: :uuid, null: true, foreign_key: { to_table: :account_memberships, on_delete: :nullify } ) end end
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20240320113428_create_media_streams.rb
Ruby
mit
95
develop
564
class CreateMediaStreams < ActiveRecord::Migration[7.1] def change create_table :media_streams, id: :uuid do |t| t.references(:phone_call, type: :uuid, null: false, foreign_key: true) t.references(:account, type: :uuid, null: false, foreign_key: true) t.string(:url, null: false) t.string(:...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20241006051609_create_sip_trunk_inbound_source_ip_addresses.rb
Ruby
mit
95
develop
811
class CreateSIPTrunkInboundSourceIPAddresses < ActiveRecord::Migration[7.2] def change create_table :sip_trunk_inbound_source_ip_addresses, id: :uuid do |t| t.references :sip_trunk, type: :uuid, null: false, foreign_key: { on_delete: :cascade }, index: false t.references :inbound_source_ip_address, ty...
github
somleng/somleng
https://github.com/somleng/somleng
db/migrate/20210617085541_create_inbound_sip_trunks.rb
Ruby
mit
95
develop
526
class CreateInboundSIPTrunks < ActiveRecord::Migration[6.1] def change create_table :inbound_sip_trunks, id: :uuid do |t| t.references :carrier, type: :uuid, null: false, foreign_key: true t.string :name, null: false t.string :trunk_prefix_replacement t.inet :source_ip, null: false t...
github
somleng/somleng
https://github.com/somleng/somleng
lib/invalid_request_schema_responder.rb
Ruby
mit
95
develop
508
require_relative "application_responder" class InvalidRequestSchemaResponder < ApplicationResponder def display(_resource, given_options = {}) controller.render( given_options.merge!(options, format => json_resource_errors, status: :bad_request) ) end def json_resource_errors serializer_class ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/call_service.rb
Ruby
mit
95
develop
350
module CallService class << self def configure yield(configuration) configuration end def configuration @configuration ||= Configuration.new end alias config configuration end end require_relative "call_service/configuration" require_relative "call_service/client" require_rel...
github
somleng/somleng
https://github.com/somleng/somleng
lib/filter_form_builder.rb
Ruby
mit
95
develop
3,717
class FilterFormBuilder < ActionView::Helpers::FormBuilder def date_range(options) title = options.fetch(:title) from_date, to_date = options.fetch(:filter_value) hint = options[:hint] picker_options = options.fetch(:picker_options, {}) if options[:restrict_date_range] hint ||= "Max 3 month...
github
somleng/somleng
https://github.com/somleng/somleng
lib/jsonapi_pagination.rb
Ruby
mit
95
develop
1,345
class JSONAPIPagination attr_reader :paginated_collection, :resources, :original_uri, :params, :pagination_options def initialize(resources, original_url, **options) @resources = resources @original_uri = URI.parse(original_url) @params = parse_params @pagination_options = options.fetch(:pagination...
github
somleng/somleng
https://github.com/somleng/somleng
lib/somleng_region.rb
Ruby
mit
95
develop
316
module SomlengRegion class << self def configure yield(configuration) configuration end def configuration @configuration ||= Configuration.new end alias config configuration end end require_relative "somleng_region/configuration" require_relative "somleng_region/region"
github
somleng/somleng
https://github.com/somleng/somleng
lib/jsonapi_responder.rb
Ruby
mit
95
develop
1,370
require_relative "application_responder" class JSONAPIResponder < ApplicationResponder def display(resource, given_options = {}) serializer_class = options.delete(:serializer_class) || resource.jsonapi_serializer_class decorator_class = options.key?(:decorator_class) ? options.fetch(:decorator_class) : resou...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser.rb
Ruby
mit
95
develop
477
module TwiMLParser end require_relative "twiml_parser/node" require_relative "twiml_parser/parser" require_relative "twiml_parser/node_parser" require_relative "twiml_parser/verb_parser" require_relative "twiml_parser/message_parser" require_relative "twiml_parser/redirect_parser" require_relative "twiml_parser/twiml_...
github
somleng/somleng
https://github.com/somleng/somleng
lib/api_responder.rb
Ruby
mit
95
develop
690
class APIResponder < ApplicationResponder def display(resource, given_options = {}) serializer_class = options.delete(:serializer_class) serializer_options = options.delete(:serializer_options) || {} serializable_resource = if resource_is_collection?(resource) resource.map(&:decorated) else ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/call_service/response.rb
Ruby
mit
95
develop
213
module CallService class Response < SimpleDelegator def fetch(key) response_body.fetch(key.to_s) end private def response_body @response_body ||= JSON.parse(body) end end end
github
somleng/somleng
https://github.com/somleng/somleng
lib/call_service/client.rb
Ruby
mit
95
develop
2,934
require "digest" module CallService class Client attr_reader :default_host, :default_region, :username, :password, :queue_url, :subscriber_realm, :http_client, :sqs_client def initialize(**options) @default_host = options.fetch(:default_host) { CallService.configuration.default_host } @default_r...
github
somleng/somleng
https://github.com/somleng/somleng
lib/simple_form_components/input_group.rb
Ruby
mit
95
develop
569
# custom component requires input group wrapper module SimpleFormComponents module InputGroup def prepend(_wrapper_options = nil) template.content_tag(:span, options[:prepend], class: "input-group-text", data: input_html_options.dig(:data, :prepend_data)) end def append(_wrapper_options = nil) ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser/action_validator.rb
Ruby
mit
95
develop
355
module TwiMLParser class ActionValidator URL_FORMAT = /\A#{URI::DEFAULT_PARSER.make_regexp(%w[http https])}\z/ def valid?(action, options = {}) return false if action.blank? && options[:allow_blank].blank? return true if action.blank? return true if action.starts_with?("/") URL_FORMA...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser/parser.rb
Ruby
mit
95
develop
1,246
module TwiMLParser class Parser attr_reader :node_parser, :message_parser, :redirect_parser def initialize(options = {}) @node_parser = options.fetch(:node_parser, NodeParser.new) @message_parser = options.fetch(:message_parser, MessageParser.new) @redirect_parser = options.fetch(:redirect_...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser/message_parser.rb
Ruby
mit
95
develop
1,402
module TwiMLParser class MessageParser < VerbParser Result = Struct.new(:body, :to, :from, :action, :method, keyword_init: true) do def self.name "Message" end end attr_reader :action_validator, :method_validator, :uppercase_attribute def initialize(options = {}) super() ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser/redirect_parser.rb
Ruby
mit
95
develop
1,036
module TwiMLParser class RedirectParser < VerbParser attr_reader :action_validator, :method_validator, :uppercase_attribute def initialize(options = {}) super() @action_validator = options.fetch(:action_validator, ActionValidator.new) @method_validator = options.fetch(:method_validator, Met...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twiml_parser/node_parser.rb
Ruby
mit
95
develop
512
module TwiMLParser class NodeParser def parse(node) build_node(node) end private def build_node(node) Node.new( attributes: node.attributes.transform_values { |v| v.value.strip }, name: node.name, text?: node.text?, children: build_children(node), ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twilio_api/responder.rb
Ruby
mit
95
develop
1,180
module TwilioAPI class Responder < ApplicationResponder def display(resource, given_options = {}) serializer_class = options.delete(:serializer_class) serializer_options = options.delete(:serializer_options) || {} serializable_resource = if resource_is_collection?(resource) prepare_colle...
github
somleng/somleng
https://github.com/somleng/somleng
lib/twilio_api/pagination.rb
Ruby
mit
95
develop
2,247
module TwilioAPI class Pagination DEFAULT_LIMIT_PER_PAGE = 50 Info = Struct.new( :uri, :page_number, :page_size, :first_page_uri, :next_page_uri, :previous_page_uri, keyword_init: true ) attr_reader :paginated_collection, :resources, :requested_uri, :params def initialize(resources,...
github
somleng/somleng
https://github.com/somleng/somleng
lib/ok_computer/rack_server.rb
Ruby
mit
95
develop
458
require "rackup/handler" module OkComputer module RackServer def self.run!(port: 3000) fork do handler = Rackup::Handler.get(:puma) handler.run(self, Port: port, Threads: "1:3", workers: 0) end end def self.call(_env) checks = OkComputer::Registry.all checks.run ...
github
somleng/somleng
https://github.com/somleng/somleng
lib/somleng_region/region.rb
Ruby
mit
95
develop
1,238
require "ostruct" module SomlengRegion class Region < OpenStruct class RegionNotFound < StandardError; end MOCK_REGIONS = [ new( identifier: "ap-southeast-1", alias: "hydrogen", group_id: 1, human_name: "South East Asia (Singapore)", nat_ip: "13.250.230.15" ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/spec_helper.rb
Ruby
mit
95
develop
5,082
if ENV.key?("CI") require "simplecov" require "simplecov-lcov" SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true SimpleCov.start("rails") end # This file was generated by the `rails generate rspec:install` command. Conventional...
github
somleng/somleng
https://github.com/somleng/somleng
spec/factories.rb
Ruby
mit
95
develop
25,033
FactoryBot.define do sequence(:phone_number, "855972345678") sequence(:ip_address) { IPAddr.new(SecureRandom.random_number(2**32), Socket::AF_INET) } trait :with_status_callback_url do status_callback_url { "https://rapidpro.ngrok.com/handle/33/" } end trait :with_status_callback_method do status_ca...
github
somleng/somleng
https://github.com/somleng/somleng
spec/rails_helper.rb
Ruby
mit
95
develop
2,612
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= "test" require File.expand_path("../config/environment", __dir__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/mailers/devise_mailer_spec.rb
Ruby
mit
95
develop
955
require "rails_helper" RSpec.describe DeviseMailer, type: :mailer do describe "#confirmation_instructions" do it "handles normal domains" do carrier = create(:carrier, subdomain: "example") user = create(:user, carrier:) mail = DeviseMailer.confirmation_instructions(user, "abc") mail_bo...
github
somleng/somleng
https://github.com/somleng/somleng
spec/mailers/error_log_mailer_spec.rb
Ruby
mit
95
develop
1,937
require "rails_helper" RSpec.describe ErrorLogMailer, type: :mailer do describe "#notify" do it "handles alerts" do carrier = create( :carrier, name: "Rocket Communications", custom_app_host: "dashboard.rocket-communications.com", website: "https://rocket-communications.com"...
github
somleng/somleng
https://github.com/somleng/somleng
spec/mailers/forgot_subdomain_mailer_spec.rb
Ruby
mit
95
develop
568
require "rails_helper" RSpec.describe ForgotSubdomainMailer, type: :mailer do describe "#forgot_subdomain" do it "handles multiple domains" do carrier = create(:carrier, name: "AT&T") other_carrier = create(:carrier, name: "T-Mobile") mail = ForgotSubdomainMailer.forgot_subdomain( emai...
github
somleng/somleng
https://github.com/somleng/somleng
spec/mailers/previews/forgot_subdomain_mailer_preview.rb
Ruby
mit
95
develop
205
class ForgotSubdomainMailerPreview < ActionMailer::Preview def forgot_subdomain ForgotSubdomainMailer.forgot_subdomain( email: "bobchann@example.com", carriers: [Carrier.first] ) end end
github
somleng/somleng
https://github.com/somleng/somleng
spec/mailers/previews/devise_mailer_preview.rb
Ruby
mit
95
develop
529
class DeviseMailerPreview < ActionMailer::Preview def confirmation_instructions user = User.last DeviseMailer.confirmation_instructions(user, "faketoken") end def invitation_instructions user = User.last DeviseMailer.invitation_instructions(user, "faketoken") end def reset_password_instructi...
github
somleng/somleng
https://github.com/somleng/somleng
spec/channels/sms_gateway_connection_channel_spec.rb
Ruby
mit
95
develop
448
require "rails_helper" RSpec.describe SMSGatewayConnectionChannel, type: :channel do describe "#ping" do it "updates the connection status" do sms_gateway = stub_current_sms_gateway subscribe perform(:ping) expect(sms_gateway.connected?).to eq(true) end end def stub_current_sms...
github
somleng/somleng
https://github.com/somleng/somleng
spec/channels/sms_message_channel_spec.rb
Ruby
mit
95
develop
6,425
require "rails_helper" RSpec.describe SMSMessageChannel, type: :channel do describe "#sent" do it "handles sent delivery status" do sms_gateway = stub_current_sms_gateway message = create( :message, :sending, sms_gateway:, status_callback_url: "https://www.example.com/...
github
somleng/somleng
https://github.com/somleng/somleng
spec/channels/application_connection/connection_spec.rb
Ruby
mit
95
develop
1,101
require "rails_helper" module ApplicationCable RSpec.describe Connection, type: :channel do it "successfully connects" do sms_gateway = create(:sms_gateway) connect("/cable", headers: { "X-Device-Key" => sms_gateway.device_token }) expect(connection.current_sms_gateway).to eq(sms_gateway) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/validators/subdomain_validator_spec.rb
Ruby
mit
95
develop
640
require "rails_helper" RSpec.describe SubdomainValidator do it "validates a subdomain" do validatable_klass = Struct.new(:subdomain) do include ActiveModel::Validations def self.model_name ActiveModel::Name.new(self, nil, "temp") end validates :subdomain, subdomain: true end...
github
somleng/somleng
https://github.com/somleng/somleng
spec/validators/phone_number_type_validator_spec.rb
Ruby
mit
95
develop
1,248
require "rails_helper" RSpec.describe PhoneNumberTypeValidator do it "validates a phone number type" do validatable_klass = Class.new do include ActiveModel::Model include ActiveModel::Attributes attribute :number, PhoneNumberType.new attribute :type def self.model_name Ac...
github
somleng/somleng
https://github.com/somleng/somleng
spec/validators/country_subdivision_validator_spec.rb
Ruby
mit
95
develop
897
require "rails_helper" RSpec.describe CountrySubdivisionValidator do it "validates a country subdivision" do validatable_klass = Class.new do include ActiveModel::Model include ActiveModel::Attributes attribute :region attribute :country_code def self.model_name ActiveMode...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/import_csv_spec.rb
Ruby
mit
95
develop
1,130
require "rails_helper" RSpec.describe ImportCSV do it "imports a CSV" do carrier = create(:carrier, billing_currency: "USD") import = create( :import, carrier:, resource_type: "PhoneNumber", file: create(:active_storage_attachment, filename: "phone_numbers.csv") ) ImportCSV.c...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/export_csv_spec.rb
Ruby
mit
95
develop
753
require "rails_helper" RSpec.describe ExportCSV do it "exports a CSV" do carrier = create(:carrier) user = create(:user, :carrier, carrier:) export = create( :export, resource_type: "PhoneCall", user:, scoped_to: { carrier_id: carrier.id } ) phone_call = create(:phone_cal...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/process_media_stream_event_spec.rb
Ruby
mit
95
develop
592
require "rails_helper" RSpec.describe ProcessMediaStreamEvent do it "processes a media stream events" do media_stream = create(:media_stream, :initialized) ProcessMediaStreamEvent.call(create(:media_stream_event, :connect, media_stream:)) expect(media_stream.status).to eq("connected") ProcessMediaS...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/update_phone_call_spec.rb
Ruby
mit
95
develop
2,442
require "rails_helper" RSpec.describe UpdatePhoneCall do it "handles completed events for queued calls" do phone_call = create(:phone_call, :queued) client = build_fake_client UpdatePhoneCall.call(phone_call, client:, status: :completed) expect(phone_call.reload).to have_attributes( status: "...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/destroy_account_spec.rb
Ruby
mit
95
develop
839
require "rails_helper" RSpec.describe DestroyAccount do it "destroys an account" do account = create(:account) client = instance_spy(RatingEngineClient) result = DestroyAccount.call(account, client:) expect(result).to be_truthy expect(account).to have_attributes( persisted?: false ) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/resolve_phone_number_country_spec.rb
Ruby
mit
95
develop
921
require "rails_helper" RSpec.describe ResolvePhoneNumberCountry do it "resolves a phone number country" do result = ResolvePhoneNumberCountry.call( build_phone_number("855715500234"), fallback_country: ISO3166::Country.new("KH") ) expect(result).to eq(ISO3166::Country.new("KH")) end it ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/fail_sending_messages_spec.rb
Ruby
mit
95
develop
472
require "rails_helper" RSpec.describe FailSendingMessages do it "fails sending messages" do messages = [ create(:message, :sending), create(:message, :sending, sending_at: 5.minutes.ago), create(:message, :sent, sending_at: 5.minutes.ago) ] FailSendingMessages.call expect(messages...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/handle_call_heartbeats_spec.rb
Ruby
mit
95
develop
800
require "rails_helper" RSpec.describe HandleCallHeartbeats do it "updates the last heartbeat at for the phone calls" do phone_call_already_heartbeat = create( :phone_call, :answered, last_heartbeat_at: 1.minute.ago ) phone_call_without_heartbeat = create( :phone_call, :answe...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_phone_calls_from_outbound_dial_spec.rb
Ruby
mit
95
develop
1,320
require "rails_helper" RSpec.describe CreatePhoneCallsFromOutboundDial do it "creates outbound phone calls" do sip_trunk = create(:sip_trunk) account = create(:account, carrier: sip_trunk.carrier) parent_call = create(:phone_call, :outbound, :answered, account:, sip_trunk:, to: "855715100210", region: "h...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/destroy_tariff_schedule_spec.rb
Ruby
mit
95
develop
1,224
require "rails_helper" RSpec.describe DestroyTariffSchedule do it "destroys a tariff schedule" do tariff_schedule = create(:tariff_schedule) create(:destination_tariff, schedule: tariff_schedule) client = instance_spy(RatingEngineClient) result = DestroyTariffSchedule.call(tariff_schedule, client:) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/refresh_carrier_rates_spec.rb
Ruby
mit
95
develop
422
require "rails_helper" RSpec.describe RefreshCarrierRates do it "refreshes the rates for all carriers" do carrier = create(:carrier) create_list(:account, 2, billing_enabled: true, carrier:) create(:account, billing_enabled: false) client = instance_spy(RatingEngineClient) RefreshCarrierRates.ca...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/check_verification_code_spec.rb
Ruby
mit
95
develop
629
require "rails_helper" RSpec.describe CheckVerificationCode do it "creates a verification attempt" do verification = create(:verification, code: "1234", status: :pending) CheckVerificationCode.call(verification:, code: "9876") expect(verification).to have_attributes( verification_attempts_count: ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/destroy_tariff_plan_spec.rb
Ruby
mit
95
develop
981
require "rails_helper" RSpec.describe DestroyTariffPlan do it "destroys a tariff plan" do tariff_plan = create(:tariff_plan) client = instance_spy(RatingEngineClient) result = DestroyTariffPlan.call(tariff_plan, client:) expect(result).to be_truthy expect(tariff_plan).to have_attributes( ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_message_charge_spec.rb
Ruby
mit
95
develop
1,544
require "rails_helper" RSpec.describe CreateMessageCharge do it "creates a message charge" do account = create(:account, billing_enabled: true) create( :tariff_plan_subscription, account:, plan: create( :tariff_plan, :configured, :outbound_messages, carrier: account.carrier,...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_sip_trunk_spec.rb
Ruby
mit
95
develop
612
require "rails_helper" RSpec.describe CreateSIPTrunk do it "creates a subscriber" do fake_call_service_client = build_fake_call_service_client sip_trunk = create( :sip_trunk, :client_credentials_authentication, username: "username", password: "password" ) CreateSIPTrunk.call(...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/update_message_status_spec.rb
Ruby
mit
95
develop
1,465
require "rails_helper" RSpec.describe UpdateMessageStatus do it "updates a message status" do message = create(:message, :queued, :with_status_callback_url) UpdateMessageStatus.new(message).call { message.mark_as_sending! } expect(message).to have_attributes( status: "sending" ) expect(Ex...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/process_outbound_calls_queue_spec.rb
Ruby
mit
95
develop
1,174
require "rails_helper" RSpec.describe ProcessOutboundCallsQueue do it "recovers the queues" do account = create(:account) queue = build_test_queue(OutboundCallsQueue.new(account)) older_item = SecureRandom.uuid processing_item = SecureRandom.uuid queue.tmp_enqueue(older_item, score: 2.minutes.ag...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/notify_sms_gateway_down_spec.rb
Ruby
mit
95
develop
646
require "rails_helper" RSpec.describe NotifySMSGatewayDown do it "notifies when the SMS Gateway is down" do sms_gateway = create(:sms_gateway, :disconnected, name: "My SMS Gateway") NotifySMSGatewayDown.call(sms_gateway) expect(ErrorLog.last).to have_attributes( carrier: sms_gateway.carrier, ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/schedule_outbound_call_spec.rb
Ruby
mit
95
develop
753
require "rails_helper" RSpec.describe ScheduleOutboundCall do it "schedules an outbound call" do account = create(:account) phone_call = create(:phone_call, account:) queue = OutboundCallsQueue.new(account) ScheduleOutboundCall.call(phone_call, queue:) expect(queue.peek).to eq(phone_call.id) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/initiate_outbound_call_spec.rb
Ruby
mit
95
develop
6,810
require "rails_helper" RSpec.describe InitiateOutboundCall do it "initiates an outbound call" do carrier = create(:carrier) account = create(:account, :billing_enabled, carrier:) sip_trunk = create( :sip_trunk, sip_profile: "test", outbound_host: "sip.example.com", region: :helium...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_inbound_phone_call_spec.rb
Ruby
mit
95
develop
1,703
require "rails_helper" RSpec.describe CreateInboundPhoneCall do it "creates an inbound phone call" do phone_call = CreateInboundPhoneCall.call(build_params) expect(phone_call).to have_attributes( initiating_at: be_present, initiated_at: be_present, status: "initiated" ) end it "ad...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_error_log_spec.rb
Ruby
mit
95
develop
2,264
require "rails_helper" RSpec.describe CreateErrorLog do it "creates an error log" do error_log = CreateErrorLog.call( type: :inbound_message, error_message: "An error message" ) expect(error_log).to be_persisted end it "notifies subscribed carrier team members" do carrier = create(:...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_tariff_package_wizard_form_spec.rb
Ruby
mit
95
develop
1,378
require "rails_helper" RSpec.describe CreateTariffPackageWizardForm do it "creates a tariff package with associated records" do carrier = create(:carrier, billing_currency: "USD") form = TariffPackageWizardForm.new( carrier:, name: "Standard", tariffs: [ { enabled: true, rate: 0.01, categor...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/delete_expired_carriers_spec.rb
Ruby
mit
95
develop
1,758
require "rails_helper" RSpec.describe DeleteExpiredCarriers do it "deletes expired carriers" do expired_user = create_carrier_owner(created_at: 7.days.ago) new_user = create_carrier_owner(created_at: Time.current) confirmed_user = create_carrier_owner(created_at: 7.days.ago, confirmed_at: Time.current) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/send_outbound_message_spec.rb
Ruby
mit
95
develop
2,097
require "rails_helper" RSpec.describe SendOutboundMessage do it "broadcast to sms gateway" do message = create_message(:queued) expect { SendOutboundMessage.call(message) }.to have_broadcasted_to( message.sms_gateway ).from_channel( SMSMessageChannel ).with( type: "messag...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/execute_messaging_twiml_spec.rb
Ruby
mit
95
develop
5,906
require "rails_helper" RSpec.describe ExecuteMessagingTwiML do it "handles empty responses" do message = create( :message, :inbound, sms_url: "https://www.example.com/messaging.xml", sms_method: "POST" ) stub_request(:post, "https://www.example.com/messaging.xml").to_return(body:...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/revoke_sip_trunk_permissions_spec.rb
Ruby
mit
95
develop
640
require "rails_helper" RSpec.describe RevokeSIPTrunkPermissions do it "revokes SIP trunk permissions" do revoked_ips = [] allow_any_instance_of(CallService::Client).to receive(:remove_permission) { |_, ip| revoked_ips << ip } create(:inbound_source_ip_address, ip: "38.0.101.76") create(:inbound_sour...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_event_spec.rb
Ruby
mit
95
develop
785
require "rails_helper" RSpec.describe CreateEvent do it "creates an event" do phone_call = create(:phone_call, :completed) event = CreateEvent.call(eventable: phone_call, type: "phone_call.completed") expect(event).to be_persisted end it "notifies the event to webhook endpoint" do carrier = cr...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/update_sip_trunk_spec.rb
Ruby
mit
95
develop
1,319
require "rails_helper" RSpec.describe UpdateSIPTrunk do it "handles changing to IP address authentication mode" do fake_call_service_client = build_fake_call_service_client sip_trunk = create( :sip_trunk, :client_credentials_authentication, region: :hydrogen, username: "username" ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/reschedule_outbound_calls_spec.rb
Ruby
mit
95
develop
645
require "rails_helper" RSpec.describe RescheduleOutboundCalls do it "schedules outbound calls" do phone_calls = create_list(:phone_call, 2, :queued, created_at: 31.minutes.ago) create(:phone_call, :queued, created_at: 31.minutes.ago, initiation_queued_at: Time.current) create(:phone_call, :queued) wo...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_inbound_message_spec.rb
Ruby
mit
95
develop
3,495
require "rails_helper" RSpec.describe CreateInboundMessage do it "creates an inbound message" do sms_gateway = create(:sms_gateway) account = create(:account, carrier: sms_gateway.carrier, billing_enabled: true) create( :tariff_plan_subscription, account:, plan: create( :tariff_...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_phone_number_plan_spec.rb
Ruby
mit
95
develop
1,254
require "rails_helper" RSpec.describe CreatePhoneNumberPlan do it "creates a phone number plan" do carrier = create(:carrier) account = create(:account, carrier:) phone_number = create(:phone_number, carrier:, number: "12513095500") plan = CreatePhoneNumberPlan.call( phone_number:, accou...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/publish_outbound_calls_queue_metrics_spec.rb
Ruby
mit
95
develop
921
require "rails_helper" RSpec.describe PublishOutboundCallsQueueMetrics do it "publishes metrics about the queue" do create_list(:phone_call, 3, :queued, region: :hydrogen) create(:phone_call, :completed, region: :hydrogen) CallServiceCapacity.set_for("hydrogen", capacity: 5) CallServiceCapacity.set_f...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/import_phone_number_spec.rb
Ruby
mit
95
develop
5,495
require "rails_helper" RSpec.describe ImportPhoneNumber do it "imports a phone number" do carrier = create(:carrier, country_code: "KH") import = create_import(carrier:) phone_number = ImportPhoneNumber.call( import:, data: { number: "1234", type: "short_code", visibi...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/expire_initiating_phone_calls_spec.rb
Ruby
mit
95
develop
446
require "rails_helper" RSpec.describe ExpireInitiatingPhoneCalls do it "expires initiating phone calls" do to_be_expired_phone_call = create(:phone_call, :initiating, initiating_at: 2.days.ago) phone_call = create(:phone_call, :initiating, initiated_at: 11.hours.ago) ExpireInitiatingPhoneCalls.call ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/queue_outbound_message_spec.rb
Ruby
mit
95
develop
1,714
require "rails_helper" RSpec.describe QueueOutboundMessage do it "queues a message" do message = create(:message, :accepted) create(:incoming_phone_number, account: message.account, messaging_service: message.messaging_service) QueueOutboundMessage.call(message) expect(message.queued?).to eq(true) ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/notify_webhook_endpoint_spec.rb
Ruby
mit
95
develop
2,702
require "rails_helper" RSpec.describe NotifyWebhookEndpoint do it "re-enqueues the job if it receives a non 2xx response" do event = create(:event) webhook_endpoint = create(:webhook_endpoint) stub_request(:post, webhook_endpoint.url).to_return(status: 500) _first_log_for_failed_request = create( ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/onboard_carrier_spec.rb
Ruby
mit
95
develop
1,013
require "rails_helper" RSpec.describe OnboardCarrier do it "onboards a new carrier" do rating_engine_client = instance_spy(RatingEngineClient) carrier, owner = OnboardCarrier.call( name: "AT&T", country_code: "US", website: "https://www.att.com", restricted: true, subdomain: "a...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/delete_sip_trunk_spec.rb
Ruby
mit
95
develop
579
require "rails_helper" RSpec.describe DeleteSIPTrunk do it "deletes a subscriber" do fake_call_service_client = build_fake_call_service_client sip_trunk = create( :sip_trunk, :client_credentials_authentication, username: "username" ) sip_trunk.destroy! DeleteSIPTrunk.call(sip_t...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/expire_in_progress_phone_calls_spec.rb
Ruby
mit
95
develop
1,591
require "rails_helper" RSpec.describe ExpireInProgressPhoneCalls do it "expires in progress phone calls" do account = create(:account) to_be_expired_phone_call1 = create(:phone_call, :initiated, account:, region: :hydrogen, last_heartbeat_at: 15.minutes.ago) to_be_expired_phone_call2 = create(:phone_call...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/publish_interaction_data_spec.rb
Ruby
mit
95
develop
2,653
require "rails_helper" RSpec.describe PublishInteractionData do it "publishes interaction data" do create_phone_call_interaction(phone_call_params: { to: "855715900760" }) create_phone_call_interaction(phone_call_params: { to: "855715900760" }) create_phone_call_interaction(phone_call_params: { to: "6143...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/process_recording_spec.rb
Ruby
mit
95
develop
1,975
require "rails_helper" RSpec.describe ProcessRecording do it "attaches a raw recording file to the recording" do recording = create( :recording, :in_progress, status_callback_url: "https://example.com/recording-callback", status_callback_method: "POST", raw_recording_url: "https://r...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/expire_queued_phone_calls_spec.rb
Ruby
mit
95
develop
548
require "rails_helper" RSpec.describe ExpireQueuedPhoneCalls do it "expires queued phone calls older than 7 days" do to_be_expired_queued_phone_call = create(:phone_call, :queued, created_at: 7.days.ago) _to_be_expired_initiating_phone_call = create(:phone_call, :initiating, created_at: 7.days.ago) phone...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/sync_rating_engine_transactions_spec.rb
Ruby
mit
95
develop
3,136
require "rails_helper" RSpec.describe SyncRatingEngineTransactions do it "syncs rating engine transactions" do account = create(:account) message = create(:message, :inbound, account:) phone_call = create(:phone_call, :outbound, :initiated, account:) existing_balance_transaction = create(:balance_tra...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/create_verification_spec.rb
Ruby
mit
95
develop
5,167
require "rails_helper" RSpec.describe CreateVerification do it "creates a new SMS verification" do verification_service, sms_gateway = create_verification_service( name: "Rocket Rides" ) verification = CreateVerification.call( build_verification_params( verification_service:, ...
github
somleng/somleng
https://github.com/somleng/somleng
spec/workflows/twilio_api/notify_webhook_spec.rb
Ruby
mit
95
develop
1,629
require "rails_helper" module TwilioAPI RSpec.describe NotifyWebhook do it "notifies a webhook via HTTP POST by default" do account = create(:account) url = "https://www.example.com/status_callback_url?b=2&a=1" request_validator = twilio_request_validator(account) stub_request(:post, url)...
github
somleng/somleng
https://github.com/somleng/somleng
spec/models/global_call_session_limiter_spec.rb
Ruby
mit
95
develop
1,537
require "rails_helper" RSpec.describe GlobalCallSessionLimiter do it "adds a session" do session_limiter = GlobalCallSessionLimiter.new(expiry: 20.minutes) session_limiter.add_session_to("hydrogen") expect(session_limiter.session_count_for(:hydrogen)).to eq(1) session_limiter.add_session_to("helium...