From 757a1aaa850bf48e45ee1dd2225cda1c9fa47d73 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 22 Aug 2016 17:23:38 +0100 Subject: [PATCH] Made rubocop happy by formatting and minor syntax tweaks. --- Vagrantfile | 1 - app/controllers/diary_entry_controller.rb | 2 +- app/controllers/issues_controller.rb | 236 +++++---- app/helpers/issues_helper.rb | 171 +++---- app/models/issue.rb | 81 ++-- app/models/issue_comment.rb | 6 +- app/models/notifier.rb | 3 +- app/models/report.rb | 5 +- app/models/user.rb | 2 +- config/routes.rb | 4 +- ...0160822153055_create_issues_and_reports.rb | 11 +- .../20160822153115_create_issue_comments.rb | 11 +- ...160822153153_add_report_count_to_issues.rb | 4 +- db/structure.sql | 447 ++++++++---------- test/controllers/issues_controller_test.rb | 137 +++--- test/models/issue_comment_test.rb | 2 +- test/models/issue_test.rb | 2 +- test/models/report_test.rb | 2 +- 18 files changed, 515 insertions(+), 612 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 7b033146c..2d450ec4a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : - Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "8192"] diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index ed5a64057..105ddb590 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -153,7 +153,7 @@ class DiaryEntryController < ApplicationController if @entry @title = t "diary_entry.view.title", :user => params[:display_name], :title => @entry.title if params[:comment_id] - @reported_comment = DiaryComment.where(id: params[:comment_id]) + @reported_comment = DiaryComment.where(:id => params[:comment_id]) end else @title = t "diary_entry.no_such_entry.title", :id => params[:id] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 81bf7606c..d31326a7d 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -4,122 +4,112 @@ class IssuesController < ApplicationController before_action :authorize_web before_action :require_user before_action :set_issues - before_action :check_permission, only: [:index, :show, :resolve,:open,:ignore,:comment] - before_action :find_issue, only: [:show, :resolve, :reopen, :ignore] - before_action :get_user_role, only: [:show, :index] + before_action :check_permission, :only => [:index, :show, :resolve, :open, :ignore, :comment] + before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore] + before_action :setup_user_role, :only => [:show, :index] helper_method :sort_column, :sort_direction def index if @user.moderator? @issue_types = @moderator_issues - @users = User.joins(:roles).where(user_roles: {role: 'moderator'}) + @users = User.joins(:roles).where(:user_roles => { :role => "moderator" }) else @issue_types = @admin_issues - @users = User.joins(:roles).where(user_roles: {role: 'administrator'}) + @users = User.joins(:roles).where(:user_roles => { :role => "administrator" }) end - @issues = Issue.where(issue_type: @user_role).order(sort_column + " " + sort_direction) + @issues = Issue.where(:issue_type => @user_role).order(sort_column + " " + sort_direction) # If search - if params[:search_by_user] and !params[:search_by_user].blank? + if params[:search_by_user] && !params[:search_by_user].blank? @find_user = User.find_by_display_name(params[:search_by_user]) if @find_user - @issues = @issues.where(reported_user_id: @find_user.id) - else - notice = t('issues.index.search.user_not_found') + @issues = @issues.where(:reported_user_id => @find_user.id) + else + notice = t("issues.index.search.user_not_found") end end - - if params[:status] and !params[:status][0].blank? - @issues = @issues.where(status: params[:status][0].to_i) + if params[:status] && !params[:status][0].blank? + @issues = @issues.where(:status => params[:status][0].to_i) end - if params[:issue_type] and !params[:issue_type][0].blank? - @issues = @issues.where(reportable_type: params[:issue_type][0]) + if params[:issue_type] && !params[:issue_type][0].blank? + @issues = @issues.where(:reportable_type => params[:issue_type][0]) end # If last_updated_by - if params[:last_updated_by] and !params[:last_updated_by][0].blank? - last_reported_by = params[:last_updated_by][0].to_s == "nil" ? nil : params[:last_updated_by][0].to_i - @issues = @issues.where(updated_by: last_updated_by) + if params[:last_updated_by] && !params[:last_updated_by][0].blank? + last_updated_by = params[:last_updated_by][0].to_s == "nil" ? nil : params[:last_updated_by][0].to_i + @issues = @issues.where(:updated_by => last_updated_by) end - if @issues.first == nil - notice = t('issues.index.search.issues_not_found') - end + notice = t("issues.index.search.issues_not_found") if @issues.first.nil? - if params[:last_reported_by] and !params[:last_reported_by][0].blank? + if params[:last_reported_by] && !params[:last_reported_by][0].blank? last_reported_by = params[:last_reported_by][0].to_s == "nil" ? nil : params[:last_reported_by][0].to_i - @issues = @issues.where(updated_by: last_reported_by) + @issues = @issues.where(:updated_by => last_reported_by) end - if notice - redirect_to issues_path, notice: notice - end + redirect_to issues_path, :notice => notice if notice end def show @read_reports = @issue.read_reports @unread_reports = @issue.unread_reports @comments = @issue.comments - @related_issues = @issue.user.issues.where(issue_type: @user_role) - if @issue.updated_by - @updated_by_admin = User.find(@issue.updated_by) - end + @related_issues = @issue.user.issues.where(:issue_type => @user_role) + + @updated_by_admin = User.find(@issue.updated_by) if @issue.updated_by end def new unless create_new_issue_params.blank? @issue = Issue.find_or_initialize_by(create_new_issue_params) - path = 'issues.report_strings.' + @issue.reportable.class.name.to_s + path = "issues.report_strings." + @issue.reportable.class.name.to_s @report_strings_yaml = t(path) flash[:referer] = params[:referer] end end def create - @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id],params[:reportable_type]) + @issue = Issue.find_by_reportable_id_and_reportable_type(params[:reportable_id], params[:reportable_type]) # Check if Issue already exists - if !@issue + unless @issue @issue = Issue.find_or_initialize_by(issue_params) @issue.updated_by = nil # Reassign to moderators if it is a moderator issue @issue.issue_type = "administrator" - if @moderator_issues.include? @issue.reportable.class.name - reassign_issue - end + reassign_issue if @moderator_issues.include? @issue.reportable.class.name end # Check if details provided are sufficient if check_report_params @report = @issue.reports.build(report_params) - details = get_report_details + details = report_details @report.reporter_user_id = @user.id @report.details = details # Checking if instance has been updated since last report - @last_report = @issue.reports.order(updated_at: :desc).last + @last_report = @issue.reports.order(:updated_at => :desc).last if check_if_updated - if @issue.reopen - @issue.save! - end + @issue.save! if @issue.reopen end if @issue.save! @issue.report_count = @issue.reports.count @issue.save! - - @admins_or_mods = UserRole.where(role: @issue.issue_type) + + @admins_or_mods = UserRole.where(:role => @issue.issue_type) @admins_or_mods.each do |user| Notifier.new_issue_notification(@issue.id, User.find(user.user_id)).deliver_now end - redirect_to flash[:referer], notice: t('issues.create.successful_report') + redirect_to flash[:referer], :notice => t("issues.create.successful_report") end else - redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.create.provide_details') + redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id, :reported_user_id => @issue.reported_user_id), :notice => t("issues.create.provide_details") end end @@ -127,43 +117,40 @@ class IssuesController < ApplicationController @issue = Issue.find_by(issue_params) # Check if details provided are sufficient if check_report_params - @report = @issue.reports.where(reporter_user_id: @user.id).first - - if @report == nil + @report = @issue.reports.where(:reporter_user_id => @user.id).first + + if @report.nil? @report = @issue.reports.build(report_params) @report.reporter_user_id = @user.id - notice = t('issues.update.new_report') + notice = t("issues.update.new_report") end - details = get_report_details - @report.details = details + details = report_details + @report.details = details - # Checking if instance has been updated since last report - @last_report = @issue.reports.order(updated_at: :desc).last + # Checking if instance has been updated since last report + @last_report = @issue.reports.order(:updated_at => :desc).last if check_if_updated @issue.reopen @issue.save! end - if notice == nil - notice = t('issues.update.successful_update') - end - + notice = t("issues.update.successful_update") if notice.nil? if @report.save! @issue.report_count = @issue.reports.count @issue.save! - redirect_to flash[:referer], notice: notice + redirect_to flash[:referer], :notice => notice end else - redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.update.provide_details') - end + redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id, :reported_user_id => @issue.reported_user_id), :notice => t("issues.update.provide_details") + end end def comment @issue = Issue.find(params[:id]) if issue_comment_params.blank? - notice = t('issues.comment.provide_details') + notice = t("issues.comment.provide_details") else @issue_comment = @issue.comments.build(issue_comment_params) @issue_comment.commenter_user_id = @user.id @@ -174,16 +161,16 @@ class IssuesController < ApplicationController @issue_comment.save! @issue.updated_by = @user.id @issue.save! - notice = t('issues.comment.comment_created') + notice = t("issues.comment.comment_created") end - redirect_to @issue, notice: notice + redirect_to @issue, :notice => notice end # Status Transistions def resolve if @issue.resolve @issue.save! - redirect_to @issue, notice: t('issues.resolved') + redirect_to @issue, :notice => t("issues.resolved") else render :show end @@ -193,7 +180,7 @@ class IssuesController < ApplicationController if @issue.ignore @issue.updated_by = @user.id @issue.save! - redirect_to @issue, notice: t('issues.ignored') + redirect_to @issue, :notice => t("issues.ignored") else render :show end @@ -201,9 +188,9 @@ class IssuesController < ApplicationController def reopen if @issue.reopen - @issue.updated_by = @user.id + @issue.updated_by = @user.id @issue.save! - redirect_to @issue, notice: t('issues.reopened') + redirect_to @issue, :notice => t("issues.reopened") else render :show end @@ -211,83 +198,78 @@ class IssuesController < ApplicationController # Reassign Issues between Administrators and Moderators def reassign_issue - if @issue.issue_type == "moderator" - @issue.issue_type = "administrator" - else - @issue.issue_type = "moderator" - end + @issue.issue_type = upgrade_issue(@issue.issue_type) @issue.save! end private - def set_issues - @admin_issues = [ 'DiaryEntry', 'DiaryComment', 'User'] - @moderator_issues = [ 'Changeset', 'Note' ] + def upgrade_issue(type) + if type == "moderator" + "administrator" + else + "moderator" end + end - def get_user_role - # Get user role - if @user.administrator? - @user_role = "administrator" - else - @user_role = "moderator" - end - end - - def check_if_updated - if @issue.reportable and (@issue.ignored? or @issue.resolved?) and @issue.reportable.has_attribute?(:updated_by) and @issue.reportable.updated_at > @last_report.updated_at - return true - else - return false - end - end - - def get_report_details - details = params[:report][:details] + "--||--" - details = details + params[:report_type].to_s + "--||--" - return details - end + def set_issues + @admin_issues = %w(DiaryEntry DiaryComment User) + @moderator_issues = %w(Changeset Note) + end - def check_report_params - if params[:report] and params[:report][:details] and params[:report_type] - return true - end + def setup_user_role + # Get user role + @user_role = @user.administrator? ? "administrator" : "moderator" + end + + def check_if_updated + if @issue.reportable && (@issue.ignored? || @issue.resolved?) && @issue.reportable.has_attribute?(:updated_by) && @issue.reportable.updated_at > @last_report.updated_at + return true + else return false end + end - def find_issue - @issue = Issue.find(params[:id]) - end + def report_details + params[:report][:details] + "--||--" + params[:report_type].to_s + "--||--" + end - def check_permission - unless @user.administrator? or @user.moderator? - flash[:error] = t('application.require_admin.not_an_admin') - redirect_to root_path - end - end + def check_report_params + params[:report] && params[:report][:details] && params[:report_type] + end - def create_new_issue_params - params.permit(:reportable_id, :reportable_type, :reported_user_id) - end + def find_issue + @issue = Issue.find(params[:id]) + end - def issue_params - params[:issue].permit(:reportable_id, :reportable_type,:reported_user_id) + def check_permission + unless @user.administrator? || @user.moderator? + flash[:error] = t("application.require_admin.not_an_admin") + redirect_to root_path end + end - def report_params - params[:report].permit(:details) - end + def create_new_issue_params + params.permit(:reportable_id, :reportable_type, :reported_user_id) + end - def issue_comment_params - params.require(:issue_comment).permit(:body) - end + def issue_params + params[:issue].permit(:reportable_id, :reportable_type, :reported_user_id) + end - def sort_column - Issue.column_names.include?(params[:sort]) ? params[:sort] : "status" - end + def report_params + params[:report].permit(:details) + end - def sort_direction - %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" - end + def issue_comment_params + params.require(:issue_comment).permit(:body) + end + + def sort_column + Issue.column_names.include?(params[:sort]) ? params[:sort] : "status" + end + + def sort_direction + %w(asc desc).include?(params[:direction]) ? params[:direction] : "asc" + end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 92fe74ca7..f34510154 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,109 +1,74 @@ module IssuesHelper + def reportable_url(reportable) + class_name = reportable.class.name + case class_name + when "DiaryEntry" + link_to reportable.title, :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id + when "User" + link_to reportable.display_name.to_s, :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name + when "DiaryComment" + link_to "#{reportable.diary_entry.title}, Comment id ##{reportable.id}", :controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :comment_id => reportable.id + when "Changeset" + link_to "Changeset ##{reportable.id}", :controller => :browse, :action => :changeset, :id => reportable.id + when "Note" + link_to "Note ##{reportable.id}", :controller => :browse, :action => :note, :id => reportable.id + end + end - def reportable_url(reportable) - class_name = reportable.class.name - case class_name - when "DiaryEntry" - link_to reportable.title, :controller => reportable.class.name.underscore, - :action => :view, - :display_name => reportable.user.display_name, - :id => reportable.id - when "User" - link_to reportable.display_name.to_s, :controller => reportable.class.name.underscore, - :action => :view, - :display_name => reportable.display_name - when "DiaryComment" - link_to "#{reportable.diary_entry.title}, Comment id ##{reportable.id}", :controller => reportable.diary_entry.class.name.underscore, - :action => :view, - :display_name => reportable.diary_entry.user.display_name, - :id => reportable.diary_entry.id, - :comment_id => reportable.id - when "Changeset" - link_to "Changeset ##{reportable.id}", :controller => :browse, - :action => :changeset, - :id => reportable.id - when "Note" - link_to "Note ##{reportable.id}", :controller => :browse, - :action => :note, - :id => reportable.id - else - nil - end - end + def reports_url(issue) + class_name = issue.reportable.class.name + case class_name + when "DiaryEntry" + link_to issue.reportable.title, issue + when "User" + link_to issue.reportable.display_name.to_s, issue + when "DiaryComment" + link_to "#{issue.reportable.diary_entry.title}, Comment id ##{issue.reportable.id}", issue + when "Changeset" + link_to "Changeset ##{issue.reportable.id}", issue + when "Note" + link_to "Note ##{issue.reportable.id}", issue + end + end - def reports_url(issue) - class_name = issue.reportable.class.name - case class_name - when "DiaryEntry" - link_to issue.reportable.title, issue - when "User" - link_to issue.reportable.display_name.to_s, issue - when "DiaryComment" - link_to "#{issue.reportable.diary_entry.title}, Comment id ##{issue.reportable.id}", issue - when "Changeset" - link_to "Changeset ##{issue.reportable.id}",issue - when "Note" - link_to "Note ##{issue.reportable.id}", issue - else - nil - end - end + def instance_url(reportable) + class_name = reportable.class.name + case class_name + when "DiaryEntry" + link_to "Show Instance", :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id + when "User" + link_to "Show Instance", :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name + when "DiaryComment" + link_to "Show Instance", :controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :comment_id => reportable.id + when "Changeset" + link_to "Show Instance", :controller => :browse, :action => :changeset, :id => reportable.id + when "Note" + link_to "Show Instance", :controller => :browse, :action => :note, :id => reportable.id + end + end - def instance_url(reportable) - class_name = reportable.class.name - case class_name - when "DiaryEntry" - link_to "Show Instance", :controller => reportable.class.name.underscore, - :action => :view, - :display_name => reportable.user.display_name, - :id => reportable.id - when "User" - link_to "Show Instance", :controller => reportable.class.name.underscore, - :action => :view, - :display_name => reportable.display_name - when "DiaryComment" - link_to "Show Instance", :controller => reportable.diary_entry.class.name.underscore, - :action => :view, - :display_name => reportable.diary_entry.user.display_name, - :id => reportable.diary_entry.id, - :comment_id => reportable.id - when "Changeset" - link_to "Show Instance", :controller => :browse, - :action => :changeset, - :id => reportable.id - when "Note" - link_to "Show Instance", :controller => :browse, - :action => :note, - :id => reportable.id - else - nil - end - end + def sortable(column, title = nil) + title ||= column.titleize + direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" + if column == sort_column + arrow = direction == "desc" ? ["25B2".hex].pack("U") : ["25BC".hex].pack("U") + title += arrow + end + link_to title, params.merge(:sort => column, :direction => direction) + end - def sortable(column,title=nil) - title ||= column.titleize - direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" - if column == sort_column - arrow = direction == "desc" ? ["25B2".hex].pack("U") : ["25BC".hex].pack("U") - title = title + arrow - end - link_to title, params.merge(:sort => column, :direction => direction) - end - - def report_type(report_class) - case report_class - when "DiaryEntry" - t('activerecord.models.diary_entry') - when "User" - t('activerecord.models.user') - when "DiaryComment" - t('activerecord.models.diary_comment') - when "Changeset" - t('activerecord.models.changeset') - when "Note" - t('activerecord.models.note') - else - nil - end - end + def report_type(report_class) + case report_class + when "DiaryEntry" + t("activerecord.models.diary_entry") + when "User" + t("activerecord.models.user") + when "DiaryComment" + t("activerecord.models.diary_comment") + when "Changeset" + t("activerecord.models.changeset") + when "Note" + t("activerecord.models.note") + end + end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 690a02477..963a27a6e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,49 +1,48 @@ class Issue < ActiveRecord::Base - belongs_to :reportable, :polymorphic => true - belongs_to :user, :class_name => "User", :foreign_key => :reported_user_id - belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by + belongs_to :reportable, :polymorphic => true + belongs_to :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 - has_many :comments, :class_name => "IssueComment", dependent: :destroy - - validates :reportable_id, :uniqueness => { :scope => [ :reportable_type ] } - validates :reported_user_id, :presence => true + has_many :reports, :dependent => :destroy + has_many :comments, :class_name => "IssueComment", :dependent => :destroy - # Check if more statuses are needed - enum status: %w( open ignored resolved ) - enum type: %w( administrator moderator ) + validates :reportable_id, :uniqueness => { :scope => [:reportable_type] } + validates :reported_user_id, :presence => true - scope :with_status, -> (issue_status) { where(:status => statuses[issue_status])} + # Check if more statuses are needed + enum :status => %w(open ignored resolved) + enum :type => %w(administrator moderator) - def read_reports - resolved_at.present? ? reports.where("updated_at < ?", resolved_at) : nil - end + scope :with_status, -> (issue_status) { where(:status => statuses[issue_status]) } - def unread_reports + def read_reports + resolved_at.present? ? reports.where("updated_at < ?", resolved_at) : nil + end + + def unread_reports resolved_at.present? ? reports.where("updated_at >= ?", resolved_at) : reports - end - - include AASM - aasm :column => :status, :no_direct_assignment => true do - state :open, :initial => true - state :ignored - state :resolved - - event :ignore do - transitions :from => :open, :to => :ignored - end - - event :resolve do - transitions :from => :open, :to => :resolved - after do - self.resolved_at = Time.now.getutc - end - end - - event :reopen do - transitions :from => :resolved, :to => :open - transitions :from => :ignored, :to => :open - end - - end + end + + include AASM + aasm :column => :status, :no_direct_assignment => true do + state :open, :initial => true + state :ignored + state :resolved + + event :ignore do + transitions :from => :open, :to => :ignored + end + + event :resolve do + transitions :from => :open, :to => :resolved + after do + self.resolved_at = Time.now.getutc + end + end + + event :reopen do + transitions :from => :resolved, :to => :open + transitions :from => :ignored, :to => :open + end + end end diff --git a/app/models/issue_comment.rb b/app/models/issue_comment.rb index 866a85b84..2122a6489 100644 --- a/app/models/issue_comment.rb +++ b/app/models/issue_comment.rb @@ -1,6 +1,6 @@ class IssueComment < ActiveRecord::Base - belongs_to :issue - belongs_to :user, :class_name => "User", :foreign_key => :commenter_user_id + belongs_to :issue + belongs_to :user, :class_name => "User", :foreign_key => :commenter_user_id - validates :body, :presence => true + validates :body, :presence => true end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index b3648aa5c..1b1da7b5e 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -172,7 +172,7 @@ class Notifier < ActionMailer::Base end end - def new_issue_notification(issue_id,recipient) + def new_issue_notification(issue_id, recipient) with_recipient_locale recipient do @url = url_for(:host => SERVER_URL, :controller => "issues", @@ -198,5 +198,4 @@ class Notifier < ActionMailer::Base EMAIL_FROM end end - end diff --git a/app/models/report.rb b/app/models/report.rb index f997215a8..fa90cf04e 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,5 +1,4 @@ class Report < ActiveRecord::Base - belongs_to :issue - belongs_to :user, :class_name => "User", :foreign_key => :reporter_user_id - + belongs_to :issue + belongs_to :user, :class_name => "User", :foreign_key => :reporter_user_id end diff --git a/app/models/user.rb b/app/models/user.rb index 1c38ea1cc..6fbf8eecb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,7 +29,7 @@ class User < ActiveRecord::Base has_many :issues, :class_name => "Issue", :foreign_key => :reported_user_id has_one :issue, :class_name => "Issue", :foreign_key => :updated_by has_many :issue_comments - + has_many :reports scope :visible, -> { where(:status => %w(pending active confirmed)) } diff --git a/config/routes.rb b/config/routes.rb index 468b99327..7692ebdad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -297,8 +297,8 @@ OpenStreetMap::Application.routes.draw do post "reopen" end end - - post '/comment' => 'issues#comment' + + post "/comment" => "issues#comment" # redactions resources :redactions diff --git a/db/migrate/20160822153055_create_issues_and_reports.rb b/db/migrate/20160822153055_create_issues_and_reports.rb index 1fce3d051..aa7af1a73 100644 --- a/db/migrate/20160822153055_create_issues_and_reports.rb +++ b/db/migrate/20160822153055_create_issues_and_reports.rb @@ -14,10 +14,10 @@ class CreateIssuesAndReports < ActiveRecord::Migration t.datetime :updated_at t.integer :updated_by - t.timestamps null: false + t.timestamps :null => false end - add_foreign_key :issues, :users, :column => :reported_user_id,:name => "issues_reported_user_id_fkey", on_delete: :cascade + add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey", :on_delete => :cascade add_index :issues, :reported_user_id add_index :issues, [:reportable_id, :reportable_type] @@ -29,14 +29,13 @@ class CreateIssuesAndReports < ActiveRecord::Migration t.datetime :created_at t.datetime :updated_at - t.timestamps null: false + t.timestamps :null => false end - add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey", on_delete: :cascade - add_foreign_key :reports, :users,:column => :reporter_user_id, :name => "reports_reporter_user_id_fkey", on_delete: :cascade + add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey", :on_delete => :cascade + add_foreign_key :reports, :users, :column => :reporter_user_id, :name => "reports_reporter_user_id_fkey", :on_delete => :cascade add_index :reports, :reporter_user_id add_index :reports, :issue_id - end end diff --git a/db/migrate/20160822153115_create_issue_comments.rb b/db/migrate/20160822153115_create_issue_comments.rb index 98b2afd10..57e35f48b 100644 --- a/db/migrate/20160822153115_create_issue_comments.rb +++ b/db/migrate/20160822153115_create_issue_comments.rb @@ -6,14 +6,13 @@ class CreateIssueComments < ActiveRecord::Migration t.text :body t.datetime :created_at t.boolean :reassign - t.timestamps null: false + t.timestamps :null => false end - add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", on_delete: :cascade - add_foreign_key :issue_comments, :users,:column => :commenter_user_id, :name => "issue_comments_commenter_user_id", on_delete: :cascade - - add_index :issue_comments, :commenter_user_id - add_index :issue_comments, :issue_id + add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", :on_delete => :cascade + add_foreign_key :issue_comments, :users, :column => :commenter_user_id, :name => "issue_comments_commenter_user_id", :on_delete => :cascade + add_index :issue_comments, :commenter_user_id + add_index :issue_comments, :issue_id end end diff --git a/db/migrate/20160822153153_add_report_count_to_issues.rb b/db/migrate/20160822153153_add_report_count_to_issues.rb index f7ee556cf..17a1151e7 100644 --- a/db/migrate/20160822153153_add_report_count_to_issues.rb +++ b/db/migrate/20160822153153_add_report_count_to_issues.rb @@ -1,7 +1,7 @@ class AddReportCountToIssues < ActiveRecord::Migration def change add_column :issues, :report_count, :integer, :default => 0 - add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", on_delete: :cascade - add_index :issues, :updated_by + add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", :on_delete => :cascade + add_index :issues, :updated_by end end diff --git a/db/structure.sql b/db/structure.sql index 3ee7b9ac6..8c43c1764 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2,16 +2,12 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.5.3 --- Dumped by pg_dump version 9.5.3 - SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -SET row_security = off; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - @@ -27,20 +23,6 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; --- --- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public; - - --- --- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST'; - - SET search_path = public, pg_catalog; -- @@ -124,47 +106,20 @@ CREATE TYPE user_status_enum AS ENUM ( ); --- --- Name: maptile_for_point(bigint, bigint, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer - LANGUAGE c STRICT - AS '$libdir/libpgosm', 'maptile_for_point'; - - --- --- Name: tile_for_point(integer, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint - LANGUAGE c STRICT - AS '$libdir/libpgosm', 'tile_for_point'; - - --- --- Name: xid_to_int4(xid); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION xid_to_int4(xid) RETURNS integer - LANGUAGE c IMMUTABLE STRICT - AS '$libdir/libpgosm', 'xid_to_int4'; - - SET default_tablespace = ''; SET default_with_oids = false; -- --- Name: acls; Type: TABLE; Schema: public; Owner: - +-- Name: acls; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE acls ( id integer NOT NULL, address inet, - k character varying(255) NOT NULL, - v character varying(255), - domain character varying(255) + k character varying NOT NULL, + v character varying, + domain character varying ); @@ -188,7 +143,7 @@ ALTER SEQUENCE acls_id_seq OWNED BY acls.id; -- --- Name: changeset_comments; Type: TABLE; Schema: public; Owner: - +-- Name: changeset_comments; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE changeset_comments ( @@ -221,18 +176,18 @@ ALTER SEQUENCE changeset_comments_id_seq OWNED BY changeset_comments.id; -- --- Name: changeset_tags; Type: TABLE; Schema: public; Owner: - +-- Name: changeset_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE changeset_tags ( changeset_id bigint NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL ); -- --- Name: changesets; Type: TABLE; Schema: public; Owner: - +-- Name: changesets; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE changesets ( @@ -268,7 +223,7 @@ ALTER SEQUENCE changesets_id_seq OWNED BY changesets.id; -- --- Name: changesets_subscribers; Type: TABLE; Schema: public; Owner: - +-- Name: changesets_subscribers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE changesets_subscribers ( @@ -278,15 +233,15 @@ CREATE TABLE changesets_subscribers ( -- --- Name: client_applications; Type: TABLE; Schema: public; Owner: - +-- Name: client_applications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE client_applications ( id integer NOT NULL, - name character varying(255), - url character varying(255), - support_url character varying(255), - callback_url character varying(255), + name character varying, + url character varying, + support_url character varying, + callback_url character varying, key character varying(50), secret character varying(50), user_id integer, @@ -322,18 +277,18 @@ ALTER SEQUENCE client_applications_id_seq OWNED BY client_applications.id; -- --- Name: current_node_tags; Type: TABLE; Schema: public; Owner: - +-- Name: current_node_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_node_tags ( node_id bigint NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL ); -- --- Name: current_nodes; Type: TABLE; Schema: public; Owner: - +-- Name: current_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_nodes ( @@ -368,31 +323,31 @@ ALTER SEQUENCE current_nodes_id_seq OWNED BY current_nodes.id; -- --- Name: current_relation_members; Type: TABLE; Schema: public; Owner: - +-- Name: current_relation_members; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_relation_members ( relation_id bigint NOT NULL, member_type nwr_enum NOT NULL, member_id bigint NOT NULL, - member_role character varying(255) NOT NULL, + member_role character varying NOT NULL, sequence_id integer DEFAULT 0 NOT NULL ); -- --- Name: current_relation_tags; Type: TABLE; Schema: public; Owner: - +-- Name: current_relation_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_relation_tags ( relation_id bigint NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL ); -- --- Name: current_relations; Type: TABLE; Schema: public; Owner: - +-- Name: current_relations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_relations ( @@ -424,7 +379,7 @@ ALTER SEQUENCE current_relations_id_seq OWNED BY current_relations.id; -- --- Name: current_way_nodes; Type: TABLE; Schema: public; Owner: - +-- Name: current_way_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_way_nodes ( @@ -435,18 +390,18 @@ CREATE TABLE current_way_nodes ( -- --- Name: current_way_tags; Type: TABLE; Schema: public; Owner: - +-- Name: current_way_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_way_tags ( way_id bigint NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL ); -- --- Name: current_ways; Type: TABLE; Schema: public; Owner: - +-- Name: current_ways; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE current_ways ( @@ -478,7 +433,7 @@ ALTER SEQUENCE current_ways_id_seq OWNED BY current_ways.id; -- --- Name: diary_comments; Type: TABLE; Schema: public; Owner: - +-- Name: diary_comments; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE diary_comments ( @@ -513,19 +468,19 @@ ALTER SEQUENCE diary_comments_id_seq OWNED BY diary_comments.id; -- --- Name: diary_entries; Type: TABLE; Schema: public; Owner: - +-- Name: diary_entries; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE diary_entries ( id bigint NOT NULL, user_id bigint NOT NULL, - title character varying(255) NOT NULL, + title character varying NOT NULL, body text NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, latitude double precision, longitude double precision, - language_code character varying(255) DEFAULT 'en'::character varying NOT NULL, + language_code character varying DEFAULT 'en'::character varying NOT NULL, visible boolean DEFAULT true NOT NULL, body_format format_enum DEFAULT 'markdown'::format_enum NOT NULL ); @@ -551,7 +506,7 @@ ALTER SEQUENCE diary_entries_id_seq OWNED BY diary_entries.id; -- --- Name: friends; Type: TABLE; Schema: public; Owner: - +-- Name: friends; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE friends ( @@ -581,7 +536,7 @@ ALTER SEQUENCE friends_id_seq OWNED BY friends.id; -- --- Name: gps_points; Type: TABLE; Schema: public; Owner: - +-- Name: gps_points; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE gps_points ( @@ -596,12 +551,12 @@ CREATE TABLE gps_points ( -- --- Name: gpx_file_tags; Type: TABLE; Schema: public; Owner: - +-- Name: gpx_file_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE gpx_file_tags ( gpx_id bigint DEFAULT 0 NOT NULL, - tag character varying(255) NOT NULL, + tag character varying NOT NULL, id bigint NOT NULL ); @@ -626,19 +581,19 @@ ALTER SEQUENCE gpx_file_tags_id_seq OWNED BY gpx_file_tags.id; -- --- Name: gpx_files; Type: TABLE; Schema: public; Owner: - +-- Name: gpx_files; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE gpx_files ( id bigint NOT NULL, user_id bigint NOT NULL, visible boolean DEFAULT true NOT NULL, - name character varying(255) DEFAULT ''::character varying NOT NULL, + name character varying DEFAULT ''::character varying NOT NULL, size bigint, latitude double precision, longitude double precision, "timestamp" timestamp without time zone NOT NULL, - description character varying(255) DEFAULT ''::character varying NOT NULL, + description character varying DEFAULT ''::character varying NOT NULL, inserted boolean NOT NULL, visibility gpx_visibility_enum DEFAULT 'public'::gpx_visibility_enum NOT NULL ); @@ -737,24 +692,24 @@ ALTER SEQUENCE issues_id_seq OWNED BY issues.id; -- --- Name: languages; Type: TABLE; Schema: public; Owner: - +-- Name: languages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE languages ( - code character varying(255) NOT NULL, - english_name character varying(255) NOT NULL, - native_name character varying(255) + code character varying NOT NULL, + english_name character varying NOT NULL, + native_name character varying ); -- --- Name: messages; Type: TABLE; Schema: public; Owner: - +-- Name: messages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE messages ( id bigint NOT NULL, from_user_id bigint NOT NULL, - title character varying(255) NOT NULL, + title character varying NOT NULL, body text NOT NULL, sent_on timestamp without time zone NOT NULL, message_read boolean DEFAULT false NOT NULL, @@ -785,19 +740,19 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id; -- --- Name: node_tags; Type: TABLE; Schema: public; Owner: - +-- Name: node_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE node_tags ( node_id bigint NOT NULL, version bigint NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL ); -- --- Name: nodes; Type: TABLE; Schema: public; Owner: - +-- Name: nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE nodes ( @@ -814,11 +769,11 @@ CREATE TABLE nodes ( -- --- Name: note_comments; Type: TABLE; Schema: public; Owner: - +-- Name: note_comments; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE note_comments ( - id integer NOT NULL, + id bigint NOT NULL, note_id bigint NOT NULL, visible boolean NOT NULL, created_at timestamp without time zone NOT NULL, @@ -849,11 +804,11 @@ ALTER SEQUENCE note_comments_id_seq OWNED BY note_comments.id; -- --- Name: notes; Type: TABLE; Schema: public; Owner: - +-- Name: notes; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE notes ( - id integer NOT NULL, + id bigint NOT NULL, latitude integer NOT NULL, longitude integer NOT NULL, tile bigint NOT NULL, @@ -884,12 +839,12 @@ ALTER SEQUENCE notes_id_seq OWNED BY notes.id; -- --- Name: oauth_nonces; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_nonces; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE oauth_nonces ( id integer NOT NULL, - nonce character varying(255), + nonce character varying, "timestamp" integer, created_at timestamp without time zone, updated_at timestamp without time zone @@ -916,7 +871,7 @@ ALTER SEQUENCE oauth_nonces_id_seq OWNED BY oauth_nonces.id; -- --- Name: oauth_tokens; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_tokens; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE oauth_tokens ( @@ -936,9 +891,9 @@ CREATE TABLE oauth_tokens ( allow_write_api boolean DEFAULT false NOT NULL, allow_read_gpx boolean DEFAULT false NOT NULL, allow_write_gpx boolean DEFAULT false NOT NULL, - callback_url character varying(255), + callback_url character varying, verifier character varying(20), - scope character varying(255), + scope character varying, valid_to timestamp without time zone, allow_write_notes boolean DEFAULT false NOT NULL ); @@ -964,15 +919,15 @@ ALTER SEQUENCE oauth_tokens_id_seq OWNED BY oauth_tokens.id; -- --- Name: redactions; Type: TABLE; Schema: public; Owner: - +-- Name: redactions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE redactions ( id integer NOT NULL, - title character varying(255), + title character varying, description text, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, + created_at timestamp without time zone, + updated_at timestamp without time zone, user_id bigint NOT NULL, description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL ); @@ -998,33 +953,33 @@ ALTER SEQUENCE redactions_id_seq OWNED BY redactions.id; -- --- Name: relation_members; Type: TABLE; Schema: public; Owner: - +-- Name: relation_members; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE relation_members ( relation_id bigint DEFAULT 0 NOT NULL, member_type nwr_enum NOT NULL, member_id bigint NOT NULL, - member_role character varying(255) NOT NULL, + member_role character varying NOT NULL, version bigint DEFAULT 0 NOT NULL, sequence_id integer DEFAULT 0 NOT NULL ); -- --- Name: relation_tags; Type: TABLE; Schema: public; Owner: - +-- Name: relation_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE relation_tags ( relation_id bigint DEFAULT 0 NOT NULL, - k character varying(255) DEFAULT ''::character varying NOT NULL, - v character varying(255) DEFAULT ''::character varying NOT NULL, + k character varying DEFAULT ''::character varying NOT NULL, + v character varying DEFAULT ''::character varying NOT NULL, version bigint NOT NULL ); -- --- Name: relations; Type: TABLE; Schema: public; Owner: - +-- Name: relations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE relations ( @@ -1071,16 +1026,16 @@ ALTER SEQUENCE reports_id_seq OWNED BY reports.id; -- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE schema_migrations ( - version character varying(255) NOT NULL + version character varying NOT NULL ); -- --- Name: user_blocks; Type: TABLE; Schema: public; Owner: - +-- Name: user_blocks; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE user_blocks ( @@ -1117,26 +1072,26 @@ ALTER SEQUENCE user_blocks_id_seq OWNED BY user_blocks.id; -- --- Name: user_preferences; Type: TABLE; Schema: public; Owner: - +-- Name: user_preferences; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE user_preferences ( user_id bigint NOT NULL, - k character varying(255) NOT NULL, - v character varying(255) NOT NULL + k character varying NOT NULL, + v character varying NOT NULL ); -- --- Name: user_roles; Type: TABLE; Schema: public; Owner: - +-- Name: user_roles; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE user_roles ( id integer NOT NULL, user_id bigint NOT NULL, + role user_role_enum NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, - role user_role_enum NOT NULL, granter_id bigint NOT NULL ); @@ -1161,13 +1116,13 @@ ALTER SEQUENCE user_roles_id_seq OWNED BY user_roles.id; -- --- Name: user_tokens; Type: TABLE; Schema: public; Owner: - +-- Name: user_tokens; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE user_tokens ( id bigint NOT NULL, user_id bigint NOT NULL, - token character varying(255) NOT NULL, + token character varying NOT NULL, expiry timestamp without time zone NOT NULL, referer text ); @@ -1193,40 +1148,40 @@ ALTER SEQUENCE user_tokens_id_seq OWNED BY user_tokens.id; -- --- Name: users; Type: TABLE; Schema: public; Owner: - +-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE users ( - email character varying(255) NOT NULL, + email character varying NOT NULL, id bigint NOT NULL, - pass_crypt character varying(255) NOT NULL, + pass_crypt character varying NOT NULL, creation_time timestamp without time zone NOT NULL, - display_name character varying(255) DEFAULT ''::character varying NOT NULL, + display_name character varying DEFAULT ''::character varying NOT NULL, data_public boolean DEFAULT false NOT NULL, description text DEFAULT ''::text NOT NULL, home_lat double precision, home_lon double precision, home_zoom smallint DEFAULT 3, nearby integer DEFAULT 50, - pass_salt character varying(255), + pass_salt character varying, image_file_name text, email_valid boolean DEFAULT false NOT NULL, - new_email character varying(255), - creation_ip character varying(255), - languages character varying(255), + new_email character varying, + creation_ip character varying, + languages character varying, status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL, terms_agreed timestamp without time zone, consider_pd boolean DEFAULT false NOT NULL, - preferred_editor character varying(255), + auth_uid character varying, + preferred_editor character varying, terms_seen boolean DEFAULT false NOT NULL, - auth_uid character varying(255), description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL, - image_fingerprint character varying(255), + image_fingerprint character varying, changesets_count integer DEFAULT 0 NOT NULL, traces_count integer DEFAULT 0 NOT NULL, diary_entries_count integer DEFAULT 0 NOT NULL, image_use_gravatar boolean DEFAULT false NOT NULL, - image_content_type character varying(255), + image_content_type character varying, auth_provider character varying ); @@ -1251,7 +1206,7 @@ ALTER SEQUENCE users_id_seq OWNED BY users.id; -- --- Name: way_nodes; Type: TABLE; Schema: public; Owner: - +-- Name: way_nodes; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE way_nodes ( @@ -1263,19 +1218,19 @@ CREATE TABLE way_nodes ( -- --- Name: way_tags; Type: TABLE; Schema: public; Owner: - +-- Name: way_tags; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE way_tags ( way_id bigint DEFAULT 0 NOT NULL, - k character varying(255) NOT NULL, - v character varying(255) NOT NULL, + k character varying NOT NULL, + v character varying NOT NULL, version bigint NOT NULL ); -- --- Name: ways; Type: TABLE; Schema: public; Owner: - +-- Name: ways; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE ways ( @@ -1464,7 +1419,7 @@ ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regcl -- --- Name: acls_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: acls_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY acls @@ -1472,7 +1427,7 @@ ALTER TABLE ONLY acls -- --- Name: changeset_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: changeset_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY changeset_comments @@ -1480,7 +1435,7 @@ ALTER TABLE ONLY changeset_comments -- --- Name: changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: changesets_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY changesets @@ -1488,7 +1443,7 @@ ALTER TABLE ONLY changesets -- --- Name: client_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: client_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY client_applications @@ -1496,7 +1451,7 @@ ALTER TABLE ONLY client_applications -- --- Name: current_node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_node_tags @@ -1504,7 +1459,7 @@ ALTER TABLE ONLY current_node_tags -- --- Name: current_nodes_pkey1; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_nodes_pkey1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_nodes @@ -1512,7 +1467,7 @@ ALTER TABLE ONLY current_nodes -- --- Name: current_relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_relation_members @@ -1520,7 +1475,7 @@ ALTER TABLE ONLY current_relation_members -- --- Name: current_relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_relation_tags @@ -1528,7 +1483,7 @@ ALTER TABLE ONLY current_relation_tags -- --- Name: current_relations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_relations @@ -1536,7 +1491,7 @@ ALTER TABLE ONLY current_relations -- --- Name: current_way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_way_nodes @@ -1544,7 +1499,7 @@ ALTER TABLE ONLY current_way_nodes -- --- Name: current_way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_way_tags @@ -1552,7 +1507,7 @@ ALTER TABLE ONLY current_way_tags -- --- Name: current_ways_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: current_ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY current_ways @@ -1560,7 +1515,7 @@ ALTER TABLE ONLY current_ways -- --- Name: diary_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: diary_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY diary_comments @@ -1568,7 +1523,7 @@ ALTER TABLE ONLY diary_comments -- --- Name: diary_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: diary_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY diary_entries @@ -1576,7 +1531,7 @@ ALTER TABLE ONLY diary_entries -- --- Name: friends_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: friends_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY friends @@ -1584,7 +1539,7 @@ ALTER TABLE ONLY friends -- --- Name: gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: gpx_file_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY gpx_file_tags @@ -1592,7 +1547,7 @@ ALTER TABLE ONLY gpx_file_tags -- --- Name: gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: gpx_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY gpx_files @@ -1616,7 +1571,7 @@ ALTER TABLE ONLY issues -- --- Name: languages_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: languages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY languages @@ -1624,7 +1579,7 @@ ALTER TABLE ONLY languages -- --- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY messages @@ -1632,7 +1587,7 @@ ALTER TABLE ONLY messages -- --- Name: node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: node_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY node_tags @@ -1640,7 +1595,7 @@ ALTER TABLE ONLY node_tags -- --- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY nodes @@ -1648,7 +1603,7 @@ ALTER TABLE ONLY nodes -- --- Name: note_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: note_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY note_comments @@ -1656,7 +1611,7 @@ ALTER TABLE ONLY note_comments -- --- Name: notes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY notes @@ -1664,7 +1619,7 @@ ALTER TABLE ONLY notes -- --- Name: oauth_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: oauth_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY oauth_nonces @@ -1672,7 +1627,7 @@ ALTER TABLE ONLY oauth_nonces -- --- Name: oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY oauth_tokens @@ -1680,7 +1635,7 @@ ALTER TABLE ONLY oauth_tokens -- --- Name: redactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: redactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY redactions @@ -1688,7 +1643,7 @@ ALTER TABLE ONLY redactions -- --- Name: relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: relation_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY relation_members @@ -1696,7 +1651,7 @@ ALTER TABLE ONLY relation_members -- --- Name: relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: relation_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY relation_tags @@ -1704,7 +1659,7 @@ ALTER TABLE ONLY relation_tags -- --- Name: relations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: relations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY relations @@ -1720,7 +1675,7 @@ ALTER TABLE ONLY reports -- --- Name: user_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY user_blocks @@ -1728,7 +1683,7 @@ ALTER TABLE ONLY user_blocks -- --- Name: user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY user_preferences @@ -1736,7 +1691,7 @@ ALTER TABLE ONLY user_preferences -- --- Name: user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY user_roles @@ -1744,7 +1699,7 @@ ALTER TABLE ONLY user_roles -- --- Name: user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY user_tokens @@ -1752,7 +1707,7 @@ ALTER TABLE ONLY user_tokens -- --- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY users @@ -1760,7 +1715,7 @@ ALTER TABLE ONLY users -- --- Name: way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: way_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY way_nodes @@ -1768,7 +1723,7 @@ ALTER TABLE ONLY way_nodes -- --- Name: way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: way_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY way_tags @@ -1776,7 +1731,7 @@ ALTER TABLE ONLY way_tags -- --- Name: ways_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: ways_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY ways @@ -1784,196 +1739,196 @@ ALTER TABLE ONLY ways -- --- Name: acls_k_idx; Type: INDEX; Schema: public; Owner: - +-- Name: acls_k_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX acls_k_idx ON acls USING btree (k); -- --- Name: changeset_tags_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changeset_tags_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX changeset_tags_id_idx ON changeset_tags USING btree (changeset_id); -- --- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changesets_bbox_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- -CREATE INDEX changesets_bbox_idx ON changesets USING gist (min_lat, max_lat, min_lon, max_lon); +CREATE INDEX changesets_bbox_idx ON changesets USING btree (min_lat, max_lat, min_lon, max_lon); -- --- Name: changesets_closed_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changesets_closed_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX changesets_closed_at_idx ON changesets USING btree (closed_at); -- --- Name: changesets_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changesets_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX changesets_created_at_idx ON changesets USING btree (created_at); -- --- Name: changesets_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changesets_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX changesets_user_id_created_at_idx ON changesets USING btree (user_id, created_at); -- --- Name: changesets_user_id_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: changesets_user_id_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX changesets_user_id_id_idx ON changesets USING btree (user_id, id); -- --- Name: current_nodes_tile_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_nodes_tile_idx ON current_nodes USING btree (tile); -- --- Name: current_nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_nodes_timestamp_idx ON current_nodes USING btree ("timestamp"); -- --- Name: current_relation_members_member_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_relation_members_member_idx ON current_relation_members USING btree (member_type, member_id); -- --- Name: current_relations_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_relations_timestamp_idx ON current_relations USING btree ("timestamp"); -- --- Name: current_way_nodes_node_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_way_nodes_node_idx ON current_way_nodes USING btree (node_id); -- --- Name: current_ways_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: current_ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX current_ways_timestamp_idx ON current_ways USING btree ("timestamp"); -- --- Name: diary_comment_user_id_created_at_index; Type: INDEX; Schema: public; Owner: - +-- Name: diary_comment_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX diary_comment_user_id_created_at_index ON diary_comments USING btree (user_id, created_at); -- --- Name: diary_comments_entry_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: diary_comments_entry_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX diary_comments_entry_id_idx ON diary_comments USING btree (diary_entry_id, id); -- --- Name: diary_entry_created_at_index; Type: INDEX; Schema: public; Owner: - +-- Name: diary_entry_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX diary_entry_created_at_index ON diary_entries USING btree (created_at); -- --- Name: diary_entry_language_code_created_at_index; Type: INDEX; Schema: public; Owner: - +-- Name: diary_entry_language_code_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX diary_entry_language_code_created_at_index ON diary_entries USING btree (language_code, created_at); -- --- Name: diary_entry_user_id_created_at_index; Type: INDEX; Schema: public; Owner: - +-- Name: diary_entry_user_id_created_at_index; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX diary_entry_user_id_created_at_index ON diary_entries USING btree (user_id, created_at); -- --- Name: friends_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: friends_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX friends_user_id_idx ON friends USING btree (user_id); -- --- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: - +-- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX gpx_file_tags_gpxid_idx ON gpx_file_tags USING btree (gpx_id); -- --- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: - +-- Name: gpx_file_tags_tag_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX gpx_file_tags_tag_idx ON gpx_file_tags USING btree (tag); -- --- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: gpx_files_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX gpx_files_timestamp_idx ON gpx_files USING btree ("timestamp"); -- --- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: gpx_files_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX gpx_files_user_id_idx ON gpx_files USING btree (user_id); -- --- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: - +-- Name: gpx_files_visible_visibility_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX gpx_files_visible_visibility_idx ON gpx_files USING btree (visible, visibility); -- --- Name: index_changeset_comments_on_created_at; Type: INDEX; Schema: public; Owner: - +-- Name: index_changeset_comments_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_changeset_comments_on_created_at ON changeset_comments USING btree (created_at); -- --- Name: index_changesets_subscribers_on_changeset_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_changesets_subscribers_on_changeset_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_changesets_subscribers_on_changeset_id ON changesets_subscribers USING btree (changeset_id); -- --- Name: index_changesets_subscribers_on_subscriber_id_and_changeset_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_changesets_subscribers_on_subscriber_id_and_changeset_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_changesets_subscribers_on_subscriber_id_and_changeset_id ON changesets_subscribers USING btree (subscriber_id, changeset_id); -- --- Name: index_client_applications_on_key; Type: INDEX; Schema: public; Owner: - +-- Name: index_client_applications_on_key; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key); @@ -2015,28 +1970,28 @@ CREATE INDEX index_issues_on_updated_by ON issues USING btree (updated_by); -- --- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: - +-- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_note_comments_on_body ON note_comments USING gin (to_tsvector('english'::regconfig, body)); -- --- Name: index_note_comments_on_created_at; Type: INDEX; Schema: public; Owner: - +-- Name: index_note_comments_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_note_comments_on_created_at ON note_comments USING btree (created_at); -- --- Name: index_oauth_nonces_on_nonce_and_timestamp; Type: INDEX; Schema: public; Owner: - +-- Name: index_oauth_nonces_on_nonce_and_timestamp; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_oauth_nonces_on_nonce_and_timestamp ON oauth_nonces USING btree (nonce, "timestamp"); -- --- Name: index_oauth_tokens_on_token; Type: INDEX; Schema: public; Owner: - +-- Name: index_oauth_tokens_on_token; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_oauth_tokens_on_token ON oauth_tokens USING btree (token); @@ -2057,196 +2012,196 @@ CREATE INDEX index_reports_on_reporter_user_id ON reports USING btree (reporter_ -- --- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_user_blocks_on_user_id ON user_blocks USING btree (user_id); -- --- Name: messages_from_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: messages_from_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX messages_from_user_id_idx ON messages USING btree (from_user_id); -- --- Name: messages_to_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: messages_to_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX messages_to_user_id_idx ON messages USING btree (to_user_id); -- --- Name: nodes_changeset_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: nodes_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX nodes_changeset_id_idx ON nodes USING btree (changeset_id); -- --- Name: nodes_tile_idx; Type: INDEX; Schema: public; Owner: - +-- Name: nodes_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX nodes_tile_idx ON nodes USING btree (tile); -- --- Name: nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: nodes_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX nodes_timestamp_idx ON nodes USING btree ("timestamp"); -- --- Name: note_comments_note_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: note_comments_note_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX note_comments_note_id_idx ON note_comments USING btree (note_id); -- --- Name: notes_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: notes_created_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX notes_created_at_idx ON notes USING btree (created_at); -- --- Name: notes_tile_status_idx; Type: INDEX; Schema: public; Owner: - +-- Name: notes_tile_status_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX notes_tile_status_idx ON notes USING btree (tile, status); -- --- Name: notes_updated_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: notes_updated_at_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX notes_updated_at_idx ON notes USING btree (updated_at); -- --- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: - +-- Name: points_gpxid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX points_gpxid_idx ON gps_points USING btree (gpx_id); -- --- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: - +-- Name: points_tile_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX points_tile_idx ON gps_points USING btree (tile); -- --- Name: relation_members_member_idx; Type: INDEX; Schema: public; Owner: - +-- Name: relation_members_member_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX relation_members_member_idx ON relation_members USING btree (member_type, member_id); -- --- Name: relations_changeset_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: relations_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX relations_changeset_id_idx ON relations USING btree (changeset_id); -- --- Name: relations_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: relations_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX relations_timestamp_idx ON relations USING btree ("timestamp"); -- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); -- --- Name: user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX user_id_idx ON friends USING btree (friend_user_id); -- --- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: - +-- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX user_roles_id_role_unique ON user_roles USING btree (user_id, role); -- --- Name: user_tokens_token_idx; Type: INDEX; Schema: public; Owner: - +-- Name: user_tokens_token_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX user_tokens_token_idx ON user_tokens USING btree (token); -- --- Name: user_tokens_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: user_tokens_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX user_tokens_user_id_idx ON user_tokens USING btree (user_id); -- --- Name: users_auth_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_auth_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX users_auth_idx ON users USING btree (auth_provider, auth_uid); -- --- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX users_display_name_idx ON users USING btree (display_name); -- --- Name: users_display_name_lower_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_display_name_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX users_display_name_lower_idx ON users USING btree (lower((display_name)::text)); -- --- Name: users_email_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_email_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX users_email_idx ON users USING btree (email); -- --- Name: users_email_lower_idx; Type: INDEX; Schema: public; Owner: - +-- Name: users_email_lower_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX users_email_lower_idx ON users USING btree (lower((email)::text)); -- --- Name: way_nodes_node_idx; Type: INDEX; Schema: public; Owner: - +-- Name: way_nodes_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX way_nodes_node_idx ON way_nodes USING btree (node_id); -- --- Name: ways_changeset_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: ways_changeset_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX ways_changeset_id_idx ON ways USING btree (changeset_id); -- --- Name: ways_timestamp_idx; Type: INDEX; Schema: public; Owner: - +-- Name: ways_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX ways_timestamp_idx ON ways USING btree ("timestamp"); @@ -2704,7 +2659,7 @@ ALTER TABLE ONLY ways -- PostgreSQL database dump complete -- -SET search_path TO "$user", public; +SET search_path TO "$user",public; INSERT INTO schema_migrations (version) VALUES ('1'); @@ -2782,8 +2737,6 @@ INSERT INTO schema_migrations (version) VALUES ('20121203124841'); INSERT INTO schema_migrations (version) VALUES ('20130328184137'); -INSERT INTO schema_migrations (version) VALUES ('20131029121300'); - INSERT INTO schema_migrations (version) VALUES ('20131212124700'); INSERT INTO schema_migrations (version) VALUES ('20140115192822'); @@ -2802,11 +2755,13 @@ INSERT INTO schema_migrations (version) VALUES ('20150111192335'); INSERT INTO schema_migrations (version) VALUES ('20150222101847'); -INSERT INTO schema_migrations (version) VALUES ('20150516073616'); +INSERT INTO schema_migrations (version) VALUES ('20150818224516'); + +INSERT INTO schema_migrations (version) VALUES ('20160822153055'); -INSERT INTO schema_migrations (version) VALUES ('20150526130032'); +INSERT INTO schema_migrations (version) VALUES ('20160822153115'); -INSERT INTO schema_migrations (version) VALUES ('20150719160821'); +INSERT INTO schema_migrations (version) VALUES ('20160822153153'); INSERT INTO schema_migrations (version) VALUES ('21'); diff --git a/test/controllers/issues_controller_test.rb b/test/controllers/issues_controller_test.rb index a6e1d6b3f..d42b37ae5 100644 --- a/test/controllers/issues_controller_test.rb +++ b/test/controllers/issues_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' +require "test_helper" class IssuesControllerTest < ActionController::TestCase - fixtures :users,:user_roles + fixtures :users, :user_roles def test_view_dashboard_without_auth # Access issues_path without login @@ -21,16 +21,16 @@ class IssuesControllerTest < ActionController::TestCase assert_response :success # Access issues_path by moderator - session[:user]= users(:moderator_user).id + session[:user] = users(:moderator_user).id get :index assert_response :success end def test_new_issue_without_login # Test creation of a new issue and a new report without logging in - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 1} + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 1 assert_response :redirect - assert_redirected_to login_path(:referer => new_issue_path(:reportable_id=>1, :reportable_type=>"User",:reported_user_id=> 1)) + assert_redirected_to login_path(:referer => new_issue_path(:reportable_id => 1, :reportable_type => "User", :reported_user_id => 1)) end def test_new_issue_after_login @@ -39,18 +39,19 @@ class IssuesControllerTest < ActionController::TestCase # Login session[:user] = users(:normal_user).id - assert_equal Issue.count,0 - - # Create an Issue and a report - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 2} + assert_equal Issue.count, 0 + + # Create an Issue and a report + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 assert_response :success - assert_difference "Issue.count",1 do + assert_difference "Issue.count", 1 do details = "Details of a report" - post :create, { :report => { :details => details}, - :report_type => "[OFFENSIVE]", - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } + post :create, + :report => { :details => details }, + :report_type => "[OFFENSIVE]", + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } end - assert_equal Issue.count,1 + assert_equal Issue.count, 1 assert_response :redirect assert_redirected_to root_path end @@ -61,40 +62,43 @@ class IssuesControllerTest < ActionController::TestCase # Login session[:user] = users(:normal_user).id - assert_equal Issue.count,0 + assert_equal Issue.count, 0 # Create an Issue and a report - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 2} + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 assert_response :success - assert_difference "Issue.count",1 do + assert_difference "Issue.count", 1 do details = "Details of a report" - post :create, { :report => { :details => details}, - :report_type => "[OFFENSIVE]", - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } - end - assert_equal Issue.count,1 + post :create, + :report => { :details => details }, + :report_type => "[OFFENSIVE]", + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } + end + assert_equal Issue.count, 1 assert_response :redirect assert_redirected_to root_path - - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 2} + + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 assert_response :success # Report without report_type assert_no_difference "Issue.count" do details = "Details of another report under the same issue" - post :create, { :report => { :details => details}, - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } + post :create, + :report => { :details => details }, + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } end assert_response :redirect - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").reports.count,1 + assert_equal Issue.find_by_reportable_id_and_reportable_type(1, "User").reports.count, 1 # Report without details assert_no_difference "Issue.count" do - post :create, { :report_type => "[OFFENSIVE]", - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } + post :create, + :report_type => "[OFFENSIVE]", + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } end assert_response :redirect - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").reports.count,1 + assert_equal Issue.find_by_reportable_id_and_reportable_type(1, "User").reports.count, 1 end def test_new_report_with_complete_details @@ -103,43 +107,46 @@ class IssuesControllerTest < ActionController::TestCase # Login session[:user] = users(:normal_user).id - assert_equal Issue.count,0 + assert_equal Issue.count, 0 # Create an Issue and a report - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 2} + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 assert_response :success - assert_difference "Issue.count",1 do + assert_difference "Issue.count", 1 do details = "Details of a report" - post :create, { :report => { :details => details}, - :report_type => "[OFFENSIVE]", - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } + post :create, + :report => { :details => details }, + :report_type => "[OFFENSIVE]", + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } end - assert_equal Issue.count,1 + assert_equal Issue.count, 1 assert_response :redirect assert_redirected_to root_path - + # Create a report for an existing Issue - get :new, {reportable_id: 1, reportable_type: "User", reported_user_id: 2} + get :new, :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 assert_response :success assert_no_difference "Issue.count" do details = "Details of another report under the same issue" - post :create, { :report => { :details => details}, - :report_type => "[OFFENSIVE]", - :issue => { reportable_id: 1, reportable_type: "User", reported_user_id: 2} } + post :create, + :report => { :details => details }, + :report_type => "[OFFENSIVE]", + :issue => { :reportable_id => 1, :reportable_type => "User", :reported_user_id => 2 } end assert_response :redirect - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").reports.count,2 + report_count = Issue.find_by_reportable_id_and_reportable_type(1, "User").reports.count + assert_equal report_count, 2 end def test_change_status_by_normal_user # Login as normal user session[:user] = users(:normal_user).id - + # Create Issue - test_new_issue_after_login - assert_equal Issue.count,1 - - get :resolve, id: Issue.find_by_reportable_id_and_reportable_type(1,"User").id + test_new_issue_after_login + assert_equal Issue.count, 1 + + get :resolve, :id => Issue.find_by_reportable_id_and_reportable_type(1, "User").id assert_response :redirect assert_redirected_to root_path @@ -151,25 +158,25 @@ class IssuesControllerTest < ActionController::TestCase # Create Issue test_new_issue_after_login - assert_equal Issue.count,1 + assert_equal Issue.count, 1 assert_response :redirect # Login as administrator session[:user] = users(:administrator_user).id - + # Test 'Resolved' - get :resolve, id: Issue.find_by_reportable_id_and_reportable_type(1,"User").id - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").resolved?, true + get :resolve, :id => Issue.find_by_reportable_id_and_reportable_type(1, "User").id + assert_equal Issue.find_by_reportable_id_and_reportable_type(1, "User").resolved?, true assert_response :redirect # Test 'Reopen' - get :reopen, id: Issue.find_by_reportable_id_and_reportable_type(1,"User").id - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").open?, true + get :reopen, :id => Issue.find_by_reportable_id_and_reportable_type(1, "User").id + assert_equal Issue.find_by_reportable_id_and_reportable_type(1, "User").open?, true assert_response :redirect # Test 'Ignored' - get :ignore, id: Issue.find_by_reportable_id_and_reportable_type(1,"User").id - assert_equal Issue.find_by_reportable_id_and_reportable_type(1,"User").ignored?, true + get :ignore, :id => Issue.find_by_reportable_id_and_reportable_type(1, "User").id + assert_equal Issue.find_by_reportable_id_and_reportable_type(1, "User").ignored?, true assert_response :redirect end @@ -178,33 +185,33 @@ class IssuesControllerTest < ActionController::TestCase session[:user] = users(:administrator_user).id # No issues against the user - get :index, search_by_user: "test1" + get :index, :search_by_user => "test1" assert_response :redirect assert_redirected_to issues_path # User doesn't exist - get :index, search_by_user: "test1000" + get :index, :search_by_user => "test1000" assert_response :redirect assert_redirected_to issues_path # Create Issue against user_id:2 test_new_issue_after_login - assert_equal Issue.count,1 - assert_equal Issue.first.reported_user_id,2 + assert_equal Issue.count, 1 + assert_equal Issue.first.reported_user_id, 2 session[:user] = users(:administrator_user).id # Find Issue against user_id:2 - get :index, search_by_user: "test2" + get :index, :search_by_user => "test2" assert_response :success end def test_comment_by_normal_user # Create Issue test_new_issue_after_login - assert_equal Issue.count,1 + assert_equal Issue.count, 1 - get :comment, id: 1 + get :comment, :id => 1 assert_response :redirect assert_redirected_to root_path end @@ -212,13 +219,13 @@ class IssuesControllerTest < ActionController::TestCase def test_comment # Create Issue test_new_issue_after_login - assert_equal Issue.count,1 + assert_equal Issue.count, 1 @issue = Issue.all.first # Login as administrator session[:user] = users(:administrator_user).id - get :comment, id: @issue.id, :issue_comment => { body: "test comment" } + get :comment, :id => @issue.id, :issue_comment => { :body => "test comment" } assert_response :redirect assert_redirected_to @issue end diff --git a/test/models/issue_comment_test.rb b/test/models/issue_comment_test.rb index e7f5f3442..53ba35889 100644 --- a/test/models/issue_comment_test.rb +++ b/test/models/issue_comment_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class IssueCommentTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/issue_test.rb b/test/models/issue_test.rb index c3887b818..7e15ee90c 100644 --- a/test/models/issue_test.rb +++ b/test/models/issue_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class IssueTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/report_test.rb b/test/models/report_test.rb index 198d9ddf9..c7d4f0adc 100644 --- a/test/models/report_test.rb +++ b/test/models/report_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ReportTest < ActiveSupport::TestCase # test "the truth" do -- 2.39.5