Moves assignable user tests to spec

pull/411/head
Hagen Schink 11 years ago
parent 2820418f2b
commit 0ab79c2efe
  1. 23
      spec/models/work_package_spec.rb
  2. 15
      test/unit/issue_test.rb

@ -13,7 +13,6 @@ require 'spec_helper'
describe WorkPackage do
let(:stub_work_package) { FactoryGirl.build_stubbed(:work_package) }
let(:stub_user) { FactoryGirl.build_stubbed(:user) }
let(:stub_version) { FactoryGirl.build_stubbed(:version) }
let(:stub_project) { FactoryGirl.build_stubbed(:project) }
let(:issue) { FactoryGirl.create(:issue) }
@ -143,10 +142,26 @@ describe WorkPackage do
end
describe :assignable_users do
it 'should return all users the project deems to be assignable' do
stub_work_package.project.stub!(:assignable_users).and_return([stub_user])
let(:user) { FactoryGirl.build_stubbed(:user) }
stub_work_package.assignable_users.should include(stub_user)
context "single user" do
before { stub_work_package.project.stub(:assignable_users).and_return([user]) }
subject { stub_work_package.assignable_users }
it 'should return all users the project deems to be assignable' do
should include(user)
end
end
context "multiple users" do
let(:user_2) { FactoryGirl.build_stubbed(:user) }
before { stub_work_package.project.stub(:assignable_users).and_return([user, user_2]) }
subject { stub_work_package.assignable_users.uniq }
it { should eq(stub_work_package.assignable_users) }
end
end

@ -16,21 +16,6 @@ class IssueTest < ActiveSupport::TestCase
fixtures :all
context "#assignable_users" do
should "be Users" do
assert_kind_of User, Issue.find(1).assignable_users.first
end
should "not show the issue author twice" do
assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
assert_equal 2, assignable_user_ids.length
assignable_user_ids.each do |user_id|
assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
end
end
end
def test_create_should_send_email_notification
Journal.delete_all
ActionMailer::Base.deliveries.clear

Loading…
Cancel
Save