Add followable specific notices to follows controller actions and render notice on AJAX JS response.
This commit is contained in:
@@ -49,10 +49,23 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Follow"
|
||||
|
||||
expect(page).not_to have_link "Follow"
|
||||
expect(page).to have_link "Unfollow"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Should display new follower notice after user clicks on follow button", :js do
|
||||
user = create(:user)
|
||||
login_as(user)
|
||||
|
||||
visit send(followable_path, arguments)
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Follow"
|
||||
end
|
||||
|
||||
expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.create.notice_html"))
|
||||
end
|
||||
|
||||
scenario "Display unfollow button when user already following" do
|
||||
user = create(:user)
|
||||
follow = create(:follow, user: user, followable: followable)
|
||||
@@ -63,7 +76,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
expect(page).to have_link("Unfollow")
|
||||
end
|
||||
|
||||
scenario "Should display follow button after user clicks on unfollow button", :js do
|
||||
scenario "Should update follow button and show destroy notice after user clicks on unfollow button", :js do
|
||||
user = create(:user)
|
||||
follow = create(:follow, user: user, followable: followable)
|
||||
login_as(user)
|
||||
@@ -72,10 +85,24 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Unfollow"
|
||||
|
||||
expect(page).not_to have_link "Unfollow"
|
||||
expect(page).to have_link "Follow"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Should display destroy follower notice after user clicks on unfollow button", :js do
|
||||
user = create(:user)
|
||||
follow = create(:follow, user: user, followable: followable)
|
||||
login_as(user)
|
||||
|
||||
visit send(followable_path, arguments)
|
||||
within "##{dom_id(followable)}" do
|
||||
click_link "Unfollow"
|
||||
end
|
||||
|
||||
expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.destroy.notice_html"))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user