2025-05-05 09:29:55 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-04-28 14:52:05 +02:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
2023-05-31 12:15:15 +02:00
|
|
|
RSpec.describe AnnouncementsController do
|
2023-03-07 15:04:32 +01:00
|
|
|
let(:announcement) { build(:announcement) }
|
2022-05-31 11:55:27 +02:00
|
|
|
|
2016-04-28 14:52:05 +02:00
|
|
|
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
|
|
|
|
|
|
2024-01-04 17:01:17 +01:00
|
|
|
it do
|
|
|
|
|
expect(assigns(:announcement)).to eql announcement
|
|
|
|
|
end
|
|
|
|
|
|
2018-11-23 15:06:32 +01:00
|
|
|
it { expect(response).to be_successful }
|
2016-04-28 14:52:05 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "#update" do
|
|
|
|
|
before do
|
|
|
|
|
expect(announcement).to receive(:save).and_call_original
|
|
|
|
|
put :update,
|
2016-10-17 10:21:42 +02:00
|
|
|
params: {
|
|
|
|
|
announcement: {
|
|
|
|
|
until_date: "2011-01-11",
|
|
|
|
|
text: "announcement!!!",
|
|
|
|
|
active: 1
|
|
|
|
|
}
|
2016-04-28 14:52:05 +02:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "edits the announcement" do
|
2016-06-23 10:14:46 +02:00
|
|
|
expect(response).to redirect_to action: :edit
|
2016-07-22 16:30:22 +02:00
|
|
|
expect(controller).to set_flash[:notice].to I18n.t(:notice_successful_update)
|
2016-04-28 14:52:05 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|