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 | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/rooms/involvements_controller_test.rb | Ruby | mit | 4,291 | main | 2,330 | require "test_helper"
class Rooms::InvolvementsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show" do
get room_involvement_url(rooms(:designers))
assert_response :success
end
test "update involvement sends turbo update when becoming visible and when going in... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/rooms/closeds_controller_test.rb | Ruby | mit | 4,291 | main | 2,617 | require "test_helper"
class Rooms::ClosedsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show redirects to get general show" do
get rooms_open_url(users(:david).rooms.closeds.last)
assert_redirected_to room_url(users(:david).rooms.closeds.last)
end
test "new"... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/rooms/opens_controller_test.rb | Ruby | mit | 4,291 | main | 1,712 | require "test_helper"
class Rooms::OpensControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show redirects to get general show" do
get rooms_open_url(users(:david).rooms.opens.last)
assert_redirected_to room_url(users(:david).rooms.opens.last)
end
test "new" do
... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/rooms/directs_controller_test.rb | Ruby | mit | 4,291 | main | 850 | require "test_helper"
class Rooms::DirectsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "create" do
post rooms_directs_url, params: { user_ids: [ users(:jz).id ] }
room = Room.last
assert_redirected_to room_url(room)
assert room.users.include?(users(:davi... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/messages/boosts_controller_test.rb | Ruby | mit | 4,291 | main | 810 | require "test_helper"
class Messages::BoostsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
@message = messages(:first)
end
test "create" do
assert_turbo_stream_broadcasts [ @message.room, :messages ], count: 1 do
assert_difference -> { @message.boosts.count }, 1 do
... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/messages/by_bots_controller_test.rb | Ruby | mit | 4,291 | main | 1,930 | require "test_helper"
class Messages::ByBotsControlleTest < ActionDispatch::IntegrationTest
setup do
@room = rooms(:watercooler)
end
test "create" do
assert_difference -> { Message.count }, +1 do
post room_bot_messages_url(@room, users(:bender).bot_key), params: +"Hello Bot World!"
assert_eq... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/sessions/transfers_controller_test.rb | Ruby | mit | 4,291 | main | 452 | require "test_helper"
class Sessions::TransfersControllerTest < ActionDispatch::IntegrationTest
test "show renders when not signed in" do
get session_transfer_url("some-token")
assert_response :success
end
test "update establishes a session when the code is valid" do
user = users(:david)
put s... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/custom_styles_controller_test.rb | Ruby | mit | 4,291 | main | 772 | require "test_helper"
class Accounts::CustomStylesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "edit" do
get edit_account_custom_styles_url
assert_response :ok
end
test "update" do
assert users(:david).administrator?
put account_custom_styles_url, p... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/bots_controller_test.rb | Ruby | mit | 4,291 | main | 1,182 | require "test_helper"
class Accounts::BotsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "index" do
get account_bots_url
assert_response :ok
end
test "create" do
get new_account_bot_url
assert_response :ok
post account_bots_url, params: { user: { ... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/join_codes_controller_test.rb | Ruby | mit | 4,291 | main | 469 | require "test_helper"
class Accounts::JoinCodesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "create new join code" do
assert_changes -> { accounts(:signal).reload.join_code } do
post account_join_code_url
assert_redirected_to edit_account_url
end
en... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/logos_controller_test.rb | Ruby | mit | 4,291 | main | 1,247 | require "test_helper"
require "vips"
class Accounts::LogosControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show stock" do
get account_logo_url
assert_valid_png_response size: 512
end
test "show stock small size" do
get account_logo_url(size: :small)
ass... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/users_controller_test.rb | Ruby | mit | 4,291 | main | 873 | require "test_helper"
class Accounts::UsersControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "update" do
assert users(:david).administrator?
put account_user_url(users(:david)), params: { user: { role: "administrator" } }
assert_redirected_to edit_account_url
... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/accounts/bots/keys_controller_test.rb | Ruby | mit | 4,291 | main | 323 | require "test_helper"
class Accounts::Bots::KeysControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "update" do
assert_changes -> { users(:bender).reload.bot_token } do
put account_bot_key_url(users(:bender))
assert_redirected_to account_bots_url
end
end
e... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/autocompletable/users_controller_test.rb | Ruby | mit | 4,291 | main | 1,235 | require "test_helper"
class Autocompletable::UsersControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "search returns matching users" do
get autocompletable_users_url(format: :json), params: { query: "da" }
assert_response :success
assert_equal "David", response.pa... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/users/bans_controller_test.rb | Ruby | mit | 4,291 | main | 2,134 | require "test_helper"
class Users::BansControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "create bans user and creates ban records from sessions" do
user = users(:kevin)
user.sessions.create!(ip_address: "203.0.113.1", user_agent: "Test")
user.sessions.create!(ip_... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/users/sidebars_controller_test.rb | Ruby | mit | 4,291 | main | 838 | require "test_helper"
class Users::SidebarsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show" do
get user_sidebar_url
users(:david).rooms.opens.each do |room|
assert_match /#{room.name}/, @response.body
end
end
test "unread directs" do
rooms(... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/users/profiles_controller_test.rb | Ruby | mit | 4,291 | main | 723 | require "test_helper"
class Users::ProfilesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show" do
get user_profile_url
assert_response :success
end
test "update" do
put user_profile_url, params: { user: { name: "John Doe", bio: "Acrobat" } }
assert... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/users/push_subscriptions_controller_test.rb | Ruby | mit | 4,291 | main | 1,363 | require "test_helper"
class Users::PushSubscriptionsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "create new push subscription" do
subscription_params = { "endpoint" => "https://apple", "p256dh_key" => "123", "auth_key" => "456" }
post user_push_subscriptions_ur... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/controllers/users/avatars_controller_test.rb | Ruby | mit | 4,291 | main | 638 | require "test_helper"
class Users::AvatarsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in :david
end
test "show initials" do
get user_avatar_url(users(:kevin).avatar_token)
assert_select "text", text: "K"
end
test "show image" do
users(:kevin).update! avatar: fixture_file_... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/channels/presence_channel_test.rb | Ruby | mit | 4,291 | main | 1,281 | require "test_helper"
class PresenceChannelTest < ActionCable::Channel::TestCase
setup do
stub_connection(current_user: users(:david))
end
test "subscribes" do
room = users(:david).rooms.first
subscribe room_id: room.id
assert subscription.confirmed?
assert_has_stream_for room
end
tes... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/channels/application_cable/connection_test.rb | Ruby | mit | 4,291 | main | 547 | require "test_helper"
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
test "connects with valid user_id cookie" do
cookies.signed[:session_token] = sessions(:david_safari).token
connect
assert_equal users(:david), connection.current_user
end
test "rejects connection with... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/performance/create_dummy_cookies.rb | Ruby | mit | 4,291 | main | 483 | key_generator = ActiveSupport::KeyGenerator.new("dummy", iterations: 1000)
signed_cookie_secret = key_generator.generate_key("signed cookie")
signed_cookie_verifier = ActiveSupport::MessageVerifier.new(signed_cookie_secret, digest: "SHA1", serializer: ActiveSupport::MessageEncryptor::NullSerializer)
(1..10000).each do... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/lib/restricted_http/private_network_guard_test.rb | Ruby | mit | 4,291 | main | 3,265 | require "test_helper"
require "restricted_http/private_network_guard"
class RestrictedHTTP::PrivateNetworkGuardTest < ActiveSupport::TestCase
test "private_ip? returns true for 'This' network (RFC1700)" do
assert_private_ip "0.0.0.0"
assert_private_ip "0.255.255.255"
end
test "private_ip? returns true f... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/lib/rails_ext/action_text_attachables_test.rb | Ruby | mit | 4,291 | main | 1,562 | require "test_helper"
class ActionText::AttachmentTest < ActiveSupport::TestCase
setup do
@user = users(:david)
end
test "from_node" do
html = %Q(<action-text-attachment sgid="#{@user.attachable_sgid}"></action-text-attachment>)
node = ActionText::Fragment.wrap(html).find_all(ActionText::Attachment.... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/test_helpers/session_test_helper.rb | Ruby | mit | 4,291 | main | 338 | module SessionTestHelper
def parsed_cookies
ActionDispatch::Cookies::CookieJar.build(request, cookies.to_hash)
end
def sign_in(user)
user = users(user) unless user.is_a? User
post session_url, params: { email_address: user.email_address, password: "secret123456" }
assert cookies[:session_token].p... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/test_helpers/system_test_helper.rb | Ruby | mit | 4,291 | main | 1,455 | module SystemTestHelper
def sign_in(email_address, password = "secret123456")
visit root_url
fill_in "email_address", with: email_address
fill_in "password", with: password
click_on "log_in"
assert_selector "a.btn", text: "Designers"
end
def wait_for_cable_connection
assert_selector "tu... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/test_helpers/turbo_test_helper.rb | Ruby | mit | 4,291 | main | 654 | module TurboTestHelper
def assert_rendered_turbo_stream_broadcast(*streambles, action:, target:, &block)
streams = find_broadcasts_for(*streambles)
target = ActionView::RecordIdentifier.dom_id(*target)
assert_select Nokogiri::HTML.fragment(streams), %(turbo-stream[action="#{action}"][target="#{target}"]),... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/test_helpers/mention_test_helper.rb | Ruby | mit | 4,291 | main | 383 | module MentionTestHelper
def mention_attachment_for(name)
user = users(name)
attachment_body = ApplicationController.render partial: "users/mention", locals: { user: user }
"<action-text-attachment sgid=\"#{user.attachable_sgid}\" content-type=\"application/vnd.campfire.mention\" content=\"#{attachment_bo... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/helpers/content_filters_test.rb | Ruby | mit | 4,291 | main | 9,486 | require "test_helper"
class ContentFiltersTest < ActionView::TestCase
test "entire message contains an unfurled URL" do
text = "https://basecamp.com/"
message = Message.create! room: rooms(:pets), body: unfurled_message_body_for_basecamp(text), client_message_id: "0015", creator: users(:jason)
filtered ... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/first_run_test.rb | Ruby | mit | 4,291 | main | 647 | require "test_helper"
class FirstRunTest < ActiveSupport::TestCase
setup do
Account.destroy_all
Room.destroy_all
User.destroy_all
end
test "creating makes first user an administrator" do
user = create_first_run_user
assert user.administrator?
end
test "first user has access to first roo... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/action_text_attachment_test.rb | Ruby | mit | 4,291 | main | 1,480 | require "test_helper"
class ActionTextAttachmentTest < ActiveSupport::TestCase
setup do
@user = users(:david)
end
test "lookup user attachable with invalid sgid" do
message, signature = @user.attachable_sgid.split("--")
html = %Q(<action-text-attachment sgid="#{message}--invalid"></action-text-atta... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/membership_test.rb | Ruby | mit | 4,291 | main | 2,474 | require "test_helper"
class MembershipTest < ActiveSupport::TestCase
setup do
@membership = memberships(:david_watercooler)
end
test "connected scope" do
@membership.connected
assert Membership.connected.exists?(@membership.id)
@membership.disconnected
assert_not Membership.connected.exists... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/account_test.rb | Ruby | mit | 4,291 | main | 1,005 | require "test_helper"
class AccountTest < ActiveSupport::TestCase
test "settings" do
accounts(:signal).settings.restrict_room_creation_to_administrators = true
assert accounts(:signal).settings.restrict_room_creation_to_administrators?
assert_equal({ "restrict_room_creation_to_administrators" => true }, ... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/user_test.rb | Ruby | mit | 4,291 | main | 1,373 | require "test_helper"
class UserTest < ActiveSupport::TestCase
test "user does not prevent very long passwords" do
users(:david).update(password: "secret" * 50)
assert users(:david).valid?
end
test "creating users grants membership to the open rooms" do
assert_difference -> { Membership.count }, +Ro... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/message_test.rb | Ruby | mit | 4,291 | main | 1,544 | require "test_helper"
class MessageTest < ActiveSupport::TestCase
include ActionCable::TestHelper, ActiveJob::TestHelper
test "creating a message enqueues to push later" do
assert_enqueued_jobs 1, only: [ Room::PushMessageJob ] do
create_new_message_in rooms(:designers)
end
end
test "all emoji"... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/webhook_test.rb | Ruby | mit | 4,291 | main | 2,311 | require "test_helper"
class WebhookTest < ActiveSupport::TestCase
test "payload" do
message = messages(:first)
message_path = Rails.application.routes.url_helpers.room_at_message_path(message.room, message)
bot_messages_path = Rails.application.routes.url_helpers.room_bot_messages_path(message.room, user... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/room_test.rb | Ruby | mit | 4,291 | main | 1,356 | require "test_helper"
class RoomTest < ActiveSupport::TestCase
test "grant membership to user" do
rooms(:watercooler).memberships.grant_to(users(:kevin))
assert rooms(:watercooler).users.include?(users(:kevin))
end
test "revoke membership from user" do
rooms(:watercooler).memberships.revoke_from(use... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/message/attachment_test.rb | Ruby | mit | 4,291 | main | 1,037 | require "test_helper"
class Message::AttachmentTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
include ActionDispatch::TestProcess
test "creating a message creates image thumbnail" do
message = create_attachment_message("moon.jpg", "image/jpeg")
assert message.attachment.representation(:thu... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/message/searchable_test.rb | Ruby | mit | 4,291 | main | 1,262 | require "test_helper"
class Message::SearchableTest < ActiveSupport::TestCase
test "message body is indexed and searchable" do
message = rooms(:designers).messages.create! body: "My hovercraft is full of eels", client_message_id: "earth", creator: users(:david)
assert_equal [ message ], rooms(:designers).mes... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/account/joinable_test.rb | Ruby | mit | 4,291 | main | 416 | require "test_helper"
class Account::JoinableTest < ActiveSupport::TestCase
test "new accounts get a joinable code" do
Account.destroy_all
account = Account.create!(name: "Chat")
assert_match /\w{4}-\w{4}-\w{4}/, account.join_code
end
test "accounts can reset join code" do
assert_changes -> { ac... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/room/push_test.rb | Ruby | mit | 4,291 | main | 3,083 | require "test_helper"
class Room::PushTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
test "deliver new message to other room users with push subscriptions" do
task_count = Push::Subscription.count - users(:david).push_subscriptions.count
perform_enqueued_jobs only: Room::PushMessageJob do
... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/opengraph/document_test.rb | Ruby | mit | 4,291 | main | 1,988 | require "test_helper"
class Opengraph::DocumentTest < ActiveSupport::TestCase
test "extract opengraph tags using property attribute" do
document = Opengraph::Document.new("<html><head><meta property=\"og:url\" content=\"https://example.com\"><meta property=\"og:title\" content=\"Hey!\"><meta property=\"og:descri... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/opengraph/location_test.rb | Ruby | mit | 4,291 | main | 3,052 | require "test_helper"
require "restricted_http/private_network_guard"
class Opengraph::LocationTest < ActiveSupport::TestCase
test "url validations" do
assert Opengraph::Location.new("https://www.example.com").valid?
assert Opengraph::Location.new("http://www.example.com").valid?
assert_not Opengraph::L... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/opengraph/fetch_test.rb | Ruby | mit | 4,291 | main | 4,724 | require "test_helper"
require "restricted_http/private_network_guard"
class Opengraph::FetchTest < ActiveSupport::TestCase
setup do
@fetch = Opengraph::Fetch.new
@url = URI.parse("https://www.example.com")
end
test "#fetch_document fetches valid HTML" do
WebMock.stub_request(:get, "https://www.examp... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/opengraph/metadata_test.rb | Ruby | mit | 4,291 | main | 7,250 | require "test_helper"
class Opengraph::MetadataTest < ActiveSupport::TestCase
test "successful fetch" do
body = <<~HTML
<html>
<head>
<meta property="og:url" content="https://example.com">
<meta property="og:title" content="Hey!">
<meta property="og:description" conten... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/user/bot_test.rb | Ruby | mit | 4,291 | main | 1,188 | require "test_helper"
class User::BotTest < ActiveSupport::TestCase
test "create bot" do
token = "5M0aLYwQyBXOXa5Wsz6NZb11EE4tW2"
SecureRandom.stubs(:alphanumeric).returns(token)
uuid = "3574925f-479d-44f8-82b7-fc039af5367c"
Random.stubs(:uuid).returns(uuid)
bot = User.create_bot!(name: "Bender... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/user/role_test.rb | Ruby | mit | 4,291 | main | 754 | require "test_helper"
class User::RoleTest < ActiveSupport::TestCase
test "creating subsequent users makes them members" do
assert User.create!(name: "User", email_address: "user@example.com", password: "secret123456").member?
end
test "can_administer?" do
assert User.new(role: :administrator).can_admin... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/rooms/open_test.rb | Ruby | mit | 4,291 | main | 453 | require "test_helper"
class Rooms::OpenTest < ActiveSupport::TestCase
test "grants access to all users after creation" do
room = Rooms::Open.create!(name: "My open room with everyone!", creator: users(:david))
assert_equal User.count, room.users.count
end
test "grants access to all users after becoming ... |
github | basecamp/once-campfire | https://github.com/basecamp/once-campfire | test/models/rooms/direct_test.rb | Ruby | mit | 4,291 | main | 791 | require "test_helper"
class Rooms::DirectTest < ActiveSupport::TestCase
test "create room for same users" do
room = Rooms::Direct.find_or_create_for([ users(:david), users(:kevin) ])
assert room.users.include?(users(:david))
assert room.users.include?(users(:kevin))
assert_not room.users.include?(use... |
github | errbit/errbit | https://github.com/errbit/errbit | Gemfile | Ruby | mit | 4,272 | main | 2,979 | # frozen_string_literal: true
source "https://rubygems.org"
ruby file: ".ruby-version"
gem "rails", "8.1.3"
gem "sprockets-rails"
gem "stimulus-rails"
gem "importmap-rails"
gem "turbo-rails"
gem "activemodel-serializers-xml"
gem "actionmailer_inline_css"
gem "decent_exposure"
gem "devise"
gem "pundit"
gem "dotenv"
... |
github | errbit/errbit | https://github.com/errbit/errbit | lib/tasks/errbit/demo.rake | Ruby | mit | 4,272 | main | 2,341 | # frozen_string_literal: true
namespace :errbit do
desc "Add a demo app & errors to your database (for testing)"
task demo: :environment do
require "factory_bot_rails"
app = FactoryBot.create(:app, name: "Demo App #{Time.zone.now.strftime("%N")}")
# Report a number of errors for the application
a... |
github | errbit/errbit | https://github.com/errbit/errbit | lib/tasks/errbit/database.rake | Ruby | mit | 4,272 | main | 1,493 | # frozen_string_literal: true
namespace :errbit do
desc "Updates cached attributes on Problem"
task problem_recache: :environment do
ProblemRecacher.run
end
desc "Delete resolved errors from the database. (Useful for limited heroku databases)"
task clear_resolved: :environment do
puts "=== Cleared #... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/spec_helper.rb | Ruby | mit | 4,272 | main | 1,367 | # frozen_string_literal: true
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require "simplecov"
SimpleCov.start "rails" do
enable_coverage :branch
primary_coverage :branch
# https://github.com/simplecov-ruby/simplecov/issu... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/helpers/hash_helper_spec.rb | Ruby | mit | 4,272 | main | 902 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe HashHelper, type: :helper do
describe ".pretty_hash" do
let(:expected_pretty_hash) do
<<~HASH.chomp
{
"action" => "some_action",
"controller" => "some_controller"
}
HASH
end
it "is expect... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/helpers/navigation_helper_spec.rb | Ruby | mit | 4,272 | main | 499 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NavigationHelper, type: :helper do
describe "#page_count_from_end" do
it "returns the page number when counting from the last occurrence of a notice" do
expect(page_count_from_end(1, 6)).to eq 6
expect(page_count_from_end(6, 6)).to ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/helpers/problems_helper_spec.rb | Ruby | mit | 4,272 | main | 2,203 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ProblemsHelper, type: :helper do
describe "#auto_link_format" do
it "handles links with target and wraps paragraph" do
expect(
helper.auto_link_format("Goto https://errbit.com/ and say hello to team@errbit.invalid")
).to eq(... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/helpers/application_helper_spec.rb | Ruby | mit | 4,272 | main | 279 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ApplicationHelper, type: :helper do
let(:notice) { create(:notice) }
describe "#generate_problem_ical" do
it "return the ical format" do
helper.generate_problem_ical([notice])
end
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/errbit_plugin/mock_issue_tracker.rb | Ruby | mit | 4,272 | main | 956 | # frozen_string_literal: true
module ErrbitPlugin
class MockIssueTracker < IssueTracker
def self.label
"mock"
end
def self.note
"A fake issue tracker to help in testing purpose"
end
def self.fields
{
foo: {label: "foo"},
bar: {label: "bar"}
}
end
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/watchers_controller_spec.rb | Ruby | mit | 4,272 | main | 1,223 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe WatchersController, type: :controller do
let(:user) { create(:user) }
let(:problem) { create(:problem) }
before { sign_in user }
describe "#create" do
let(:app) { create(:app) }
context "successful watcher create" do
before d... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/apps_controller_spec.rb | Ruby | mit | 4,272 | main | 13,431 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe AppsController, type: :controller do
it_requires_authentication
it_requires_admin_privileges for: {new: :get, edit: :get, create: :post, update: :patch, destroy: :delete}
let(:app_params) { {name: "BestApp"} }
let(:admin) { create(:user, adm... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/comments_controller_spec.rb | Ruby | mit | 4,272 | main | 1,699 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe CommentsController, type: :controller do
let(:app) { create(:app) }
describe "POST /apps/:app_id/errs/:id/comments/create" do
render_views
before do
sign_in create(:user, admin: true)
end
context "successful comment creat... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/site_config_controller_spec.rb | Ruby | mit | 4,272 | main | 2,139 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe SiteConfigController, type: :controller do
it_requires_admin_privileges for: {
index: :get,
update: :patch
}
let(:admin) { create(:user, admin: true) }
before { sign_in admin }
describe "#index" do
it "has an index action" do... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/problems_controller_spec.rb | Ruby | mit | 4,272 | main | 16,496 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ProblemsController, type: :controller do
it_requires_authentication(
for: {
index: :get, show: :get, resolve: :patch, search: :get
},
params: {app_id: "dummyid", id: "dummyid"}
)
let(:app) { create(:app) }
let(:err) { crea... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/notices_controller_spec.rb | Ruby | mit | 4,272 | main | 4,061 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NoticesController, type: :controller do
it_requires_authentication for: {locate: :get}
let(:notice) { create(:notice) }
let(:xml) { Rails.root.join("spec/fixtures/hoptoad_test_notice.xml").read }
let(:app) { create(:app) }
let(:error_re... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/users/omniauth_callbacks_controller_spec.rb | Ruby | mit | 4,272 | main | 4,015 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Users::OmniauthCallbacksController, type: :controller do
def stub_env_for_github_omniauth(login, token = nil, email = "user@example.com")
# This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/cl... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/devise/sessions_controller_spec.rb | Ruby | mit | 4,272 | main | 845 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Devise::SessionsController, type: :controller do
render_views
describe "POST /users/sign_in" do
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
let(:app) { create(:app) }
let(:user) { create(:user) }... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/api/v3/notices_controller_spec.rb | Ruby | mit | 4,272 | main | 3,271 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Api::V3::NoticesController, type: :controller do
let(:app) { create(:app) }
let(:project_id) { app.api_key }
let(:legit_params) { {project_id: project_id, key: project_id} }
let(:legit_body) do
Rails.root.join("spec/fixtures/api_v3_req... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/api/v1/comments_controller_spec.rb | Ruby | mit | 4,272 | main | 2,351 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Api::V1::CommentsController, type: :controller do
context "when logged in" do
before do
@user = create(:user)
end
describe "GET /api/v1/problems/:problem_id/comments" do
before do
@problem = create(:problem)
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/api/v1/notices_controller_spec.rb | Ruby | mit | 4,272 | main | 2,175 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Api::V1::NoticesController, type: :controller do
context "when logged in" do
before do
@user = create(:user)
end
describe "GET /api/v1/notices" do
before do
create(:notice, created_at: Time.zone.parse("2012-08-01"))... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/controllers/api/v1/problems_controller_spec.rb | Ruby | mit | 4,272 | main | 4,309 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Api::V1::ProblemsController, type: :controller do
context "when logged in" do
before do
@user = create(:user)
end
describe "GET /api/v1/problems/:id" do
before do
notice = create(:notice)
err = create(:err, ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/macros.rb | Ruby | mit | 4,272 | main | 1,368 | # frozen_string_literal: true
def it_requires_authentication(options = {})
default_options = {
for: {
index: :get,
show: :get,
new: :get,
create: :post,
edit: :get,
update: :patch,
destroy: :delete
},
params: {id: "4c6c760494df2a18cc000015"}
}
options.reverse... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/rspec-rebound.rb | Ruby | mit | 4,272 | main | 879 | # frozen_string_literal: true
require "rspec/rebound"
RSpec.configure do |config|
# show retry status in spec process
config.verbose_retry = true
# show exception that triggers a retry if verbose_retry is set to true
config.display_try_failure_messages = true
# run retry only on features
# config.around... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/mongoid.rb | Ruby | mit | 4,272 | main | 227 | # frozen_string_literal: true
RSpec.configure do |config|
config.before(:suite) do
Mongoid::Config.truncate!
Mongoid::Tasks::Database.create_indexes
end
config.before do
Mongoid::Config.truncate!
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/vcr.rb | Ruby | mit | 4,272 | main | 285 | # frozen_string_literal: true
VCR.configure do |c|
c.cassette_library_dir = Rails.root.join("spec/cassettes")
c.hook_into :webmock
c.ignore_localhost = true
c.default_cassette_options = {
decode_compressed_response: true,
allow_unused_http_interactions: false
}
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/devise.rb | Ruby | mit | 4,272 | main | 262 | # frozen_string_literal: true
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::IntegrationHelpers, type: :system
config.include Devise::Test::IntegrationHelpers, type: :request
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/selenium-webdriver.rb | Ruby | mit | 4,272 | main | 385 | # frozen_string_literal: true
RSpec.configure do |config|
config.before(:each, type: :system) do
# Chrome headless
driven_by :selenium_chrome_headless
# Chrome non-headless
# driven_by :selenium_chrome
# Firefox headless
# driven_by :selenium_headless
# Firefox non-headless
# driven_b... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/support/capybara.rb | Ruby | mit | 4,272 | main | 1,039 | # frozen_string_literal: true
# https://github.com/teamcapybara/capybara/blob/3.40.0/lib/capybara/registrations/drivers.rb#L31-L41
Capybara.register_driver :selenium_chrome_headless do |app|
version = Capybara::Selenium::Driver.load_selenium
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(ver... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/sign_in_with_google_spec.rb | Ruby | mit | 4,272 | main | 974 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Sign in with Google", type: :system, retry: 3 do
context "sign in via Google with recognized user" do
let!(:user) { create(:user, google_uid: "123456789") }
before { expect(Errbit::Config).to receive(:google_authentication).and_return(tru... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/sign_in_with_github_spec.rb | Ruby | mit | 4,272 | main | 965 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Sign in with GitHub", type: :system, retry: 3 do
context "sign in via GitHub with recognized user" do
let!(:user) { create(:user, github_login: "biow0lf") }
before { expect(Errbit::Config).to receive(:github_authentication).and_return(tru... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/sign_in_with_google_with_domain_validation_spec.rb | Ruby | mit | 4,272 | main | 1,469 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Sign in with Google with domain validation", type: :system, retry: 3 do
before { expect(Errbit::Config).to receive(:google_authentication).and_return(true).at_least(:once).times }
before { expect(Errbit::Config).to receive(:google_auto_provisio... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/watch_unwatch_app_spec.rb | Ruby | mit | 4,272 | main | 980 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "A user can watch and unwatch an application", type: :system, retry: 3 do
context "when user log in and watch a project" do
it "is expected to log in and watch a project" do
current_user = create(:user)
app = create(:app)
sig... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/sign_in_and_sign_out_spec.rb | Ruby | mit | 4,272 | main | 1,435 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Sign in and sign out with email and password", type: :system, retry: 3 do
let!(:user) { create(:user, password: "password") }
context "when user successful sign in and sign out" do
it "is expected to sign in user and sign out" do
visi... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/system/sign_in_with_google_with_auto_provision_spec.rb | Ruby | mit | 4,272 | main | 776 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Sign in with Google with auto provision", type: :system, retry: 3 do
context "create an account for recognized user if they log in" do
before { expect(Errbit::Config).to receive(:google_authentication).and_return(true) }
before { expect(E... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/initializers/action_mailer_spec.rb | Ruby | mit | 4,272 | main | 1,944 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "initializers/action_mailer" do
def load_initializer
load File.join(Rails.root, "config", "initializers", "action_mailer.rb")
end
after do
ActionMailer::Base.delivery_method = :test
end
describe "delivery method" do
it "sets t... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/initializers/devise_spec.rb | Ruby | mit | 4,272 | main | 1,404 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Devise do
def load_initializer
load File.join(Rails.root, "config", "initializers", "devise.rb")
end
after do
# reset to the defaults
load_initializer
end
describe "omniauth github" do
it "sets the client options correctly... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/jobs/destroy_problems_by_id_job_spec.rb | Ruby | mit | 4,272 | main | 638 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe DestroyProblemsByIdJob, type: :job do
it { expect(subject).to be_an(ApplicationJob) }
it "destroys all selected problems" do
app = create(:app)
problem = create(:problem, app: app)
expect do
described_class.perform_later([prob... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/jobs/destroy_problems_by_app_job_spec.rb | Ruby | mit | 4,272 | main | 618 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe DestroyProblemsByAppJob, type: :job do
it { expect(subject).to be_an(ApplicationJob) }
it "destroys all problems" do
app = create(:app)
create(:problem, app: app)
expect do
described_class.perform_later(app.id)
end.to chan... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/mailers/mailer_spec.rb | Ruby | mit | 4,272 | main | 3,658 | # frozen_string_literal: true
require "rails_helper"
RSpec.shared_examples "a notification email" do
it "should have X-Mailer header" do
expect(email).to have_header("X-Mailer", "Errbit")
end
it "should have X-Errbit-Host header" do
expect(email).to have_header("X-Errbit-Host", Errbit::Config.host)
e... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/mailers/previews/mailer_preview.rb | Ruby | mit | 4,272 | main | 387 | # frozen_string_literal: true
class MailerPreview < ActionMailer::Preview
def err_notification
error_report = nil
Mailer.with(error_report: error_report).err_notification
end
def comment_notification
user = FactoryBot.create(:user)
# problem
comment = FactoryBot.create(:comment, user: user)... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/mailers/previews/devise/mailer_preview.rb | Ruby | mit | 4,272 | main | 339 | # frozen_string_literal: true
module Devise
class MailerPreview < ActionMailer::Preview
def reset_password_instructions
record = FactoryBot.create(:user, reset_password_token: "reset-password-token")
token = record.reset_password_token
Devise::Mailer.reset_password_instructions(record, token)... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/app_spec.rb | Ruby | mit | 4,272 | main | 8,304 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe App, type: :model do
context "Attributes" do
it { is_expected.to have_field(:_id).of_type(String) }
it { is_expected.to have_field(:name).of_type(String) }
it { is_expected.to have_fields(:api_key, :github_repo, :bitbucket_repo, :asse... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/watcher_spec.rb | Ruby | mit | 4,272 | main | 1,448 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Watcher, type: :model do
context "validations" do
it "requires an email address or an associated user" do
watcher = build(:watcher, email: nil, user: nil)
expect(watcher.valid?).to eq(false)
expect(watcher.errors[:base]).to in... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/comment_observer_spec.rb | Ruby | mit | 4,272 | main | 891 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Callback on Comment", type: :model do
context "when a Comment is saved" do
let(:comment) { build(:comment) }
context "and it is emailable?" do
before { allow(comment).to receive(:emailable?).and_return(true) }
it "should send... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/err_spec.rb | Ruby | mit | 4,272 | main | 519 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Err, type: :model do
context "validations" do
it "requires a fingerprint" do
err = build(:err, fingerprint: nil)
expect(err.valid?).to eq(false)
expect(err.errors[:fingerprint]).to include("can't be blank")
end
it "re... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/problem_spec.rb | Ruby | mit | 4,272 | main | 19,776 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Problem, type: :model do
context "validations" do
it "requires an environment" do
err = build(:problem, environment: nil)
expect(err.valid?).to eq(false)
expect(err.errors[:environment]).to include("can't be blank")
end
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/backtrace_spec.rb | Ruby | mit | 4,272 | main | 822 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Backtrace, type: :model do
describe ".find_or_create" do
let(:lines) do
[
{"number" => "123", "file" => "/some/path/to.rb", "method" => "abc"},
{"number" => "345", "file" => "/path/to.rb", "method" => "dowhat"}
]
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/fabricators_spec.rb | Ruby | mit | 4,272 | main | 568 | # frozen_string_literal: true
require "rails_helper"
# TODO: add factory bot factories validator/linter.
# Fabrication::Config.fabricator_path.each do |folder|
# Dir.glob(File.join(Rails.root, folder, "**", "*.rb")).each do |file|
# require file
# end
# end
# RSpec.describe "Fabrication", type: :model do
# ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/user_spec.rb | Ruby | mit | 4,272 | main | 2,198 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe User, type: :model do
context "validations" do
it "require that a name is present" do
user = build(:user, name: nil)
expect(user.valid?).to eq(false)
expect(user.errors[:name]).to eq(["can't be blank"])
end
it "requ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/comment_spec.rb | Ruby | mit | 4,272 | main | 1,777 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Comment, type: :model do
context "validations" do
it "should require a body" do
comment = build(:comment, body: nil)
expect(comment.valid?).to eq(false)
expect(comment.errors[:body]).to include("can't be blank")
end
end
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/issue_spec.rb | Ruby | mit | 4,272 | main | 3,044 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Issue, type: :model do
subject { described_class.new(problem: problem, user: user, body: body) }
let(:problem) { notice.problem }
let(:notice) { create(:notice) }
let(:user) { create(:user, admin: true) }
let(:issue_tracker) do
create(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.