Skip to content

Commit

Permalink
Merge pull request #1237 from projecthydra/guard_zotero_reference
Browse files Browse the repository at this point in the history
Check to make sure Zotero integration is enabled. Fixes #1235
  • Loading branch information
jcoyne committed Jul 9, 2015
2 parents cc429ac + f0dd1f0 commit ca4722f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/users/_user_info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<dd class="col-xs-7"><%= link_to user.orcid, user.orcid, { target: '_blank' } %></dd>
<% end %>

<% if user.zotero_userid.present? %>
<% if Sufia.config.arkivo_api && user.zotero_userid.present? %>
<dt class="col-xs-5"><%= zotero_label(html_class: 'profile') %></dt>
<dd class="col-xs-7"><%= link_to zotero_profile_url(user.zotero_userid), zotero_profile_url(user.zotero_userid), { target: '_blank' } %></dd>
<% end %>
Expand Down
29 changes: 29 additions & 0 deletions spec/views/users/_user_info.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe 'users/_user_info.html.erb', type: :view do
let(:user) { stub_model(User, user_key: 'jdoe42') }

context 'with Zotero disabled' do
before do
allow(Sufia.config).to receive(:arkivo_api) { false }
allow(user).to receive(:zotero_userid).and_raise(NoMethodError)
render "users/user_info", user: user
end

it 'does not display a Zotero profile link' do
expect(rendered).not_to match(/Zotero Profile/)
end
end

context 'with Zotero enabled' do
before do
allow(Sufia.config).to receive(:arkivo_api) { true }
allow(user).to receive(:zotero_userid) { 'jdoe42zotero' }
render "users/user_info", user: user
end

it 'displays a Zotero profile link' do
expect(rendered).to match(/Zotero Profile/)
end
end
end

0 comments on commit ca4722f

Please sign in to comment.