Update code style automatically using rubocop gem (#563)

* install rubocop

* 1961 automatic rubocop fixes

* update rubocop.yml to ignore half of the remaining cops

* rubocop lint warnings

* random other warnings fixed
This commit is contained in:
Devin Howard 2016-07-26 08:14:23 +08:00 committed by GitHub
parent 17bccd809a
commit 7d4da81272
109 changed files with 1387 additions and 1570 deletions

14
.rubocop.yml Normal file
View file

@ -0,0 +1,14 @@
AllCops:
TargetRubyVersion: 2.3
Exclude:
- 'db/**/*'
- 'tmp/**/*'
- 'bin/**/*'
- 'vendor/**/*'
- 'app/assets/javascripts/node_modules/**/*'
Rails:
Enabled: true
Metrics/LineLength:
Max: 100

View file

@ -1 +1 @@
ruby-2.1.3
2.1.3

View file

@ -59,4 +59,5 @@ group :development, :test do
gem 'pry-rails'
gem 'quiet_assets'
gem 'tunemygc'
gem 'rubocop'
end

View file

@ -40,6 +40,7 @@ GEM
tzinfo (~> 1.1)
addressable (2.3.8)
arel (6.0.3)
ast (2.3.0)
aws-sdk (1.66.0)
aws-sdk-v1 (= 1.66.0)
aws-sdk-v1 (1.66.0)
@ -151,8 +152,11 @@ GEM
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
parser (2.3.1.2)
ast (~> 2.2)
pg (0.18.4)
pkg-config (1.1.7)
powerpack (0.1.1)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@ -202,6 +206,7 @@ GEM
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
rake (11.2.2)
redis (3.3.0)
responders (2.2.0)
@ -223,6 +228,13 @@ GEM
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.41.1)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
@ -256,6 +268,7 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.1.0)
uservoice-ruby (0.0.11)
ezcrypto (>= 0.7.2)
json (>= 1.7.5)
@ -303,6 +316,7 @@ DEPENDENCIES
rails_12factor
redis
rspec-rails
rubocop
sass-rails
shoulda-matchers
simplecov

12
Vagrantfile vendored
View file

@ -31,15 +31,15 @@ sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '3112';"
SCRIPT
VAGRANTFILE_API_VERSION = "2"
VAGRANTFILE_API_VERSION = '2'.freeze
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.box = 'trusty64'
config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 5001, host: 5001
config.vm.network "private_network", ip: "10.0.1.11"
config.vm.synced_folder ".", "/vagrant", :nfs => true
config.vm.network 'private_network', ip: '10.0.1.11'
config.vm.synced_folder '.', '/vagrant', nfs: true
config.vm.provision "shell", inline: $script
config.vm.provision 'shell', inline: $script
end

View file

@ -1,3 +1,2 @@
class Api::MappingsController < API::RestfulController
end

View file

@ -1,3 +1,2 @@
class Api::MapsController < API::RestfulController
end

View file

@ -35,9 +35,7 @@ class API::RestfulController < ActionController::Base
def token_user
token = params[:access_token]
access_token = Token.find_by_token(token)
if access_token
@token_user ||= access_token.user
end
@token_user ||= access_token.user if access_token
end
def doorkeeper_user
@ -49,5 +47,4 @@ class API::RestfulController < ActionController::Base
def permitted_params
@permitted_params ||= PermittedParams.new(params)
end
end

View file

@ -1,3 +1,2 @@
class Api::SynapsesController < API::RestfulController
end

View file

@ -1,7 +1,6 @@
class Api::TokensController < API::RestfulController
def my_tokens
raise Pundit::NotAuthorizedError.new unless current_user
raise Pundit::NotAuthorizedError unless current_user
instantiate_collection page_collection: false, timeframe_collection: false
respond_with_collection
end
@ -15,5 +14,4 @@ class Api::TokensController < API::RestfulController
def visible_records
current_user.tokens
end
end

View file

@ -1,3 +1,2 @@
class Api::TopicsController < API::RestfulController
end

View file

@ -20,12 +20,12 @@ class ApplicationController < ActionController::Base
helper_method :admin?
def after_sign_in_path_for(resource)
sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'https')
sign_in_url = url_for(action: 'new', controller: 'sessions', only_path: false, protocol: 'https')
if request.referer == sign_in_url
super
elsif params[:uv_login] == "1"
"http://support.metamaps.cc/login_success?sso=" + current_sso_token
elsif params[:uv_login] == '1'
'http://support.metamaps.cc/login_success?sso=' + current_sso_token
else
stored_location_for(resource) || request.referer || root_path
end
@ -33,35 +33,35 @@ class ApplicationController < ActionController::Base
def handle_unauthorized
if authenticated?
head :forbidden # TODO make this better
head :forbidden # TODO: make this better
else
redirect_to new_user_session_path, notice: "Try signing in to do that."
redirect_to new_user_session_path, notice: 'Try signing in to do that.'
end
end
private
def get_invite_link
@invite_link = "#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : "")
@invite_link = "#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
end
def require_no_user
if authenticated?
redirect_to edit_user_path(user), notice: "You must be logged out."
redirect_to edit_user_path(user), notice: 'You must be logged out.'
return false
end
end
def require_user
unless authenticated?
redirect_to new_user_session_path, notice: "You must be logged in."
redirect_to new_user_session_path, notice: 'You must be logged in.'
return false
end
end
def require_admin
unless authenticated? && admin?
redirect_to root_url, notice: "You need to be an admin for that."
redirect_to root_url, notice: 'You need to be an admin for that.'
return false
end
end

View file

@ -10,15 +10,15 @@ class MainController < ApplicationController
# home page
def home
@maps = policy_scope(Map).order("updated_at DESC").page(1).per(20)
@maps = policy_scope(Map).order('updated_at DESC').page(1).per(20)
respond_to do |format|
format.html {
if not authenticated?
format.html do
if !authenticated?
render 'main/home'
else
render 'maps/activemaps'
end
}
end
end
end
@ -29,21 +29,21 @@ class MainController < ApplicationController
term = params[:term]
user = params[:user] ? params[:user] : false
if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..6] != "mapper:" && term.downcase != "topic:"
if term && !term.empty? && term.downcase[0..3] != 'map:' && term.downcase[0..6] != 'mapper:' && !term.casecmp('topic:').zero?
# remove "topic:" if appended at beginning
term = term[6..-1] if term.downcase[0..5] == "topic:"
term = term[6..-1] if term.downcase[0..5] == 'topic:'
# if desc: search desc instead
desc = false
if term.downcase[0..4] == "desc:"
if term.downcase[0..4] == 'desc:'
term = term[5..-1]
desc = true
end
# if link: search link instead
link = false
if term.downcase[0..4] == "link:"
if term.downcase[0..4] == 'link:'
term = term[5..-1]
link = true
end
@ -54,7 +54,7 @@ class MainController < ApplicationController
lOne = m.name.length + 1
lTwo = m.name.length
if term.downcase[0..lTwo] == m.name.downcase + ":"
if term.downcase[0..lTwo] == m.name.downcase + ':'
term = term[lOne..-1]
filterByMetacode = m
end
@ -64,7 +64,7 @@ class MainController < ApplicationController
builder = policy_scope(Topic)
if filterByMetacode
if term == ""
if term == ''
builder = builder.none
else
builder = builder.where('LOWER("name") like ? OR
@ -96,14 +96,14 @@ class MainController < ApplicationController
term = params[:term]
user = params[:user] ? params[:user] : nil
if term && !term.empty? && term.downcase[0..5] != "topic:" && term.downcase[0..6] != "mapper:" && term.downcase != "map:"
if term && !term.empty? && term.downcase[0..5] != 'topic:' && term.downcase[0..6] != 'mapper:' && !term.casecmp('map:').zero?
# remove "map:" if appended at beginning
term = term[4..-1] if term.downcase[0..3] == "map:"
term = term[4..-1] if term.downcase[0..3] == 'map:'
# if desc: search desc instead
desc = false
if term.downcase[0..4] == "desc:"
if term.downcase[0..4] == 'desc:'
term = term[5..-1]
desc = true
end
@ -111,10 +111,10 @@ class MainController < ApplicationController
search = '%' + term.downcase + '%'
builder = policy_scope(Map)
if desc
builder = builder.where('LOWER("desc") like ?', search)
builder = if desc
builder.where('LOWER("desc") like ?', search)
else
builder = builder.where('LOWER("name") like ?', search)
builder.where('LOWER("name") like ?', search)
end
builder = builder.where(user: user) if user
@maps = builder.order(:name)
@ -128,13 +128,13 @@ class MainController < ApplicationController
# get /search/mappers?term=SOMETERM
def searchmappers
term = params[:term]
if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..5] != "topic:" && term.downcase != "mapper:"
if term && !term.empty? && term.downcase[0..3] != 'map:' && term.downcase[0..5] != 'topic:' && !term.casecmp('mapper:').zero?
# remove "mapper:" if appended at beginning
term = term[7..-1] if term.downcase[0..6] == "mapper:"
term = term[7..-1] if term.downcase[0..6] == 'mapper:'
search = term.downcase + '%'
skip_policy_scope # TODO builder = policy_scope(User)
skip_policy_scope # TODO: builder = policy_scope(User)
builder = User.where('LOWER("name") like ?', search)
@mappers = builder.order(:name)
else
@ -156,15 +156,15 @@ class MainController < ApplicationController
# remove any duplicate synapse types that just differ by
# leading or trailing whitespaces
collectedDesc = []
@synapses.to_a.uniq(&:desc).delete_if {|s|
desc = s.desc == nil || s.desc == "" ? "" : s.desc.strip
if collectedDesc.index(desc) == nil
@synapses.to_a.uniq(&:desc).delete_if do |s|
desc = s.desc.nil? || s.desc == '' ? '' : s.desc.strip
if collectedDesc.index(desc).nil?
collectedDesc.push(desc)
boolean = false
false # return this value
else
boolean = true
true # return this value
end
end
}
elsif topic1id && !topic1id.empty?
@one = policy_scope(Synapse).where('node1_id = ? AND node2_id = ?', topic1id, topic2id)
@two = policy_scope(Synapse).where('node2_id = ? AND node1_id = ?', topic1id, topic2id)

View file

@ -1,5 +1,4 @@
class MappingsController < ApplicationController
before_action :require_user, only: [:create, :update, :destroy]
after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index
@ -58,6 +57,7 @@ class MappingsController < ApplicationController
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def mapping_params
params.require(:mapping).permit(:id, :xloc, :yloc, :mappable_id, :mappable_type, :map_id)

View file

