Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Update gemspec name
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Sep 14, 2016
1 parent d7f0c77 commit f776eda
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
49 changes: 49 additions & 0 deletions spec/timber/contexts/organizations/action_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
require "spec_helper"

describe Timber::Contexts::Organizations::ActionController do
around(:each) do |example|
class PagesController < ActionController::Base
layout nil

def index
render json: {}
end

def method_for_action(action_name)
action_name
end

private
def current_organization
# I want this to execute a query and test logging that query
Organization.first
end
end

example.run

Object.send(:remove_const, :PagesController)
end

let(:context) { described_class.new(PagesController.new) }

describe "#name" do
subject { context.name }
it { should be_nil }

context "with an organization" do
before(:each) { Organization.create!(name: "Timber") }
it { should eq("Timber") }

context "with an organization context" do
around(:each) do |example|
Timber::CurrentContext.add(context) do
example.run
end
end

it { should eq("Timber") }
end
end
end
end
65 changes: 65 additions & 0 deletions spec/timber/contexts/users/action_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require "spec_helper"

describe Timber::Contexts::Users::ActionController do
around(:each) do |example|
class PagesController < ActionController::Base
layout nil

def index
render json: {}
end

def method_for_action(action_name)
action_name
end

private
def current_user
# I want this to execute a query and test logging that query
@user ||= User.first
end
end

example.run

Object.send(:remove_const, :PagesController)

Timber::Probes::ActiveSupportLogSubscriber.insert!
end

let(:context) { described_class.new(PagesController.new) }

describe "#email" do
subject { context.email }
it { should be_nil }

context "with a user" do
before(:each) { User.create!(email: "a@a.com") }
it { should eq("a@a.com") }

context "with a user context" do
around(:each) do |example|
Timber::CurrentContext.add(context) do
example.run
end
end

it { should eq("a@a.com") }

context "with a debug log level" do
around(:each) do |example|
old_level = ::Rails.logger.level
::Rails.logger.level = ::Logger::DEBUG
example.run
::Rails.logger.level = old_level
end

# If the user object is not cached, it will create an infinite loop.
# This is because getting the user executes a query, which in turn creates
# logs, with tries to grab the user again, etc.
it { should eq("a@a.com") }
end
end
end
end
end
2 changes: 1 addition & 1 deletion timber-io.gemspec → timberio.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "timber/version"

Gem::Specification.new do |s|
s.name = "timber-io"
s.name = "timberio"
s.version = Timber::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Timber Technologies, Inc."]
Expand Down

0 comments on commit f776eda

Please sign in to comment.