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 | errbit/errbit | https://github.com/errbit/errbit | spec/models/notice_spec.rb | Ruby | mit | 4,272 | main | 7,124 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Notice, type: :model do
context "validations" do
it "requires a backtrace" do
notice = build(:notice, backtrace: nil)
expect(notice.valid?).to eq(false)
expect(notice.errors[:backtrace_id]).to include("can't be blank")
end... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/issue_tracker_spec.rb | Ruby | mit | 4,272 | main | 697 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe IssueTracker, type: :model do
describe "Association" do
it { is_expected.to be_embedded_in(:app) }
end
describe "Attributes" do
it { is_expected.to have_field(:type_tracker).of_type(String) }
it { is_expected.to have_field(:options... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notice_observer_spec.rb | Ruby | mit | 4,272 | main | 6,805 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Callback on Notice", type: :model do
let(:notice_attrs_for) do
lambda do |api_key|
{
error_class: "HoptoadTestingException",
message: "some message",
backtrace: [
{
"number" => "425",
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/error_report_spec.rb | Ruby | mit | 4,272 | main | 11,037 | # frozen_string_literal: true
require "rails_helper"
require "airbrake/version"
require "airbrake/backtrace"
require "airbrake/notice"
require "airbrake/utils/params_cleaner"
# MonkeyPatch to instanciate a Airbrake::Notice without configure
# Airbrake
#
module Airbrake
API_VERSION = "2.4"
class Notice
def f... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notice_fingerprinter_spec.rb | Ruby | mit | 4,272 | main | 2,510 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NoticeFingerprinter, type: :model do
let(:fingerprinter) { described_class.new }
let(:notice) { create(:notice) }
let(:backtrace) { create(:backtrace) }
describe "#generate" do
it "generates the same fingerprint for the same notice" do
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/slack_service_spec.rb | Ruby | mit | 4,272 | main | 4,236 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::SlackService, type: :model do
let(:backtrace) do
create(:backtrace,
lines: [
{number: 22, file: "/path/to/file/1.rb", method: "first_method"},
{number: 44, file: "/path/to/file/2.rb", method: "second_... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/pushover_service_spec.rb | Ruby | mit | 4,272 | main | 865 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::PushoverService, type: :model do
it "should send a notification to Pushover.net" do
notice = create(:notice)
notification_service = create(:pushover_notification_service, app: notice.app)
problem = notice.problem
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/hoiio_service_spec.rb | Ruby | mit | 4,272 | main | 543 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::HoiioService, type: :model do
it "should send a notification to hoiio" do
notice = create(:notice)
notification_service = create(:hoiio_notification_service, app: notice.app)
problem = notice.problem
sms = dou... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/hubot_service_spec.rb | Ruby | mit | 4,272 | main | 542 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::HubotService, type: :model do
it "should send a notification to Hubot" do
notice = create(:notice)
notification_service = create(:hubot_notification_service, app: notice.app)
problem = notice.problem
expect(HT... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/webhook_service_spec.rb | Ruby | mit | 4,272 | main | 1,039 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::WebhookService, type: :model do
it "should send a notification to a user-specified URL" do
notice = create(:notice)
notification_service = create(:webhook_notification_service, app: notice.app)
problem = notice.pro... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/models/notification_services/campfire_service_spec.rb | Ruby | mit | 4,272 | main | 567 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NotificationServices::CampfireService, type: :model do
it "should send a notification to campfire" do
notice = create(:notice)
notification_service = create(:campfire_notification_service, app: notice.app)
problem = notice.problem
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/watcher_factory.rb | Ruby | mit | 4,272 | main | 266 | # frozen_string_literal: true
FactoryBot.define do
factory :watcher do
app
watcher_type { "email" }
sequence(:email) { |n| "email#{n}@example.com" }
end
factory :user_watcher, parent: :watcher do
user
watcher_type { "user" }
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/app_factory.rb | Ruby | mit | 4,272 | main | 292 | # frozen_string_literal: true
FactoryBot.define do
factory :app do
sequence(:name) { |n| "App ##{n}" }
repository_branch { ["main", "master"].sample }
end
factory :app_with_watcher, parent: :app do
after(:build) do |app|
build(:watcher, app: app)
end
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/notice_factory.rb | Ruby | mit | 4,272 | main | 527 | # frozen_string_literal: true
FactoryBot.define do
factory :notice do
app
err
error_class { "FooError" }
message { "FooError: Too Much Bar" }
backtrace
server_environment { {"environment-name" => "production"} }
request { {"component" => "foo", "action" => "bar"} }
notifier { {... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/backtrace_factory.rb | Ruby | mit | 4,272 | main | 294 | # frozen_string_literal: true
FactoryBot.define do
factory :backtrace do
lines do
99.times.map do
{
number: rand(999),
file: "/path/to/file/#{SecureRandom.hex(4)}.rb",
method: ActiveSupport.methods.sample
}
end
end
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/notification_service_factory.rb | Ruby | mit | 4,272 | main | 1,300 | # frozen_string_literal: true
FactoryBot.define do
factory :notification_service do
app
sequence(:room_id) { |n| "word#{n}" }
sequence(:api_token) { |n| "word#{n}" }
sequence(:subdomain) { |n| "word#{n}" }
end
factory :gtalk_notification_service, parent: :notification_service, class: "Notific... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/problem_factory.rb | Ruby | mit | 4,272 | main | 663 | # frozen_string_literal: true
FactoryBot.define do
factory :problem do
app
comments { [] }
error_class { "FooError" }
environment { "production" }
end
factory :problem_with_comments, parent: :problem do
after(:create) do |problem|
create_list(:comment, 3, err: problem)
end
end... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/factories/user_factory.rb | Ruby | mit | 4,272 | main | 205 | # frozen_string_literal: true
FactoryBot.define do
factory :user do
email { Faker::Internet.unique.email }
name { Faker::Name.unique.name }
password { Faker::Internet.password }
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | spec/lib/configurator_spec.rb | Ruby | mit | 4,272 | main | 2,163 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Configurator do
before do
allow(ENV).to receive(:[]).and_return(nil)
allow(ENV).to receive(:[]).with("VARONE").and_return("zoom")
allow(ENV).to receive(:[]).with("VARTHREE").and_return("zipp")
end
it "takes the first existing env, ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/lib/sparklines_spec.rb | Ruby | mit | 4,272 | main | 566 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Sparklines do
it "includes each percentage and adds a percent sign" do
percentages = [33, 75, 100]
html = described_class.for_relative_percentages(percentages)
percentages.each do |percentage|
expect(html).to include("#{percentage... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/lib/airbrake_api/v3/notice_parser_spec.rb | Ruby | mit | 4,272 | main | 4,390 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe AirbrakeApi::V3::NoticeParser do
let(:app) { create(:app) }
let(:notifier_params) do
{
"name" => "notifiername",
"version" => "notifierversion",
"url" => "notifierurl"
}
end
it "raises error when errors attribute i... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/lib/errbit/version_spec.rb | Ruby | mit | 4,272 | main | 1,013 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Errbit::Version do
let(:version) { "0.0.0" }
context "release version" do
subject { described_class.new(version).full_version }
it "generates a release version" do
expect(subject).to eq(version)
end
it "does not use a com... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/issue_trackers/markdown.erb_spec.rb | Ruby | mit | 4,272 | main | 475 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "issue_trackers/markdown.erb", type: :view do
let(:problem) do
problem = create(:problem)
err = create(:err, problem: problem)
create(:notice, err: err)
problem
end
before do
allow(view).to receive(:problem).and_return(Prob... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/issue_trackers/text.erb_spec.rb | Ruby | mit | 4,272 | main | 471 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "issue_trackers/text.erb", type: :view do
let(:problem) do
problem = create(:problem)
err = create(:err, problem: problem)
create(:notice, err: err)
problem
end
before do
allow(view).to receive(:problem).and_return(ProblemD... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/problems/index.html.erb_spec.rb | Ruby | mit | 4,272 | main | 1,480 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "problems/index.html.erb", type: :view do
let(:problem_1) { create(:problem) }
let(:problem_2) { create(:problem, app: problem_1.app) }
before do
allow(view).to receive(:selected_problems).and_return([])
allow(view).to receive(:all_er... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/problems/show.ics.erb_spec.rb | Ruby | mit | 4,272 | main | 326 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "problems/show.ics.erb", type: :view do
let(:problem) { ProblemDecorator.new(create(:problem)) }
before do
allow(view).to receive(:problem).and_return(problem)
end
it "works" do
render template: "problems/show", formats: [:ics]
en... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/problems/show.html.erb_spec.rb | Ruby | mit | 4,272 | main | 6,836 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "problems/show.html.erb", type: :view do
let(:problem) { create(:problem) }
let(:comment) { create(:comment) }
let(:pivotal_tracker) do
Class.new(ErrbitPlugin::MockIssueTracker) do
def self.label
"pivotal"
end
d... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/problems/index.atom.builder_spec.rb | Ruby | mit | 4,272 | main | 417 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "problems/index.atom.builder", type: :view do
it "display problem message" do
app = App.new(new_record: false)
allow(view).to receive(:problems).and_return([Problem.new(
message: "foo",
new_record: false, app: app
), Proble... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/apps/edit.html.erb_spec.rb | Ruby | mit | 4,272 | main | 1,240 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "apps/edit.html.erb", type: :view do
let(:app) { stub_model(App) }
let(:app_decorate) { AppDecorator.new(app) }
before do
allow(view).to receive(:app).and_return(app)
allow(view).to receive(:app_decorate).and_return(app_decorate)
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/apps/new.html.erb_spec.rb | Ruby | mit | 4,272 | main | 911 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "apps/new.html.erb", type: :view do
let(:app) { stub_model(App) }
let(:app_decorate) { AppDecorator.new(app) }
before do
allow(view).to receive(:app).and_return(app)
allow(view).to receive(:app_decorate).and_return(app_decorate)
a... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/apps/show.atom.builder_spec.rb | Ruby | mit | 4,272 | main | 487 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "apps/show.atom.builder", type: :view do
let(:notice) { create(:notice) }
let(:app) { notice.app }
let(:problems) { [notice.problem] }
before do
allow(view).to receive(:app).and_return(app)
allow(view).to receive(:problems).and_ret... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/apps/show.html.erb_spec.rb | Ruby | mit | 4,272 | main | 1,429 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "apps/show.html.erb", type: :view do
let(:app) { stub_model(App) }
let(:user) { stub_model(User) }
let(:action_bar) do
view.content_for(:action_bar)
end
before do
allow(view).to receive(:app).and_return(app)
allow(view).to re... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/users/edit.html.erb_spec.rb | Ruby | mit | 4,272 | main | 503 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "users/edit.html.erb", type: :view do
let(:user) { stub_model(User, name: "shingara") }
before do
allow(view).to receive(:current_user).and_return(user)
assign(:user, user)
end
it "is expected to have per_page option" do
render... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/users/index.html.erb_spec.rb | Ruby | mit | 4,272 | main | 334 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "users/index.html.erb", type: :view do
let(:user) { create(:user) }
before { assign(:users, Kaminari.paginate_array([user], total_count: 1).page(1)) }
it "should see users option" do
render
expect(rendered).to match(/class="user_list... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/users/show.html.erb_spec.rb | Ruby | mit | 4,272 | main | 2,007 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "users/show.html.erb", type: :view do
let(:user) do
stub_model(User, created_at: Time.zone.now, email: "test@example.com")
end
before do
allow(Errbit::Config).to receive(:github_authentication).and_return(true)
allow(controller).to... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/users/new.html.erb_spec.rb | Ruby | mit | 4,272 | main | 484 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "users/new.html.erb", type: :view do
let(:user) { stub_model(User) }
before do
allow(view).to receive(:current_user).and_return(user)
assign(:user, user)
end
it "is expected to have per_page option" do
render
expect(render... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/site_config/index.html.erb_spec.rb | Ruby | mit | 4,272 | main | 759 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "site_config/index.html.erb", type: :view do
let(:config) { SiteConfig.document }
before do
assign(:config, config)
render
end
it "renders a form to edit site configuration" do
expect(rendered).to have_selector("form", count: 1... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/notices/_user_attributes.html.erb_spec.rb | Ruby | mit | 4,272 | main | 541 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "notices/_user_attributes.html.erb", type: :view do
describe "autolink" do
let(:notice) do
user_attributes = {"foo" => {"bar" => "https://example.com"}}
create(:notice, user_attributes: user_attributes)
end
it "renders tab... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/views/notices/_summary.html.erb_spec.rb | Ruby | mit | 4,272 | main | 351 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "notices/_summary.html.erb", type: :view do
let(:notice) { create(:notice, framework: "Rails 3.2.11") }
it "renders application framework" do
render "notices/summary", notice: notice, problem: notice.problem
expect(rendered).to have_con... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/issue_tracker_type_decorator_spec.rb | Ruby | mit | 4,272 | main | 1,776 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe IssueTrackerTypeDecorator, type: :decorator do
let(:fake_tracker_class) do
klass = Class.new(ErrbitPlugin::IssueTracker) do
def self.label
"fake"
end
def self.note
"a note"
end
def self.fields
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/backtrace_decorator_spec.rb | Ruby | mit | 4,272 | main | 1,991 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe BacktraceDecorator, type: :decorator do
let(:backtrace) do
described_class.new(
Backtrace.new(
lines: [
{number: 131,
file: "[PROJECT_ROOT]app/controllers/accounts_controller.rb",
method: :update_pr... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/app_decorator_spec.rb | Ruby | mit | 4,272 | main | 1,839 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe AppDecorator, type: :decorator do
describe "#email_at_notices" do
it "return the list separate by comma" do
expect(described_class.new(double(email_at_notices: [2, 3])).email_at_notices).to eq("2, 3")
end
end
describe "#notify_us... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/issue_tracker_decorator_spec.rb | Ruby | mit | 4,272 | main | 849 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe IssueTrackerDecorator, type: :decorator do
let(:fake_tracker) do
klass = Class.new(ErrbitPlugin::IssueTracker) do
def self.label
"fake"
end
def self.note
"a note"
end
def self.fields
{
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/issue_tracker_field_decorator_spec.rb | Ruby | mit | 4,272 | main | 417 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe IssueTrackerFieldDecorator, type: :decorator do
describe "#label" do
it "return the label of field_info by default" do
expect(described_class.new(:foo, label: "hello").label).to eq("hello")
end
it "return the key of field if no l... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/decorators/backtrace_line_decorator_spec.rb | Ruby | mit | 4,272 | main | 2,275 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe BacktraceLineDecorator, type: :decorator do
let(:backtrace_line) do
described_class.new(
number: 884,
file: "/path/to/file/ea315ea4.rb",
method: :instance_eval
)
end
let(:backtrace_line_in_app) do
described_class.... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/policies/app_policy_spec.rb | Ruby | mit | 4,272 | main | 3,167 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe AppPolicy do
subject { described_class.new(user, record) }
describe "#initialize" do
context "when user not present" do
let(:record) { create(:app) }
let(:user) { nil }
it { expect { subject }.to raise_error(Pundit::NotAu... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/policies/application_policy_spec.rb | Ruby | mit | 4,272 | main | 1,683 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ApplicationPolicy do
let(:record) { create(:user, admin: false) }
subject { described_class.new(user, record) }
context "when user present" do
context "when user is an admin" do
let(:user) { create(:user, admin: true) }
it { ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/policies/user_policy_spec.rb | Ruby | mit | 4,272 | main | 5,656 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UserPolicy do
subject { described_class.new(user, record) }
it do
expect(described_class::FIELDS)
.to eq([:name, :username, :email, :password, :github_login, :per_page, :time_zone, :password, :password_confirmation])
end
describe ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/requests/unlink_googles_controller_spec.rb | Ruby | mit | 4,272 | main | 1,584 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UnlinkGooglesController, type: :request do
describe "#update" do
context "when user is logged in" do
context "when user has access" do
let!(:current_user) { create(:user, google_uid: "google-uid") }
before { sign_in(curre... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/requests/unlink_githubs_controller_spec.rb | Ruby | mit | 4,272 | main | 1,681 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UnlinkGithubsController, type: :request do
describe "#update" do
context "when user is logged in" do
context "when user has access" do
let!(:current_user) { create(:user, github_login: "biow0lf", github_oauth_token: "token123") }
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/requests/notices_controller_spec.rb | Ruby | mit | 4,272 | main | 1,815 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Notices management", type: :request do
let(:errbit_app) { create(:app, api_key: "APIKEY") }
describe "create a new notice" do
context "with valid notice" do
let(:xml) { Rails.root.join("spec/fixtures/hoptoad_test_notice.xml").read }
... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/requests/users_controller_spec.rb | Ruby | mit | 4,272 | main | 15,229 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UsersController, type: :request do
# before { I18n.locale = "pt-BR" }
describe "#index" do
context "when user is logged in" do
context "when user has access" do
let!(:current_user) { create(:user, name: "Jon Snow", admin: true)... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/requests/health_controller_spec.rb | Ruby | mit | 4,272 | main | 644 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe HealthController, type: :request do
let(:errbit_app) { create(:app, api_key: "APIKEY") }
describe "api_key_tester" do
it "will let you know when the api_key is not valid" do
get "/health/api-key-tester?api_key=garbagekey"
expect... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/problem_destroy_spec.rb | Ruby | mit | 4,272 | main | 2,667 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ProblemDestroy do
let(:problem_destroy) do
ProblemDestroy.new(problem)
end
context "in unit way" do
let(:problem) do
problem = Problem.new
allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2]))... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/problem_merge_spec.rb | Ruby | mit | 4,272 | main | 2,170 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ProblemMerge do
let(:problem) { create(:problem_with_errs) }
let(:problem_1) { create(:problem_with_errs) }
describe "#initialize" do
it "failed if less than 2 uniq problem pass in args" do
expect do
ProblemMerge.new(problem... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/notice_refingerprinter_spec.rb | Ruby | mit | 4,272 | main | 1,186 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe NoticeRefingerprinter do
let(:app) { create(:app) }
let(:backtrace) { create(:backtrace) }
before do
notices
end
context "identical backtraces" do
let(:notices) do
5.times.map do
notice = create(:notice, backtrace: ... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/problem_recacher_spec.rb | Ruby | mit | 4,272 | main | 877 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ProblemRecacher do
let(:app) { create(:app) }
let(:backtrace) { create(:backtrace) }
before do
notices
NoticeRefingerprinter.run
described_class.run
end
context "minor backtrace differences" do
let(:notices) do
li... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/outdated_problem_clearer_spec.rb | Ruby | mit | 4,272 | main | 1,592 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe OutdatedProblemClearer do
before do
allow(Errbit::Config).to receive(:notice_deprecation_days).and_return(7)
end
describe "#execute" do
let!(:problems) { create_list(:problem, 3) }
context "without old problems" do
it "do no... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/resolved_problem_clearer_spec.rb | Ruby | mit | 4,272 | main | 1,419 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe ResolvedProblemClearer do
describe "#execute" do
let!(:problems) { create_list(:problem, 3) }
context "without problem resolved" do
it "do nothing" do
expect do
expect(subject.execute).to eq(0)
end.not_to ch... |
github | errbit/errbit | https://github.com/errbit/errbit | spec/interactors/user_destroy_spec.rb | Ruby | mit | 4,272 | main | 617 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UserDestroy do
describe "#destroy" do
let!(:app) { create(:app) }
let!(:user) { create(:user) }
let!(:user_watcher) { create(:user_watcher, app: app, user: user) }
it "is expected to delete user" do
expect do
describe... |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/issue_tracker_decorator.rb | Ruby | mit | 4,272 | main | 222 | # frozen_string_literal: true
# Decorates an instance of IssueTracker
class IssueTrackerDecorator < Draper::Decorator
delegate_all
def type
@type ||= IssueTrackerTypeDecorator.new(object.tracker.class)
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/backtrace_decorator.rb | Ruby | mit | 4,272 | main | 336 | # frozen_string_literal: true
class BacktraceDecorator < Draper::Decorator
def lines
@lines ||= (object.lines || []).map { |line| BacktraceLineDecorator.new(line) }
end
# Group lines into sections of in-app files and external files
def grouped_lines
lines.chunk do |line|
line.in_app? || false
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/issue_tracker_field_decorator.rb | Ruby | mit | 4,272 | main | 573 | # frozen_string_literal: true
class IssueTrackerFieldDecorator < Draper::Decorator
attr_reader :object, :field_info
def initialize(field, field_info)
@object = field
@field_info = field_info
end
alias_method :key, :object
def label
field_info[:label] || object.to_s.titleize
end
def input(... |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/app_decorator.rb | Ruby | mit | 4,272 | main | 938 | # frozen_string_literal: true
class AppDecorator < Draper::Decorator
decorates_association :issue_tracker
delegate_all
def email_at_notices
object.email_at_notices.join(", ")
end
def use_site_fingerprinter
return true if object.notice_fingerprinter.nil?
return true if object.notice_fingerprint... |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/issue_tracker_type_decorator.rb | Ruby | mit | 4,272 | main | 738 | # frozen_string_literal: true
# Decorates an IssueTracker class
class IssueTrackerTypeDecorator < Draper::Decorator
delegate_all
# return hash of icons as data URIs
def icons
return unless object.icons
object.icons.reduce({}) do |c, (k, v)|
c[k] = "data:#{v[0]};base64,#{Base64.encode64(v[1])}"
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/decorators/backtrace_line_decorator.rb | Ruby | mit | 4,272 | main | 2,694 | # frozen_string_literal: true
class BacktraceLineDecorator < Draper::Decorator
EMPTY_STRING = ""
def in_app?
return false if file.blank?
file.match Backtrace::IN_APP_PATH
end
def number
object[:number]
end
def column
object[:column]
end
def file
object.try(:[], :file).to_s
en... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/form_helper.rb | Ruby | mit | 4,272 | main | 565 | # frozen_string_literal: true
module FormHelper
def errors_for(document)
return unless document.errors.any?
content_tag(:div, class: "error-messages") do
body = content_tag(:h2, "Dang. The following errors are keeping this from being a success.")
body + content_tag(:ul) do
document.error... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/sort_helper.rb | Ruby | mit | 4,272 | main | 430 | # frozen_string_literal: true
module SortHelper
def link_for_sort(name, field = nil)
field ||= name.underscore
current = (params_sort == field)
order = (current && (params_order == "asc")) ? "desc" : "asc"
url = request.path + "?sort=#{field}&order=#{order}"
url += "&all_errs=true" if all_errs
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/apps_helper.rb | Ruby | mit | 4,272 | main | 1,383 | # frozen_string_literal: true
module AppsHelper
def link_to_copy_attributes_from_other_app
return if App.count <= 1
html = link_to("copy settings from another app", "#",
class: "button copy_config")
html << select("duplicate", "app",
App.all.asc(:name).reject { |a| a == @app }
.collect... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/hash_helper.rb | Ruby | mit | 4,272 | main | 566 | # frozen_string_literal: true
module HashHelper
def pretty_hash(hash, nesting = 0)
return "{}" if hash.empty? || hash.is_a?(String)
tab_size = 2
nesting += 1
pretty = "{"
sorted_keys = hash.keys.sort
sorted_keys.each do |key|
val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nestin... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/application_helper.rb | Ruby | mit | 4,272 | main | 1,937 | # frozen_string_literal: true
module ApplicationHelper
def message_graph(problem)
create_percentage_table_for(problem.messages)
end
def generate_problem_ical(notices)
calendar = Icalendar::Calendar.new
notices.each_with_index do |notice, index|
calendar.event do |event|
event.summary ... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/navigation_helper.rb | Ruby | mit | 4,272 | main | 1,662 | # frozen_string_literal: true
module NavigationHelper
# Returns ' active' if you are on a given controller
# - active_if_here(:users) => ' active' if users controller
# Or on one of a list of controllers
# - active_if_here([:users, :blogs, :comments])
# Or on certain action(s) in a certain controller
# -... |
github | errbit/errbit | https://github.com/errbit/errbit | app/helpers/problems_helper.rb | Ruby | mit | 4,272 | main | 1,132 | # frozen_string_literal: true
module ProblemsHelper
def problem_confirm(action)
t(format("problems.confirm.%s", action)) unless Errbit::Config.confirm_err_actions.eql? false
end
def auto_link_format(body)
sanitize(
auto_link(simple_format(body), :all, target: "_blank").html_safe,
tags: ["a",... |
github | errbit/errbit | https://github.com/errbit/errbit | app/policies/user_policy.rb | Ruby | mit | 4,272 | main | 1,320 | # frozen_string_literal: true
class UserPolicy < ApplicationPolicy
FIELDS = [
:name, :username, :email, :password, :github_login, :per_page, :time_zone,
:password, :password_confirmation
].freeze
# @param user [User] The user making the request
# @param record [User] The record being accessed
def in... |
github | errbit/errbit | https://github.com/errbit/errbit | app/policies/app_policy.rb | Ruby | mit | 4,272 | main | 872 | # frozen_string_literal: true
class AppPolicy < ApplicationPolicy
# @param user [User] The user making the request
# @param record [App] The record being accessed
def initialize(user, record) # rubocop:disable Style/RedundantInitialize, Lint/UselessMethodDefinition
super
end
def index?
false
end
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/policies/application_policy.rb | Ruby | mit | 4,272 | main | 1,148 | # frozen_string_literal: true
class ApplicationPolicy
attr_reader :user, :record
# @param user [User] The user making the request
# @param record [Mongoid::Document] The record being accessed
def initialize(user, record)
raise Pundit::NotAuthorizedError, "must be logged in" if user.blank?
@user = use... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/problem_destroy.rb | Ruby | mit | 4,272 | main | 895 | # frozen_string_literal: true
class ProblemDestroy
attr_reader :problem
def initialize(problem)
@problem = problem
end
def execute
delete_errs
delete_comments
problem.delete
end
##
# Destroy all problem pass in args
#
# @params [ Array[Problem] ] problems the list of problem need t... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/notice_refingerprinter.rb | Ruby | mit | 4,272 | main | 1,049 | # frozen_string_literal: true
class NoticeRefingerprinter
LOG_EVERY = 100
LOG_ITR = "%.1f%% complete, %i notice(s) remaining"
LOG_START = "Regenerating notice fingerprints for %i notices"
def self.run
count = Notice.count
puts format(LOG_START, count)
Notice.no_timeout.each_with_index do |notice,... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/resolved_problem_clearer.rb | Ruby | mit | 4,272 | main | 766 | # frozen_string_literal: true
class ResolvedProblemClearer
##
# Clear all problem already resolved
#
def execute
nb_problem_resolved.tap do |nb|
if nb > 0
criteria.each do |problem|
ProblemDestroy.new(problem).execute
end
compact_database
end
end
end
p... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/user_destroy.rb | Ruby | mit | 4,272 | main | 334 | # frozen_string_literal: true
class UserDestroy
attr_reader :user
# @param user [User] User to destroy
def initialize(user)
@user = user
end
def destroy
App.watched_by(user).each do |app|
watcher = app.watchers.where(user: user).first
app.watchers.delete(watcher)
end
user.dest... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/problem_merge.rb | Ruby | mit | 4,272 | main | 660 | # frozen_string_literal: true
class ProblemMerge
attr_reader :merged_problem, :child_problems
def initialize(*problems)
problems = problems.flatten.uniq
@merged_problem = problems[0]
@child_problems = problems[1..]
fail ArgumentError, "need almost 2 uniq different problems" if @child_problems.empt... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/outdated_problem_clearer.rb | Ruby | mit | 4,272 | main | 861 | # frozen_string_literal: true
class OutdatedProblemClearer
##
# Clear all problem not present for more than one week.
#
def execute
nb_problem_outdated.tap do |nb|
if nb > 0
criteria.each do |problem|
ProblemDestroy.new(problem).execute
end
compact_database
en... |
github | errbit/errbit | https://github.com/errbit/errbit | app/interactors/problem_recacher.rb | Ruby | mit | 4,272 | main | 638 | # frozen_string_literal: true
class ProblemRecacher
LOG_EVERY = 100
LOG_ITR = "%.1f%% complete, %i problem(s) remaining"
LOG_START = "Re-caching problem attributes for %i problems"
def self.run
count = Problem.count
puts format(LOG_START, count)
Problem.no_timeout.each_with_index do |problem, ind... |
github | errbit/errbit | https://github.com/errbit/errbit | app/jobs/destroy_problems_by_id_job.rb | Ruby | mit | 4,272 | main | 385 | # frozen_string_literal: true
class DestroyProblemsByIdJob < ApplicationJob
queue_as :default
# @param problem_ids [Array<String>]
def perform(problem_ids)
bson_problem_ids = []
problem_ids.each do |id|
bson_problem_ids << BSON::ObjectId.from_string(id)
end
problems = Problem.find(bson_p... |
github | errbit/errbit | https://github.com/errbit/errbit | app/jobs/destroy_problems_by_app_job.rb | Ruby | mit | 4,272 | main | 234 | # frozen_string_literal: true
class DestroyProblemsByAppJob < ApplicationJob
queue_as :default
# @param app_id [String]
def perform(app_id)
app = App.find_by(id: app_id)
ProblemDestroy.execute(app.problems)
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/unlink_googles_controller.rb | Ruby | mit | 4,272 | main | 310 | # frozen_string_literal: true
class UnlinkGooglesController < ApplicationController
def update
@user = User.find(params[:user_id])
authorize @user
@user.update!(google_uid: nil)
flash[:success] = "Successfully unlinked #{@user.email} account!"
redirect_to user_path(@user)
end
end |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/application_controller.rb | Ruby | mit | 4,272 | main | 945 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
include Pundit::Authorization
protect_from_forgery
before_action :authenticate_user_from_token!
before_action :authenticate_user!
before_action :set_time_zone
rescue_from Pundit::NotAuthorizedError, with: :user_not_author... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/users_controller.rb | Ruby | mit | 4,272 | main | 1,203 | # frozen_string_literal: true
class UsersController < ApplicationController
def index
@users = policy_scope(User)
.order_by(name: :asc)
.page(params[:page])
.per(current_user.per_page)
end
def show
@user = User.find(params[:id])
authorize @user
end
def new
@user = User.ne... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/watchers_controller.rb | Ruby | mit | 4,272 | main | 502 | # frozen_string_literal: true
class WatchersController < ApplicationController
def create
app = App.find(params[:app_id])
app.watchers.create!(user: current_user)
flash[:success] = t(".success", app: app.name)
redirect_to app_path(app)
end
def destroy
app = App.find(params[:app_id])
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/comments_controller.rb | Ruby | mit | 4,272 | main | 763 | # frozen_string_literal: true
class CommentsController < ApplicationController
expose :app
expose :problem
expose :comment
def create
problem.comments << comment
if problem.save
flash[:success] = I18n.t("comments.create.success")
else
flash[:error] = I18n.t("comments.create.error")
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/unlink_githubs_controller.rb | Ruby | mit | 4,272 | main | 358 | # frozen_string_literal: true
class UnlinkGithubsController < ApplicationController
def update
@user = User.find(params[:user_id])
authorize @user
@user.update!(github_login: nil, github_oauth_token: nil)
flash[:success] = "Successfully unlinked #{Errbit::Config.github_site_title} account!"
r... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/notices_controller.rb | Ruby | mit | 4,272 | main | 1,757 | # frozen_string_literal: true
class NoticesController < ApplicationController
class ParamsError < StandardError
end
skip_before_action :authenticate_user!, only: :create
skip_before_action :verify_authenticity_token, only: :create
rescue_from ParamsError, with: :bad_params
def create
# params[:data]... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/problems_controller.rb | Ruby | mit | 4,272 | main | 4,380 | # frozen_string_literal: true
class ProblemsController < ApplicationController
include ProblemsSearcher
before_action :need_selected_problem, only: [
:resolve_several, :unresolve_several, :unmerge_several
]
expose(:app_scope) do
params[:app_id] ? App.where(_id: params[:app_id]) : App.all
end
exp... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/apps_controller.rb | Ruby | mit | 4,272 | main | 5,378 | # frozen_string_literal: true
class AppsController < ApplicationController
include ProblemsSearcher
before_action :require_admin!, except: [:index, :show, :search]
before_action :parse_email_at_notices_or_set_default, only: [:create, :update]
before_action :parse_notice_at_notices_or_set_default, only: [:crea... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/site_config_controller.rb | Ruby | mit | 4,272 | main | 660 | # frozen_string_literal: true
class SiteConfigController < ApplicationController
before_action :require_admin!
def index
@config = SiteConfig.document
end
def update
SiteConfig.document
.update(notice_fingerprinter: filtered_update_params.to_h)
flash[:success] = I18n.t("site_config.update.... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/health_controller.rb | Ruby | mit | 4,272 | main | 368 | # frozen_string_literal: true
class HealthController < ActionController::Base # rubocop:disable Rails/ApplicationController
def api_key_tester
app = App.where(api_key: params[:api_key]).first
is_good_result = app ? true : false
response_status = is_good_result ? :ok : :forbidden
render json: {ok: is_... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/users/omniauth_callbacks_controller.rb | Ruby | mit | 4,272 | main | 5,467 | # frozen_string_literal: true
module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def github_auto_sign_up(github_token)
return if Errbit::Config.github_org_id.nil?
# See if the user is a member of the organization that we have access for
# If they are, automati... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/concerns/problems_searcher.rb | Ruby | mit | 4,272 | main | 699 | # frozen_string_literal: true
module ProblemsSearcher
extend ActiveSupport::Concern
included do
expose(:params_sort) do
if ["environment", "app", "message", "last_notice_at", "count"].member?(params[:sort])
params[:sort]
else
"last_notice_at"
end
end
expose(:params_o... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/api/v1/stats_controller.rb | Ruby | mit | 4,272 | main | 1,081 | # frozen_string_literal: true
module Api
module V1
class StatsController < ApplicationController
respond_to :json, :xml
# The stats API only requires an api_key for the given app.
skip_before_action :authenticate_user!
before_action :require_api_key_or_authenticate_user!
def app
... |
github | errbit/errbit | https://github.com/errbit/errbit | app/controllers/api/v1/comments_controller.rb | Ruby | mit | 4,272 | main | 1,174 | # frozen_string_literal: true
module Api
module V1
class CommentsController < ApplicationController
skip_before_action :verify_authenticity_token
skip_before_action :authenticate_user!
respond_to :json, :xml
FIELDS = ["_id", "err_id", "user_id", "body"].freeze
def index
re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.