@ -5,20 +5,20 @@ class MapsController < ApplicationController
respond_to :html, :json, :csv
autocomplete :map, :name, :full => true, :extra_data => [:user_id]
autocomplete :map, :name, full: true, extra_data: [:user_id]
# GET /explore/active
def activemaps
page = params[:page].present? ? params[:page] : 1
@maps = policy_scope(Map).order("updated_at DESC")
@maps = policy_scope(Map).order('updated_at DESC')
.page(page).per(20)
respond_to do |format|
format.html {
format.html do
# root url => main/home. main/home renders maps/activemaps view.
redirect_to root_url and return if authenticated?
redirect_to(root_url) && return if authenticated?
respond_with(@maps, @user)
}
end
format.json { render json: @maps }
end
end
@ -27,9 +27,9 @@ class MapsController < ApplicationController
def featuredmaps
page = params[:page].present? ? params[:page] : 1
@maps = policy_scope(
Map.where("maps.featured = ? AND maps.permission != ?",
true, "private")
).order("updated_at DESC").page(page).per(20)
Map.where('maps.featured = ? AND maps.permission != ?',
true, 'private')
).order('updated_at DESC').page(page).per(20)
respond_to do |format|
format.html { respond_with(@maps, @user) }
@ -39,15 +39,15 @@ class MapsController < ApplicationController
# GET /explore/mine
def mymaps
if !authenticated?
unless authenticated?
skip_policy_scope
return redirect_to explore_active_path
end
page = params[:page].present? ? params[:page] : 1
@maps = policy_scope(
Map.where("maps.user_id = ?", current_user.id)
).order("updated_at DESC").page(page).per(20)
Map.where('maps.user_id = ?', current_user.id)
).order('updated_at DESC').page(page).per(20)
respond_to do |format|
format.html { respond_with(@maps, @user) }
@ -57,15 +57,15 @@ class MapsController < ApplicationController
# GET /explore/shared
def sharedmaps
if !authenticated?
unless authenticated?
skip_policy_scope
return redirect_to explore_active_path
end
page = params[:page].present? ? params[:page] : 1
@maps = policy_scope(
Map.where("maps.id IN (?)", current_user.shared_maps.map(&:id))
).order("updated_at DESC").page(page).per(20)
Map.where('maps.id IN (?)', current_user.shared_maps.map(&:id))
).order('updated_at DESC').page(page).per(20)
respond_to do |format|
format.html { respond_with(@maps, @user) }
@ -78,7 +78,7 @@ class MapsController < ApplicationController
page = params[:page].present? ? params[:page] : 1
@user = User.find(params[:id])
@maps = policy_scope(Map.where(user: @user))
.order("updated_at DESC").page(page).per(20)
.order('updated_at DESC').page(page).per(20)
respond_to do |format|
format.html { respond_with(@maps, @user) }
@ -92,16 +92,16 @@ class MapsController < ApplicationController
authorize @map
respond_to do |format|
format.html {
format.html do
@allmappers = @map.contributors
@allcollaborators = @map.editors
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
@alltopics = @map.topics.to_a.delete_if { |t| !policy(t).show? }
@allsynapses = @map.synapses.to_a.delete_if { |s| !policy(s).show? }
@allmappings = @map.mappings.to_a.delete_if { |m| !policy(m).show? }
@allmessages = @map.messages.sort_by(&:created_at)
respond_with(@allmappers, @allcollaborators, @allmappings, @allsynapses, @alltopics, @allmessages, @map)
}
end
format.json { render json: @map }
format.csv { redirect_to action: :export, format: :csv }
format.xls { redirect_to action: :export, format: :xls }
@ -135,10 +135,10 @@ class MapsController < ApplicationController
end
respond_to do |format|
format.json {
format.json do
head :ok if valid_event
head :bad_request if not valid_event
}
head :bad_request unless valid_event
end
end
end
@ -149,12 +149,11 @@ class MapsController < ApplicationController
@allmappers = @map.contributors
@allcollaborators = @map.editors
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
@alltopics = @map.topics.to_a.delete_if { |t| !policy(t).show? }
@allsynapses = @map.synapses.to_a.delete_if { |s| !policy(s).show? }
@allmappings = @map.mappings.to_a.delete_if { |m| !policy(m).show? }
@json = Hash.new()
@json = {}
@json['map'] = @map
@json['topics'] = @alltopics
@json['synapses'] = @allsynapses
@ -171,7 +170,7 @@ class MapsController < ApplicationController
# POST maps
def create
@user = current_user
@map = Map.new()
@map = Map.new
@map.name = params[:name]
@map.desc = params[:desc]
@map.permission = params[:permission]
@ -213,11 +212,11 @@ class MapsController < ApplicationController
if @map.save
respond_to do |format|
format.json { render :json => @map }
format.json { render json: @map }
end
else
respond_to do |format|
format.json { render :json => "invalid params" }
format.json { render json: 'invalid params' }
end
end
end
@ -241,27 +240,27 @@ class MapsController < ApplicationController
@map = Map.find(params[:id])
authorize @map
userIds = params[:access] || []
added = userIds.select { |uid|
added = userIds.select do |uid|
user = User.find(uid)
if user.nil? || (current_user && user == current_user)
false
else
not @map.collaborators.include?(user)
!@map.collaborators.include?(user)
end
}
removed = @map.collaborators.select { |user| not userIds.include?(user.id.to_s) }.map(&:id)
added.each { |uid|
um = UserMap.create({ user_id: uid.to_i, map_id: @map.id })
end
removed = @map.collaborators.select { |user| !userIds.include?(user.id.to_s) }.map(&:id)
added.each do |uid|
UserMap.create(user_id: uid.to_i, map_id: @map.id)
user = User.find(uid.to_i)
MapMailer.invite_to_edit_email(@map, current_user, user).deliver_later
}
removed.each { |uid|
@map.user_maps.select{ |um| um.user_id == uid }.each{ |um| um.destroy }
}
end
removed.each do |uid|
@map.user_maps.select { |um| um.user_id == uid }.each(&:destroy)
end
respond_to do |format|
format.json do
render :json => { :message => "Successfully altered edit permissions" }
render json: { message: 'Successfully altered edit permissions' }
end
end
end
@ -274,15 +273,15 @@ class MapsController < ApplicationController
png = Base64.decode64(params[:encoded_image]['data:image/png;base64,'.length..-1])
StringIO.open(png) do |data|
data.class.class_eval { attr_accessor :original_filename, :content_type }
data.original_filename = "map-" + @map.id.to_s + "-screenshot.png"
data.content_type = "image/png"
data.original_filename = 'map-' + @map.id.to_s + '-screenshot.png'
data.content_type = 'image/png'
@map.screenshot = data
end
if @map.save
render :json => {:message => "Successfully uploaded the map screenshot."}
render json: { message: 'Successfully uploaded the map screenshot.' }
else
render :json => {:message => "Failed to upload image."}
render json: { message: 'Failed to upload image.' }
end
end

View file

@ -1,5 +1,4 @@
class MessagesController < ApplicationController
before_action :require_user, except: [:show]
after_action :verify_authorized

View file

@ -1,11 +1,10 @@
class MetacodeSetsController < ApplicationController
before_action :require_admin
# GET /metacode_sets
# GET /metacode_sets.json
def index
@metacode_sets = MetacodeSet.order("name").all
@metacode_sets = MetacodeSet.order('name').all
respond_to do |format|
format.html # index.html.erb
@ -53,12 +52,12 @@ class MetacodeSetsController < ApplicationController
# create the InMetacodeSet for all the metacodes that were selected for the set
@metacodes = params[:metacodes][:value].split(',')
@metacodes.each do |m|
InMetacodeSet.create(:metacode_id => m, :metacode_set_id => @metacode_set.id)
InMetacodeSet.create(metacode_id: m, metacode_set_id: @metacode_set.id)
end
format.html { redirect_to metacode_sets_url, notice: 'Metacode set was successfully created.' }
format.json { render json: @metacode_set, status: :created, location: metacode_sets_url }
else
format.html { render action: "new" }
format.html { render action: 'new' }
format.json { render json: @metacode_set.errors, status: :unprocessable_entity }
end
end
@ -87,13 +86,13 @@ class MetacodeSetsController < ApplicationController
# add the new metacodes
@addedMetacodes = @newMetacodes - @currentMetacodes
@addedMetacodes.each do |m|
InMetacodeSet.create(:metacode_id => m, :metacode_set_id => @metacode_set.id)
InMetacodeSet.create(metacode_id: m, metacode_set_id: @metacode_set.id)
end
format.html { redirect_to metacode_sets_url, notice: 'Metacode set was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.html { render action: 'edit' }
format.json { render json: @metacode_set.errors, status: :unprocessable_entity }
end
end
@ -105,9 +104,7 @@ class MetacodeSetsController < ApplicationController
@metacode_set = MetacodeSet.find(params[:id])
# delete everything that tracks what's in the set
@metacode_set.in_metacode_sets.each do |m|
m.destroy
end
@metacode_set.in_metacode_sets.each(&:destroy)
@metacode_set.destroy
@ -122,5 +119,4 @@ class MetacodeSetsController < ApplicationController
def metacode_set_params
params.require(:metacode_set).permit(:desc, :mapperContributed, :name)
end
end

View file

@ -4,16 +4,16 @@ class MetacodesController < ApplicationController
# GET /metacodes
# GET /metacodes.json
def index
@metacodes = Metacode.order("name").all
@metacodes = Metacode.order('name').all
respond_to do |format|
format.html {
format.html do
unless authenticated? && user.admin
redirect_to root_url, notice: "You need to be an admin for that."
redirect_to root_url, notice: 'You need to be an admin for that.'
return false
end
render :index
}
end
format.json { render json: @metacodes }
end
end

View file

@ -19,7 +19,7 @@ class SynapsesController < ApplicationController
# POST /synapses.json
def create
@synapse = Synapse.new(synapse_params)
@synapse.desc = "" if @synapse.desc.nil?
@synapse.desc = '' if @synapse.desc.nil?
authorize @synapse
respond_to do |format|
@ -35,7 +35,7 @@ class SynapsesController < ApplicationController
# PUT /synapses/1.json
def update
@synapse = Synapse.find(params[:id])
@synapse.desc = "" if @synapse.desc.nil?
@synapse.desc = '' if @synapse.desc.nil?
authorize @synapse
respond_to do |format|

View file

@ -9,10 +9,10 @@ class TopicsController < ApplicationController
# GET /topics/autocomplete_topic
def autocomplete_topic
term = params[:term]
if term && !term.empty?
@topics = policy_scope(Topic.where('LOWER("name") like ?', term.downcase + '%')).order('"name"')
@topics = if term && !term.empty?
policy_scope(Topic.where('LOWER("name") like ?', term.downcase + '%')).order('"name"')
else
@topics = []
[]
end
render json: autocomplete_array_json(@topics)
end
@ -23,7 +23,7 @@ class TopicsController < ApplicationController
authorize @topic
respond_to do |format|
format.html {
format.html do
@alltopics = [@topic].concat(policy_scope(Topic.relatives1(@topic.id)).to_a).concat(policy_scope(Topic.relatives2(@topic.id)).to_a)
@allsynapses = policy_scope(Synapse.for_topic(@topic.id)).to_a
puts @alltopics.length
@ -32,7 +32,7 @@ puts @allsynapses.length
@allcreators += @allsynapses.map(&:user).uniq
respond_with(@allsynapses, @alltopics, @allcreators, @topic)
}
end
format.json { render json: @topic }
end
end
@ -48,7 +48,7 @@ puts @allsynapses.length
@allcreators = @alltopics.map(&:user).uniq
@allcreators += @allsynapses.map(&:user).uniq
@json = Hash.new()
@json = {}
@json['topic'] = @topic
@json['creators'] = @allcreators
@json['relatives'] = @alltopics
@ -68,7 +68,7 @@ puts @allsynapses.length
@alltopics = policy_scope(Topic.relatives1(@topic.id)).to_a.concat(policy_scope(Topic.relatives2(@topic.id)).to_a).uniq
@alltopics.delete_if do |topic|
topicsAlreadyHas.index(topic.id) != nil
!topicsAlreadyHas.index(topic.id).nil?
end
@json = Hash.new(0)
@ -90,22 +90,22 @@ puts @allsynapses.length
alltopics = policy_scope(Topic.relatives1(@topic.id)).to_a.concat(policy_scope(Topic.relatives2(@topic.id)).to_a).uniq
alltopics.delete_if do |topic|
topicsAlreadyHas.index(topic.id.to_s) != nil
!topicsAlreadyHas.index(topic.id.to_s).nil?
end
# find synapses between topics in alltopics array
allsynapses = policy_scope(Synapse.for_topic(@topic.id)).to_a
synapse_ids = (allsynapses.map(&:node1_id) + allsynapses.map(&:node2_id)).uniq
allsynapses.delete_if do |synapse|
synapse_ids.index(synapse.id) != nil
!synapse_ids.index(synapse.id).nil?
end
creatorsAlreadyHas = params[:creators] ? params[:creators].split(',').map(&:to_i) : []
allcreators = (alltopics.map(&:user) + allsynapses.map(&:user)).uniq.delete_if do |user|
creatorsAlreadyHas.index(user.id) != nil
!creatorsAlreadyHas.index(user.id).nil?
end
@json = Hash.new()
@json = {}
@json['topics'] = alltopics
@json['synapses'] = allsynapses
@json['creators'] = allcreators

View file

@ -1,5 +1,6 @@
class Users::PasswordsController < Devise::PasswordsController
protected
def after_resetting_password_path_for(resource)
signed_in_root_path(resource)
end

View file

@ -3,6 +3,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_account_update_params, only: [:update]
protected
def after_sign_up_path_for(resource)
signed_in_root_path(resource)
end
@ -12,6 +13,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
end
private
def configure_sign_up_params
devise_parameter_sanitizer.for(:sign_up) << [:name, :joinedwithcode]
end

View file

@ -20,19 +20,17 @@ class UsersController < ApplicationController
def update
@user = current_user
if user_params[:password] == "" && user_params[:password_confirmation] == ""
if user_params[:password] == '' && user_params[:password_confirmation] == ''
# not trying to change the password
if @user.update_attributes(user_params.except(:password, :password_confirmation))
if params[:remove_image] == "1"
@user.image = nil
end
@user.image = nil if params[:remove_image] == '1'
@user.save
sign_in(@user, :bypass => true)
sign_in(@user, bypass: true)
respond_to do |format|
format.html { redirect_to root_url, notice: "Account updated!" }
format.html { redirect_to root_url, notice: 'Account updated!' }
end
else
sign_in(@user, :bypass => true)
sign_in(@user, bypass: true)
respond_to do |format|
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
end
@ -42,23 +40,21 @@ class UsersController < ApplicationController
correct_pass = @user.valid_password?(params[:current_password])
if correct_pass && @user.update_attributes(user_params)
if params[:remove_image] == "1"
@user.image = nil
end
@user.image = nil if params[:remove_image] == '1'
@user.save
sign_in(@user, :bypass => true)
sign_in(@user, bypass: true)
respond_to do |format|
format.html { redirect_to root_url, notice: "Account updated!" }
format.html { redirect_to root_url, notice: 'Account updated!' }
end
else
respond_to do |format|
if correct_pass
u = User.find(@user.id)
sign_in(u, :bypass => true)
sign_in(u, bypass: true)
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
else
sign_in(@user, :bypass => true)
format.html { redirect_to edit_user_path(@user), notice: "Incorrect current password" }
sign_in(@user, bypass: true)
format.html { redirect_to edit_user_path(@user), notice: 'Incorrect current password' }
end
end
end
@ -69,10 +65,10 @@ class UsersController < ApplicationController
def details
@user = User.find(params[:id])
@details = Hash.new
@details = {}
@details['name'] = @user.name
@details['created_at'] = @user.created_at.strftime("%m/%d/%Y")
@details['created_at'] = @user.created_at.strftime('%m/%d/%Y')
@details['image'] = @user.image.url(:ninetysix)
@details['generation'] = @user.generation
@details['numSynapses'] = @user.synapses.count

View file

@ -1,22 +1,22 @@
module ApplicationHelper
def get_metacodeset
@m = current_user.settings.metacodes
set = @m[0].include?("metacodeset") ? MetacodeSet.find(@m[0].sub("metacodeset-","").to_i) : false
return set
set = @m[0].include?('metacodeset') ? MetacodeSet.find(@m[0].sub('metacodeset-', '').to_i) : false
set
end
def user_metacodes
@m = current_user.settings.metacodes
set = get_metacodeset
if set
@metacodes = set.metacodes.to_a
@metacodes = if set
set.metacodes.to_a
else
@metacodes = Metacode.where(id: @m).to_a
Metacode.where(id: @m).to_a
end
@metacodes.sort! { |m1, m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1)
end
def determine_invite_link
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : "")
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
end
end

