@read_reports = @issue.read_reports
@unread_reports = @issue.unread_reports
@comments = @issue.comments
- @related_issues = @issue.user.issues.where(:issue_type => @user_role)
+ @related_issues = @issue.reported_user.issues.where(:issue_type => @user_role)
@updated_by_admin = User.find(@issue.updated_by) if @issue.updated_by
end
class Issue < ActiveRecord::Base
belongs_to :reportable, :polymorphic => true
- belongs_to :user, :class_name => "User", :foreign_key => :reported_user_id
+ belongs_to :reported_user, :class_name => "User", :foreign_key => :reported_user_id
belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by
has_many :reports, :dependent => :destroy
<td><%= l(issue.updated_at.to_datetime, :format => :friendly) %></td>
<td><% if issue.user_updated %> <%= issue.user_updated.display_name %> <% else %> - <% end %></td>
<td><%= reports_url(issue) %></td>
- <td><%= link_to issue.user.display_name , :controller => :user, :action => :view,:display_name => issue.user.display_name %></td>
+ <td><%= link_to issue.reported_user.display_name , :controller => :user, :action => :view, :display_name => issue.reported_user.display_name %></td>
<td><%= instance_url(issue.reportable) %></td>
</tr>
<% end %>
def test_change_status_by_normal_user
target_user = create(:user)
- issue = create(:issue, :reportable => target_user, :reported_user_id => target_user.id)
+ issue = create(:issue, :reportable => target_user, :reported_user => target_user)
# Login as normal user
session[:user] = create(:user).id
def test_change_status_by_admin
target_user = create(:user)
- issue = create(:issue, :reportable => target_user, :reported_user_id => target_user.id)
+ issue = create(:issue, :reportable => target_user, :reported_user => target_user)
# Login as administrator
session[:user] = create(:administrator_user).id
def test_search_issues
good_user = create(:user)
bad_user = create(:user)
- create(:issue, :reportable => bad_user, :reported_user_id => bad_user.id, :issue_type => "administrator")
+ create(:issue, :reportable => bad_user, :reported_user => bad_user, :issue_type => "administrator")
# Login as administrator
session[:user] = create(:administrator_user).id
factory :issue do
# Default to reporting users
association :reportable, :factory => :user
-
- # reported_user_id
- association :user, :factory => :user
+ association :reported_user, :factory => :user
end
end