Skip to content
Draft
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
4 changes: 2 additions & 2 deletions app/controllers/workshop_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def set_index_variables # needs to not be private
else
current_user.projects.order(:name)
end
# @workshops = Workshop.joins(:workshop_logs)
# .order(:title)
@workshops = Workshop.where(id: @workshop_logs_unpaginated.select(:workshop_id).distinct)
.order(:title)
end

private
Expand Down
11 changes: 11 additions & 0 deletions app/views/workshop_logs/_search_boxes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
onchange: "this.form.requestSubmit()" %>
</div>

<!-- Workshop -->
<div class="flex flex-col w-full sm:w-1/2 md:w-1/4 lg:w-1/5">
<%= label_tag :workshop_id, "Workshop", class: "text-sm font-medium text-gray-700 mb-1" %>
<%= select_tag :workshop_id,
options_from_collection_for_select(@workshops, :id, :title, params[:workshop_id]),
include_blank: "All workshops",
class: "rounded-md border border-gray-300 px-3 py-2 text-gray-800 shadow-sm
focus:border-blue-500 focus:ring focus:ring-blue-200 focus:outline-none w-full",
onchange: "this.form.requestSubmit()" %>
</div>

<!-- Facilitator -->
<div class="flex flex-col w-full sm:w-1/2 md:w-1/4 lg:w-1/5">
<%= label_tag :user_id, "Facilitator", class: "text-sm font-medium text-gray-700 mb-1" %>
Expand Down
28 changes: 28 additions & 0 deletions spec/requests/workshop_logs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@
clear_enqueued_jobs
end

describe "GET /index" do
it "loads the index page successfully" do
get workshop_logs_path
expect(response).to have_http_status(:success)
end

it "filters workshop logs by workshop_id" do
workshop_log = create(:workshop_log, valid_attributes)
other_workshop = create(:workshop)
other_log = create(:workshop_log, valid_attributes.merge(workshop_id: other_workshop.id))

get workshop_logs_path, params: { workshop_id: workshop.id }

expect(response).to have_http_status(:success)
expect(assigns(:workshop_logs_unpaginated)).to include(workshop_log)
expect(assigns(:workshop_logs_unpaginated)).not_to include(other_log)
end

it "populates workshops dropdown with only workshops from visible logs" do
workshop_log = create(:workshop_log, valid_attributes)

get workshop_logs_path

expect(response).to have_http_status(:success)
expect(assigns(:workshops)).to include(workshop)
end
end

describe "POST /create" do
context "with valid parameters" do
it "creates a WorkshopLog" do
Expand Down