if create_new_report_params.present?
@report = Report.new
@report.issue = Issue.find_or_initialize_by(create_new_report_params)
- path = "issues.report_strings." + @report.issue.reportable.class.name.to_s
- @report_strings_yaml = t(path)
end
end
end
def report_params
- params[:report].permit(:details)
+ params[:report].permit(:details, :category)
end
end
# issue_id :integer
# user_id :integer
# details :text not null
+# category :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
belongs_to :user
validates :details, :presence => true
+ validates :category, :presence => true
+
+ def self.categories_for(reportable)
+ case reportable.class.name
+ when "DiaryEntry" then %w[spam offensive threat other]
+ when "DiaryComment" then %w[spam offensive threat other]
+ when "User" then %w[spam offensive threat vandal other]
+ when "Changeset" then %w[undiscussed_import mechanical_edit edit_error spam vandalism other]
+ when "Note" then %w[spam vandalism personal abusive other]
+ else %w[other]
+ end
+ end
end
On <%= l report.updated_at.to_datetime, :format => :friendly %>
</span>
<br/>
+ <span class="deemphasize">
+ Category: <%= report.category %>
+ </span>
+ <br/>
<%= report.details %>
<br/>
</div>
<p><%= t('issues.new.select') %>:</p>
<div class="new-report-form">
- <% @report_strings_yaml.each do |k,v| %>
+ <% Report.categories_for(@report.issue.reportable).each do |c| %>
<div style="padding-left:5px">
- <%= radio_button_tag :report_type, v[:type].to_s %>
- <%= label_tag v[:details].to_s %> <br/>
+ <%= radio_button :report, :category, c %>
+ <%= label_tag "report_category_#{c}", t("reports.categories.#{@report.issue.reportable.class.name}.#{c}") %> <br/>
</div>
<% end %>
</div>
resolved: Issue status has been set to 'Resolved'
ignored: Issue status has been set to 'Ignored'
reopened: Issue status has been set to 'Open'
- report_strings:
+ reports:
+ categories:
DiaryEntry:
- spam:
- type: "[SPAM]"
- details: This Diary Entry is/contains spam
- offensive:
- type: "[OFFENSIVE]"
- details: This Diary Entry is obscene/offensive
- threat:
- type: "[THREAT]"
- details: This Diary Entry contains a threat
- other:
- type: "[OTHER]"
- details: Other
+ spam: This Diary Entry is/contains spam
+ offensive: This Diary Entry is obscene/offensive
+ threat: This Diary Entry contains a threat
+ other: Other
DiaryComment:
- spam:
- type: "[SPAM]"
- details: This Diary Comment is/contains spam
- offensive:
- type: "[OFFENSIVE]"
- details: This Diary Comment is obscene/offensive
- threat:
- type: "[THREAT]"
- details: This Diary Comment contains a threat
- other:
- type: "[OTHER]"
- details: Other
+ spam: This Diary Comment is/contains spam
+ offensive: This Diary Comment is obscene/offensive
+ threat: This Diary Comment contains a threat
+ other: Other
User:
- spam:
- type: "[SPAM]"
- details: This User profile is/contains spam
- offensive:
- type: "[OFFENSIVE]"
- details: This User profile is obscene/offensive
- threat:
- type: "[THREAT]"
- details: This User profile contains a threat
- vandal:
- type: "[VANDAL]"
- details: This User is a vandal
- other:
- type: "[OTHER]"
- details: Other
+ spam: This User profile is/contains spam
+ offensive: This User profile is obscene/offensive
+ threat: This User profile contains a threat
+ vandal: This User is a vandal
+ other: Other
Changeset:
- undiscussed_import:
- type: "[UNDISCUSSED-IMPORT]"
- details: This changeset is an undiscussed import
- mechanical_edit:
- type: "[MECH-EDIT]"
- details: This changeset is a mechanical edit
- edit_error:
- type: "[EDIT-ERROR]"
- details: This changeset contains a newbie or an editor error
- spam:
- type: "[SPAM]"
- details: This changeset is/contains spam
- vandalism:
- type: "[VANDALISM]"
- details: This changeset is/contains vandalism
- other:
- type: "[OTHER]"
- details: Other
+ undiscussed_import: This changeset is an undiscussed import
+ mechanical_edit: This changeset is a mechanical edit
+ edit_error: This changeset contains a newbie or an editor error
+ spam: This changeset is/contains spam
+ vandalism: This changeset is/contains vandalism
+ other: Other
Note:
- spam:
- type: "[SPAM]"
- details: This note is spam
- vandalism:
- type: "[VANDALISM]"
- details: This note is vandalism
- personal:
- type: "[PERSONAL]"
- details: This note contains personal data
- abusive:
- type: "[ABUSIVE]"
- details: This note is abusive
- other:
- type: "[OTHER]"
- details: Other
+ spam: This note is spam
+ vandalism: This note is vandalism
+ personal: This note contains personal data
+ abusive: This note is abusive
+ other: Other
layouts:
project_name:
# in <title>
t.integer :issue_id
t.integer :user_id
t.text :details, :null => false
+ t.string :category, :null => false
t.timestamps :null => false
end
issue_id integer,
user_id integer,
details text NOT NULL,
+ category character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
+ category = "other"
post :create,
:params => {
:report => {
:details => details,
+ :category => category,
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
}
}
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
+ category = "other"
post :create,
:params => {
:report => {
:details => details,
+ :category => category,
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
}
}
# Report without details
assert_no_difference "Issue.count" do
+ category = "other"
post :create,
:params => {
:report => {
+ :category => category,
:issue => { :reportable_id => 1, :reportable_type => "User" }
}
}
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
+ category = "other"
post :create,
:params => {
:report => {
:details => details,
+ :category => category,
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
}
}
assert_response :success
assert_no_difference "Issue.count" do
details = "Details of another report under the same issue"
+ category = "other"
post :create,
:params => {
:report => {
:details => details,
+ :category => category,
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
}
}
FactoryBot.define do
factory :report do
sequence(:details) { |n| "Report details #{n}" }
+ category "other"
issue
user
end
report.details = ""
assert !report.valid?
end
+
+ def test_category_required
+ report = create(:report)
+
+ assert report.valid?
+ report.category = ""
+ assert !report.valid?
+ end
end
assert page.has_content? "Report"
assert page.has_content? I18n.t("issues.new.disclaimer.intro")
- choose "report_type__SPAM" # FIXME: use label text when the radio button labels are working
+ choose I18n.t("reports.categories.DiaryEntry.spam")
fill_in "report_details", :with => "This is advertising"
click_on "Save changes"