docbrown/config/initializers/slack_notifier.rb
Mac Siri 40f488d991 Migrate to Travis CI (part 2) (#591)
* Update Travis.yml

* Update README

* Update README

* Adjust test to not rely on env vars

* Update encryption

* Refactor

* Update env key

* Stub AWS calls

* Create ApplicationConfig

* Fix specs

* Fix lint

* Update ApplicationConfig

* Remove travis env vars

* Fix lint

* Extend character limit to 100

* Add env to travis

* Take out auto-restart after deploy

* Immediately discarded test cache

* Stub GA in request specs

* Stub Pusher

* Fix broken specs

* Update fixture

* Add CodeClimate id

* Change CodeClimate key

* Remove merge mistakes

* WIP

* Add Envied gem & Change README

* Add missing keys

* Add missing key

* Update fixture

* Fix broken spec

* Add Slack Notification for Travis

* Fix wording

* Fix typo
2018-07-20 20:17:18 -04:00

36 lines
837 B
Ruby

class NoOpHTTPClient
def self.post(uri, params = {})
# bonus, you could log or observe posted params here
end
end
def create_normal_notifier
Slack::Notifier.new(
ApplicationConfig["SLACK_WEBHOOK_URL"],
channel: ApplicationConfig["SLACK_CHANNEL"],
username: "activity_bot",
)
end
def create_test_channel_notifier
Slack::Notifier.new(
ApplicationConfig["SLACK_WEBHOOK_URL"],
channel: "#test",
username: "development_test_bot",
)
end
def create_stubbed_notifier
Slack::Notifier.new "WEBHOOK_URL" do
http_client NoOpHTTPClient
end
end
::SlackBot = case Rails.env
when "production"
create_normal_notifier
when "development"
create_test_channel_notifier
when "test"
create_stubbed_notifier
end