Skip to content

Commit

Permalink
#46 add some integration tests for navigation label
Browse files Browse the repository at this point in the history
  • Loading branch information
danielboggs committed Mar 29, 2016
1 parent 346a964 commit e3b50d2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/admin/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def ransack_text_search_chain(model)

# Returns a deletion warning message for the given ActiveRecord instance
def deletion_warning(resource)
return %{Are you sure you want to delete the #{resource.model_name.human.downcase}#{Tolaria.display_name(resource)}”? This action is not reversible.}
return %{Are you sure you want to delete the #{@managed_class.navigation_label.singularize.downcase}#{Tolaria.display_name(resource)}”? This action is not reversible.}
end

def contextual_form_url
Expand Down
3 changes: 2 additions & 1 deletion test/demo/app/models/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ class Video < ActiveRecord::Base
validates_presence_of :youtube_id

manage_with_tolaria using:{
navigation_label: "YouTube Videos",
icon: "youtube-play",
category: "Media",
permit_params: [
:title,
:yotube_id,
:youtube_id,
:description,
],
}
Expand Down
45 changes: 45 additions & 0 deletions test/integration/navigation_label_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require "test_helper"

class NavigationLabelTest < ActionDispatch::IntegrationTest

def setup
Video.destroy_all
end

def teardown
Video.destroy_all
end

test "navigation label is overidden" do

sign_in_dummy_administrator!

# index view is overridden
visit("/admin/videos")
assert page.has_content?("YouTube Videos")
assert page.has_content?("New YouTube Video")
assert page.has_content?("No YouTube Videos live here")

# new/edit view is overriden
first(".button.-primary").click
assert page.has_content?("New YouTube Video")
fill_in("video[title]", with:"Neko Atsume")
fill_in("video[youtube_id]", with:"xxxxxxxxxxx")
first(".button[name=save]").click

# created flash message is overridden
assert page.has_content?("created the YouTube Video"), "should see flash message"

# show view is overriden
find_link("Inspect").click
assert page.has_content?("YouTube Videos")
assert page.has_content?("Edit This YouTube Video")

# updated flash message is overriden
first(".button.-primary").click
first(".button[name=save]").click
assert page.has_content?("updated the youtube video"), "should see flash message"

end

end

0 comments on commit e3b50d2

Please sign in to comment.