View file

@ -1,26 +1,9 @@
module DeviseHelper
def devise_error_messages!
message = resource.errors.to_a[0]
#return "" if resource.errors.empty?
#messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
#sentence = I18n.t("errors.messages.not_saved",
# :count => resource.errors.count,
# :resource => resource.class.model_name.human.downcase)
#html = <<-HTML
#<div id="error_explanation">
# <h2>#{sentence}</h2>
# <ul>#{messages}</ul>
#</div>
#HTML
#html.html_safe
resource.errors.to_a[0]
end
def devise_error_messages?
resource.errors.empty? ? false : true
end
end

View file

@ -1,5 +1,4 @@
module MapsHelper
## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_map_array_json(maps)
temp = []
@ -13,13 +12,13 @@ module MapsHelper
map['topicCount'] = m.topics.count
map['synapseCount'] = m.synapses.count
map['contributorCount'] = m.contributors.count
map['rtype'] = "map"
map['rtype'] = 'map'
contributorTip = ''
firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
if m.contributors.count > 0
firstContributorImage = m.contributors[0].image.url(:thirtytwo)
m.contributors.each_with_index do |c, index|
m.contributors.each_with_index do |c, _index|
userImage = c.image.url(:thirtytwo)
name = c.name
contributorTip += '<li> <img class="tipUserImage" width="25" height="25" src=' + userImage + ' />' + '<span>' + name + '</span> </li>'
@ -30,7 +29,6 @@ module MapsHelper
temp.push map
end
return temp
temp
end
end

View file

@ -1,6 +1,4 @@
module SynapsesHelper
## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_synapse_generic_json(unique)
temp = []
@ -11,7 +9,7 @@ module SynapsesHelper
temp.push synapse
end
return temp
temp
end
## this one is for building our custom JSON autocomplete format for typeahead
@ -20,17 +18,16 @@ module SynapsesHelper
synapses.each do |s|
synapse = {}
synapse['id'] = s.id
synapse['label'] = s.desc == nil || s.desc == "" ? "(no description)" : s.desc
synapse['label'] = s.desc.nil? || s.desc == '' ? '(no description)' : s.desc
synapse['value'] = s.desc
synapse['permission'] = s.permission
synapse['mapCount'] = s.maps.count
synapse['originator'] = s.user.name
synapse['originatorImage'] = s.user.image.url(:thirtytwo)
synapse['rtype'] = "synapse"
synapse['rtype'] = 'synapse'
temp.push synapse
end
return temp
temp
end
end

View file

@ -1,5 +1,4 @@
module TopicsHelper
## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_array_json(topics)
temp = []
@ -16,13 +15,13 @@ module TopicsHelper
topic['synapseCount'] = t.synapses.count
topic['originator'] = t.user.name
topic['originatorImage'] = t.user.image.url(:thirtytwo)
topic['rtype'] = "topic"
topic['rtype'] = 'topic'
topic['inmaps'] = t.inmaps
topic['inmapsLinks'] = t.inmapsLinks
temp.push topic
end
return temp
temp
end
# find all nodes in any given nodes network
@ -30,21 +29,17 @@ module TopicsHelper
# recurse starting with a node to find all connected nodes and return an array of topics that constitutes the starting nodes network
# if the array of nodes is empty initialize it
if array.nil?
array = Array.new
end
array = [] if array.nil?
# add the node to the array
array.push(node)
if count == 0
return array
end
return array if count == 0
count = count - 1
count -= 1
# check if each relative is already in the array and if not, call the network function again
if not node.relatives.empty?
if !node.relatives.empty?
if (node.relatives - array).empty?
return array
else

View file

@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "team@metamaps.cc"
default from: 'team@metamaps.cc'
layout 'mailer'
end

View file

@ -1,5 +1,5 @@
class MapMailer < ApplicationMailer
default from: "team@metamaps.cc"
default from: 'team@metamaps.cc'
def invite_to_edit_email(map, inviter, invitee)
@inviter = inviter

View file

@ -1,5 +1,5 @@
class Event < ActiveRecord::Base
KINDS = %w[user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map]
KINDS = %w(user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map).freeze
# has_many :notifications, dependent: :destroy
belongs_to :eventable, polymorphic: true
@ -10,22 +10,21 @@ class Event < ActiveRecord::Base
after_create :notify_webhooks!, if: :map
validates_inclusion_of :kind, :in => KINDS
validates_presence_of :eventable
validates :kind, inclusion: { in: KINDS }
validates :eventable, presence: true
# def notify!(user)
# notifications.create!(user: user)
# end
def belongs_to?(this_user)
self.user_id == this_user.id
user_id == this_user.id
end
def notify_webhooks!
# group = self.discussion.group
self.map.webhooks.each { |webhook| WebhookService.publish! webhook: webhook, event: self }
map.webhooks.each { |webhook| WebhookService.publish! webhook: webhook, event: self }
# group.webhooks.each { |webhook| WebhookService.publish! webhook: webhook, event: self }
end
handle_asynchronously :notify_webhooks!
end

View file

@ -2,17 +2,9 @@ class Events::ConversationStartedOnMap < Event
# after_create :notify_users!
def self.publish!(map, user)
create!(kind: "conversation_started_on_map",
create!(kind: 'conversation_started_on_map',
eventable: map,
map: map,
user: user)
end
private
#def notify_users!
# unless comment_vote.user == comment_vote.comment_user
# notify!(comment_vote.comment_user)
# end
#end
end

View file

@ -2,17 +2,9 @@ class Events::NewMapping < Event
# after_create :notify_users!
def self.publish!(mapping, user)
create!(kind: mapping.mappable_type == "Topic" ? "topic_added_to_map" : "synapse_added_to_map",
create!(kind: mapping.mappable_type == 'Topic' ? 'topic_added_to_map' : 'synapse_added_to_map',
eventable: mapping,
map: mapping.map,
user: user)
end
private
#def notify_users!
# unless comment_vote.user == comment_vote.comment_user
# notify!(comment_vote.comment_user)
# end
#end
end

View file

@ -2,17 +2,9 @@ class Events::UserPresentOnMap < Event
# after_create :notify_users!
def self.publish!(map, user)
create!(kind: "user_present_on_map",
create!(kind: 'user_present_on_map',
eventable: map,
map: map,
user: user)
end
private
#def notify_users!
# unless comment_vote.user == comment_vote.comment_user
# notify!(comment_vote.comment_user)
# end
#end
end

View file

@ -1,4 +1,4 @@
class InMetacodeSet < ActiveRecord::Base
belongs_to :metacode, :class_name => "Metacode", :foreign_key => "metacode_id"
belongs_to :metacode_set, :class_name => "MetacodeSet", :foreign_key => "metacode_set_id"
belongs_to :metacode, class_name: 'Metacode', foreign_key: 'metacode_id'
belongs_to :metacode_set, class_name: 'MetacodeSet', foreign_key: 'metacode_set_id'
end

View file

@ -1,11 +1,10 @@
class Map < ActiveRecord::Base
belongs_to :user
has_many :topicmappings, -> { Mapping.topicmapping }, class_name: :Mapping, dependent: :destroy
has_many :synapsemappings, -> { Mapping.synapsemapping }, class_name: :Mapping, dependent: :destroy
has_many :topics, through: :topicmappings, source: :mappable, source_type: "Topic"
has_many :synapses, through: :synapsemappings, source: :mappable, source_type: "Synapse"
has_many :topics, through: :topicmappings, source: :mappable, source_type: 'Topic'
has_many :synapses, through: :synapsemappings, source: :mappable, source_type: 'Synapse'
has_many :messages, as: :resource, dependent: :destroy
has_many :user_maps, dependent: :destroy
@ -15,11 +14,11 @@ class Map < ActiveRecord::Base
has_many :events, -> { includes :user }, as: :eventable, dependent: :destroy
# This method associates the attribute ":image" with a file attachment
has_attached_file :screenshot, :styles => {
:thumb => ['188x126#', :png]
has_attached_file :screenshot, styles: {
thumb: ['188x126#', :png]
#:full => ['940x630#', :png]
},
:default_url => 'https://s3.amazonaws.com/metamaps-assets/site/missing-map.png'
default_url: 'https://s3.amazonaws.com/metamaps-assets/site/missing-map.png'
validates :name, presence: true
validates :arranged, inclusion: { in: [true, false] }
@ -27,7 +26,7 @@ class Map < ActiveRecord::Base
validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) }
# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/
validates_attachment_content_type :screenshot, content_type: /\Aimage\/.*\Z/
def mappings
topicmappings + synapsemappings
@ -41,15 +40,15 @@ class Map < ActiveRecord::Base
def contributors
contributors = []
self.mappings.each do |m|
contributors.push(m.user) if !contributors.include?(m.user)
mappings.each do |m|
contributors.push(m.user) unless contributors.include?(m.user)
end
return contributors
contributors
end
def editors
collaborators + [self.user]
collaborators + [user]
end
def topic_count
@ -60,9 +59,7 @@ class Map < ActiveRecord::Base
synapses.length
end
def user_name
user.name
end
delegate :name, to: :user, prefix: true
def user_image
user.image.url
@ -81,15 +78,15 @@ class Map < ActiveRecord::Base
end
def created_at_str
created_at.strftime("%m/%d/%Y")
created_at.strftime('%m/%d/%Y')
end
def updated_at_str
updated_at.strftime("%m/%d/%Y")
updated_at.strftime('%m/%d/%Y')
end
def as_json(options={})
json = super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count, :contributor_count, :collaborator_ids, :screenshot_url], :except => [:screenshot_content_type, :screenshot_file_size, :screenshot_file_name, :screenshot_updated_at])
def as_json(_options = {})
json = super(methods: [:user_name, :user_image, :topic_count, :synapse_count, :contributor_count, :collaborator_ids, :screenshot_url], except: [:screenshot_content_type, :screenshot_file_size, :screenshot_file_name, :screenshot_updated_at])
json[:created_at_clean] = created_at_str
json[:updated_at_clean] = updated_at_str
json
@ -103,11 +100,10 @@ class Map < ActiveRecord::Base
attr_accessor :content_type, :original_filename
end
data.content_type = "image/png"
data.original_filename = File.basename('map-' + self.id.to_s + '-screenshot.png')
data.content_type = 'image/png'
data.original_filename = File.basename('map-' + id.to_s + '-screenshot.png')
self.screenshot = data
self.save
save
end
end

View file

@ -1,29 +1,25 @@
class Mapping < ActiveRecord::Base
scope :topicmapping, -> { where(mappable_type: :Topic) }
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
belongs_to :mappable, polymorphic: true
belongs_to :map, :class_name => "Map", :foreign_key => "map_id", touch: true
belongs_to :map, class_name: 'Map', foreign_key: 'map_id', touch: true
belongs_to :user
validates :xloc, presence: true,
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
unless: proc { |m| m.mappable_type == 'Synapse' }
validates :yloc, presence: true,
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
unless: proc { |m| m.mappable_type == 'Synapse' }
validates :map, presence: true
validates :mappable, presence: true
def user_name
self.user.name
end
delegate :name, to: :user, prefix: true
def user_image
self.user.image.url
user.image.url
end
def as_json(options={})
super(:methods =>[:user_name, :user_image])
def as_json(_options = {})
super(methods: [:user_name, :user_image])
end
end

View file

@ -1,19 +1,15 @@
class Message < ActiveRecord::Base
belongs_to :user
belongs_to :resource, polymorphic: true
def user_name
self.user.name
end
delegate :name, to: :user, prefix: true
def user_image
self.user.image.url
user.image.url
end
def as_json(options={})
json = super(:methods =>[:user_name, :user_image])
def as_json(_options = {})
json = super(methods: [:user_name, :user_image])
json
end
end

View file

