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.
155 lines
4.7 KiB
155 lines
4.7 KiB
11 years ago
|
#-- copyright
|
||
11 years ago
|
# OpenProject Meeting Plugin
|
||
|
#
|
||
|
# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
11 years ago
|
# 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.md for more details.
|
||
11 years ago
|
#++
|
||
|
|
||
12 years ago
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||
14 years ago
|
|
||
10 years ago
|
describe MeetingsController, type: :controller do
|
||
7 years ago
|
let(:project) { FactoryBot.create :project }
|
||
9 years ago
|
|
||
|
before do
|
||
|
allow(Project).to receive(:find).and_return(project)
|
||
|
|
||
11 years ago
|
allow(@controller).to receive(:authorize)
|
||
|
allow(@controller).to receive(:check_if_login_required)
|
||
14 years ago
|
end
|
||
12 years ago
|
|
||
10 years ago
|
describe 'GET' do
|
||
|
describe 'index' do
|
||
14 years ago
|
before(:each) do
|
||
14 years ago
|
@ms = [mock_model(Meeting), mock_model(Meeting), mock_model(Meeting)]
|
||
11 years ago
|
allow(@ms).to receive(:from_tomorrow).and_return(@ms)
|
||
9 years ago
|
|
||
|
allow(project).to receive(:meetings).and_return(@ms)
|
||
12 years ago
|
[:with_users_by_date, :page, :per_page].each do |meth|
|
||
11 years ago
|
expect(@ms).to receive(meth).and_return(@ms)
|
||
12 years ago
|
end
|
||
|
@grouped = double('grouped')
|
||
11 years ago
|
expect(Meeting).to receive(:group_by_time).with(@ms).and_return(@grouped)
|
||
14 years ago
|
end
|
||
10 years ago
|
describe 'html' do
|
||
14 years ago
|
before(:each) do
|
||
7 years ago
|
get 'index', params: { project_id: project.id }
|
||
14 years ago
|
end
|
||
10 years ago
|
it { expect(response).to be_success }
|
||
|
it { expect(assigns(:meetings_by_start_year_month_date)).to eql @grouped }
|
||
14 years ago
|
end
|
||
|
end
|
||
12 years ago
|
|
||
10 years ago
|
describe 'show' do
|
||
14 years ago
|
before(:each) do
|
||
|
@m = mock_model(Meeting)
|
||
9 years ago
|
allow(Meeting).to receive_message_chain(:includes, :find).and_return(@m)
|
||
9 years ago
|
allow(@m).to receive(:project).and_return(project)
|
||
11 years ago
|
allow(allow(@m).to receive(:agenda)).to receive(:present?).and_return(false)
|
||
14 years ago
|
end
|
||
10 years ago
|
describe 'html' do
|
||
14 years ago
|
before(:each) do
|
||
7 years ago
|
get 'show', params: { id: @m.id }
|
||
14 years ago
|
end
|
||
10 years ago
|
it { expect(response).to be_success }
|
||
14 years ago
|
end
|
||
|
end
|
||
12 years ago
|
|
||
10 years ago
|
describe 'new' do
|
||
14 years ago
|
before(:each) do
|
||
9 years ago
|
allow(Project).to receive(:find).and_return(project)
|
||
14 years ago
|
@m = mock_model(Meeting)
|
||
11 years ago
|
allow(@m).to receive(:project=)
|
||
|
allow(@m).to receive(:author=)
|
||
|
allow(Meeting).to receive(:new).and_return(@m)
|
||
14 years ago
|
end
|
||
10 years ago
|
describe 'html' do
|
||
14 years ago
|
before(:each) do
|
||
7 years ago
|
get 'new', params: { project_id: project.id }
|
||
14 years ago
|
end
|
||
10 years ago
|
it { expect(response).to be_success }
|
||
|
it { expect(assigns(:meeting)).to eql @m }
|
||
14 years ago
|
end
|
||
|
end
|
||
12 years ago
|
|
||
10 years ago
|
describe 'edit' do
|
||
14 years ago
|
before(:each) do
|
||
|
@m = mock_model(Meeting)
|
||
9 years ago
|
allow(Meeting).to receive_message_chain(:includes, :find).and_return(@m)
|
||
9 years ago
|
allow(@m).to receive(:project).and_return(project)
|
||
14 years ago
|
end
|
||
10 years ago
|
describe 'html' do
|
||
14 years ago
|
before(:each) do
|
||
7 years ago
|
get 'edit', params: { id: @m.id }
|
||
14 years ago
|
end
|
||
10 years ago
|
it { expect(response).to be_success }
|
||
|
it { expect(assigns(:meeting)).to eql @m }
|
||
14 years ago
|
end
|
||
|
end
|
||
9 years ago
|
|
||
|
describe 'create' do
|
||
|
render_views
|
||
|
|
||
|
before do
|
||
|
allow(Project).to receive(:find).and_return(project)
|
||
7 years ago
|
post :create,
|
||
|
params: {
|
||
|
project_id: project.id,
|
||
|
meeting: {
|
||
|
title: 'Foobar',
|
||
|
duration: '1.0',
|
||
|
}.merge(params)
|
||
|
}
|
||
9 years ago
|
end
|
||
|
|
||
|
describe 'invalid start_date' do
|
||
|
let(:params) {
|
||
|
{
|
||
|
start_date: '-',
|
||
|
start_time_hour: '10:00'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
it 'renders an error' do
|
||
|
expect(response).to be_success
|
||
|
expect(response).to render_template :new
|
||
|
expect(response.body)
|
||
|
.to have_selector '#errorExplanation li',
|
||
|
text: "Start date " +
|
||
|
I18n.t('activerecord.errors.messages.not_an_iso_date')
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe 'invalid start_time_hour' do
|
||
|
let(:params) {
|
||
|
{
|
||
|
start_date: '2015-06-01',
|
||
|
start_time_hour: '-'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
it 'renders an error' do
|
||
|
expect(response).to be_success
|
||
|
expect(response).to render_template :new
|
||
|
expect(response.body)
|
||
|
.to have_selector '#errorExplanation li',
|
||
8 years ago
|
text: "Starting time " +
|
||
9 years ago
|
I18n.t('activerecord.errors.messages.invalid_time_format')
|
||
|
end
|
||
|
end
|
||
|
end
|
||
14 years ago
|
end
|
||
13 years ago
|
end
|