Skip to content

Commit

Permalink
Merge pull request #2 from SOFware/update-variable-names
Browse files Browse the repository at this point in the history
Updating variable names to declare Notify
  • Loading branch information
xsavvyx authored May 24, 2023
2 parents a195659 + 405ed54 commit 47b1810
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ Add to your config/application.rb within your namespaced module
end
```

Add these variables to your env files

```
NOTIFY_SLACK_WEBHOOK_URL
NOTIFY_SLACK_NOTIFY_CHANNEL
NOTIFY_CURRENT_REPOSITORY_URL
NOTIFY_TEST_RUN_ID
```

### Debug your Slack setup

Create rake task to test the connection to your Slack channel
Expand All @@ -38,13 +47,13 @@ Create rake task to test the connection to your Slack channel
namespace :chat_notifier do
desc "Tests chat notifier"
task debug: :environment do
unless ENV["SLACK_WEBHOOK_URL"]
puts "You MUST set the environment variables for:\nSLACK_WEBHOOK_URL"
unless ENV["NOTIFY_SLACK_WEBHOOK_URL"]
puts "You MUST set the environment variables for:\nNOTIFY_SLACK_WEBHOOK_URL"
return
end
ENV["DEBUG"] = "1"
ENV["CURRENT_REPOSITORY_URL"] = "https://example.com"
ENV["TEST_RUN_ID"] = "9999"
ENV["NOTIFY_CURRENT_REPOSITORY_URL"] = "https://example.com"
ENV["NOTIFY_TEST_RUN_ID"] = "9999"
require "chat_notifier"

failure = ChatNotifier::DebugExceptionLocation.new(location: "fake/path.rb")
Expand Down
4 changes: 2 additions & 2 deletions lib/chat_notifier/chatter/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def handles?(settings)
end

def webhook_url
settings.fetch("SLACK_WEBHOOK_URL", nil)
settings.fetch("NOTIFY_SLACK_WEBHOOK_URL", nil)
end

def channel
settings.fetch("SLACK_NOTIFY_CHANNEL", nil)
settings.fetch("NOTIFY_SLACK_NOTIFY_CHANNEL", nil)
end

def payload(data)
Expand Down
2 changes: 1 addition & 1 deletion lib/chat_notifier/repository/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ChatNotifier
class Repository
class Github < self
def url
settings.fetch("CURRENT_REPOSITORY_URL", nil)
settings.fetch("NOTIFY_CURRENT_REPOSITORY_URL", nil)
end

def link(sha)
Expand Down
2 changes: 1 addition & 1 deletion lib/chat_notifier/test_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def ruby_version
end

def url
settings.fetch("CURRENT_REPOSITORY_URL")
settings.fetch("NOTIFY_CURRENT_REPOSITORY_URL")
end

def test_run_url
Expand Down
2 changes: 1 addition & 1 deletion lib/chat_notifier/test_environment/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_run_url
end

def run_id
settings.fetch("TEST_RUN_ID")
settings.fetch("NOTIFY_TEST_RUN_ID")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/chatter/slack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
describe ChatNotifier::Chatter::Slack do
let(:settings) do
{
"SLACK_WEBHOOK_URL" => "https://hooks.slack.com/abc/123",
"SLACK_NOTIFY_CHANNEL" => "#test"
"NOTIFY_SLACK_WEBHOOK_URL" => "https://hooks.slack.com/abc/123",
"NOTIFY_SLACK_NOTIFY_CHANNEL" => "#test"
}
end

Expand Down
2 changes: 1 addition & 1 deletion test/repository/github_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe ChatNotifier::Repository::Github do
let(:settings) do
{
"CURRENT_REPOSITORY_URL" => "https://github.com/example/repo"
"NOTIFY_CURRENT_REPOSITORY_URL" => "https://github.com/example/repo"
}
end
let(:repository) { ChatNotifier::Repository::Github.new(settings: settings) }
Expand Down
6 changes: 3 additions & 3 deletions test/test_environment/github_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:settings) do
{
"DEBUG" => false,
"CURRENT_REPOSITORY_URL" => "https://github.com/test/test_repo",
"TEST_RUN_ID" => "12345"
"NOTIFY_CURRENT_REPOSITORY_URL" => "https://github.com/test/test_repo",
"NOTIFY_TEST_RUN_ID" => "12345"
}
end

Expand All @@ -19,7 +19,7 @@
end

describe "#run_id" do
it "returns the TEST_RUN_ID from settings" do
it "returns the NOTIFY_TEST_RUN_ID from settings" do
expect(ChatNotifier::TestEnvironment::Github.new(settings: settings).run_id).must_equal("12345")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:settings) do
{
"DEBUG" => debug,
"CURRENT_REPOSITORY_URL" => "https://github.com/test/test_repo"
"NOTIFY_CURRENT_REPOSITORY_URL" => "https://github.com/test/test_repo"
}
end

Expand Down

0 comments on commit 47b1810

Please sign in to comment.