Skip to content

Commit

Permalink
Add tests for social media reordering'
Browse files Browse the repository at this point in the history
  • Loading branch information
GDSNewt committed Jan 8, 2025
1 parent 84dff18 commit 1a301ef
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,27 @@ class Admin::EditionableSocialMediaAccountsControllerTest < ActionController::Te
assert_response :redirect
assert_empty @edition.social_media_accounts
end

view_test "GET :reorder displays the reorderable social media accounts" do
get :reorder, params: { edition_id: @edition }

assert_response :success
assert_select ".gem-c-reorderable-list__item", count: @edition.social_media_accounts.count
end

test "PUT :reorder updates the ordering of social media accounts" do
social_media_account1 = create(:social_media_account, socialable: @edition, ordering: 1)
social_media_account2 = create(:social_media_account, socialable: @edition, ordering: 2)

put :reorder,
params: { edition_id: @edition,
ordering: {
social_media_account2.id.to_s => "1",
social_media_account1.id.to_s => "2",
} }

assert_response :redirect
reordered_accounts = @edition.reload.social_media_accounts.where(id: [social_media_account1.id, social_media_account2.id]).order(:ordering)
assert_equal [social_media_account2, social_media_account1], reordered_accounts
end
end

0 comments on commit 1a301ef

Please sign in to comment.