Skip to content

Commit

Permalink
chore: Removed development_mode config field
Browse files Browse the repository at this point in the history
  • Loading branch information
jylamont committed Jan 7, 2025
1 parent e487b7b commit 814d8ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 48 deletions.
12 changes: 5 additions & 7 deletions lib/vero/config.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

class Vero::Config
attr_writer :development_mode # Deprecated field

attr_writer :domain
attr_accessor :tracking_api_key, :development_mode, :async, :disabled, :logging
attr_accessor :tracking_api_key, :async, :disabled, :logging

ACCEPTED_ATTRIBUTES = %i[tracking_api_key development_mode async disabled logging domain]
ACCEPTED_ATTRIBUTES = %i[tracking_api_key async disabled logging domain]

def initialize
reset!
Expand All @@ -15,10 +17,7 @@ def config_params
end

def request_params
{
tracking_api_key: tracking_api_key,
development_mode: development_mode
}.compact
{tracking_api_key: tracking_api_key}.compact
end

def domain
Expand All @@ -40,7 +39,6 @@ def disable_requests!

def reset!
self.disabled = false
self.development_mode = false
self.async = true
self.logging = false
self.tracking_api_key = nil
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
describe :track! do
it "should call the TrackAPI object via the configured sender" do
input = {event_name: "test_event", identity: {email: "[email protected]"}, data: {test: "test"}}
expected = input.merge(tracking_api_key: "abc123", development_mode: true)
expected = input.merge(tracking_api_key: "abc123")

mock_context = Vero::Context.new
allow(mock_context.config).to receive(:configured?).and_return(true)
allow(mock_context.config).to receive(:tracking_api_key).and_return("abc123")
allow(mock_context.config).to receive(:development_mode).and_return(true)

allow(Vero::App).to receive(:default_context).and_return(mock_context)

Expand All @@ -27,12 +26,11 @@
describe Vero::Api::Users do
let(:subject) { Vero::Api::Users }
let(:mock_context) { Vero::Context.new }
let(:expected) { input.merge(tracking_api_key: "abc123", development_mode: true) }
let(:expected) { input.merge(tracking_api_key: "abc123") }

before :each do
allow(mock_context.config).to receive(:configured?).and_return(true)
allow(mock_context.config).to receive(:tracking_api_key).and_return("abc123")
allow(mock_context.config).to receive(:development_mode).and_return(true)
allow(Vero::App).to receive(:default_context).and_return(mock_context)
end

Expand Down
31 changes: 0 additions & 31 deletions spec/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@
describe :request_params do
it "should return a hash of tracking_api_key and development_mode if they are set" do
config.tracking_api_key = nil
config.development_mode = nil
expect(config.request_params).to eq({})

config.tracking_api_key = "abcd1234"
expect(config.request_params).to eq({tracking_api_key: "abcd1234"})

config.development_mode = true
expect(config.request_params).to eq({tracking_api_key: "abcd1234", development_mode: true})
end
end

Expand All @@ -60,33 +56,6 @@
end
end

describe :development_mode do
it "by default it should return false regardless of Rails environment" do
stub_env("development") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end

stub_env("test") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end

stub_env("production") do
config = Vero::Config.new
expect(config.development_mode).to be(false)
end
end

it "can be overritten with the config block" do
config.development_mode = true
expect(config.request_params[:development_mode]).to be(true)

config.reset!
expect(config.request_params[:development_mode]).to be(false)
end
end

describe :test_mode do
it "should not raise error even though not configured properly" do
input = {event_name: "test_event"}
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/trackable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def vero_context(user, logging = true, async = false, disabled = true)
event_name: "test_event",
tracking_api_key: "YWJjZDEyMzQ6ZWZnaDU2Nzg=",
identity: {email: "[email protected]", age: 20, _user_type: "User"},
data: {test: 1},
development_mode: true
data: {test: 1}
}
@url = "https://api.getvero.com/api/v1/track.json"
@user = User.new
Expand Down Expand Up @@ -311,8 +310,7 @@ def vero_context(user, logging = true, async = false, disabled = true)
event_name: "test_event",
tracking_api_key: "YWJjZDEyMzQ6ZWZnaDU2Nzg=",
identity: {email: "[email protected]", age: 20, _user_type: "UserWithoutInterface"},
data: {test: 1},
development_mode: true
data: {test: 1}
}

context = Vero::Context.new(Vero::App.default_context)
Expand Down
2 changes: 0 additions & 2 deletions spec/lib/view_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
context "Vero::App has been properly configured" do
before :each do
@tracking_api_key = "abcd1234"
@api_dev_mode = false

Vero::App.init do |c|
c.tracking_api_key = @tracking_api_key
c.development_mode = @api_dev_mode
end
end

Expand Down

0 comments on commit 814d8ce

Please sign in to comment.