Permalink
Browse files

links added (#13)

* links added

* satisfying the hound

* took care of hound vios

* fixed vio
  • Loading branch information...
pedantix committed Jul 24, 2016
1 parent b36481f commit 1d4189c32e7833fea0ce5f813cb4b663d4dc12c1
@@ -1,6 +1,7 @@
class DirectivesController < ApplicationController
helper_method :directive
before_action :authenticate_user!, except: :show
before_action :authenticate_user!, except: [:show, :qr_code]
include ApplicationHelper
def show
end
@@ -35,6 +36,13 @@ def destroy
redirect_to root_path
end
def qr_code
svg_file = Tempfile.new(["qr_code", ".svg"])
svg_file.write qr_helper(user)
send_file svg_file, type: "image/svg+xml",
x_sendfile: true
end
private
def directive_params
@@ -1,6 +1,6 @@
module ApplicationHelper
def qr_helper
url = user_directives_url(current_user)
def qr_helper(user = current_user)
url = user_directives_url(user)
qrcode = RQRCode::QRCode.new(url)
@@ -14,6 +14,7 @@
<% if current_user.has_directive? %>
<article>
<p class="callout"><%= current_user.directive.content %></p>
<%= link_to t(".download_directive"), qr_code_user_directives_path(current_user), class: "button expanded large" %>
<%= link_to t(".edit_directive"), edit_user_directives_path(current_user), class: "button expanded large" %>
<%= link_to t(".delete_directive"), user_directives_path(current_user), class: "button expanded large", method: :delete %>
View
@@ -31,6 +31,7 @@ en:
create_directive: Create Directive
delete_directive: Delete Directive
edit_directive: Edit Directive
download_directive: Download
directives:
form:
content: Content
@@ -0,0 +1,22 @@
require "rails_helper"
describe DirectivesController do
let(:user) { create :user }
let(:qr_svg_xml) do
url = user_directives_url(user)
qrcode = RQRCode::QRCode.new(url)
qrcode.as_svg(offset: 0, color: "000",
shape_rendering: "crispEdges",
module_size: 9)
end
context "GET #qr_code" do
it "should respond with svg xml" do
get :qr_code, user_id: user.id
expect(subject).to respond_with :ok
expect(response.body).to eq qr_svg_xml
end
end
end
@@ -11,6 +11,24 @@
expect(page).not_to have_link t("application.top_bar.edit_directive")
expect(page).not_to have_link t("application.top_bar.create_directive")
expect(page).not_to have_link t("pages.home.download_directive"),
href: qr_code_user_directives_path(user)
end
scenario "When viewing your own directive" do
visit root_path
click_on "Sign In"
fill_form :user, email: user.email, password: user.password
within "form" do
click_on "Sign In"
end
expect(page).to have_text directive.content
expect(page).to have_link t("application.top_bar.edit_directive")
expect(page).to have_link t("pages.home.download_directive"),
href: qr_code_user_directives_path(user)
end
end

0 comments on commit 1d4189c

Please sign in to comment.