diff --git a/rails/spec/requests/api/public_stories_spec.rb b/rails/spec/requests/api/public_stories_spec.rb index cd28f1af5..a136e8632 100644 --- a/rails/spec/requests/api/public_stories_spec.rb +++ b/rails/spec/requests/api/public_stories_spec.rb @@ -32,10 +32,10 @@ def json_response context "filters" do let!(:place_1) { create(:place, community: community, region: "the internet") } let!(:place_2) { create(:place, community: community, type_of_place: "online") } - let!(:place_3) { create(:place, community: orphan_community, type_of_place: "being deleted") } + let!(:place_being_deleted) { create(:place, community: orphan_community, type_of_place: "being deleted") } let!(:speaker_1) { create(:speaker, community: community) } let!(:speaker_2) { create(:speaker, community: community, speaker_community: "ruby for good") } - let!(:speaker_3) { create(:speaker, community: orphan_community) } + let!(:speaker_being_deleted) { create(:speaker, community: orphan_community) } # Story: # - place 2 @@ -88,33 +88,31 @@ def json_response # Story: # - place 1 - # - type of place: being deleted - # - speaker 3 + # - speaker - will be deleted in test # - language: English - let!(:story_4) do + let!(:story_with_no_speaker) do create( :story, community: orphan_community, topic: "test work", language: "English", places: [place_1], - speakers: [speaker_3], + speakers: [speaker_being_deleted], permission_level: :anonymous ) end # Story: - # - place 3 - # - type of place: being deleted + # - place - will be deleted in test # - speaker 1 # - language: English - let!(:story_5) do + let!(:story_with_no_place) do create( :story, community: orphan_community, topic: "test work", language: "English", - places: [place_3], + places: [place_being_deleted], speakers: [speaker_1], permission_level: :anonymous ) @@ -162,12 +160,13 @@ def json_response expect(json_response["total"]).to eq(2) expect(json_response["stories"].map { |s| s["id"] }).to contain_exactly(story_1.id, story_2.id) - end it "orphaned stories are excluded" do - speaker_3.destroy - place_3.destroy + # ensures that story_with_no_speaker does not show up in list: + speaker_being_deleted.destroy + # ensures that story_with_no_place does not show up in list: + place_being_deleted.destroy get "/api/communities/orphaned_community/stories" expect(json_response["total"]).to eq(0)