Skip to content
Permalink
Browse files

Making email visible to editors

  • Loading branch information...
arfon committed Jan 28, 2019
1 parent f5355d9 commit 180ccb1d2fa996409f5616dff3dac7c390ff52eb
Showing with 16 additions and 1 deletion.
  1. +5 −1 app/models/user.rb
  2. +2 −0 app/views/papers/_admin.html.erb
  3. +8 −0 spec/models/user_spec.rb
  4. +1 −0 spec/views/papers/show.html.erb_spec.rb
@@ -2,7 +2,7 @@ class User < ActiveRecord::Base

has_many :papers
has_one :editor

before_create :set_sha

def self.from_omniauth(auth)
@@ -42,6 +42,10 @@ def profile_complete?
email.present? && github_username.present?
end

def editor?
self.editor ? true:false
end

private

def set_sha
@@ -14,7 +14,9 @@
<%# button_to "Start review", start_review_paper_path(paper), :class => "btn btn-primary left start-review" %>
<%= button_to "Reject paper", reject_paper_path(paper), :data => { :confirm => "Are you sure?" }, :form_class => "left", :class => "btn btn-danger start-review" %>
<% end %>
<% end %>

<% if current_user.editor? %>
<%= mail_to paper.submitting_author.email if paper.submitting_author.email? %>
<% end %>

@@ -14,6 +14,14 @@
assert !user.admin?
end

it "should know who the editors are" do
user = create(:user)
editor = create(:editor, :user => user)

expect(user.editor).to eq(editor)
expect(user.editor?).to eq(true)
end

it "should know how to parameterize itself properly" do
user = create(:user)

@@ -58,6 +58,7 @@

it "shows the withdraw button to admins" do
user = create(:user, :admin => true)
editor = create(:editor, :user => user)
author = create(:user)
allow(view).to receive_message_chain(:current_user).and_return(user)

0 comments on commit 180ccb1

Please sign in to comment.
You can’t perform that action at this time.