kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
3.2 KiB
150 lines
3.2 KiB
11 years ago
|
#-- copyright
|
||
|
# OpenProject is a project management system.
|
||
|
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
|
require 'spec_helper'
|
||
|
|
||
|
describe StatusesController do
|
||
|
let(:user) { FactoryGirl.create(:admin) }
|
||
|
let(:status) { FactoryGirl.create(:status) }
|
||
|
|
||
|
before { User.stub(:current).and_return user }
|
||
|
|
||
|
shared_examples_for :response do
|
||
|
subject { response }
|
||
|
|
||
|
it { should be_success }
|
||
|
|
||
|
it { should render_template(template) }
|
||
|
end
|
||
|
|
||
|
shared_examples_for :redirect do
|
||
|
subject { response }
|
||
|
|
||
|
it { should be_redirect }
|
||
|
|
||
|
it { should redirect_to({ action: :index }) }
|
||
|
end
|
||
|
|
||
|
shared_examples_for :statuses do
|
||
|
subject { Status.find_by_name(name) }
|
||
|
|
||
|
it { should_not be_nil }
|
||
|
end
|
||
|
|
||
|
describe :index do
|
||
|
let(:template) { 'index' }
|
||
|
|
||
|
before { get :index }
|
||
|
|
||
|
it_behaves_like :response
|
||
|
end
|
||
|
|
||
|
describe :new do
|
||
|
let(:template) { 'new' }
|
||
|
|
||
|
before { get :new }
|
||
|
|
||
|
it_behaves_like :response
|
||
|
end
|
||
|
|
||
|
describe :create do
|
||
|
let(:name) { 'New Status' }
|
||
|
|
||
|
before { post :create, status: { name: name } }
|
||
|
|
||
|
it_behaves_like :statuses
|
||
|
|
||
|
it_behaves_like :redirect
|
||
|
end
|
||
|
|
||
|
describe :edit do
|
||
|
let(:template) { 'edit' }
|
||
|
|
||
|
before do
|
||
|
status
|
||
|
|
||
|
get :edit, id: status.id
|
||
|
end
|
||
|
|
||
|
it_behaves_like :response
|
||
|
end
|
||
|
|
||
|
describe :update do
|
||
|
let(:name) { 'Renamed Status' }
|
||
|
|
||
|
before do
|
||
|
status
|
||
|
|
||
|
post :update,
|
||
|
id: status.id,
|
||
|
status: { name: name }
|
||
|
end
|
||
|
|
||
|
it_behaves_like :statuses
|
||
|
|
||
|
it_behaves_like :redirect
|
||
|
end
|
||
|
|
||
|
describe :destroy do
|
||
|
let(:name) { status.name }
|
||
|
|
||
|
shared_examples_for :destroyed do
|
||
|
subject { Status.find_by_name(name) }
|
||
|
|
||
|
it { should be_nil }
|
||
|
end
|
||
|
|
||
|
context "unused" do
|
||
|
before do
|
||
|
status
|
||
|
|
||
|
post :destroy, id: status.id
|
||
|
end
|
||
|
|
||
|
it_behaves_like :destroyed
|
||
|
|
||
|
it_behaves_like :redirect
|
||
|
end
|
||
|
|
||
|
context "used" do
|
||
|
let(:work_package) { FactoryGirl.create(:work_package,
|
||
|
status: status) }
|
||
|
|
||
|
before do
|
||
|
work_package
|
||
|
|
||
|
post :destroy, id: status.id
|
||
|
end
|
||
|
|
||
|
it_behaves_like :statuses
|
||
|
|
||
|
it_behaves_like :redirect
|
||
|
end
|
||
|
end
|
||
|
end
|