@ -1,21 +1,21 @@
class Metacode < ActiveRecord::Base
has_many :in_metacode_sets
has_many :metacode_sets, :through => :in_metacode_sets
has_many :metacode_sets, through: :in_metacode_sets
has_many :topics
# This method associates the attribute ":aws_icon" with a file attachment
has_attached_file :aws_icon, :styles => {
:ninetysix => ['96x96#', :png],
has_attached_file :aws_icon, styles: {
ninetysix: ['96x96#', :png]
},
:default_url => 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
default_url: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
# Validate the attached icon is image/jpg, image/png, etc
validates_attachment_content_type :aws_icon, :content_type => /\Aimage\/.*\Z/
validates_attachment_content_type :aws_icon, content_type: /\Aimage\/.*\Z/
validate :aws_xor_manual_icon
validate :manual_icon_https
before_create do
self.manual_icon = nil if self.manual_icon == ""
self.manual_icon = nil if manual_icon == ''
end
def icon(*args)
@ -33,30 +33,30 @@ class Metacode < ActiveRecord::Base
end
def hasSelected(user)
return true if user.settings.metacodes.include? self.id.to_s
return false
return true if user.settings.metacodes.include? id.to_s
false
end
def inMetacodeSet(metacode_set)
return true if self.metacode_sets.include? metacode_set
return false
return true if metacode_sets.include? metacode_set
false
end
private
def aws_xor_manual_icon
if aws_icon.blank? && manual_icon.blank?
errors.add(:base, "Either aws_icon or manual_icon is required")
errors.add(:base, 'Either aws_icon or manual_icon is required')
end
if aws_icon.present? && manual_icon.present?
errors.add(:base, "Specify aws_icon or manual_icon, not both")
errors.add(:base, 'Specify aws_icon or manual_icon, not both')
end
end
def manual_icon_https
if manual_icon.present?
unless manual_icon.starts_with? 'https'
errors.add(:base, "Manual icon must begin with https")
errors.add(:base, 'Manual icon must begin with https')
end
end
end

View file

@ -1,5 +1,5 @@
class MetacodeSet < ActiveRecord::Base
belongs_to :user
has_many :in_metacode_sets
has_many :metacodes, :through => :in_metacode_sets
has_many :metacodes, through: :in_metacode_sets
end

View file

@ -1,14 +1,13 @@
class PermittedParams < Struct.new(:params)
%w[map synapse topic mapping token].each do |kind|
%w(map synapse topic mapping token).each do |kind|
define_method(kind) do
permitted_attributes = self.send("#{kind}_attributes")
permitted_attributes = send("#{kind}_attributes")
params.require(kind).permit(*permitted_attributes)
end
alias_method :"api_#{kind}", kind.to_sym
end
alias :read_attribute_for_serialization :send
alias read_attribute_for_serialization send
def token_attributes
[:description]
@ -29,5 +28,4 @@ class PermittedParams < Struct.new(:params)
def mapping_attributes
[:xloc, :yloc, :map_id, :mappable_type, :mappable_id]
end
end

View file

@ -1,12 +1,12 @@
class Synapse < ActiveRecord::Base
belongs_to :user
belongs_to :defer_to_map, :class_name => 'Map', :foreign_key => 'defer_to_map_id'
belongs_to :defer_to_map, class_name: 'Map', foreign_key: 'defer_to_map_id'
belongs_to :topic1, :class_name => "Topic", :foreign_key => "node1_id"
belongs_to :topic2, :class_name => "Topic", :foreign_key => "node2_id"
belongs_to :topic1, class_name: 'Topic', foreign_key: 'node1_id'
belongs_to :topic2, class_name: 'Topic', foreign_key: 'node2_id'
has_many :mappings, as: :mappable, dependent: :destroy
has_many :maps, :through => :mappings
has_many :maps, through: :mappings
validates :desc, length: { minimum: 0, allow_nil: false }
@ -18,13 +18,11 @@ class Synapse < ActiveRecord::Base
validates :category, inclusion: { in: ['from-to', 'both'], allow_nil: true }
scope :for_topic, ->(topic_id = nil) {
where("node1_id = ? OR node2_id = ?", topic_id, topic_id)
where('node1_id = ? OR node2_id = ?', topic_id, topic_id)
}
# :nocov:
def user_name
user.name
end
delegate :name, to: :user, prefix: true
# :nocov:
# :nocov:
@ -36,7 +34,7 @@ class Synapse < ActiveRecord::Base
# :nocov:
def collaborator_ids
if defer_to_map
defer_to_map.editors.select{|mapper| not mapper == self.user }.map(&:id)
defer_to_map.editors.select { |mapper| mapper != user }.map(&:id)
else
[]
end
@ -54,9 +52,8 @@ class Synapse < ActiveRecord::Base
# :nocov:
# :nocov:
def as_json(options={})
super(:methods =>[:user_name, :user_image, :calculated_permission, :collaborator_ids])
def as_json(_options = {})
super(methods: [:user_name, :user_image, :calculated_permission, :collaborator_ids])
end
# :nocov:
end

View file

@ -6,6 +6,7 @@ class Token < ActiveRecord::Base
CHARS = 32
private
def assign_token
self.token = generate_token
end
@ -13,10 +14,7 @@ class Token < ActiveRecord::Base
def generate_token
loop do
candidate = SecureRandom.base64(CHARS).gsub(/\W/, '')
if candidate.size >= CHARS
return candidate[0...CHARS]
return candidate[0...CHARS] if candidate.size >= CHARS
end
end
end
end

View file

@ -2,15 +2,15 @@ class Topic < ActiveRecord::Base
include TopicsHelper
belongs_to :user
belongs_to :defer_to_map, :class_name => 'Map', :foreign_key => 'defer_to_map_id'
belongs_to :defer_to_map, class_name: 'Map', foreign_key: 'defer_to_map_id'
has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', dependent: :destroy
has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', dependent: :destroy
has_many :topics1, :through => :synapses2, source: :topic1
has_many :topics2, :through => :synapses1, source: :topic2
has_many :synapses1, class_name: 'Synapse', foreign_key: 'node1_id', dependent: :destroy
has_many :synapses2, class_name: 'Synapse', foreign_key: 'node2_id', dependent: :destroy
has_many :topics1, through: :synapses2, source: :topic1
has_many :topics2, through: :synapses1, source: :topic2
has_many :mappings, as: :mappable, dependent: :destroy
has_many :maps, :through => :mappings
has_many :maps, through: :mappings
belongs_to :metacode
@ -27,12 +27,12 @@ class Topic < ActiveRecord::Base
# }
# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
# This method associates the attribute ":image" with a file attachment
has_attached_file :audio
# Validate the attached audio is audio/wav, audio/mp3, etc
validates_attachment_content_type :audio, :content_type => /\Aaudio\/.*\Z/
validates_attachment_content_type :audio, content_type: /\Aaudio\/.*\Z/
def synapses
synapses1 + synapses2
@ -54,9 +54,7 @@ class Topic < ActiveRecord::Base
.references(:synapses)
}
def user_name
user.name
end
delegate :name, to: :user, prefix: true
def user_image
user.image.url
@ -86,19 +84,19 @@ class Topic < ActiveRecord::Base
end
end
def as_json(options={})
super(:methods =>[:user_name, :user_image, :map_count, :synapse_count, :inmaps, :inmapsLinks, :calculated_permission, :collaborator_ids])
def as_json(_options = {})
super(methods: [:user_name, :user_image, :map_count, :synapse_count, :inmaps, :inmapsLinks, :calculated_permission, :collaborator_ids])
end
def collaborator_ids
if defer_to_map
defer_to_map.editors.select{|mapper| not mapper == self.user }.map(&:id)
defer_to_map.editors.select { |mapper| mapper != user }.map(&:id)
else
[]
end
end
# TODO move to a decorator?
# TODO: move to a decorator?
def synapses_csv(output_format = 'array')
output = []
synapses.each do |synapse|
@ -108,7 +106,7 @@ class Topic < ActiveRecord::Base
elsif synapse.node2_id == id
output << synapse.node2_id.to_s + '<-' + synapse.node1_id.to_s
else
fail 'invalid synapse on topic in synapse_csv'
raise 'invalid synapse on topic in synapse_csv'
end
elsif synapse.category == 'both'
if synapse.node1_id == id
@ -116,7 +114,7 @@ class Topic < ActiveRecord::Base
elsif synapse.node2_id == id
output << synapse.node2_id.to_s + '<->' + synapse.node1_id.to_s
else
fail 'invalid synapse on topic in synapse_csv'
raise 'invalid synapse on topic in synapse_csv'
end
end
end
@ -125,13 +123,13 @@ class Topic < ActiveRecord::Base
elsif output_format == 'text'
return output.join('; ')
else
fail 'invalid argument to synapses_csv'
raise 'invalid argument to synapses_csv'
end
output
end
def topic_autocomplete_method
"Get: #{self.name}"
"Get: #{name}"
end
def mk_permission

View file

@ -1,7 +1,6 @@
require 'open-uri'
class User < ActiveRecord::Base
has_many :topics
has_many :synapses
has_many :maps
@ -16,40 +15,39 @@ class User < ActiveRecord::Base
serialize :settings, UserPreference
validates :password, :presence => true,
:length => { :within => 8..40 },
:on => :create
validates :password, :length => { :within => 8..40 },
:allow_blank => true,
:on => :update
validates_confirmation_of :password
validates :password, presence: true,
length: { within: 8..40 },
on: :create
validates :password, length: { within: 8..40 },
allow_blank: true,
on: :update
validates :password, confirmation: true
validates_presence_of :name # done by devise
validates_presence_of :email # done by devise
validates_uniqueness_of :name # done by devise
validates_uniqueness_of :email # done by devise
validates :name, presence: true # done by devise
validates :email, presence: true # done by devise
validates :name, uniqueness: true # done by devise
validates :email, uniqueness: true # done by devise
validates :joinedwithcode, :presence => true, :inclusion => { :in => $codes, :message => "%{value} is not valid" }, :on => :create
validates :joinedwithcode, presence: true, inclusion: { in: $codes, message: '%{value} is not valid' }, on: :create
# This method associates the attribute ":image" with a file attachment
has_attached_file :image, :styles => {
:thirtytwo => ['32x32#', :png],
:sixtyfour => ['64x64#', :png],
:ninetysix => ['96x96#', :png],
:onetwentyeight => ['128x128#', :png]
has_attached_file :image, styles: {
thirtytwo: ['32x32#', :png],
sixtyfour: ['64x64#', :png],
ninetysix: ['96x96#', :png],
onetwentyeight: ['128x128#', :png]
},
:default_url => 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
default_url: 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
# Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates_attachment_content_type :image, content_type: %r(\Aimage/.*\Z)
# override default as_json
def as_json(options={})
{ :id => self.id,
:name => self.name,
:image => self.image.url(:sixtyfour),
:admin => self.admin
}
def as_json(_options = {})
{ id: id,
name: name,
image: image.url(:sixtyfour),
admin: admin }
end
def as_json_for_autocomplete
@ -60,8 +58,8 @@ class User < ActiveRecord::Base
json['profile'] = image.url(:sixtyfour)
json['mapCount'] = maps.count
json['generation'] = generation
json['created_at'] = created_at.strftime("%m/%d/%Y")
json['rtype'] = "mapper"
json['created_at'] = created_at.strftime('%m/%d/%Y')
json['rtype'] = 'mapper'
json
end
@ -82,14 +80,11 @@ class User < ActiveRecord::Base
def settings
# make sure we always return a UserPreference instance
if read_attribute(:settings).nil?
write_attribute :settings, UserPreference.new
end
read_attribute :settings
self[:settings] = UserPreference.new if self[:settings].nil?
self[:settings]
end
def settings=(val)
write_attribute :settings, val
self[:settings] = val
end
end

View file

@ -3,7 +3,7 @@ class UserPreference
def initialize
array = []
Metacode.all.each do |m|
Metacode.all.find_each do |m|
array.push(m.id.to_s)
end
@metacodes = array

View file

@ -3,11 +3,10 @@ class Webhook < ActiveRecord::Base
validates :uri, presence: true
validates :hookable, presence: true
validates_inclusion_of :kind, in: %w[slack]
validates :kind, inclusion: { in: %w(slack) }
validates :event_types, length: { minimum: 1 }
def headers
{}
end
end

View file

@ -2,15 +2,15 @@ Webhooks::Slack::Base = Struct.new(:event) do
include Routing
def username
"Metamaps Bot"
'Metamaps Bot'
end
def icon_url
"https://pbs.twimg.com/profile_images/539300245029392385/dJ1bwnw7.jpeg"
'https://pbs.twimg.com/profile_images/539300245029392385/dJ1bwnw7.jpeg'
end
def text
"something"
'something'
end
def attachments
@ -22,7 +22,7 @@ Webhooks::Slack::Base = Struct.new(:event) do
}]
end
alias :read_attribute_for_serialization :send
alias_method :read_attribute_for_serialization, :send
private
@ -59,7 +59,6 @@ Webhooks::Slack::Base = Struct.new(:event) do
def author
@author ||= eventable.author
end
end
# webhooks:

View file

@ -1,27 +1,25 @@
class Webhooks::Slack::ConversationStartedOnMap < Webhooks::Slack::Base
def text
"There is a live conversation starting on map *#{event.map.name}*. #{view_map_on_metamaps('Join in!')}"
end
# todo: it would be sweet if it sends it with the metacode as the icon_url
# TODO: it would be sweet if it sends it with the metacode as the icon_url
def attachment_fallback
"" #{}"*#{eventable.name}*\n#{eventable.description}\n"
'' # {}"*#{eventable.name}*\n#{eventable.description}\n"
end
def attachment_title
"" #proposal_link(eventable)
'' # proposal_link(eventable)
end
def attachment_text
"" # "#{eventable.description}\n"
'' # "#{eventable.description}\n"
end
def attachment_fields
[{
title: "nothing",
value: "nothing"
title: 'nothing',
value: 'nothing'
}] # [motion_vote_field]
end
end

View file

@ -1,26 +1,24 @@
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
def text
"\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps()}*"
"\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps}*"
end
def attachment_fallback
"" #{}"*#{eventable.name}*\n#{eventable.description}\n"
'' # {}"*#{eventable.name}*\n#{eventable.description}\n"
end
def attachment_title
"" #proposal_link(eventable)
'' # proposal_link(eventable)
end
def attachment_text
"" # "#{eventable.description}\n"
'' # "#{eventable.description}\n"
end
def attachment_fields
[{
title: "nothing",
value: "nothing"
title: 'nothing',
value: 'nothing'
}] # [motion_vote_field]
end
end

View file

