Skip to content

Commit

Permalink
fix bug where updating any project would destroy all the other notifi…
Browse files Browse the repository at this point in the history
…ers for all of the other project
  • Loading branch information
jamesgolick committed Dec 4, 2008
1 parent 26d6326 commit 5483c81
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/integrity/notifier.rb
Expand Up @@ -18,7 +18,7 @@ def self.available
end

def self.enable_notifiers(project, enabled, config={})
all.destroy!
all(:project_id => project).destroy!
list_of_enabled_notifiers(enabled).each do |name|
create! :project_id => project, :name => name, :config => config[name]
end
Expand Down
18 changes: 18 additions & 0 deletions spec/notifier_spec.rb
Expand Up @@ -15,6 +15,10 @@ def sample_notifier(attributes={})
def sample_project
@project ||= Integrity::Project.create(:name => "Blah", :uri => "blah.blah")
end

def other_project
@other_project ||= Integrity::Project.create(:name => "Blah Blah Blah", :uri => "blah.blah")
end

describe "configuring a notifier" do
it "should not be valid by default" do
Expand Down Expand Up @@ -52,6 +56,20 @@ def sample_project
sample_project.enable_notifiers("Blah", "Blah" => { "foo" => "bar" })
}.should change(Integrity::Notifier, :count).by(1)
end

it "should destroy all of the previous notifiers for that project" do
sample_project.enable_notifiers("Blah", "Blah" => { "foo" => "bar" })
sample_project.enable_notifiers(["Cuack", "Test"], "Cuack" => { "foo" => "bar"},
"Test" => { "bar" => "baz "})

sample_project.notifiers.length.should == 2
end

it "should not destroy all of the other notifiers that exist for other projects" do
other_project.enable_notifiers("Blah", "Blah" => { "foo" => "bar" })
sample_project.enable_notifiers("Blah", "Blah" => { "foo" => "bar" })
other_project.notifiers.length.should == 1
end
end

describe "Notifying the world of a build" do
Expand Down

0 comments on commit 5483c81

Please sign in to comment.