-
Notifications
You must be signed in to change notification settings - Fork 49
Use slug in wishlist url #164
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
base: master
Are you sure you want to change the base?
Changes from all commits
98d77b7
9178c16
64ea806
5280fb0
87412cc
0e49872
e45e1fe
807f056
ad7db14
a5f47cc
f9be02e
f8eebda
0fe1182
b2d8dec
2fa27d2
d0b4ea3
75e2744
6204930
9283eba
d63b040
205553e
398787d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| class AddColumnSlugToWishlists < ActiveRecord::Migration[5.1] | ||
| def change | ||
| add_column :wishlists, :slug, :string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a unique index to this column since we search by it so often. We should probably disallow nulls too. |
||
| add_index :wishlists, :slug, unique: true | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,12 +104,11 @@ | |
|
|
||
| scenario "I can update an existing wishlist" do | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is fine, but let's really test this change in the unit tests ( For the model specs, you'll want to verify that the slug gets set correctly after a save or an update. We'll also need to test how wishlist items with duplicate slugs are handled (see above). We probably don't need to test input edge cases since String#parameterize/ActiveSupport are well-tested already. |
||
| click_link "DC General" | ||
| dc_general_path = current_path | ||
| click_link "Edit Wishlist" | ||
| fill_in("wishlist_name", with: "VA General") | ||
| click_button "Update Wishlist" | ||
|
|
||
| expect(current_path).to eq dc_general_path | ||
| expect(current_path).to eq wishlist_path('va-general') | ||
| expect(page).to have_text "Wishlist was successfully updated." | ||
| expect(page).to have_text "VA General" | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when an admin tries to add/update a valid wishlist that results in a duplicate slug? For example, "Wishlist 1" and "wishlist-1" are unique names but would result in the same slug. Since we're using them as the param, slugs must be unique.
Validations are run before the
before_savecallback, so a simple validation won't work. Maybe abefore_validationcallback or some sort of slug incrementing would work? I bet someone's solved this and written a blog post.