summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-12-10 12:36:35 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-12-10 12:36:35 +0100
commit61cfb16a75e65f085cd3480fe954472e63c0d207 (patch)
tree52028d263b3d9d8411fb1af2122970b819b01f58
parent631eeaa618b9cd9f2b13b8c6aac922c85e6ed3b2 (diff)
downloadgitorious-mainline-outdated-61cfb16a75e65f085cd3480fe954472e63c0d207.zip
gitorious-mainline-outdated-61cfb16a75e65f085cd3480fe954472e63c0d207.tar.gz
gitorious-mainline-outdated-61cfb16a75e65f085cd3480fe954472e63c0d207.tar.bz2
Don't attempt to create a committership delete event when deleting a user
-rw-r--r--app/models/committership.rb1
-rw-r--r--test/unit/committership_test.rb10
2 files changed, 11 insertions, 0 deletions
diff --git a/app/models/committership.rb b/app/models/committership.rb
index 0eeaedf..1097a45 100644
--- a/app/models/committership.rb
+++ b/app/models/committership.rb
@@ -146,6 +146,7 @@ class Committership < ActiveRecord::Base
end
def add_removed_committer_event
+ return unless repository
repository.project.create_event(Action::REMOVE_COMMITTER, repository,
creator, committer.title)
end
diff --git a/test/unit/committership_test.rb b/test/unit/committership_test.rb
index b69283e..28a3e0e 100644
--- a/test/unit/committership_test.rb
+++ b/test/unit/committership_test.rb
@@ -234,4 +234,14 @@ class CommittershipTest < ActiveSupport::TestCase
assert_equal [:commit, :review], @cs.permission_list.sort_by(&:to_s)
end
end
+
+ should "explode on destroy if there's no repository" do
+ # The repository will be gone if we're deleting the
+ # user/repository and it cascades down to the committership
+ cs = new_committership
+ cs.save!
+ assert_nothing_raised(NoMethodError) do
+ cs.repository.user.destroy
+ end
+ end
end