@ -1,27 +1,25 @@
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
def text
"New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps()}*"
"New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps}*"
end
# todo: it would be sweet if it sends it with the metacode as the icon_url
# TODO: it would be sweet if it sends it with the metacode as the icon_url
def attachment_fallback
"" #{}"*#{eventable.name}*\n#{eventable.description}\n"
'' # {}"*#{eventable.name}*\n#{eventable.description}\n"
end
def attachment_title
"" #proposal_link(eventable)
'' # proposal_link(eventable)
end
def attachment_text
"" # "#{eventable.description}\n"
'' # "#{eventable.description}\n"
end
def attachment_fields
[{
title: "nothing",
value: "nothing"
title: 'nothing',
value: 'nothing'
}] # [motion_vote_field]
end
end

View file

@ -1,27 +1,25 @@
class Webhooks::Slack::UserPresentOnMap < Webhooks::Slack::Base
def text
"Mapper *#{event.user.name}* has joined the map *#{event.map.name}*. #{view_map_on_metamaps('Map with them')}"
end
# todo: it would be sweet if it sends it with the metacode as the icon_url
# TODO: it would be sweet if it sends it with the metacode as the icon_url
def attachment_fallback
"" #{}"*#{eventable.name}*\n#{eventable.description}\n"
'' # {}"*#{eventable.name}*\n#{eventable.description}\n"
end
def attachment_title
"" #proposal_link(eventable)
'' # proposal_link(eventable)
end
def attachment_text
"" # "#{eventable.description}\n"
'' # "#{eventable.description}\n"
end
def attachment_fields
[{
title: "nothing",
value: "nothing"
title: 'nothing',
value: 'nothing'
}] # [motion_vote_field]
end
end

View file

@ -11,7 +11,7 @@ class ApplicationPolicy
end
def show?
scope.where(:id => record.id).exists?
scope.where(id: record.id).exists?
end
def create?
@ -34,7 +34,7 @@ class ApplicationPolicy
false
end
# TODO update this function to enable some flag in the interface
# TODO: update this function to enable some flag in the interface
# so that admins usually can't do super admin stuff unless they
# explicitly say they want to (E.g. seeing/editing/deleting private
# maps - they should be able to, but not by accident)

View file

@ -1,5 +1,5 @@
class MainPolicy < ApplicationPolicy
def initialize(user, record)
def initialize(user, _record)
@user = user
@record = nil
end

View file

@ -1,7 +1,7 @@
class MapPolicy < ApplicationPolicy
class Scope < Scope
def resolve
visible = ['public', 'commons']
visible = %w(public commons)
permission = 'maps.permission IN (?)'
if user
shared_maps = user.shared_maps.map(&:id)

View file

@ -1,11 +1,11 @@
class MappingPolicy < ApplicationPolicy
class Scope < Scope
def resolve
# TODO base this on the map policy
# TODO: base this on the map policy
# it would be nice if we could also base this on the mappable, but that
# gets really complicated. Devin thinks it's OK to SHOW a mapping for
# a private topic, since you can't see the private topic anyways
visible = ['public', 'commons']
visible = %w(public commons)
permission = 'maps.permission IN (?)'
if user
scope.joins(:maps).where(permission + ' OR maps.user_id = ?', visible, user.id)

View file

@ -1,7 +1,7 @@
class MessagePolicy < ApplicationPolicy
class Scope < Scope
def resolve
visible = ['public', 'commons']
visible = %w(public commons)
permission = 'maps.permission IN (?)'
if user
scope.joins(:maps).where(permission + ' OR maps.user_id = ?', visible, user.id)
@ -11,9 +11,7 @@ class MessagePolicy < ApplicationPolicy
end
end
def show?
resource_policy.show?
end
delegate :show?, to: :resource_policy
def create?
record.resource.present? && resource_policy.update?
@ -32,5 +30,4 @@ class MessagePolicy < ApplicationPolicy
def resource_policy
@resource_policy ||= Pundit.policy(user, record.resource)
end
end

View file

@ -1,7 +1,7 @@
class SynapsePolicy < ApplicationPolicy
class Scope < Scope
def resolve
visible = ['public', 'commons']
visible = %w(public commons)
permission = 'synapses.permission IN (?)'
if user
scope.where(permission + ' OR synapses.defer_to_map_id IN (?) OR synapses.user_id = ?', visible, user.shared_maps.map(&:id), user.id)
@ -13,7 +13,7 @@ class SynapsePolicy < ApplicationPolicy
def create?
user.present?
# todo add validation against whether you can see both topics
# TODO: add validation against whether you can see both topics
end
def show?
@ -25,7 +25,7 @@ class SynapsePolicy < ApplicationPolicy
end
def update?
if not user.present?
if !user.present?
false
elsif record.defer_to_map.present?
map_policy.update?

View file

@ -4,7 +4,7 @@ class TokenPolicy < ApplicationPolicy
if user
scope.where('tokens.user_id = ?', user.id)
else
scope.where(:id => nil).where("id IS NOT ?", nil) # to just return none
scope.where(id: nil).where('id IS NOT ?', nil) # to just return none
end
end
end
@ -20,5 +20,4 @@ class TokenPolicy < ApplicationPolicy
def destroy?
user.present? && record.user == user
end
end

View file

@ -1,7 +1,7 @@
class TopicPolicy < ApplicationPolicy
class Scope < Scope
def resolve
visible = ['public', 'commons']
visible = %w(public commons)
permission = 'topics.permission IN (?)'
if user
scope.where(permission + ' OR topics.defer_to_map_id IN (?) OR topics.user_id = ?', visible, user.shared_maps.map(&:id), user.id)
@ -24,7 +24,7 @@ class TopicPolicy < ApplicationPolicy
end
def update?
if not user.present?
if !user.present?
false
elsif record.defer_to_map.present?
map_policy.update?

View file

@ -13,5 +13,4 @@ class NewMapSerializer < ActiveModel::Serializer
has_many :mappings, serializer: NewMappingSerializer
has_many :contributors, root: :users, serializer: NewUserSerializer
has_many :collaborators, root: :users, serializer: NewUserSerializer
end

View file

@ -12,8 +12,8 @@ class NewMappingSerializer < ActiveModel::Serializer
has_one :map, serializer: NewMapSerializer
def filter(keys)
keys.delete(:xloc) unless object.mappable_type == "Topic"
keys.delete(:yloc) unless object.mappable_type == "Topic"
keys.delete(:xloc) unless object.mappable_type == 'Topic'
keys.delete(:yloc) unless object.mappable_type == 'Topic'
keys
end
end

View file

@ -11,5 +11,4 @@ class NewSynapseSerializer < ActiveModel::Serializer
has_one :topic1, root: :topics, serializer: NewTopicSerializer
has_one :topic2, root: :topics, serializer: NewTopicSerializer
has_one :user, serializer: NewUserSerializer
end

View file

@ -10,5 +10,4 @@ class NewTopicSerializer < ActiveModel::Serializer
has_one :user, serializer: NewUserSerializer
has_one :metacode, serializer: NewMetacodeSerializer
end

View file

@ -4,5 +4,4 @@ class TokenSerializer < ActiveModel::Serializer
:description,
:created_at,
:updated_at
end

View file

@ -24,6 +24,7 @@ class MapExportService < Struct.new(:user, :map)
def topic_headings
[:id, :name, :metacode, :x, :y, :description, :link, :user, :permission]
end
def synapse_headings
[:topic1, :topic2, :category, :description, :user, :permission]
end
@ -64,7 +65,7 @@ class MapExportService < Struct.new(:user, :map)
def to_spreadsheet
spreadsheet = []
spreadsheet << ["Topics"]
spreadsheet << ['Topics']
spreadsheet << topic_headings.map(&:capitalize)
exportable_topics.each do |topics|
# convert exportable_topics into an array of arrays
@ -72,7 +73,7 @@ class MapExportService < Struct.new(:user, :map)
end
spreadsheet << []
spreadsheet << ["Synapses"]
spreadsheet << ['Synapses']
spreadsheet << synapse_headings.map(&:capitalize)
exportable_synapses.each do |synapse|
# convert exportable_synapses into an array of arrays

View file

@ -1,32 +1,31 @@
class Perm
# e.g. Perm::ISSIONS
ISSIONS = [:commons, :public, :private]
ISSIONS = [:commons, :public, :private].freeze
class << self
def short(permission)
case permission
when :commons
"co"
'co'
when :public
"pu"
'pu'
when :private
"pr"
'pr'
else
fail "Invalid permission"
raise 'Invalid permission'
end
end
def long(perm)
case perm
when "co"
when 'co'
:commons
when "pu"
when 'pu'
:public
when "pr"
when 'pr'
:private
else
fail "Invalid short permission"
raise 'Invalid short permission'
end
end

View file

@ -1,18 +1,16 @@
class WebhookService
def self.publish!(webhook:, event:)
return false unless webhook.event_types.include? event.kind
HTTParty.post webhook.uri, body: payload_for(webhook, event), headers: webhook.headers
end
private
def self.payload_for(webhook, event)
class << self
def payload_for(webhook, event)
WebhookSerializer.new(webhook_object_for(webhook, event), root: false).to_json
end
def self.webhook_object_for(webhook, event)
def webhook_object_for(webhook, event)
"Webhooks::#{webhook.kind.classify}::#{event.kind.classify}".constantize.new(event)
end
end
end

View file

@ -31,12 +31,12 @@ module Metamaps
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
config.encoding = 'utf-8'
config.to_prepare do
Doorkeeper::ApplicationsController.layout "doorkeeper"
Doorkeeper::AuthorizationsController.layout "doorkeeper"
Doorkeeper::AuthorizedApplicationsController.layout "doorkeeper"
Doorkeeper::ApplicationsController.layout 'doorkeeper'
Doorkeeper::AuthorizationsController.layout 'doorkeeper'
Doorkeeper::AuthorizedApplicationsController.layout 'doorkeeper'
Doorkeeper::ApplicationController.helper ApplicationHelper
end
@ -60,6 +60,6 @@ module Metamaps
config.active_record.raise_in_transactional_callbacks = true
# pundit errors return 403 FORBIDDEN
config.action_dispatch.rescue_responses["Pundit::NotAuthorizedError"] = :forbidden
config.action_dispatch.rescue_responses['Pundit::NotAuthorizedError'] = :forbidden
end
end

View file

@ -11,4 +11,4 @@ end
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

View file

@ -33,8 +33,9 @@ Metamaps::Application.configure do
domain: ENV['SMTP_DOMAIN'],
authentication: 'plain',
enable_starttls_auto: true,
openssl_verify_mode: 'none' }
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
openssl_verify_mode: 'none'
}
config.action_mailer.default_url_options = { host: 'localhost:3000' }
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true

View file

@ -20,10 +20,9 @@ Metamaps::Application.configure do
# Compress JavaScripts and CSS
config.assets.compress = true
# S3 file storage
config.paperclip_defaults = {
:storage => :s3,
storage: :s3,
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
@ -41,8 +40,9 @@ Metamaps::Application.configure do
# domain: ENV['SMTP_DOMAIN']
authentication: 'plain',
enable_starttls_auto: true,
openssl_verify_mode: 'none' }
config.action_mailer.default_url_options = { :host => ENV['MAILER_DEFAULT_URL'] }
openssl_verify_mode: 'none'
}
config.action_mailer.default_url_options = { host: ENV['MAILER_DEFAULT_URL'] }
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true

View file

@ -11,7 +11,7 @@ Metamaps::Application.configure do
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching
config.consider_all_requests_local = true

View file

@ -1,4 +1,4 @@
$codes = []
if ActiveRecord::Base.connection.table_exists? 'users'
$codes = ActiveRecord::Base.connection.execute("SELECT code FROM users").map {|user| user["code"] }
$codes = ActiveRecord::Base.connection.execute('SELECT code FROM users').map { |user| user['code'] }
end

View file

@ -16,7 +16,6 @@ Devise.setup do |config|
# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
config.secret_key = ENV['DEVISE_SECRET_KEY']
# ==> ORM configuration

View file

@ -4,4 +4,4 @@
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register "application/xls", :xls
Mime::Type.register 'application/xls', :xls

View file

@ -2,6 +2,6 @@ require 'uservoice-ruby'
def current_sso_token
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
:email => current_user.email
email: current_user.email
}, 300) # Default expiry time is 5 minutes = 300 seconds
end

View file

@ -1 +1 @@
METAMAPS_VERSION = '2.8.5'
METAMAPS_VERSION = '2.8.5'.freeze

View file

@ -1,5 +1,4 @@
Metamaps::Application.routes.draw do
use_doorkeeper
root to: 'main#home', via: :get
@ -22,14 +21,14 @@ Metamaps::Application.routes.draw do
resources :messages, only: [:show, :create, :update, :destroy]
resources :mappings, except: [:index, :new, :edit]
resources :metacode_sets, :except => [:show]
resources :metacode_sets, except: [:show]
resources :metacodes, :except => [:destroy]
resources :metacodes, except: [:destroy]
get 'metacodes/:name', to: 'metacodes#show'
resources :synapses, except: [:index, :new, :edit]
resources :topics, except: [:index, :new, :edit] do
get :autocomplete_topic, :on => :collection
get :autocomplete_topic, on: :collection
end
get 'topics/:id/network', to: 'topics#network', as: :network
get 'topics/:id/relative_numbers', to: 'topics#relative_numbers', as: :relative_numbers
@ -48,7 +47,7 @@ Metamaps::Application.routes.draw do
get 'explore/shared', to: 'maps#sharedmaps'
get 'explore/mapper/:id', to: 'maps#usermaps'
devise_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, :skip => :sessions
devise_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, skip: :sessions
devise_scope :user do
get 'login' => 'devise/sessions#new', :as => :new_user_session

View file

