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/alchemy/admin/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def index

# The resources controller renders the edit form as default for show actions.
def show
@assignments = @attachment.related_ingredients.joins(element: :page)
@assignments = @attachment.related_ingredients.joins(element: :page).merge(PageVersion.drafts)
render :show
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/pictures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def show
@previous = @pictures.prev_page
@next = @pictures.next_page

@assignments = @picture.related_ingredients.joins(element: :page)
@assignments = @picture.related_ingredients.joins(element: :page).merge(PageVersion.drafts)
@picture_description = @picture.descriptions.find_or_initialize_by(
language_id: Alchemy::Current.language.id
)
Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/alchemy/admin/attachments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ module Alchemy
get :show, params: {id: attachment.id}
expect(response).to render_template(:show)
end

context "with assignments" do
let!(:page) { create(:alchemy_page) }
let!(:element) { create(:alchemy_element, page: page) }
let!(:ingredient) { create(:alchemy_ingredient_file, element: element, related_object: attachment) }

before do
page.publish!
end

it "assigns all file ingredients having an assignment to @assignments" do
get :show, params: {id: attachment.id}
expect(assigns(:assignments)).to eq([ingredient])
end
end
end

describe "#create" do
Expand Down
4 changes: 4 additions & 0 deletions spec/controllers/alchemy/admin/pictures_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ module Alchemy
let!(:element) { create(:alchemy_element, page: page) }
let!(:ingredient) { create(:alchemy_ingredient_picture, element: element, related_object: picture) }

before do
page.publish!
end

it "assigns all picture ingredients having an assignment to @assignments" do
get :show, params: {id: picture.id}
expect(assigns(:assignments)).to eq([ingredient])
Expand Down