The verification interface
Every Certificate we create has a unique identifier and displays a url that can be used to verify the authenticity of the document.
In order for it to work we need to:
Create a route in our controller (
application.rb)Create appropriate templates for valid & invalid certificates
Query the database for a certificate using the
identifierDisplay the right certificate using the
valid.erbtemplateDisplay the
invalid.erbtemplate if there is no matching certificate
We start with writing a Cucumber feature. Create a new feature file:
$ touch features/verify_certificate.featureAdd the following scenario to that feature file:
# features/verify_certificate.feature
Feature: As a certificate reviewer,
In order to asses the authenticity of a certificate
I want to be able to access a web page showing me the certificate information
by clicking the verification URL
Scenario: Verify certificate with a valid URL
Given valid certificates exists
And I visit the url for a certificate
Then I should be on the valid certificate pageAdd the following step definitions to your application_steps.rb:
And the following path to your paths.rb:
Keep on running cucumber after each addition to see if the error message is changing. Create the following route to your application.rb
Now we need to create a subfolder to views called verify and create the two templates we are going to use. One for a valid certificate and one if the certificate identifier is invalid.
Add the following code to these templates:
Okay, run all your features and specs. Fire up the local server using rackup and have a look for yourself.
In order to get the verification url you'll need to access a generated pdf in your file system, open it and copy the link from the bottom of the page. Paste it in your browser and you should see the verification page.
Try modifying the long hash and reload the page. Now, you should see a page that uses the invalid.erb template.
Personally, I think we've come pretty far!
Last updated