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 | spec/models/message_spec.rb | Ruby | mit | 95 | develop | 1,529 | require "rails_helper"
RSpec.describe Message do
it "handles beneficiary data" do
outbound_message = build(
:message,
direction: :outbound_api,
to: "855715123444",
from: "856715123444"
)
inbound_message = build(
:message,
direction: :inbound,
to: "855715123444",
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/verification_spec.rb | Ruby | mit | 95 | develop | 750 | require "rails_helper"
RSpec.describe Verification do
describe ".pending" do
it "returns pending verifications" do
pending_verification = create(:verification, :pending)
_approved_verification = create(:verification, :approved)
_expired_verification = create(:verification, :expired)
expe... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/unique_fifo_queue_spec.rb | Ruby | mit | 95 | develop | 1,623 | require "rails_helper"
RSpec.describe UniqueFIFOQueue do
it "handles queuing" do
queue = build_queue
queue.enqueue("my-item")
queue.enqueue("my-item")
queue.enqueue("my-item-2")
expect(queue.peek).to eq("my-item")
queue.dequeue do |item|
expect(item).to eq("my-item")
end
expe... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/destination_rules_spec.rb | Ruby | mit | 95 | develop | 2,877 | require "rails_helper"
RSpec.describe DestinationRules do
describe "#sip_trunk" do
it "returns the sip trunk configured for the account" do
carrier = create(:carrier)
sip_trunk = create(:sip_trunk, carrier:)
_other_sip_trunk = create(:sip_trunk, carrier:)
account = create(:account, carrie... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/phone_call_spec.rb | Ruby | mit | 95 | develop | 1,462 | require "rails_helper"
RSpec.describe PhoneCall do
it "handles beneficiary data" do
outbound_call = build(
:phone_call,
:outbound,
to: "16472437399",
from: "16472437327",
)
inbound_call = build(
:phone_call,
:inbound,
to: "16472437327",
from: "16472437399"... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/sms_encoding_spec.rb | Ruby | mit | 95 | develop | 1,262 | require "rails_helper"
RSpec.describe SMSEncoding do
describe "#detect" do
it "handles GSM messages" do
encoding = SMSEncoding.new
result = encoding.detect("Hello World")
expect(result.segments).to eq(1)
expect(result.encoding).to eq("GSM")
expect(encoding.detect("å").encoding).t... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/media_stream_spec.rb | Ruby | mit | 95 | develop | 787 | require "rails_helper"
RSpec.describe MediaStream do
it "transitions to connected from initialized" do
media_stream = create(:media_stream, :initialized)
media_stream.connect!
expect(media_stream.status).to eq("connected")
end
it "handles out of order events" do
media_stream = create(:media_st... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/exponential_backoff_spec.rb | Ruby | mit | 95 | develop | 352 | require "rails_helper"
RSpec.describe ExponentialBackoff do
describe "#delay" do
it "calculates an exponential delay with jitter" do
exponential_backoff = ExponentialBackoff.new(
random_number_generator: -> { 1 }
)
result = exponential_backoff.delay(attempt: 10)
expect(result).t... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/verification_template_spec.rb | Ruby | mit | 95 | develop | 5,368 | require "rails_helper"
RSpec.describe VerificationTemplate do
describe "#render_message" do
it "renders a message template" do
verification_template = VerificationTemplate.new(
friendly_name: "Rocket Rides",
code: "123456",
locale: :en,
country_code: "KH"
)
mess... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/verification_locales_spec.rb | Ruby | mit | 95 | develop | 378 | require "rails_helper"
RSpec.describe VerificationLocales do
describe ".find_by_country" do
it "finds a locale by country" do
expect(
VerificationLocales.find_by_country(ISO3166::Country.new("KH")).locale
).to eq("km")
expect(
VerificationLocales.find_by_country(ISO3166::Countr... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/account_billing_policy_spec.rb | Ruby | mit | 95 | develop | 1,894 | require "rails_helper"
RSpec.describe AccountBillingPolicy do
it "handles accounts with disabled billing" do
carrier = create(:carrier)
account = create(:account, billing_enabled: false, carrier:)
policy = AccountBillingPolicy.new
result = policy.valid?(interaction: create(:message, account:))
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/smart_encoding_spec.rb | Ruby | mit | 95 | develop | 465 | require "rails_helper"
RSpec.describe SmartEncoding do
describe "#encode" do
it "handles smart encoding" do
smart_encoding = SmartEncoding.new
result = smart_encoding.encode("«✽» foobar")
expect(result.to_s).to eq('"*" foobar')
expect(result.smart_encoded?).to eq(true)
result = s... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/aggregate_data_spec.rb | Ruby | mit | 95 | develop | 788 | require "rails_helper"
RSpec.describe AggregateDataQuery do
it "handles key digests" do
expect(build_aggregate_data(key: [ "foo" ]).id).to eq(Digest::SHA256.hexdigest("foo"))
expect(build_aggregate_data(key: [ "FOO", "BAR" ]).id).to eq(Digest::SHA256.hexdigest("foo:bar"))
expect(build_aggregate_data(key:... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/carrier_spec.rb | Ruby | mit | 95 | develop | 261 | require "rails_helper"
RSpec.describe Carrier do
it "handles image processing" do
carrier = create(:carrier, :with_logo)
carrier.logo.variant(resize_to_limit: [ 100, 100 ]).processed
expect(carrier.logo.variant_records).to be_present
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/sip_trunk_resolver_spec.rb | Ruby | mit | 95 | develop | 2,348 | require "rails_helper"
RSpec.describe SIPTrunkResolver do
it "returns the SIP trunk if only one exists for the source IP" do
sip_trunk = create(:sip_trunk, inbound_source_ips: [ "89.0.142.86", "89.0.142.87" ])
resolver = SIPTrunkResolver.new
expect(resolver.find_sip_trunk_by(source_ip: "89.0.142.86")).t... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/carrier_standing_spec.rb | Ruby | mit | 95 | develop | 1,558 | require "rails_helper"
RSpec.describe CarrierStanding do
describe "#good_standing?" do
it "returns whether the carrier is in good standing" do
stub_const("CarrierStanding::MAX_TRIAL_INTERACTIONS_PER_MONTH", 1)
carrier = create(:carrier)
restricted_carrier = create(:carrier, :restricted)
r... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/rate_limiter_spec.rb | Ruby | mit | 95 | develop | 2,231 | require "rails_helper"
RSpec.describe RateLimiter do
it "handles per second time windows" do
travel_to(Time.new(2025, 4, 17, 0, 0, 0)) do
rate = 1
expect { build_rate_limiter(key: "my-rate-limiter-key", rate:, window_size: 1.second).request! }.not_to raise_error
expect { build_rate_limiter(key:... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/outbound_calls_queue_spec.rb | Ruby | mit | 95 | develop | 717 | require "rails_helper"
RSpec.describe OutboundCallsQueue do
describe ".each_queue" do
it "yields each queue" do
queues = Array.new(4) { build_queue }
queues[0].enqueue(SecureRandom.uuid)
queues[0].tmp_enqueue(SecureRandom.uuid)
queues[1].enqueue(SecureRandom.uuid)
queues[2].tmp_enq... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/inbound_message_behavior_spec.rb | Ruby | mit | 95 | develop | 3,192 | require "rails_helper"
RSpec.describe InboundMessageBehavior do
describe "#configured?" do
it "returns true for configured numbers" do
incoming_phone_number = create(
:incoming_phone_number,
sms_url: "https://www.example.com/sms_url.xml",
sms_method: "GET"
)
webhook_mess... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/sms_gateway_resolver_spec.rb | Ruby | mit | 95 | develop | 3,050 | require "rails_helper"
RSpec.describe SMSGatewayResolver do
describe "#resolve" do
it "returns the default SMS gateway when no channel groups are defined" do
default_sms_gateway = create(:sms_gateway)
resolver = SMSGatewayResolver.new
sms_gateway, channel = resolver.resolve(
carrier: d... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/sip_trunk_spec.rb | Ruby | mit | 95 | develop | 2,809 | require "rails_helper"
RSpec.describe SIPTrunk do
it "handles ACL" do
create(:inbound_source_ip_address, ip: "2.2.2.2", region: "helium")
sip_trunk = build(:sip_trunk, region: "hydrogen", inbound_source_ips: [ "96.9.66.256", "1.1.1.1", "1.1.1.1", "2.2.2.2", "3.3.3.3" ])
expect(sip_trunk.inbound_source_ip... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/rating_engine_client_spec.rb | Ruby | mit | 95 | develop | 19,635 | require "rails_helper"
RSpec.describe RatingEngineClient do
describe "#account_balance" do
it "sends a request to get an account balance" do
account = create(:account, billing_currency: "USD")
client = instance_spy(CGRateS::Client)
rating_engine_client = RatingEngineClient.new(client:)
al... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/aggregate_data_query_spec.rb | Ruby | mit | 95 | develop | 1,743 | require "rails_helper"
RSpec.describe AggregateDataQuery do
it "handles different having operations" do
carrier = create(:carrier)
create(:phone_number, carrier:, number: "855715100800", iso_country_code: "KH")
create(:phone_number, carrier:, number: "855715100801", iso_country_code: "KH")
create(:ph... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/sms_gateway_spec.rb | Ruby | mit | 95 | develop | 447 | require "rails_helper"
RSpec.describe SMSGateway do
it "handles connection status" do
sms_gateway = create(:sms_gateway)
expect(sms_gateway.connected?).to eq(false)
sms_gateway.receive_ping
expect(sms_gateway.connected?).to eq(true)
sms_gateway.disconnect!
expect(sms_gateway.connected?).to ... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/simple_counter_spec.rb | Ruby | mit | 95 | develop | 773 | require "rails_helper"
RSpec.describe SimpleCounter do
it "handles incrementing and decrementing" do
counter = SimpleCounter.new(key: "my-key")
2.times { counter.increment }
expect(counter.count).to eq(2)
counter.decrement
expect(counter.count).to eq(1)
2.times { counter.decrement }
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/phone_number_spec.rb | Ruby | mit | 95 | develop | 2,054 | require "rails_helper"
RSpec.describe PhoneNumber do
describe ".available" do
it "returns available phone numbers" do
_disabled_phone_number = create(:phone_number, :disabled)
_assigned_phone_number = create(:phone_number, :assigned)
phone_number = create(:phone_number)
result = PhoneNu... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/url_validator_spec.rb | Ruby | mit | 95 | develop | 998 | require "rails_helper"
RSpec.describe URLValidator do
it "validates URLs" do
validator = URLValidator.new
expect(validator.valid?("https://www.example.com")).to eq(true)
expect(validator.valid?("http://www.example.com")).to eq(false)
expect(validator.valid?("www.example.com")).to eq(false)
expec... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/tariff_calculator_spec.rb | Ruby | mit | 95 | develop | 2,430 | require "rails_helper"
RSpec.describe TariffCalculator do
it "returns the correct destination tariff" do
carrier = create(:carrier)
standard_plan = create(:tariff_plan, :outbound_messages, carrier:)
promo_plan = create(:tariff_plan, :outbound_messages, carrier:)
standard_schedule = create(:tariff_sch... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/date_range_spec.rb | Ruby | mit | 95 | develop | 1,039 | require "rails_helper"
RSpec.describe DateRange do
describe "#valid?" do
it "validates the date range" do
expect(DateRange.new(from_date: nil, to_date: nil).valid?).to be(false)
expect(DateRange.new(from_date: nil, to_date: Date.today).valid?).to be(true)
expect(DateRange.new(from_date: Time.cu... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/account_call_session_limiter_spec.rb | Ruby | mit | 95 | develop | 1,544 | require "rails_helper"
RSpec.describe AccountCallSessionLimiter do
it "adds a session" do
account_id = SecureRandom.uuid
session_limiter = AccountCallSessionLimiter.new
session_limiter.add_session_to("hydrogen", scope: account_id)
expect(session_limiter.session_count_for(:hydrogen, scope: account_i... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/fuzzy_search_spec.rb | Ruby | mit | 95 | develop | 598 | require "rails_helper"
RSpec.describe FuzzySearch do
it "returns records that approximately match the search term" do
create(:carrier, name: "Acme Telecom")
create(:carrier, name: "Global Communications")
fuzzy_search = FuzzySearch.new(Carrier.all, column: :name)
results = fuzzy_search.apply("CME")
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/infinite_precision_money_spec.rb | Ruby | mit | 95 | develop | 609 | require "rails_helper"
RSpec.describe InfinitePrecisionMoney do
it "formats with default infinite precision" do
money = InfinitePrecisionMoney.from_amount(1234.56, "USD")
expect(money.format).to eq("$1,234.56")
money = InfinitePrecisionMoney.from_amount(1234.56789, "USD")
expect(money.format).to eq(... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/models/inbound_source_ip_address_spec.rb | Ruby | mit | 95 | develop | 1,407 | require "rails_helper"
RSpec.describe InboundSourceIPAddress do
it "has scopes to return in_use and unused records" do
unused = create(:inbound_source_ip_address)
in_use = create(:inbound_source_ip_address)
create(:sip_trunk, inbound_source_ips: in_use.ip)
expect(InboundSourceIPAddress.in_use).to co... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/lib/twiml_parser/redirect_parser_spec.rb | Ruby | mit | 95 | develop | 1,142 | require "rails_helper"
module TwiMLParser
RSpec.describe RedirectParser do
it "parses a redirect verb" do
node = build_node(
content: "/status_callback.xml",
attributes: {
"method" => "get"
}
)
parser = RedirectParser.new
result = parser.parse(node)
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/lib/twiml_parser/parser_spec.rb | Ruby | mit | 95 | develop | 723 | require "rails_helper"
module TwiMLParser
RSpec.describe Parser do
it "handles parses TwiML" do
twiml = <<~TWIML
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Message action="/status_callback.json">Hello world</Message>
<Redirect method="GET">https://www.example.co... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/lib/twiml_parser/message_parser_spec.rb | Ruby | mit | 95 | develop | 2,143 | require "rails_helper"
module TwiMLParser
RSpec.describe MessageParser do
it "parses a message verb" do
node = build_node(
children: [
build_node(name: "Body", content: " Body Text ")
],
attributes: {
"to" => "+85512333333",
"from" => "+85512444444",
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/lib/call_service/client_spec.rb | Ruby | mit | 95 | develop | 5,279 | require "rails_helper"
module CallService
RSpec.describe Client do
describe "#create_call" do
it "creates a call in the hydrogen region" do
client = Client.new(region: :hydrogen, host: "https://switch.hydrogen.somleng.org")
stub_request(:post, %r{https://switch.hydrogen.somleng.org})
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/lib/somleng_region/region_spec.rb | Ruby | mit | 95 | develop | 608 | require "rails_helper"
module SomlengRegion
RSpec.describe Region do
describe "#to_s" do
it "returns the region alias" do
expect(Region.new(alias: "hydrogen").to_s).to eq("hydrogen")
end
end
describe "==(other)" do
it "handles equality" do
expect(Region.new(alias: "hydr... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/decorators/tariff_decorator_spec.rb | Ruby | mit | 95 | develop | 565 | require "rails_helper"
RSpec.describe TariffDecorator do
it "decorates a tariff" do
call_tariff = build_stubbed(
:tariff, :call,
rate_cents: InfinitePrecisionMoney.from_amount(0.005, "USD").cents
)
expect(TariffDecorator.new(call_tariff)).to have_attributes(
rate: "$0.005 / min"
)
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/decorators/phone_call_decorator_spec.rb | Ruby | mit | 95 | develop | 914 | require "rails_helper"
RSpec.describe PhoneCallDecorator do
it "decorates an inbound phone call" do
phone_call = create(:phone_call, :inbound, status: :session_timeout, from: "16189124649", to: "2442")
phone_call_decorator = PhoneCallDecorator.new(phone_call)
expect(phone_call_decorator.to).to eq("2442... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/account_settings_form_spec.rb | Ruby | mit | 95 | develop | 988 | require "rails_helper"
RSpec.describe AccountSettingsForm do
describe "validations" do
it "validates name" do
form = AccountSettingsForm.new(
name: nil
)
expect(form).to be_invalid
expect(form.errors[:name]).to be_present
end
it "validates default_tts_voice" do
for... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/sip_trunk_form_spec.rb | Ruby | mit | 95 | develop | 641 | require "rails_helper"
RSpec.describe SIPTrunkForm do
describe "validations" do
it "validates inbound source addresses" do
form = SIPTrunkForm.new(source_ip_addresses: "96.9.66.18, 96.9.66.19")
form.valid?
expect(form.errors[:source_ip_addresses]).to be_empty
form.source_ip_addresses =... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_plan_tier_form_spec.rb | Ruby | mit | 95 | develop | 1,531 | require "rails_helper"
RSpec.describe TariffPlanTierForm do
describe "#save" do
it "creates a tariff plan tier" do
tariff_plan = create(:tariff_plan)
tariff_schedule = create(:tariff_schedule, category: tariff_plan.category, carrier: tariff_plan.carrier)
form = build_form(tariff_plan:, tariff_... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/destination_tariff_form_spec.rb | Ruby | mit | 95 | develop | 2,222 | require "rails_helper"
RSpec.describe DestinationTariffForm do
it "validates the presence of the destination group" do
form = build_form(destination_group_id: nil)
form.valid?
expect(form.errors[:destination_group_id]).to be_present
end
describe "#save" do
it "create a new tariff" do
car... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_schedule_form_spec.rb | Ruby | mit | 95 | develop | 5,373 | require "rails_helper"
RSpec.describe TariffScheduleForm do
it "validates the name" do
carrier = create(:carrier)
tariff_schedule = create(:tariff_schedule, :outbound_calls, carrier:, name: "Standard")
form = build_form(carrier:)
expect(form).to be_invalid
expect(form.errors[:name]).to be_prese... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/multi_select_form_component_spec.rb | Ruby | mit | 95 | develop | 1,511 | require "rails_helper"
RSpec.describe MultiSelectFormComponent do
it "allows the selection available and existing values" do
component = MultiSelectFormComponent.new(
available_values: [ :available ],
existing_values: [ :existing ],
selected_values: [ :available, :existing ],
)
expect(... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_package_form_spec.rb | Ruby | mit | 95 | develop | 1,786 | require "rails_helper"
RSpec.describe TariffPackageForm do
it "validates the name" do
package = create(:tariff_package)
form = build_form(name: nil)
form.valid?
expect(form.errors[:name]).to be_present
form = build_form(carrier: package.carrier, name: package.name)
form.valid?
expect... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/carrier_settings_form_spec.rb | Ruby | mit | 95 | develop | 1,961 | require "rails_helper"
RSpec.describe CarrierSettingsForm do
describe "validations" do
it "validates the subdomain is unique" do
create(:carrier, subdomain: "my-carrier")
carrier = create(:carrier)
form = CarrierSettingsForm.new(carrier:, subdomain: "my-carrier")
expect(form).to be_inva... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/carrier_form_spec.rb | Ruby | mit | 95 | develop | 1,611 | require "rails_helper"
RSpec.describe CarrierForm do
describe "validations" do
it "validates the email has not yet been taken" do
create(:user, email: "johndoe@example.com")
form = CarrierForm.new(work_email: "johndoe@example.com")
expect(form).to be_invalid
expect(form.errors[:work_ema... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/messaging_service_form_spec.rb | Ruby | mit | 95 | develop | 2,366 | require "rails_helper"
RSpec.describe MessagingServiceForm do
describe "validations" do
it "validates the account_id if not explicitly set" do
form = MessagingServiceForm.new(account_id: nil)
form.valid?
expect(form.errors[:account_id]).to be_present
account = create(:account)
fo... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/destination_group_form_spec.rb | Ruby | mit | 95 | develop | 3,018 | require "rails_helper"
RSpec.describe DestinationGroupForm do
it "validates the name" do
form = DestinationGroupForm.new(name: "")
form.valid?
expect(form.errors[:name]).to be_present
end
it "validates the prefixes" do
form = DestinationGroupForm.new(prefixes: [])
form.valid?
expect(... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/balance_transaction_form_spec.rb | Ruby | mit | 95 | develop | 2,083 | require "rails_helper"
RSpec.describe BalanceTransactionForm do
describe "validations" do
it "validates the amount" do
form = build_form(amount: "-100", type: "topup")
form.valid?
expect(form.errors[:amount]).to be_present
form = build_form(amount: "100", type: "topup")
form.valid?... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/account_membership_form_spec.rb | Ruby | mit | 95 | develop | 2,561 | require "rails_helper"
RSpec.describe AccountMembershipForm do
describe "validations" do
it "validates the user is not already a member" do
carrier = create(:carrier)
account = create(:account, carrier:)
user = create(:user, carrier:, email: "johndoe@example.com")
create(:account_membersh... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_package_wizard_form_spec.rb | Ruby | mit | 95 | develop | 1,337 | require "rails_helper"
RSpec.describe TariffPackageWizardForm do
it "validates the name" do
package = create(:tariff_package)
form = build_form(name: nil)
form.valid?
expect(form.errors[:name]).to be_present
form = build_form(name: package.name, object: package)
form.valid?
expect(fo... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/user_form_spec.rb | Ruby | mit | 95 | develop | 1,109 | require "rails_helper"
RSpec.describe UserForm do
describe "validations" do
it "validates the email has not yet been taken" do
create(:user, email: "johndoe@example.com")
form = UserForm.new(email: "johndoe@example.com")
expect(form).to be_invalid
expect(form.errors[:email]).to be_prese... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_package_tariff_form_spec.rb | Ruby | mit | 95 | develop | 1,024 | require "rails_helper"
RSpec.describe TariffPackageTariffForm do
it "validates the name" do
carrier = create(:carrier)
plan = create(:tariff_plan, carrier:)
schedule = create(:tariff_schedule, carrier:)
form = build_form(
parent_form: TariffPackageWizardForm.new(carrier:, name: plan.name),
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/tariff_plan_form_spec.rb | Ruby | mit | 95 | develop | 3,935 | require "rails_helper"
RSpec.describe TariffPlanForm do
it "validates the name" do
tariff_plan = create(:tariff_plan)
form = build_form(name: nil)
expect(form).to be_invalid
expect(form.errors[:name]).to be_present
form = build_form(
name: tariff_plan.name,
category: tariff_plan.ca... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/phone_number_form_spec.rb | Ruby | mit | 95 | develop | 2,174 | require "rails_helper"
RSpec.describe PhoneNumberForm do
describe "validations" do
it "validates phone number is unique for the carrier" do
carrier = create(:carrier)
existing_phone_number = create(:phone_number, carrier:)
form = PhoneNumberForm.new(
carrier:,
number: existing_p... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/account_form_spec.rb | Ruby | mit | 95 | develop | 7,523 | require "rails_helper"
RSpec.describe AccountForm do
describe "defaults" do
it "sets default values" do
carrier = create(:carrier, :with_default_tariff_package)
create(
:tariff_package_plan,
package: carrier.default_tariff_package,
plan: create(:tariff_plan, :outbound_calls, c... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/forms/sms_gateway_channel_group_form_spec.rb | Ruby | mit | 95 | develop | 867 | require "rails_helper"
RSpec.describe SMSGatewayChannelGroupForm do
describe "validations" do
it "validates channel is in range" do
sms_gateway = create(:sms_gateway, max_channels: 2)
channel_group = create(:sms_gateway_channel_group, sms_gateway:)
form = SMSGatewayChannelGroupForm.initialize_w... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/db/application_seeder_spec.rb | Ruby | mit | 95 | develop | 2,352 | require "rails_helper"
require Rails.root.join("db/application_seeder")
describe ApplicationSeeder do
it "seeds the database" do
seeder = ApplicationSeeder.new(rating_engine_client: instance_spy(RatingEngineClient))
seeder.seed!
expect(Carrier.all).to contain_exactly(
have_attributes(
bil... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/application_policy_spec.rb | Ruby | mit | 95 | develop | 524 | require "rails_helper"
RSpec.describe ApplicationPolicy do
it "has a default policy" do
user = build_stubbed(:user)
policy = ApplicationPolicy.new(user)
expect(policy.index?).to eq(true)
expect(policy.show?).to eq(true)
expect(policy.read?).to eq(true)
expect(policy.new?).to eq(false)
e... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/tariff_plan_policy_spec.rb | Ruby | mit | 95 | develop | 385 | require "rails_helper"
RSpec.describe TariffPlanPolicy, type: :policy do
it "denies access for destroying tariff plans with subscriptions" do
user = build_stubbed(:user, :carrier)
tariff_plan = create(:tariff_plan)
create(:tariff_plan_subscription, plan: tariff_plan)
policy = TariffPlanPolicy.new(us... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/tariff_schedule_policy_spec.rb | Ruby | mit | 95 | develop | 406 | require "rails_helper"
RSpec.describe TariffSchedulePolicy, type: :policy do
it "denies access for destroying tariff schedules with plan tiers" do
user = build_stubbed(:user, :carrier)
tariff_schedule = create(:tariff_schedule)
create(:tariff_plan_tier, schedule: tariff_schedule)
policy = TariffSche... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/phone_number_policy_spec.rb | Ruby | mit | 95 | develop | 637 | require "rails_helper"
RSpec.describe PhoneNumberPolicy, type: :policy do
describe "#update?" do
it "allows access for carrier admin" do
carrier = create(:carrier)
user = build_stubbed(:user, :admin, carrier:)
phone_number = build_stubbed(:phone_number, carrier:)
policy = PhoneNumberPoli... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/two_factor_authentication_policy_spec.rb | Ruby | mit | 95 | develop | 3,041 | require "rails_helper"
RSpec.describe TwoFactorAuthenticationPolicy, type: :policy do
describe "#new?" do
it "allows access" do
user = build_stubbed(:user, otp_required_for_login: false)
policy = TwoFactorAuthenticationPolicy.new(user, nil)
expect(policy.new?).to eq(true)
end
it "deni... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/account_policy_spec.rb | Ruby | mit | 95 | develop | 1,845 | require "rails_helper"
RSpec.describe AccountPolicy, type: :policy do
it "handles access for destroying accounts" do
carrier = create(:carrier)
carrier_user = build_stubbed(:user, :carrier, carrier:)
customer_user = build_stubbed(:user, :customer, carrier:)
account = create(:account, carrier:)
a... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/destination_group_policy_spec.rb | Ruby | mit | 95 | develop | 688 | require "rails_helper"
RSpec.describe DestinationGroupPolicy, type: :policy do
it "denies access for updating catch alls" do
user = build_stubbed(:user, :carrier)
policy = DestinationGroupPolicy.new(user, build_stubbed(:destination_group, catch_all: true))
expect(policy).not_to be_edit
expect(policy... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/carrier_user_policy_spec.rb | Ruby | mit | 95 | develop | 813 | require "rails_helper"
RSpec.describe CarrierUserPolicy, type: :policy do
it "denies access to users managing themselves" do
user = build_stubbed(:user, :owner)
policy = CarrierUserPolicy.new(user, user)
expect(policy.update?).to eq(false)
expect(policy.destroy?).to eq(false)
end
it "grants ac... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/import_policy_spec.rb | Ruby | mit | 95 | develop | 506 | require "rails_helper"
RSpec.describe ImportPolicy, type: :policy do
describe "#create?" do
it "allows access for carrier admins" do
user = build_stubbed(:user, :admin)
policy = ImportPolicy.new(user)
expect(policy.create?).to eq(true)
end
it "denies access for account admins" do
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/carrier_settings_policy_spec.rb | Ruby | mit | 95 | develop | 600 | require "rails_helper"
RSpec.describe CarrierSettingsPolicy, type: :policy do
describe "#update?" do
it "allows access to carrier owners" do
carrier = build_stubbed(:carrier)
user = build_stubbed(:user, :owner, carrier:)
policy = CarrierSettingsPolicy.new(user, carrier)
expect(policy.upd... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/account_membership_policy_spec.rb | Ruby | mit | 95 | develop | 1,037 | require "rails_helper"
RSpec.describe AccountMembershipPolicy, type: :policy do
it "denies access to users managing their own membership" do
account_membership = build_stubbed(:account_membership, :owner)
policy = AccountMembershipPolicy.new(account_membership.user, account_membership)
expect(policy.up... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/incoming_phone_number_policy_spec.rb | Ruby | mit | 95 | develop | 1,149 | require "rails_helper"
RSpec.describe IncomingPhoneNumberPolicy, type: :policy do
describe "#update?" do
it "allows updates to carriers for carrier managed accounts" do
user = build_stubbed(:user, :carrier, :owner)
incoming_phone_number = build_stubbed(:incoming_phone_number, account_type: :carrier_m... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/policies/account_settings_policy_spec.rb | Ruby | mit | 95 | develop | 632 | require "rails_helper"
RSpec.describe AccountSettingsPolicy, type: :policy do
describe "#update?" do
it "allows access to account owners" do
account_membership = build_stubbed(:account_membership, :owner)
policy = AccountSettingsPolicy.new(account_membership.user, account_membership.account)
e... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/accounts_spec.rb | Ruby | mit | 95 | develop | 830 | require "rails_helper"
RSpec.describe "Admin/Accounts" do
it "List accounts" do
account = create(
:account,
:carrier_managed,
name: "Rocket Rides",
billing_currency: "USD"
)
subscription = create(:tariff_plan_subscription, account:)
stub_rating_engine_request(result: build(:r... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/tariff_packages_spec.rb | Ruby | mit | 95 | develop | 476 | require "rails_helper"
RSpec.describe "Admin/Tariff Packages" do
it "List tariff packages" do
package_plan = create(:tariff_package_plan)
page.driver.browser.authorize("admin", "password")
visit admin_tariff_packages_path
click_on(package_plan.package_id)
expect(page).to have_content(package_pla... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/verifications_spec.rb | Ruby | mit | 95 | develop | 544 | require "rails_helper"
RSpec.describe "Admin/Verifications" do
it "List verifications" do
account = create(:account, name: "Rocket Rides")
verification_service = create(:verification_service, name: "Rides Service", account:)
verification = create(:verification, verification_service:)
page.driver.bro... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/error_logs_spec.rb | Ruby | mit | 95 | develop | 593 | require "rails_helper"
RSpec.describe "Admin/Error Logs" do
it "List error logs" do
carrier = create(:carrier)
create(:error_log, error_message: "SIP trunk does not exist for 175.100.7.240")
error_log = create(:error_log, carrier:, error_message: "Phone number 1234 does not exist")
create(:error_log_... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/phone_calls_spec.rb | Ruby | mit | 95 | develop | 1,407 | require "rails_helper"
RSpec.describe "Admin/Phone Calls" do
it "Inspect phone calls" do
sip_trunk = create(:sip_trunk)
phone_call = create(
:phone_call,
:initiated,
sip_trunk:,
carrier: sip_trunk.carrier,
status_callback_url: "https://example.com/call-status-callback",
to... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/events_spec.rb | Ruby | mit | 95 | develop | 248 | require "rails_helper"
RSpec.describe "Admin / Events" do
it "List events" do
event = create(:event)
page.driver.browser.authorize("admin", "password")
visit admin_events_path
expect(page).to have_content(event.type)
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/authentication_spec.rb | Ruby | mit | 95 | develop | 200 | require "rails_helper"
RSpec.describe "Admin / Authentication" do
it "requires basic auth" do
visit admin_carriers_path
expect(page).to have_content("HTTP Basic: Access denied")
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/messages_spec.rb | Ruby | mit | 95 | develop | 1,486 | require "rails_helper"
RSpec.describe "Admin/Messages" do
it "List messages" do
sms_gateway = create(:sms_gateway, name: "GoIP")
create(
:sms_gateway_channel_group,
sms_gateway:,
name: "Smart",
route_prefixes: [ "85510" ]
)
account = create(:account, carrier: sms_gateway.carri... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/phone_numbers_spec.rb | Ruby | mit | 95 | develop | 538 | require "rails_helper"
RSpec.describe "Admin/Phone Numbers" do
it "List phone numbers" do
phone_number = create(
:phone_number,
number: "1234",
iso_country_code: "KH",
type: :short_code
)
page.driver.browser.authorize("admin", "password")
visit admin_phone_numbers_path
e... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/exports_spec.rb | Ruby | mit | 95 | develop | 434 | require "rails_helper"
RSpec.describe "Admin/Exports" do
it "List exports" do
user = create(:user, name: "John Doe")
create(:export, user:, status_message: "1 of 1,000")
page.driver.browser.authorize("admin", "password")
visit admin_exports_path
expect(page).to have_content("1 of 1,000")
ex... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/sip_trunks_spec.rb | Ruby | mit | 95 | develop | 374 | require "rails_helper"
RSpec.describe "Admin/SIP Trunks" do
it "List SIP Trunks" do
create(:sip_trunk, region: :hydrogen, name: "My SIP Trunk")
page.driver.browser.authorize("admin", "password")
visit admin_sip_trunks_path
click_on("My SIP Trunk")
expect(page).to have_content("My SIP Trunk")
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/users_spec.rb | Ruby | mit | 95 | develop | 997 | require "rails_helper"
RSpec.describe "Admin/Users" do
it "List users" do
account = create(:account, name: "Rocket Rides")
inviting_user = create(:user, name: "Joe Bloggs")
user = create(:user, name: "John Doe", invited_by: inviting_user)
create(:account_membership, user: inviting_user, account:)
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/imports_spec.rb | Ruby | mit | 95 | develop | 421 | require "rails_helper"
RSpec.describe "Admin/Imports" do
it "List imports" do
user = create(:user, name: "John Doe")
create(:import, :phone_numbers, user:)
page.driver.browser.authorize("admin", "password")
visit admin_imports_path
expect(page).to have_content("PhoneNumber")
expect(page).to... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/home_spec.rb | Ruby | mit | 95 | develop | 415 | require "rails_helper"
RSpec.describe "Admin/Home" do
it "Shows a home dashboard" do
page.driver.browser.authorize("admin", "password")
visit admin_homes_path
expect(page).to have_content("Current call sessions")
expect(page).to have_content("Call sessions limit")
expect(page).to have_content("P... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/statistics_spec.rb | Ruby | mit | 95 | develop | 1,427 | require "rails_helper"
RSpec.describe "Admin/Statistics" do
it "Show statistics" do
carrier = create(:carrier, country_code: "US")
create(:carrier, country_code: "MX")
account = create(:account, carrier:)
create_phone_call_interaction(phone_call_params: { account:, carrier:, to: "855715900760" })
... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/incoming_phone_numbers_spec.rb | Ruby | mit | 95 | develop | 459 | require "rails_helper"
RSpec.describe "Admin/Incoming Phone Numbers" do
it "List incoming phone numbers" do
incoming_phone_number = create(
:incoming_phone_number,
number: "12513095500"
)
page.driver.browser.authorize("admin", "password")
visit admin_incoming_phone_numbers_path
expe... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/tariff_schedules_spec.rb | Ruby | mit | 95 | develop | 852 | require "rails_helper"
RSpec.describe "Admin/Tariff Schedules" do
it "List tariff schedules" do
carrier = create(:carrier)
tariff_schedule = create(:tariff_schedule, carrier:)
destination_tariff = create(:destination_tariff, schedule: tariff_schedule, carrier:)
plan_tier = create(:tariff_plan_tier, sc... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/webhook_request_logs_spec.rb | Ruby | mit | 95 | develop | 331 | require "rails_helper"
RSpec.describe "Admin / Webhook Request Logs" do
it "List webhook request logs" do
webhook_request_log = create(:webhook_request_log)
page.driver.browser.authorize("admin", "password")
visit admin_webhook_request_logs_path
expect(page).to have_content(webhook_request_log.url)... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/phone_number_plans_spec.rb | Ruby | mit | 95 | develop | 439 | require "rails_helper"
RSpec.describe "Admin/Phone Number Plans" do
it "List incoming phone numbers" do
phone_number_plan = create(
:phone_number_plan,
number: "12513095500"
)
page.driver.browser.authorize("admin", "password")
visit admin_phone_number_plans_path
expect(page).to have... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/sms_gateways_spec.rb | Ruby | mit | 95 | develop | 322 | require "rails_helper"
RSpec.describe "Admin/SMS Gateways" do
it "List SIP Trunks" do
create(:sms_gateway, name: "My SMS Gateway")
page.driver.browser.authorize("admin", "password")
visit admin_sms_gateways_path
click_on("My SMS Gateway")
expect(page).to have_content("My SMS Gateway")
end
en... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/destination_groups_spec.rb | Ruby | mit | 95 | develop | 350 | require "rails_helper"
RSpec.describe "Admin/Destination Groups" do
it "List destination groups" do
destination_group = create(:destination_group)
page.driver.browser.authorize("admin", "password")
visit admin_destination_groups_path
click_on(destination_group.id)
expect(page).to have_content(de... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/tariff_plans_spec.rb | Ruby | mit | 95 | develop | 418 | require "rails_helper"
RSpec.describe "Admin/Tariff Plans" do
it "List tariff plans" do
carrier = create(:carrier)
plan = create(:tariff_plan, name: "Standard", carrier:)
plan_tier = create(:tariff_plan_tier, plan:, carrier:)
page.driver.browser.authorize("admin", "password")
visit admin_tariff_p... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/tts_events_spec.rb | Ruby | mit | 95 | develop | 279 | require "rails_helper"
RSpec.describe "Admin/TTS Events" do
it "List TTS events" do
create(:tts_event, tts_voice: "Basic.Kal")
page.driver.browser.authorize("admin", "password")
visit admin_tts_events_path
expect(page).to have_content("Basic.Kal")
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/balance_transactions_spec.rb | Ruby | mit | 95 | develop | 396 | require "rails_helper"
RSpec.describe "Admin/BalanceTransactions" do
it "List balance transactions" do
transaction = create(:balance_transaction, type: :topup)
page.driver.browser.authorize("admin", "password")
visit admin_balance_transactions_path
click_on(transaction.id)
expect(page).to have_... |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/carriers_spec.rb | Ruby | mit | 95 | develop | 295 | require "rails_helper"
RSpec.describe "Admin/Carriers" do
it "List carriers" do
create(:carrier, name: "My Carrier")
page.driver.browser.authorize("admin", "password")
visit admin_carriers_path
click_on("My Carrier")
expect(page).to have_content("My Carrier")
end
end |
github | somleng/somleng | https://github.com/somleng/somleng | spec/system/admin/media_streams_spec.rb | Ruby | mit | 95 | develop | 698 | require "rails_helper"
RSpec.describe "Admin/Media Streams" do
it "Inspect Media Streams" do
media_stream = create(:media_stream, url: "wss://example.com/audio")
media_stream_event = create(:media_stream_event, media_stream:, type: "connect")
page.driver.browser.authorize("admin", "password")
visit ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.