Skip to content

Commit

Permalink
Remove CertWatch prefix from registered admin
Browse files Browse the repository at this point in the history
  • Loading branch information
tf committed Nov 6, 2017
1 parent cdd4be2 commit 227057b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
16 changes: 8 additions & 8 deletions admin/cert_watch/certificates.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'cert_watch/views/all'

module CertWatch
ActiveAdmin.register Certificate do
ActiveAdmin.register Certificate, as: 'Certificate' do
menu priority: 100

actions :index, :new, :create, :show, :edit, :update
Expand All @@ -10,7 +10,7 @@ module CertWatch

index do
column :domain do |certificate|
link_to(certificate.domain, admin_cert_watch_certificate_path(certificate))
link_to(certificate.domain, admin_certificate_path(certificate))
end
column :state do |certificate|
cert_watch_certificate_state(certificate)
Expand Down Expand Up @@ -41,10 +41,10 @@ module CertWatch
f.actions
end

action_item(only: :show) do
action_item(:renew, only: :show) do
if resource.can_renew?
button_to(I18n.t('cert_watch.admin.certificates.renew'),
renew_admin_cert_watch_certificate_path(resource),
renew_admin_certificate_path(resource),
method: :post,
data: {
rel: 'renew',
Expand All @@ -53,10 +53,10 @@ module CertWatch
end
end

action_item(only: :show) do
action_item(:install, only: :show) do
if resource.can_install?
button_to(I18n.t('cert_watch.admin.certificates.install'),
install_admin_cert_watch_certificate_path(resource),
install_admin_certificate_path(resource),
method: :post,
data: {
rel: 'install',
Expand All @@ -68,13 +68,13 @@ module CertWatch
member_action :renew, method: :post do
resource = Certificate.find(params[:id])
resource.renew
redirect_to(admin_cert_watch_certificate_path(resource))
redirect_to(admin_certificate_path(resource))
end

member_action :install, method: :post do
resource = Certificate.find(params[:id])
resource.install
redirect_to(admin_cert_watch_certificate_path(resource))
redirect_to(admin_certificate_path(resource))
end

show title: :domain do |certificate|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
require 'rails_helper'

module Admin
RSpec.describe CertWatchCertificatesController, type: :controller do
RSpec.describe CertificatesController, type: :controller do
describe '#index' do
render_views

it 'renders table with certificate domains' do
create(:certificate, :custom, domain: 'some-custom.example.com')
create(:certificate, :auto_renewable)

get(:index)

expect(response.body).to have_selector('td a', text: 'some-custom.example.com')
end
end

describe '#show' do
render_views

it 'displays renew button for auto renewable certificate' do
certificate = create(:certificate, :auto_renewable)

get(:show, id: certificate)

expect(response.body).to have_selector('[data-rel=renew]')
end

it 'displays install button for complete certificate' do
certificate = create(:certificate, :custom, :complete)

get(:show, id: certificate)

expect(response.body).to have_selector('[data-rel=install]')
end
end

describe '#renew' do
it 'renews certificate' do
certificate = create(:certificate, :auto_renewable)

post(:renew, id: certificate)

expect(certificate.reload.state).to eq('renewing')
end
end

describe '#install' do
it 'installs certificate' do
certificate = create(:certificate, :complete, :auto_renewable)

post(:install, id: certificate)

expect(certificate.reload.state).to eq('installing')
end
end

describe '#create' do
it 'creates custom certificate' do
post(:create, certificate: {
Expand Down

0 comments on commit 227057b

Please sign in to comment.