@ -5,19 +5,19 @@ class MappingPolymorphism < ActiveRecord::Migration
add_index :mappings, [:mappable_id, :mappable_type]
Mapping.find_each do |mapping|
if mapping.synapse_id.nil? and mapping.topic_id.nil?
if mapping.synapse_id.nil? && mapping.topic_id.nil?
puts "Mapping id=#{mapping.id} has no valid id, skipping!"
next
end
if not mapping.synapse_id.nil? and not mapping.topic_id.nil?
if !mapping.synapse_id.nil? && !mapping.topic_id.nil?
puts "Mapping id=#{mapping.id} has both topic and synapse ids, skipping!"
next
end
unless mapping.synapse_id.nil?
mapping.mappable = Synapse.find_by(id: mapping.synapse_id)
else
if mapping.synapse_id.nil?
mapping.mappable = Topic.find_by(id: mapping.topic_id)
else
mapping.mappable = Synapse.find_by(id: mapping.synapse_id)
end
if mapping.mappable.nil?

View file

@ -4,12 +4,11 @@ end
class MetacodeAssetPathUpdate < ActiveRecord::Migration
def change
Metacode.first(50).each do |metacode|
if metacode.icon.start_with?("/assets/icons/")
metacode.icon = metacode.icon.sub(/^\/assets\/icons/, "https://s3.amazonaws.com/metamaps-assets/metacodes")
next unless metacode.icon.start_with?('/assets/icons/')
metacode.icon = metacode.icon.sub(/^\/assets\/icons/, 'https://s3.amazonaws.com/metamaps-assets/metacodes')
metacode.icon = metacode.icon.sub('blueprint_96px', 'blueprint/96px')
metacode.icon = metacode.icon.sub('generics_96px', 'generics/96px')
metacode.save
end
end
end
end

View file

@ -13,7 +13,7 @@ class CreateDelayedJobs < ActiveRecord::Migration
table.timestamps null: true
end
add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
add_index :delayed_jobs, [:priority, :run_at], name: 'delayed_jobs_priority'
end
def self.down

View file

@ -11,270 +11,269 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160401133937) do
ActiveRecord::Schema.define(version: 20_160_401_133_937) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension 'plpgsql'
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "handler", null: false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'delayed_jobs', force: :cascade do |t|
t.integer 'priority', default: 0, null: false
t.integer 'attempts', default: 0, null: false
t.text 'handler', null: false
t.text 'last_error'
t.datetime 'run_at'
t.datetime 'locked_at'
t.datetime 'failed_at'
t.string 'locked_by'
t.string 'queue'
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
add_index 'delayed_jobs', %w(priority run_at), name: 'delayed_jobs_priority', using: :btree
create_table "events", force: :cascade do |t|
t.string "kind", limit: 255
t.integer "eventable_id"
t.string "eventable_type"
t.integer "user_id"
t.integer "map_id"
t.integer "sequence_id"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'events', force: :cascade do |t|
t.string 'kind', limit: 255
t.integer 'eventable_id'
t.string 'eventable_type'
t.integer 'user_id'
t.integer 'map_id'
t.integer 'sequence_id'
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "events", ["eventable_type", "eventable_id"], name: "index_events_on_eventable_type_and_eventable_id", using: :btree
add_index "events", ["map_id", "sequence_id"], name: "index_events_on_map_id_and_sequence_id", unique: true, using: :btree
add_index "events", ["map_id"], name: "index_events_on_map_id", using: :btree
add_index "events", ["sequence_id"], name: "index_events_on_sequence_id", using: :btree
add_index "events", ["user_id"], name: "index_events_on_user_id", using: :btree
add_index 'events', %w(eventable_type eventable_id), name: 'index_events_on_eventable_type_and_eventable_id', using: :btree
add_index 'events', %w(map_id sequence_id), name: 'index_events_on_map_id_and_sequence_id', unique: true, using: :btree
add_index 'events', ['map_id'], name: 'index_events_on_map_id', using: :btree
add_index 'events', ['sequence_id'], name: 'index_events_on_sequence_id', using: :btree
add_index 'events', ['user_id'], name: 'index_events_on_user_id', using: :btree
create_table "in_metacode_sets", force: :cascade do |t|
t.integer "metacode_id"
t.integer "metacode_set_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'in_metacode_sets', force: :cascade do |t|
t.integer 'metacode_id'
t.integer 'metacode_set_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end
add_index "in_metacode_sets", ["metacode_id"], name: "index_in_metacode_sets_on_metacode_id", using: :btree
add_index "in_metacode_sets", ["metacode_set_id"], name: "index_in_metacode_sets_on_metacode_set_id", using: :btree
add_index 'in_metacode_sets', ['metacode_id'], name: 'index_in_metacode_sets_on_metacode_id', using: :btree
add_index 'in_metacode_sets', ['metacode_set_id'], name: 'index_in_metacode_sets_on_metacode_set_id', using: :btree
create_table "mappings", force: :cascade do |t|
t.text "category"
t.integer "xloc"
t.integer "yloc"
t.integer "topic_id"
t.integer "synapse_id"
t.integer "map_id"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "mappable_id"
t.string "mappable_type"
create_table 'mappings', force: :cascade do |t|
t.text 'category'
t.integer 'xloc'
t.integer 'yloc'
t.integer 'topic_id'
t.integer 'synapse_id'
t.integer 'map_id'
t.integer 'user_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.integer 'mappable_id'
t.string 'mappable_type'
end
add_index "mappings", ["map_id", "synapse_id"], name: "index_mappings_on_map_id_and_synapse_id", using: :btree
add_index "mappings", ["map_id", "topic_id"], name: "index_mappings_on_map_id_and_topic_id", using: :btree
add_index "mappings", ["map_id"], name: "index_mappings_on_map_id", using: :btree
add_index "mappings", ["mappable_id", "mappable_type"], name: "index_mappings_on_mappable_id_and_mappable_type", using: :btree
add_index "mappings", ["user_id"], name: "index_mappings_on_user_id", using: :btree
add_index 'mappings', %w(map_id synapse_id), name: 'index_mappings_on_map_id_and_synapse_id', using: :btree
add_index 'mappings', %w(map_id topic_id), name: 'index_mappings_on_map_id_and_topic_id', using: :btree
add_index 'mappings', ['map_id'], name: 'index_mappings_on_map_id', using: :btree
add_index 'mappings', %w(mappable_id mappable_type), name: 'index_mappings_on_mappable_id_and_mappable_type', using: :btree
add_index 'mappings', ['user_id'], name: 'index_mappings_on_user_id', using: :btree
create_table "maps", force: :cascade do |t|
t.text "name"
t.boolean "arranged"
t.text "desc"
t.text "permission"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "featured"
t.string "screenshot_file_name"
t.string "screenshot_content_type"
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
create_table 'maps', force: :cascade do |t|
t.text 'name'
t.boolean 'arranged'
t.text 'desc'
t.text 'permission'
t.integer 'user_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.boolean 'featured'
t.string 'screenshot_file_name'
t.string 'screenshot_content_type'
t.integer 'screenshot_file_size'
t.datetime 'screenshot_updated_at'
end
add_index "maps", ["user_id"], name: "index_maps_on_user_id", using: :btree
add_index 'maps', ['user_id'], name: 'index_maps_on_user_id', using: :btree
create_table "messages", force: :cascade do |t|
t.text "message"
t.integer "user_id"
t.integer "resource_id"
t.string "resource_type"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'messages', force: :cascade do |t|
t.text 'message'
t.integer 'user_id'
t.integer 'resource_id'
t.string 'resource_type'
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "messages", ["resource_id"], name: "index_messages_on_resource_id", using: :btree
add_index "messages", ["resource_type"], name: "index_messages_on_resource_type", using: :btree
add_index "messages", ["user_id"], name: "index_messages_on_user_id", using: :btree
add_index 'messages', ['resource_id'], name: 'index_messages_on_resource_id', using: :btree
add_index 'messages', ['resource_type'], name: 'index_messages_on_resource_type', using: :btree
add_index 'messages', ['user_id'], name: 'index_messages_on_user_id', using: :btree
create_table "metacode_sets", force: :cascade do |t|
t.string "name"
t.text "desc"
t.integer "user_id"
t.boolean "mapperContributed"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'metacode_sets', force: :cascade do |t|
t.string 'name'
t.text 'desc'
t.integer 'user_id'
t.boolean 'mapperContributed'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end
add_index "metacode_sets", ["user_id"], name: "index_metacode_sets_on_user_id", using: :btree
add_index 'metacode_sets', ['user_id'], name: 'index_metacode_sets_on_user_id', using: :btree
create_table "metacodes", force: :cascade do |t|
t.text "name"
t.string "manual_icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "color"
t.string "aws_icon_file_name"
t.string "aws_icon_content_type"
t.integer "aws_icon_file_size"
t.datetime "aws_icon_updated_at"
create_table 'metacodes', force: :cascade do |t|
t.text 'name'
t.string 'manual_icon'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'color'
t.string 'aws_icon_file_name'
t.string 'aws_icon_content_type'
t.integer 'aws_icon_file_size'
t.datetime 'aws_icon_updated_at'
end
create_table "oauth_access_grants", force: :cascade do |t|
t.integer "resource_owner_id", null: false
t.integer "application_id", null: false
t.string "token", null: false
t.integer "expires_in", null: false
t.text "redirect_uri", null: false
t.datetime "created_at", null: false
t.datetime "revoked_at"
t.string "scopes"
create_table 'oauth_access_grants', force: :cascade do |t|
t.integer 'resource_owner_id', null: false
t.integer 'application_id', null: false
t.string 'token', null: false
t.integer 'expires_in', null: false
t.text 'redirect_uri', null: false
t.datetime 'created_at', null: false
t.datetime 'revoked_at'
t.string 'scopes'
end
add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree
add_index 'oauth_access_grants', ['token'], name: 'index_oauth_access_grants_on_token', unique: true, using: :btree
create_table "oauth_access_tokens", force: :cascade do |t|
t.integer "resource_owner_id"
t.integer "application_id"
t.string "token", null: false
t.string "refresh_token"
t.integer "expires_in"
t.datetime "revoked_at"
t.datetime "created_at", null: false
t.string "scopes"
create_table 'oauth_access_tokens', force: :cascade do |t|
t.integer 'resource_owner_id'
t.integer 'application_id'
t.string 'token', null: false
t.string 'refresh_token'
t.integer 'expires_in'
t.datetime 'revoked_at'
t.datetime 'created_at', null: false
t.string 'scopes'
end
add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree
add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree
add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree
add_index 'oauth_access_tokens', ['refresh_token'], name: 'index_oauth_access_tokens_on_refresh_token', unique: true, using: :btree
add_index 'oauth_access_tokens', ['resource_owner_id'], name: 'index_oauth_access_tokens_on_resource_owner_id', using: :btree
add_index 'oauth_access_tokens', ['token'], name: 'index_oauth_access_tokens_on_token', unique: true, using: :btree
create_table "oauth_applications", force: :cascade do |t|
t.string "name", null: false
t.string "uid", null: false
t.string "secret", null: false
t.text "redirect_uri", null: false
t.string "scopes", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
create_table 'oauth_applications', force: :cascade do |t|
t.string 'name', null: false
t.string 'uid', null: false
t.string 'secret', null: false
t.text 'redirect_uri', null: false
t.string 'scopes', default: '', null: false
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
add_index 'oauth_applications', ['uid'], name: 'index_oauth_applications_on_uid', unique: true, using: :btree
create_table "synapses", force: :cascade do |t|
t.text "desc"
t.text "category"
t.text "weight"
t.text "permission"
t.integer "node1_id"
t.integer "node2_id"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "defer_to_map_id"
create_table 'synapses', force: :cascade do |t|
t.text 'desc'
t.text 'category'
t.text 'weight'
t.text 'permission'
t.integer 'node1_id'
t.integer 'node2_id'
t.integer 'user_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.integer 'defer_to_map_id'
end
add_index "synapses", ["node1_id", "node1_id"], name: "index_synapses_on_node1_id_and_node1_id", using: :btree
add_index "synapses", ["node1_id"], name: "index_synapses_on_node1_id", using: :btree
add_index "synapses", ["node2_id", "node2_id"], name: "index_synapses_on_node2_id_and_node2_id", using: :btree
add_index "synapses", ["node2_id"], name: "index_synapses_on_node2_id", using: :btree
add_index "synapses", ["user_id"], name: "index_synapses_on_user_id", using: :btree
add_index 'synapses', %w(node1_id node1_id), name: 'index_synapses_on_node1_id_and_node1_id', using: :btree
add_index 'synapses', ['node1_id'], name: 'index_synapses_on_node1_id', using: :btree
add_index 'synapses', %w(node2_id node2_id), name: 'index_synapses_on_node2_id_and_node2_id', using: :btree
add_index 'synapses', ['node2_id'], name: 'index_synapses_on_node2_id', using: :btree
add_index 'synapses', ['user_id'], name: 'index_synapses_on_user_id', using: :btree
create_table "tokens", force: :cascade do |t|
t.string "token"
t.string "description"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'tokens', force: :cascade do |t|
t.string 'token'
t.string 'description'
t.integer 'user_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end
add_index "tokens", ["user_id"], name: "index_tokens_on_user_id", using: :btree
add_index 'tokens', ['user_id'], name: 'index_tokens_on_user_id', using: :btree
create_table "topics", force: :cascade do |t|
t.text "name"
t.text "desc"
t.text "link"
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
t.integer "defer_to_map_id"
create_table 'topics', force: :cascade do |t|
t.text 'name'
t.text 'desc'
t.text 'link'
t.text 'permission'
t.integer 'user_id'
t.integer 'metacode_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'image_file_name'
t.string 'image_content_type'
t.integer 'image_file_size'
t.datetime 'image_updated_at'
t.string 'audio_file_name'
t.string 'audio_content_type'
t.integer 'audio_file_size'
t.datetime 'audio_updated_at'
t.integer 'defer_to_map_id'
end
add_index "topics", ["metacode_id"], name: "index_topics_on_metacode_id", using: :btree
add_index "topics", ["user_id"], name: "index_topics_on_user_id", using: :btree
add_index 'topics', ['metacode_id'], name: 'index_topics_on_metacode_id', using: :btree
add_index 'topics', ['user_id'], name: 'index_topics_on_user_id', using: :btree
create_table "user_maps", force: :cascade do |t|
t.integer "user_id"
t.integer "map_id"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'user_maps', force: :cascade do |t|
t.integer 'user_id'
t.integer 'map_id'
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "user_maps", ["map_id"], name: "index_user_maps_on_map_id", using: :btree
add_index "user_maps", ["user_id"], name: "index_user_maps_on_user_id", using: :btree
add_index 'user_maps', ['map_id'], name: 'index_user_maps_on_map_id', using: :btree
add_index 'user_maps', ['user_id'], name: 'index_user_maps_on_user_id', using: :btree
create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.text "settings"
t.string "code", limit: 8
t.string "joinedwithcode", limit: 8
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_password", limit: 128, default: ""
t.string "remember_token"
t.datetime "remember_created_at"
t.string "reset_password_token"
t.datetime "last_sign_in_at"
t.string "last_sign_in_ip"
t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at"
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.integer "generation"
create_table 'users', force: :cascade do |t|
t.string 'name'
t.string 'email'
t.text 'settings'
t.string 'code', limit: 8
t.string 'joinedwithcode', limit: 8
t.string 'crypted_password'
t.string 'password_salt'
t.string 'persistence_token'
t.string 'perishable_token'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'encrypted_password', limit: 128, default: ''
t.string 'remember_token'
t.datetime 'remember_created_at'
t.string 'reset_password_token'
t.datetime 'last_sign_in_at'
t.string 'last_sign_in_ip'
t.integer 'sign_in_count', default: 0
t.datetime 'current_sign_in_at'
t.string 'current_sign_in_ip'
t.datetime 'reset_password_sent_at'
t.boolean 'admin'
t.string 'image_file_name'
t.string 'image_content_type'
t.integer 'image_file_size'
t.datetime 'image_updated_at'
t.integer 'generation'
end
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, using: :btree
create_table "webhooks", force: :cascade do |t|
t.integer "hookable_id"
t.string "hookable_type"
t.string "kind", null: false
t.string "uri", null: false
t.text "event_types", default: [], array: true
create_table 'webhooks', force: :cascade do |t|
t.integer 'hookable_id'
t.string 'hookable_type'
t.string 'kind', null: false
t.string 'uri', null: false
t.text 'event_types', default: [], array: true
end
add_index "webhooks", ["hookable_type", "hookable_id"], name: "index_webhooks_on_hookable_type_and_hookable_id", using: :btree
add_index 'webhooks', %w(hookable_type hookable_id), name: 'index_webhooks_on_hookable_type_and_hookable_id', using: :btree
add_foreign_key "tokens", "users"
add_foreign_key 'tokens', 'users'
end

