diff --git a/app/views/users/_user_info.html.erb b/app/views/users/_user_info.html.erb index 3a4db894eb..e9f6c33d5c 100644 --- a/app/views/users/_user_info.html.erb +++ b/app/views/users/_user_info.html.erb @@ -5,7 +5,7 @@
<%= link_to user.orcid, user.orcid, { target: '_blank' } %>
<% end %> -<% if user.zotero_userid.present? %> +<% if Sufia.config.arkivo_api && user.zotero_userid.present? %>
<%= zotero_label(html_class: 'profile') %>
<%= link_to zotero_profile_url(user.zotero_userid), zotero_profile_url(user.zotero_userid), { target: '_blank' } %>
<% end %> diff --git a/spec/views/users/_user_info.html.erb_spec.rb b/spec/views/users/_user_info.html.erb_spec.rb new file mode 100644 index 0000000000..30dd3b39a1 --- /dev/null +++ b/spec/views/users/_user_info.html.erb_spec.rb @@ -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