Permalink
Browse files

Merge pull request #128 from mbrookes/display_name

Support for customized model name, addressing #65
  • Loading branch information...
mbrookes committed Apr 17, 2015
2 parents ccffcd4 + 6d1684e commit 3c451f4243708349afc33742d583b5c2f489987d
View
@@ -179,10 +179,12 @@ def Model.model_name
end
def Model.humanized_name(type = :plural)
names = model_class_name.split(/(?=[A-Z])/).map{|n| n.gsub(":", "")}
names = @display_name ? [@display_name] : model_class_name.split(/(?=[A-Z])/).map{|n| n.gsub(":", "")}
if type == :plural
names[names.length-1] = names.last.pluralize
end
return names.join(" ")
end
@@ -312,6 +314,10 @@ def Model.items_per_page(items = Upmin.configuration.items_per_page)
return @items_per_page ||= items
end
def Model.display_name (name)
return @display_name ||= name
end
###########################################################
### Methods that need to be to be overridden. If the
@@ -41,7 +41,7 @@
click_button("Save")
within(".alert.alert-danger") do
expect(page).to(have_content("User was NOT updated."))
expect(page).to(have_content("Customer was NOT updated."))
expect(page).to(have_selector("li", text: /email/i))
end
@@ -10,13 +10,13 @@
visit ("/upmin")
within(".navbar ul.nav") do
expect(page).to(have_selector("li", text: "Users"))
expect(page).to(have_selector("li", text: "Customers"))
expect(page).to(have_selector("li", text: "Products"))
expect(page).to(have_selector("li", text: "Orders"))
expect(page).to(have_selector("li", text: "Product Orders"))
expect(page).to(have_selector("li", text: "Shipments"))
click_link("Users")
click_link("Customers")
end
expect(page).to(have_selector(".upmin-model", minimum: 10))
@@ -30,13 +30,13 @@
visit ("/upmin")
within(".navbar ul.nav") do
expect(page).to(have_selector("li", text: "Users"))
expect(page).to(have_selector("li", text: "Customers"))
expect(page).to(have_selector("li", text: "Products"))
expect(page).not_to(have_selector("li", text: "Orders"))
expect(page).not_to(have_selector("li", text: "Product Orders"))
expect(page).not_to(have_selector("li", text: "Shipments"))
click_link("Users")
click_link("Customers")
end
expect(page).to(have_selector(".upmin-model", minimum: 10))
@@ -34,7 +34,7 @@
expect { click_button("Create") }.not_to(change(User, :count))
within(".alert.alert-danger") do
expect(page).to(have_content("User was NOT created."))
expect(page).to(have_content("Customer was NOT created."))
end
within(".field_with_errors") do
@@ -1,5 +1,7 @@
class AdminUser < Upmin::Model
display_name "Customer"
action :issue_coupon
end

0 comments on commit 3c451f4

Please sign in to comment.