diff --git a/app/models/notification_service.rb b/app/models/notification_service.rb index 93db32c..c5513cf 100644 --- a/app/models/notification_service.rb +++ b/app/models/notification_service.rb @@ -5,7 +5,7 @@ class NotificationService field :api_token, :type => String field :subdomain, :type => String - embedded_in :app, :inverse_of => :notfication_service + embedded_in :app, :inverse_of => :notification_service validate :check_params diff --git a/spec/fabricators/notification_service_fabricator.rb b/spec/fabricators/notification_service_fabricator.rb index bca8adb..e5f6810 100644 --- a/spec/fabricators/notification_service_fabricator.rb +++ b/spec/fabricators/notification_service_fabricator.rb @@ -1,12 +1,10 @@ -Fabricator(:notification_service) do +Fabricator :notification_service do + app! room_id { sequence :word } api_token { sequence :word } subdomain { sequence :word } end -Fabricator :campfire_notification_service, :from => :notification_service, :class_name => "NotificationService::CampfireService" do - room_id '123456' - api_token 'ertj3qh4895oqhfiugs4g74p5w96' - subdomain 'waffles' +%w(campfire).each do |t| + Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationService::#{t.camelcase}Service" end - diff --git a/spec/models/notice_observer_spec.rb b/spec/models/notice_observer_spec.rb index 2de461f..d909569 100644 --- a/spec/models/notice_observer_spec.rb +++ b/spec/models/notice_observer_spec.rb @@ -25,7 +25,6 @@ describe NoticeObserver do end describe "email notifications for a resolved issue" do - before do Errbit::Config.per_app_email_at_notices = true @app = Fabricate(:app_with_watcher, :email_at_notices => [1]) @@ -44,24 +43,24 @@ describe NoticeObserver do end end - describe "notifications for campfire" do + describe "should send a notification if a notification service is configured" do + let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service)) } + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 100)) } before do Errbit::Config.per_app_email_at_notices = true - @app = Fabricate(:app_with_watcher, :email_at_notices => [1], :issue_tracker => Fabricate(:campfire_tracker)) - @err = Fabricate(:err, :problem => Fabricate(:problem, :app => @app, :notices_count => 100)) end after do Errbit::Config.per_app_email_at_notices = false end - it "should create a campfire issue" do - @err.problem.stub(:notices_count).and_return(1) - @app.issue_tracker.stub!(:create_issue).and_return(true) - @app.issue_tracker.should_receive(:create_issue) + it "should create a campfire notification" do + err.problem.stub(:notices_count).and_return(1) + app.notification_service.stub!(:create_issue).and_return(true) + app.notification_service.should_receive(:create_issue) - Fabricate(:notice, :err => @err) + Fabricate(:notice, :err => err) end end -- libgit2 0.21.2