Skip to content

Commit

Permalink
changes per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1080 committed Nov 14, 2023
1 parent 23afda5 commit 8ab9dbf
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
3 changes: 0 additions & 3 deletions rails/app/controllers/api/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ def index
@page = Api::StoriesPage.new(community, story_params)

@stories = @page.data

# Ensure distinct
@stories = @stories.distinct
end

def show
Expand Down
46 changes: 0 additions & 46 deletions rails/spec/requests/api/public_stories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
context "filters and sort" do
let!(:place_1) { create(:place, community: community, region: "the internet") }
let!(:place_2) { create(:place, community: community, type_of_place: "online") }
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_being_deleted) { create(:speaker, community: orphan_community) }

# Story:
# - place 2
Expand Down Expand Up @@ -86,38 +84,6 @@
)
end

# Story:
# - place 1
# - speaker - will be deleted in test
# - language: English
let!(:story_with_no_speaker) do
create(
:story,
community: orphan_community,
topic: "test work",
language: "English",
places: [place_1],
speakers: [speaker_being_deleted],
permission_level: :anonymous
)
end

# Story:
# - place - will be deleted in test
# - speaker 1
# - language: English
let!(:story_with_no_place) do
create(
:story,
community: orphan_community,
topic: "test work",
language: "English",
places: [place_being_deleted],
speakers: [speaker_1],
permission_level: :anonymous
)
end

it "correctly filters" do
# filter by place (id / name)
get "/api/communities/cool_community/stories", params: {places: [place_2.id]}
Expand Down Expand Up @@ -167,7 +133,6 @@

get "/api/communities/cool_community/stories"


expect(json_meta["total"]).to eq(1)
expect(json_response["stories"].map { |s| s["id"] }).to contain_exactly(story_1.id)
end
Expand Down Expand Up @@ -215,16 +180,5 @@
expect(json_response["stories"].count).to eq(1)
expect(json_meta["hasNextPage"]).to be false
end

it "orphaned stories are excluded" do
# 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)
expect(json_response["stories"].length).to eq(0)
end
end
end
4 changes: 0 additions & 4 deletions rails/spec/requests/home_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
)
end

def json_response
JSON.parse(response.body)
end

before do
login_as user
end
Expand Down

0 comments on commit 8ab9dbf

Please sign in to comment.