Move work package watcher tests to spec

pull/411/head
Hagen Schink 11 years ago
parent d13831a4f3
commit 0396768923
  1. 55
      spec/models/work_package_watcher_spec.rb
  2. 10
      test/unit/issue_test.rb

@ -0,0 +1,55 @@
#-- copyright
# OpenProject is a project management system.
#
# Copyright (C) 2012-2013 the OpenProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe WorkPackage do
describe :watcher do
let(:user) { FactoryGirl.create(:user) }
let(:project) { FactoryGirl.create(:project) }
let(:role) { FactoryGirl.create(:role,
permissions: [:view_work_packages]) }
let(:project_member) { FactoryGirl.create(:member,
project: project,
principal: user,
roles: [role]) }
let(:work_package) { FactoryGirl.create(:work_package,
project: project) }
context :recipients do
let(:watcher) { Watcher.new(watchable: work_package,
user: user) }
before do
project_member
watcher.save!
role.remove_permission! :view_work_packages
work_package.reload
end
context :watcher do
subject { work_package.watched_by?(user) }
it { should be_true }
end
context :recipients do
subject { work_package.watcher_recipients }
it { should_not include(user.mail) }
end
end
end
end

@ -16,16 +16,6 @@ class IssueTest < ActiveSupport::TestCase
fixtures :all
def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
issue = FactoryGirl.create :issue
user = FactoryGirl.create :user, :member_in_project => issue.project
Watcher.create!(:user => user, :watchable => issue)
issue.project.members.first.roles.first.remove_permission! :view_work_packages
issue.reload
assert issue.watched_by?(user)
assert !issue.watcher_recipients.include?(user.mail)
end
def test_issue_destroy
Issue.find(1).destroy
assert_nil Issue.find_by_id(1)

Loading…
Cancel
Save