Commit f4fd06f98dda20dee13bcd26b178740bb6617824
1 parent
d6efeeb3
Exists in
master
and in
1 other branch
fixed fabricators and a terrible type
Showing
3 changed files
with
13 additions
and
16 deletions
Show diff stats
app/models/notification_service.rb
spec/fabricators/notification_service_fabricator.rb
| 1 | -Fabricator(:notification_service) do | |
| 1 | +Fabricator :notification_service do | |
| 2 | + app! | |
| 2 | 3 | room_id { sequence :word } |
| 3 | 4 | api_token { sequence :word } |
| 4 | 5 | subdomain { sequence :word } |
| 5 | 6 | end |
| 6 | 7 | |
| 7 | -Fabricator :campfire_notification_service, :from => :notification_service, :class_name => "NotificationService::CampfireService" do | |
| 8 | - room_id '123456' | |
| 9 | - api_token 'ertj3qh4895oqhfiugs4g74p5w96' | |
| 10 | - subdomain 'waffles' | |
| 8 | +%w(campfire).each do |t| | |
| 9 | + Fabricator "#{t}_notification_service".to_sym, :from => :notification_service, :class_name => "NotificationService::#{t.camelcase}Service" | |
| 11 | 10 | end |
| 12 | - | ... | ... |
spec/models/notice_observer_spec.rb
| ... | ... | @@ -25,7 +25,6 @@ describe NoticeObserver do |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | describe "email notifications for a resolved issue" do |
| 28 | - | |
| 29 | 28 | before do |
| 30 | 29 | Errbit::Config.per_app_email_at_notices = true |
| 31 | 30 | @app = Fabricate(:app_with_watcher, :email_at_notices => [1]) |
| ... | ... | @@ -44,24 +43,24 @@ describe NoticeObserver do |
| 44 | 43 | end |
| 45 | 44 | end |
| 46 | 45 | |
| 47 | - describe "notifications for campfire" do | |
| 46 | + describe "should send a notification if a notification service is configured" do | |
| 47 | + let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service)) } | |
| 48 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 100)) } | |
| 48 | 49 | |
| 49 | 50 | before do |
| 50 | 51 | Errbit::Config.per_app_email_at_notices = true |
| 51 | - @app = Fabricate(:app_with_watcher, :email_at_notices => [1], :issue_tracker => Fabricate(:campfire_tracker)) | |
| 52 | - @err = Fabricate(:err, :problem => Fabricate(:problem, :app => @app, :notices_count => 100)) | |
| 53 | 52 | end |
| 54 | 53 | |
| 55 | 54 | after do |
| 56 | 55 | Errbit::Config.per_app_email_at_notices = false |
| 57 | 56 | end |
| 58 | 57 | |
| 59 | - it "should create a campfire issue" do | |
| 60 | - @err.problem.stub(:notices_count).and_return(1) | |
| 61 | - @app.issue_tracker.stub!(:create_issue).and_return(true) | |
| 62 | - @app.issue_tracker.should_receive(:create_issue) | |
| 58 | + it "should create a campfire notification" do | |
| 59 | + err.problem.stub(:notices_count).and_return(1) | |
| 60 | + app.notification_service.stub!(:create_issue).and_return(true) | |
| 61 | + app.notification_service.should_receive(:create_issue) | |
| 63 | 62 | |
| 64 | - Fabricate(:notice, :err => @err) | |
| 63 | + Fabricate(:notice, :err => err) | |
| 65 | 64 | end |
| 66 | 65 | end |
| 67 | 66 | ... | ... |