forked from opf/openproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannouncements_controller_spec.rb
More file actions
39 lines (33 loc) · 1007 Bytes
/
Copy pathannouncements_controller_spec.rb
File metadata and controls
39 lines (33 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'
describe AnnouncementsController, type: :controller do
let(:announcement) { FactoryBot.build :announcement }
before do
allow(controller).to receive(:check_if_login_required)
expect(controller).to receive(:require_admin)
allow(Announcement).to receive(:only_one).and_return(announcement)
end
describe '#edit' do
before do
get :edit
end
it do expect(assigns(:announcement)).to eql announcement end
it { expect(response).to be_successful }
end
describe '#update' do
before do
expect(announcement).to receive(:save).and_call_original
put :update,
params: {
announcement: {
until_date: '2011-01-11',
text: 'announcement!!!',
active: 1
}
}
end
it 'edits the announcement' do
expect(response).to redirect_to action: :edit
expect(controller).to set_flash[:notice].to I18n.t(:notice_successful_update)
end
end
end