Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin promotions controller #5943

Merged
merged 2 commits into from
Nov 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def search_url
end

def row_url(promotion)
solidus_promotions.admin_promotion_path(promotion)
solidus_promotions.edit_admin_promotion_path(promotion)
end

def page_actions
Expand Down Expand Up @@ -63,14 +63,16 @@ def columns
{
header: :name,
data: ->(promotion) do
content_tag :div, promotion.name
link_to promotion.name, row_url(promotion)
tvdeyen marked this conversation as resolved.
Show resolved Hide resolved
end
},
{
header: :code,
data: ->(promotion) do
count = promotion.codes.count
(count == 1) ? promotion.codes.pick(:value) : t("spree.number_of_codes", count: count)
link_to solidus_promotions.admin_promotion_promotion_codes_path(promotion), title: t(".codes") do
tvdeyen marked this conversation as resolved.
Show resolved Hide resolved
count = promotion.codes.count
(count == 1) ? promotion.codes.pick(:value) : t("spree.number_of_codes", count: count)
end
end
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ en:
status:
active: Active
inactive: Inactive
codes: Codes
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ def destroy
flash[:notice] = t(".success")
redirect_back_or_to solidus_promotions.promotion_categories_path, status: :see_other
end

private

def authorization_subject
SolidusPromotions::PromotionCategory
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ def load_promotion
def promotion_params
params.require(:promotion).permit(:user_id, permitted_promotion_attributes)
end

def authorization_subject
SolidusPromotions::Promotion
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
expect(page).to have_content("Promotions were successfully removed.")
expect(page).not_to have_content("My active Promotion")
expect(SolidusPromotions::Promotion.count).to eq(3)

click_link("My future Promotion")
expect(page).to have_content("My future Promotion")
expect(page).to have_content("Starts at")
end
end
Loading