adds admin submit button helper
This commit is contained in:
@@ -16,6 +16,10 @@ module AdminHelper
|
|||||||
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] }
|
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin_submit_action(resource)
|
||||||
|
resource.persisted? ? "edit" : "new"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def namespace
|
def namespace
|
||||||
|
|||||||
19
spec/helpers/admin_helper_spec.rb
Normal file
19
spec/helpers/admin_helper_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe AdminHelper do
|
||||||
|
|
||||||
|
describe "#admin_submit_action" do
|
||||||
|
|
||||||
|
it "returns new when the the resource has not been persisted" do
|
||||||
|
poll = build(:poll)
|
||||||
|
expect(admin_submit_action(poll)).to eq("new")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns edit when the the resource has been persisted" do
|
||||||
|
poll = create(:poll)
|
||||||
|
expect(admin_submit_action(poll)).to eq("edit")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user