View file

@ -2,305 +2,207 @@
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
## USERS
User.new({
name: 'user',
User.new(name: 'user',
email: 'user@user.com',
password: 'toolsplusconsciousness',
code: 'qwertyui',
joinedwithcode: 'qwertyui',
admin: 'false'
}).save(validate: false)
admin: 'false').save(validate: false)
User.new({
name: 'admin',
User.new(name: 'admin',
email: 'admin@admin.com',
password: 'toolsplusconsciousness',
code: 'iuytrewq',
joinedwithcode: 'iuytrewq',
admin: 'true'
}).save(validate: false)
admin: 'true').save(validate: false)
## END USERS
## METACODES
Metacode.create({
name: 'Action',
Metacode.create(name: 'Action',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png',
color: '#BD6C85'
})
color: '#BD6C85')
Metacode.create({
name: 'Activity',
Metacode.create(name: 'Activity',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png',
color: '#6EBF65'
})
color: '#6EBF65')
Metacode.create({
name: 'Catalyst',
Metacode.create(name: 'Catalyst',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png',
color: '#EF8964',
})
color: '#EF8964')
Metacode.create({
name: 'Closed',
Metacode.create(name: 'Closed',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png',
color: '#ABB49F',
})
color: '#ABB49F')
Metacode.create({
name: 'Process',
Metacode.create(name: 'Process',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png',
color: '#BDB25E',
})
color: '#BDB25E')
Metacode.create({
name: 'Future',
Metacode.create(name: 'Future',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png',
color: '#25A17F',
})
color: '#25A17F')
Metacode.create({
name: 'Group',
Metacode.create(name: 'Group',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png',
color: '#7076BC',
})
color: '#7076BC')
Metacode.create({
name: 'Implication',
Metacode.create(name: 'Implication',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png',
color: '#83DECA',
})
color: '#83DECA')
Metacode.create({
name: 'Insight',
Metacode.create(name: 'Insight',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png',
color: '#B074AD',
})
color: '#B074AD')
Metacode.create({
name: 'Intention',
Metacode.create(name: 'Intention',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png',
color: '#BAEAFF',
})
color: '#BAEAFF')
Metacode.create({
name: 'Knowledge',
Metacode.create(name: 'Knowledge',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png',
color: '#60ACF7',
})
color: '#60ACF7')
Metacode.create({
name: 'Location',
Metacode.create(name: 'Location',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png',
color: '#ABD9A7',
})
color: '#ABD9A7')
Metacode.create({
name: 'Need',
Metacode.create(name: 'Need',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png',
color: '#D2A7D4',
})
color: '#D2A7D4')
Metacode.create({
name: 'Open',
Metacode.create(name: 'Open',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png',
color: '#9BBF71',
})
color: '#9BBF71')
Metacode.create({
name: 'Opportunity',
Metacode.create(name: 'Opportunity',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png',
color: '#889F64',
})
color: '#889F64')
Metacode.create({
name: 'Person',
Metacode.create(name: 'Person',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png',
color: '#DE925F',
})
color: '#DE925F')
Metacode.create({
name: 'Platform',
Metacode.create(name: 'Platform',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png',
color: '#21C8FE',
})
color: '#21C8FE')
Metacode.create({
name: 'Problem',
Metacode.create(name: 'Problem',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png',
color: '#99CFC4',
})
color: '#99CFC4')
Metacode.create({
name: 'Resource',
Metacode.create(name: 'Resource',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png',
color: '#C98C63',
})
color: '#C98C63')
Metacode.create({
name: 'Role',
Metacode.create(name: 'Role',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png',
color: '#A8595D',
})
color: '#A8595D')
Metacode.create({
name: 'Task',
Metacode.create(name: 'Task',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png',
color: '#3397C4',
})
color: '#3397C4')
Metacode.create({
name: 'Trajectory',
Metacode.create(name: 'Trajectory',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png',
color: '#D3AA4C',
})
color: '#D3AA4C')
Metacode.create({
name: 'Argument',
Metacode.create(name: 'Argument',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png',
color: '#7FAEFD',
})
color: '#7FAEFD')
Metacode.create({
name: 'Con',
Metacode.create(name: 'Con',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png',
color: '#CF7C74',
})
color: '#CF7C74')
Metacode.create({
name: 'Subject',
Metacode.create(name: 'Subject',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png',
color: '#8293D8',
})
color: '#8293D8')
Metacode.create({
name: 'Decision',
Metacode.create(name: 'Decision',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png',
color: '#CCA866',
})
color: '#CCA866')
Metacode.create({
name: 'Event',
Metacode.create(name: 'Event',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png',
color: '#F5854B',
})
color: '#F5854B')
Metacode.create({
name: 'Example',
Metacode.create(name: 'Example',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png',
color: '#618C61',
})
color: '#618C61')
Metacode.create({
name: 'Experience',
Metacode.create(name: 'Experience',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png',
color: '#BE995F',
})
color: '#BE995F')
Metacode.create({
name: 'Feedback',
Metacode.create(name: 'Feedback',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png',
color: '#54A19D',
})
color: '#54A19D')
Metacode.create({
name: 'Aim',
Metacode.create(name: 'Aim',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png',
color: '#B0B0B0',
})
color: '#B0B0B0')
Metacode.create({
name: 'Good',
Metacode.create(name: 'Good',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png',
color: '#BD9E86',
})
color: '#BD9E86')
Metacode.create({
name: 'Idea',
Metacode.create(name: 'Idea',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png',
color: '#C4BC5E',
})
color: '#C4BC5E')
Metacode.create({
name: 'List',
Metacode.create(name: 'List',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png',
color: '#B7A499',
})
color: '#B7A499')
Metacode.create({
name: 'Media',
Metacode.create(name: 'Media',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png',
color: '#6D94CC',
})
color: '#6D94CC')
Metacode.create({
name: 'Metamap',
Metacode.create(name: 'Metamap',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png',
color: '#AEA9FD',
})
color: '#AEA9FD')
Metacode.create({
name: 'Model',
Metacode.create(name: 'Model',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png',
color: '#B385BA',
})
color: '#B385BA')
Metacode.create({
name: 'Note',
Metacode.create(name: 'Note',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png',
color: '#A389A1',
})
color: '#A389A1')
Metacode.create({
name: 'Perspective',
Metacode.create(name: 'Perspective',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png',
color: '#2EB6CC',
})
color: '#2EB6CC')
Metacode.create({
name: 'Pro',
Metacode.create(name: 'Pro',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png',
color: '#89B879',
})
color: '#89B879')
Metacode.create({
name: 'Project',
Metacode.create(name: 'Project',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png',
color: '#85A050',
})
color: '#85A050')
Metacode.create({
name: 'Question',
Metacode.create(name: 'Question',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png',
color: '#5CB3B3',
})
color: '#5CB3B3')
Metacode.create({
name: 'Reference',
Metacode.create(name: 'Reference',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png',
color: '#A7A7A7',
})
color: '#A7A7A7')
Metacode.create({
name: 'Research',
Metacode.create(name: 'Research',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png',
color: '#CD8E89',
})
color: '#CD8E89')
Metacode.create({
name: 'Status',
Metacode.create(name: 'Status',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png',
color: '#EFA7C0',
})
color: '#EFA7C0')
Metacode.create({
name: 'Tool',
Metacode.create(name: 'Tool',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png',
color: '#828282',
})
color: '#828282')
Metacode.create({
name: 'Wildcard',
Metacode.create(name: 'Wildcard',
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png',
color: '#73C7DE',
})
color: '#73C7DE')
## END METACODES

View file

@ -1,13 +1,13 @@
require 'dotenv/tasks'
namespace :heroku do
desc "Generate the Heroku gems manifest from gem dependencies"
task :gems => :dotenv do
RAILS_ENV='production'
desc 'Generate the Heroku gems manifest from gem dependencies'
task gems: :dotenv do
RAILS_ENV = 'production'.freeze
Rake::Task[:environment].invoke
list = Rails.configuration.gems.collect do |g|
command, *options = g.send(:install_command)
options.join(" ") + "\n"
_command, *options = g.send(:install_command)
options.join(' ') + "\n"
end
File.open(File.join(RAILS_ROOT, '.gems'), 'w') do |f|

View file

@ -1,8 +1,8 @@
require 'dotenv/tasks'
namespace :perms do
desc "Update the Unix permissions on the public directory"
task :fix => :environment do
desc 'Update the Unix permissions on the public directory'
task fix: :environment do
# e.g. rake perms:fix user=mmstaging group=mmstaging
# e.g. rake perms:fix group=www-data #probably don't need this one
# e.g. rake perms:fix

View file

@ -10,7 +10,7 @@ RSpec.describe MappingsController, type: :controller do
describe 'GET #show' do
it 'assigns the requested mapping as @mapping' do
get :show, { id: mapping.to_param }
get :show, id: mapping.to_param
expect(assigns(:mapping)).to eq(mapping)
end
end
@ -19,12 +19,12 @@ RSpec.describe MappingsController, type: :controller do
context 'with valid params' do
it 'creates a new Mapping' do
expect do
post :create, { mapping: valid_attributes }
post :create, mapping: valid_attributes
end.to change(Mapping, :count).by(1)
end
it 'assigns a newly created mapping as @mapping' do
post :create, { mapping: valid_attributes }
post :create, mapping: valid_attributes
expect(assigns(:mapping)).to be_a(Mapping)
expect(assigns(:mapping)).to be_persisted
end
@ -32,7 +32,7 @@ RSpec.describe MappingsController, type: :controller do
context 'with invalid params' do
it 'assigns a newly created but unsaved mapping as @mapping' do
post :create, { mapping: invalid_attributes }
post :create, mapping: invalid_attributes
expect(assigns(:mapping)).to be_a_new(Mapping)
end
end
@ -44,13 +44,13 @@ RSpec.describe MappingsController, type: :controller do
it 'updates the requested mapping' do
put :update,
{ id: mapping.to_param, mapping: new_attributes }
id: mapping.to_param, mapping: new_attributes
mapping.reload
end
it 'assigns the requested mapping as @mapping' do
put :update,
{ id: mapping.to_param, mapping: valid_attributes }
id: mapping.to_param, mapping: valid_attributes
expect(assigns(:mapping)).to eq(mapping)
end
end
@ -58,7 +58,7 @@ RSpec.describe MappingsController, type: :controller do
context 'with invalid params' do
it 'assigns the mapping as @mapping' do
put :update,
{ id: mapping.to_param, mapping: invalid_attributes }
id: mapping.to_param, mapping: invalid_attributes
expect(assigns(:mapping)).to eq(mapping)
end
end
@ -67,7 +67,7 @@ RSpec.describe MappingsController, type: :controller do
describe 'DELETE #destroy' do
it 'destroys the requested mapping' do
expect do
delete :destroy, { id: mapping.to_param }
delete :destroy, id: mapping.to_param
end.to change(Mapping, :count).by(-1)
end
end

