Spec: Replace large event notification spec with smaller ones
Replaced one large spec with several smaller ones, and removed duplicate and broken logic to create and edit a second event. Test plan: Run specs, review refactor Change-Id: I024c024f719ccc8a1c478bb6ca3c5b980dc505a1 Reviewed-on: https://gerrit.instructure.com/67839 Tested-by: Jenkins Reviewed-by: Michael Hargiss <mhargiss@instructure.com> Product-Review: Michael Hargiss <mhargiss@instructure.com> QA-Review: Michael Hargiss <mhargiss@instructure.com>
This commit is contained in:
parent
f1c0e6145a
commit
9f20eef4d6
|
@ -327,46 +327,60 @@ describe CalendarEvent do
|
|||
channel.confirm
|
||||
end
|
||||
|
||||
it "should send notifications to participants" do
|
||||
course_with_student(:active_all => true)
|
||||
event1 = @course.calendar_events.build(:title => "test")
|
||||
event1.updating_user = @teacher
|
||||
event1.save!
|
||||
expect(event1.messages_sent).to be_include("New Event Created")
|
||||
users = event1.messages_sent["New Event Created"].map(&:user_id)
|
||||
expect(users).to include(@student.id)
|
||||
expect(users).not_to include(@teacher.id)
|
||||
event1.messages_sent["New Event Created"].each do |message|
|
||||
expect(message.url).to include "/courses/#{@course.id}/calendar_events/#{event1.id}"
|
||||
context "with calendar event created" do
|
||||
before :once do
|
||||
course_with_student(active_all: true)
|
||||
@event1 = @course.calendar_events.build(title: "test")
|
||||
@event1.updating_user = @teacher
|
||||
@event1.save!
|
||||
end
|
||||
|
||||
event1.update_attributes(:start_at => Time.now, :end_at => Time.now)
|
||||
expect(event1.messages_sent).to be_include("Event Date Changed")
|
||||
users = event1.messages_sent["Event Date Changed"].map(&:user_id)
|
||||
expect(users).to include(@student.id)
|
||||
expect(users).not_to include(@teacher.id)
|
||||
event1.messages_sent["Event Date Changed"].each do |message|
|
||||
expect(message.url).to include "/courses/#{@course.id}/calendar_events/#{event1.id}"
|
||||
context "creation notification" do
|
||||
before :once do
|
||||
@users = @event1.messages_sent["New Event Created"].map(&:user_id)
|
||||
end
|
||||
|
||||
it "should send to participants", priority: "1", test_id: 186751 do
|
||||
expect(@event1.messages_sent).to be_include("New Event Created")
|
||||
expect(@users).to include(@student.id)
|
||||
end
|
||||
|
||||
it "should have correct URL" do
|
||||
@event1.messages_sent["New Event Created"].each do |message|
|
||||
expect(message.url).to include "/courses/#{@course.id}/calendar_events/#{@event1.id}"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not send to creating teacher" do
|
||||
expect(@users).not_to include(@teacher.id)
|
||||
end
|
||||
end
|
||||
|
||||
event2 = @course.default_section.calendar_events.build(:title => "test")
|
||||
event2.updating_user = @teacher
|
||||
event2.save!
|
||||
expect(event2.messages_sent).to be_include("New Event Created")
|
||||
users = event1.messages_sent["New Event Created"].map(&:user_id)
|
||||
expect(users).to include(@student.id)
|
||||
expect(users).not_to include(@teacher.id)
|
||||
event2.messages_sent["New Event Created"].each do |message|
|
||||
expect(message.url).to include "/course_sections/#{@course.default_section.id}/calendar_events/#{event2.id}"
|
||||
end
|
||||
context "with event date edited" do
|
||||
before :once do
|
||||
@event1.update_attributes(start_at: Time.now, end_at: Time.now)
|
||||
end
|
||||
|
||||
event2.update_attributes(:start_at => Time.now, :end_at => Time.now)
|
||||
expect(event2.messages_sent).to be_include("Event Date Changed")
|
||||
users = event1.messages_sent["Event Date Changed"].map(&:user_id)
|
||||
expect(users).to include(@student.id)
|
||||
expect(users).not_to include(@teacher.id)
|
||||
event2.messages_sent["Event Date Changed"].each do |message|
|
||||
expect(message.url).to include "/course_sections/#{@course.default_section.id}/calendar_events/#{event2.id}"
|
||||
context "edit notification" do
|
||||
before :once do
|
||||
@users = @event1.messages_sent["Event Date Changed"].map(&:user_id)
|
||||
end
|
||||
|
||||
it "should send to participants", priority: "1", test_id: 193162 do
|
||||
expect(@event1.messages_sent).to be_include("Event Date Changed")
|
||||
expect(@users).to include(@student.id)
|
||||
end
|
||||
|
||||
it "should have correct url" do
|
||||
@event1.messages_sent["Event Date Changed"].each do |message|
|
||||
expect(message.url).to include "/courses/#{@course.id}/calendar_events/#{@event1.id}"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not send to editing teacher" do
|
||||
expect(@users).not_to include(@teacher.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue