Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def mutator
end

def search_params
return {} unless params[:search].present?
return { state: :active } unless params[:search].present?

params.require(:search).permit(:query, :state, :language_id, :year, :month, :order, tag_list: [])
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/topics/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<td class="text-bold-500"><%= topic.documents.size %></td>
<td class="text-bold-500"><span class="badge <%= topic.state == "active" ? "bg-success" : "bg-light-danger" %>"><%= topic.state %></span></td>
<td class="text-end">
<%= link_to topic_path(topic, search: search_params), class: "btn btn-primary btn-sm", data: { turbo: false } do %>
<%= link_to topic_path(topic, search: search_params), class: "btn btn-primary btn-sm", data: { testid: topic.id, turbo: false } do %>
<i class="bi bi-search"></i> View
<% end %>
<%= link_to edit_topic_path(topic), class: "btn btn-secondary btn-sm", data: { turbo: false } do %>
Expand Down
24 changes: 13 additions & 11 deletions spec/system/topics/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
it "shows all topics from first provider" do
expect(page).to have_text(english_active_topic.title)
expect(page).to have_text(spanish_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
end

context "when searching by title" do
Expand Down Expand Up @@ -99,7 +99,7 @@
select "English", from: "search_language_id"

expect(page).to have_text(english_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(spanish_active_topic.title)
end
end
Expand All @@ -114,7 +114,7 @@

select "2023", from: "search_year"

expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(spanish_active_topic.title)
expect(page).not_to have_text(english_active_topic.title)
end
Expand All @@ -125,7 +125,7 @@
select "2", from: "search_month"

expect(page).to have_text(spanish_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_active_topic.title)

select "3", from: "search_month"
Expand Down Expand Up @@ -165,13 +165,15 @@
context "when sorting" do
it "displays users in the selected order" do
select "asc", from: "search_order"
expect(page).to have_text(/#{english_archived_topic.title}.+#{spanish_active_topic.title}.+#{english_active_topic.title}/m)

expect(page).to have_text(/#{spanish_active_topic.title}.+#{english_active_topic.title}/m)
end
end

context "when switching to another provider" do
it "only shows topics from the selected provider" do
select provider_2.name, from: "provider_id"

expect(page).to have_text(other_provider_topic.title)
expect(page).not_to have_text(english_active_topic.title)
expect(page).not_to have_text(spanish_active_topic.title)
Expand All @@ -196,7 +198,7 @@
it "only shows topics from its first associated provider" do
expect(page).to have_text(english_active_topic.title)
expect(page).to have_text(spanish_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(other_provider_topic.title)
end

Expand Down Expand Up @@ -231,7 +233,7 @@
select "English", from: "search_language_id"

expect(page).to have_text(english_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(spanish_active_topic.title)
end
end
Expand All @@ -246,7 +248,7 @@

select "2023", from: "search_year"

expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(spanish_active_topic.title)
expect(page).not_to have_text(english_active_topic.title)
end
Expand All @@ -257,7 +259,7 @@
select "2", from: "search_month"

expect(page).to have_text(spanish_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_active_topic.title)

select "3", from: "search_month"
Expand Down Expand Up @@ -297,7 +299,7 @@
context "when sorting" do
it "displays users in the selected order" do
select "asc", from: "search_order"
expect(page).to have_text(/#{english_archived_topic.title}.+#{spanish_active_topic.title}.+#{english_active_topic.title}/m)
expect(page).to have_text(/#{spanish_active_topic.title}.+#{english_active_topic.title}/m)
end
end
end
Expand All @@ -311,7 +313,7 @@
it "only shows topics from its first associated provider" do
expect(page).to have_text(english_active_topic.title)
expect(page).to have_text(spanish_active_topic.title)
expect(page).to have_text(english_archived_topic.title)
expect(page).not_to have_text(english_archived_topic.title)
expect(page).not_to have_text(other_provider_topic.title)
end

Expand Down
12 changes: 6 additions & 6 deletions spec/system/upload_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
let(:admin) { create(:user, :admin, email: "[email protected]") }

before do
login_as(admin)
create(:language)
login_as(admin)
end

context "when creating a new topic" do
Expand Down Expand Up @@ -49,7 +49,7 @@
expect(page).to have_text("logo_ruby_for_good.png")
expect(page).to have_text("skillrx_sidebar.png")
click_button("Update Topic")
click_link("View", href: topic_path(topic))
find_link { |l| l["data-testid"] == "#{topic.id}" }.click
expect(page).to have_text("skillrx_sidebar.png")
end

Expand All @@ -62,7 +62,7 @@
expect(page).to have_text("logo_ruby_for_good.png")
expect(page).to have_text("skillrx_sidebar.png")
click_link("Cancel")
click_link("View", href: topic_path(topic))
find_link { |l| l["data-testid"] == "#{topic.id}" }.click
expect(page).to have_text("logo_ruby_for_good.png")
expect(page).not_to have_text("skillrx_sidebar.png")
end
Expand All @@ -78,7 +78,7 @@
expect(page).to have_text("file_text_test.txt")
click_button("Update Topic")
expect(page).to have_text("View")
click_link("View", href: topic_path(topic))
find_link { |l| l["data-testid"] == "#{topic.id}" }.click
expect(page).not_to have_text("file_text_test.txt")
end
end
Expand All @@ -91,7 +91,7 @@
expect(page).not_to have_text("logo_ruby_for_good.png")
click_button("Update Topic")
expect(page).to have_text("View")
click_link("View", href: topic_path(topic))
find_link { |l| l["data-testid"] == "#{topic.id}" }.click
expect(page).not_to have_text("logo_ruby_for_good.png")
end

Expand All @@ -101,7 +101,7 @@
expect(page).not_to have_text("logo_ruby_for_good.png")
click_link("Cancel")
expect(page).to have_text("View")
click_link("View", href: topic_path(topic))
find_link { |l| l["data-testid"] == "#{topic.id}" }.click
expect(page).to have_text("logo_ruby_for_good.png")
end
end
Expand Down