View file

@ -17,14 +17,14 @@ RSpec.describe MapsController, type: :controller do
describe 'GET #contains' do
it 'returns json matching schema' do
get :contains, { id: map.to_param, format: :json }
get :contains, id: map.to_param, format: :json
expect(response.body).to match_json_schema(:map_contains)
end
end
describe 'GET #show' do
it 'assigns the requested map as @map' do
get :show, { id: map.to_param }
get :show, id: map.to_param
expect(assigns(:map)).to eq(map)
end
end
@ -55,18 +55,18 @@ RSpec.describe MapsController, type: :controller do
describe 'PUT #update' do
context 'with valid params' do
let(:new_attributes) { { name: "Uncool map", permission: :private } }
let(:new_attributes) { { name: 'Uncool map', permission: :private } }
it 'updates the requested map' do
put :update,
{ id: map.to_param, map: new_attributes, format: :json }
expect(assigns(:map).name).to eq "Uncool map"
id: map.to_param, map: new_attributes, format: :json
expect(assigns(:map).name).to eq 'Uncool map'
expect(assigns(:map).permission).to eq 'private'
end
it 'assigns the requested map as @map' do
put :update,
{ id: map.to_param, map: valid_attributes, format: :json }
id: map.to_param, map: valid_attributes, format: :json
expect(assigns(:map)).to eq(map)
end
end
@ -74,7 +74,7 @@ RSpec.describe MapsController, type: :controller do
context 'with invalid params' do
it 'assigns the map as @map' do
put :update,
{ id: map.to_param, map: invalid_attributes, format: :json }
id: map.to_param, map: invalid_attributes, format: :json
expect(assigns(:map)).to eq(map)
end
end
@ -87,7 +87,7 @@ RSpec.describe MapsController, type: :controller do
it 'prevents deletion by non-owners' do
unowned_map.reload
expect do
delete :destroy, { id: unowned_map.to_param, format: :json }
delete :destroy, id: unowned_map.to_param, format: :json
end.to change(Map, :count).by(0)
expect(response.body).to eq ''
expect(response.status).to eq 403
@ -96,7 +96,7 @@ RSpec.describe MapsController, type: :controller do
it 'deletes owned map' do
owned_map.reload # ensure it's in the database
expect do
delete :destroy, { id: owned_map.to_param, format: :json }
delete :destroy, id: owned_map.to_param, format: :json
end.to change(Map, :count).by(-1)
expect(response.body).to eq ''
expect(response.status).to eq 204

View file

@ -17,14 +17,14 @@ RSpec.describe MetacodesController, type: :controller do
describe 'GET #new' do
it 'assigns a new metacode as @metacode' do
get :new, { format: :json }
get :new, format: :json
expect(assigns(:metacode)).to be_a_new(Metacode)
end
end
describe 'GET #edit' do
it 'assigns the requested metacode as @metacode' do
get :edit, { id: metacode.to_param }
get :edit, id: metacode.to_param
expect(assigns(:metacode)).to eq(metacode)
end
end
@ -34,19 +34,19 @@ RSpec.describe MetacodesController, type: :controller do
it 'creates a new Metacode' do
metacode.reload # ensure it's present to start
expect do
post :create, { metacode: valid_attributes }
post :create, metacode: valid_attributes
end.to change(Metacode, :count).by(1)
end
it 'has the correct attributes' do
post :create, { metacode: valid_attributes }
post :create, metacode: valid_attributes
# expect(Metacode.last.attributes.expect(:id)).to eq(metacode.attributes.except(:id))
expect(assigns(:metacode)).to be_a(Metacode)
expect(assigns(:metacode)).to be_persisted
end
it 'redirects to the metacode index' do
post :create, { metacode: valid_attributes }
post :create, metacode: valid_attributes
expect(response).to redirect_to(metacodes_url)
end
end
@ -63,7 +63,7 @@ RSpec.describe MetacodesController, type: :controller do
it 'updates the requested metacode' do
put :update,
{ id: metacode.to_param, metacode: new_attributes }
id: metacode.to_param, metacode: new_attributes
metacode.reload
expect(metacode.icon).to eq 'https://newimages.ca/cool-image.jpg'
expect(metacode.color).to eq '#ffffff'
@ -75,13 +75,13 @@ RSpec.describe MetacodesController, type: :controller do
context 'not admin' do
it 'denies access to create' do
sign_in create(:user, admin: false)
post :create, { metacode: valid_attributes }
post :create, metacode: valid_attributes
expect(response).to redirect_to root_url
end
it 'denies access to update' do
sign_in create(:user, admin: false)
post :update, { id: metacode.to_param, metacode: valid_attributes }
post :update, id: metacode.to_param, metacode: valid_attributes
expect(response).to redirect_to root_url
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe SynapsesController, type: :controller do
describe 'GET #show' do
it 'assigns the requested synapse as @synapse' do
get :show, { id: synapse.to_param, format: :json }
get :show, id: synapse.to_param, format: :json
expect(assigns(:synapse)).to eq(synapse)
end
end
@ -20,25 +20,25 @@ RSpec.describe SynapsesController, type: :controller do
it 'creates a new Synapse' do
synapse.reload # ensure it's present
expect do
post :create, { synapse: valid_attributes, format: :json }
post :create, synapse: valid_attributes, format: :json
end.to change(Synapse, :count).by(1)
end
it 'assigns a newly created synapse as @synapse' do
post :create, { synapse: valid_attributes, format: :json }
post :create, synapse: valid_attributes, format: :json
expect(assigns(:synapse)).to be_a(Synapse)
expect(assigns(:synapse)).to be_persisted
end
it 'returns 201 CREATED' do
post :create, { synapse: valid_attributes, format: :json }
post :create, synapse: valid_attributes, format: :json
expect(response.status).to eq 201
end
end
context 'with invalid params' do
it 'returns 422 UNPROCESSABLE ENTITY' do
post :create, { synapse: invalid_attributes, format: :json }
post :create, synapse: invalid_attributes, format: :json
expect(response.status).to eq 422
end
end
@ -54,7 +54,7 @@ RSpec.describe SynapsesController, type: :controller do
it 'updates the requested synapse' do
put :update,
{ id: synapse.to_param, synapse: new_attributes, format: :json }
id: synapse.to_param, synapse: new_attributes, format: :json
synapse.reload
expect(synapse.desc).to eq 'My new description'
expect(synapse.category).to eq 'both'
@ -63,7 +63,7 @@ RSpec.describe SynapsesController, type: :controller do
it 'returns 204 NO CONTENT' do
put :update,
{ id: synapse.to_param, synapse: valid_attributes, format: :json }
id: synapse.to_param, synapse: valid_attributes, format: :json
expect(response.status).to eq 204
end
end
@ -71,7 +71,7 @@ RSpec.describe SynapsesController, type: :controller do
context 'with invalid params' do
it 'assigns the synapse as @synapse' do
put :update,
{ id: synapse.to_param, synapse: invalid_attributes, format: :json }
id: synapse.to_param, synapse: invalid_attributes, format: :json
expect(assigns(:synapse)).to eq(synapse)
end
end
@ -83,12 +83,12 @@ RSpec.describe SynapsesController, type: :controller do
it 'destroys the requested synapse' do
synapse.reload # ensure it's present
expect do
delete :destroy, { id: synapse.to_param, format: :json }
delete :destroy, id: synapse.to_param, format: :json
end.to change(Synapse, :count).by(-1)
end
it 'returns 204 NO CONTENT' do
delete :destroy, { id: synapse.to_param, format: :json }
delete :destroy, id: synapse.to_param, format: :json
expect(response.status).to eq 204
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe TopicsController, type: :controller do
describe 'GET #show' do
it 'assigns the requested topic as @topic' do
get :show, { id: topic.to_param, format: :json }
get :show, id: topic.to_param, format: :json
expect(assigns(:topic)).to eq(topic)
end
end
@ -20,25 +20,25 @@ RSpec.describe TopicsController, type: :controller do
it 'creates a new Topic' do
topic.reload # ensure it's created
expect do
post :create, { topic: valid_attributes, format: :json }
post :create, topic: valid_attributes, format: :json
end.to change(Topic, :count).by(1)
end
it 'assigns a newly created topic as @topic' do
post :create, { topic: valid_attributes, format: :json }
post :create, topic: valid_attributes, format: :json
expect(assigns(:topic)).to be_a(Topic)
expect(assigns(:topic)).to be_persisted
end
it 'returns 201 CREATED' do
post :create, { topic: valid_attributes, format: :json }
post :create, topic: valid_attributes, format: :json
expect(response.status).to eq 201
end
end
context 'with invalid params' do
it 'assigns a newly created but unsaved topic as @topic' do
post :create, { topic: invalid_attributes, format: :json }
post :create, topic: invalid_attributes, format: :json
expect(assigns(:topic)).to be_a_new(Topic)
end
end
@ -55,7 +55,7 @@ RSpec.describe TopicsController, type: :controller do
it 'updates the requested topic' do
put :update,
{ id: topic.to_param, topic: new_attributes, format: :json }
id: topic.to_param, topic: new_attributes, format: :json
topic.reload
expect(topic.name).to eq 'Cool Topic with no number'
expect(topic.desc).to eq 'This is a cool topic.'
@ -65,13 +65,13 @@ RSpec.describe TopicsController, type: :controller do
it 'assigns the requested topic as @topic' do
put :update,
{ id: topic.to_param, topic: valid_attributes, format: :json }
id: topic.to_param, topic: valid_attributes, format: :json
expect(assigns(:topic)).to eq(topic)
end
it 'returns status of no content' do
put :update,
{ id: topic.to_param, topic: valid_attributes, format: :json }
id: topic.to_param, topic: valid_attributes, format: :json
expect(response.status).to eq 204
end
end
@ -79,7 +79,7 @@ RSpec.describe TopicsController, type: :controller do
context 'with invalid params' do
it 'assigns the topic as @topic' do
put :update,
{ id: topic.to_param, topic: invalid_attributes, format: :json }
id: topic.to_param, topic: invalid_attributes, format: :json
expect(assigns(:topic)).to eq(topic)
end
end
@ -90,7 +90,7 @@ RSpec.describe TopicsController, type: :controller do
it 'destroys the requested topic' do
owned_topic.reload # ensure it's there
expect do
delete :destroy, { id: owned_topic.to_param, format: :json }
delete :destroy, id: owned_topic.to_param, format: :json
end.to change(Topic, :count).by(-1)
expect(response.body).to eq ''
expect(response.status).to eq 204

View file

@ -15,8 +15,8 @@ FactoryGirl.define do
password 'omgwtfbbq'
factory :simple_user, aliases: [:user] do
joinedwithcode { "qwertyui" }
code { "qwertyui" }
joinedwithcode { 'qwertyui' }
code { 'qwertyui' }
transient do
validate false

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
RSpec.describe MapMailer, type: :mailer do
pending "add some examples to (or delete) #{__FILE__}"

View file

@ -6,4 +6,3 @@ RSpec.describe Map, type: :model do
it { is_expected.to validate_presence_of :permission }
it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) }
end

View file

@ -5,10 +5,14 @@ RSpec.describe Metacode, type: :model do
it { is_expected.to have_many :metacode_sets }
context 'BOTH aws_icon and manual_icon' do
let(:icon) { File.open(Rails.root.join('app', 'assets', 'images',
'user.png')) }
let(:metacode) { build(:metacode, aws_icon: icon,
manual_icon: 'https://metamaps.cc/assets/user.png') }
let(:icon) do
File.open(Rails.root.join('app', 'assets', 'images',
'user.png'))
end
let(:metacode) do
build(:metacode, aws_icon: icon,
manual_icon: 'https://metamaps.cc/assets/user.png')
end
it 'raises a validation error' do
expect { metacode.save! }.to raise_error ActiveRecord::RecordInvalid
end

View file

@ -9,5 +9,5 @@ RSpec.describe Synapse, type: :model do
it { is_expected.to validate_presence_of :permission }
it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) }
it { is_expected.to validate_inclusion_of(:category).in_array ['from-to', 'both'] }
it { is_expected.to validate_length_of(:desc).is_at_least(0) } # TODO don't allow nil
it { is_expected.to validate_length_of(:desc).is_at_least(0) } # TODO: don't allow nil
end

View file

@ -1,10 +1,10 @@
require 'rails_helper'
RSpec.describe Token, type: :model do
context "#generate_token" do
context '#generate_token' do
subject(:token) { Token.new }
it "should generate an alphanumeric token of 32 characters" do
expect(token.send(:generate_token)).to match /^[a-zA-Z0-9]{32}$/
it 'should generate an alphanumeric token of 32 characters' do
expect(token.send(:generate_token)).to match(/^[a-zA-Z0-9]{32}$/)
end
end
end

View file

@ -21,6 +21,6 @@ module ControllerHelpers
end
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
config.include ControllerHelpers, :type => :controller
config.include Devise::TestHelpers, type: :controller
config.include ControllerHelpers, type: :controller
end