diff --git a/.example-env b/.example-env index c8fb94af..54039a93 100644 --- a/.example-env +++ b/.example-env @@ -1,14 +1,43 @@ -RAILS_ENV=development +export DB_USERNAME='postgres' +export DB_PASSWORD='3112' +export DB_HOST='localhost' +export DB_PORT='5432' +export DB_NAME='metamap002' -AWS_ACCESS_KEY_ID -AWS_SECRET_ACCESS_KEY -BUNDLE_GEMFILE -SMTP_DOMAIN -SMTP_PASSWORD -SMTP_PORT -SMTP_SERVER -SMTP_USERNAME -SSO_KEY +export REALTIME_SERVER='http://localhost:5001' +export MAILER_DEFAULT_URL='localhost:3000' +export DEVISE_MAILER_SENDER='team@metamaps.cc' +export DEVISE_SECRET_KEY='f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614' + +# # you can safely leave these blank, unless you're deploying an instance, in +# # which case you'll need to set them up +# +# export S3_BUCKET_NAME +# export AWS_ACCESS_KEY_ID +# export AWS_SECRET_ACCESS_KEY +# export SSO_KEY +# +# export SMTP_DOMAIN +# export SMTP_PASSWORD +# export SMTP_PORT +# export SMTP_SERVER +# export SMTP_USERNAME + +#ruby garbage collection stuff + +export RUBY_GC_TUNE=0 #set to 1 to enable GC test +export RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928 +export RUBY_GC_HEAP_INIT_SLOTS=186426 +export RUBY_GC_HEAP_FREE_SLOTS=559278 +export RUBY_GC_HEAP_GROWTH_FACTOR=1.03 +export RUBY_GC_HEAP_GROWTH_MAX_SLOTS=74570 +export RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.4 +export RUBY_GC_MALLOC_LIMIT=32883406 +export RUBY_GC_MALLOC_LIMIT_MAX=69055153 +export RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.68 +export RUBY_GC_OLDMALLOC_LIMIT=32509481 +export RUBY_GC_OLDMALLOC_LIMIT_MAX=68269910 +export RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.4 ## find the ENV currently in use in the app using : ## grep -rIso -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" @@ -16,16 +45,3 @@ SSO_KEY # for a uniq ordered list of env vars: ## grep -rIsoh -P "(?<=ENV)(\.fetch\(|\[).[A-Z_]+.(\)|\])" | grep -oP "[A-Z_]+" | sort -u > temp -RUBY_GC_TUNE=0 #set to 1 to enable GC test -RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928 -RUBY_GC_HEAP_INIT_SLOTS=186426 -RUBY_GC_HEAP_FREE_SLOTS=559278 -RUBY_GC_HEAP_GROWTH_FACTOR=1.03 -RUBY_GC_HEAP_GROWTH_MAX_SLOTS=74570 -RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.4 -RUBY_GC_MALLOC_LIMIT=32883406 -RUBY_GC_MALLOC_LIMIT_MAX=69055153 -RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.68 -RUBY_GC_OLDMALLOC_LIMIT=32509481 -RUBY_GC_OLDMALLOC_LIMIT_MAX=68269910 -RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.4 diff --git a/.gitignore b/.gitignore index c6358ead..db060afa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,17 +8,12 @@ realtime/node_modules public/assets -#secrets -config/database.yml -config/secrets.yml +#secrets and config .env # Ignore bundler config .bundle -# Ignore the default SQLite database. -db/*.sqlite3 - # Ignore all logfiles and tempfiles. log/*.log tmp diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..83e16f80 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/Gemfile b/Gemfile index d54d13d2..b4e3bdf6 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,12 @@ group :assets do gem 'uglifier' end +group :test do + gem 'rspec-rails' + gem 'factory_girl_rails' + gem 'shoulda-matchers' +end + group :production do #this is used on heroku #gem 'rmagick' gem 'rails_12factor' diff --git a/Gemfile.lock b/Gemfile.lock index 4cfa192f..4e82a050 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,8 @@ GEM binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) - byebug (8.2.1) + byebug (5.0.0) + columnize (= 0.9.0) cancancan (1.13.1) climate_control (0.0.3) activesupport (>= 3.0) @@ -76,10 +77,16 @@ GEM responders thread_safe (~> 0.1) warden (~> 1.2.3) + diff-lcs (1.2.5) dotenv (2.0.2) erubis (2.7.0) execjs (2.6.0) ezcrypto (0.7.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) formtastic (3.1.3) actionpack (>= 3.2.13) formula (1.1.1) @@ -105,28 +112,28 @@ GEM mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) - mime-types (2.99) + mime-types (2.6.2) mimemagic (0.3.0) - mini_portile2 (2.0.0) - minitest (5.8.3) + mini_portile (0.6.2) + minitest (5.8.2) multi_json (1.11.2) nokogiri (1.6.7) mini_portile2 (~> 2.0.0.rc2) oauth (0.4.7) orm_adapter (0.5.0) - paperclip (4.3.2) + paperclip (4.3.1) activemodel (>= 3.2.0) activesupport (>= 3.2.0) cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) - pg (0.18.4) + pg (0.18.3) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-byebug (3.3.0) - byebug (~> 8.0) + pry-byebug (3.2.0) + byebug (~> 5.0) pry (~> 0.10) pry-rails (0.3.4) pry (>= 0.9.10) @@ -170,6 +177,23 @@ GEM redis (3.2.2) responders (2.1.0) railties (>= 4.2.0, < 5) + rspec-core (3.3.2) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-mocks (3.3.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-rails (3.3.3) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) sass (3.4.19) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) @@ -177,9 +201,10 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + shoulda-matchers (3.0.1) + activesupport (>= 4.0.0) slop (3.6.0) - sprockets (3.5.0) - concurrent-ruby (~> 1.0) + sprockets (3.4.0) rack (> 1, < 3) sprockets-rails (2.3.3) actionpack (>= 3.0) @@ -213,6 +238,7 @@ DEPENDENCIES coffee-rails devise dotenv + factory_girl_rails formtastic formula jbuilder @@ -229,7 +255,9 @@ DEPENDENCIES rails3-jquery-autocomplete rails_12factor redis + rspec-rails sass-rails + shoulda-matchers tunemygc uglifier uservoice-ruby diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb index 7d82de2d..8e1ccfdf 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb @@ -626,14 +626,14 @@ Metamaps.GlobalUI.Search = { self.hideLoader(); - if (datum.rtype != "noresult") { + if (["topic", "map", "mapper"].indexOf(datum.rtype) !== -1) { self.close(0, true); var win; - if (dataset == "topics") { + if (datum.rtype == "topic") { Metamaps.Router.topics(datum.id); - } else if (dataset == "maps") { + } else if (datum.rtype == "map") { Metamaps.Router.maps(datum.id); - } else if (dataset == "mappers") { + } else if (datum.rtype == "mapper") { Metamaps.Router.explore("mapper", datum.id); } } diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 9de48d8d..d5672fd9 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -1910,9 +1910,6 @@ Metamaps.Util = { * */ Metamaps.Realtime = { - stringForLocalhost: '//' + location.host.split(':')[0] + ':5001', - stringForMetamaps: 'https://realtime.metamaps.cc', - stringForHeroku: 'https://gentle-savannah-1303.herokuapp.com', videoId: 'video-wrapper', socket: null, webrtc: null, @@ -1939,9 +1936,7 @@ Metamaps.Realtime = { self.addJuntoListeners(); - var railsEnv = $('body').data('env'); - var whichToConnect = railsEnv === 'development' ? self.stringForLocalhost : self.stringForHeroku; - self.socket = new SocketIoConnection({ url: whichToConnect }); + self.socket = new SocketIoConnection({ url: '<%= ENV['REALTIME_SERVER'] %>' }); self.socket.on('connect', function () { console.log('connected'); if (!self.disconnected) { diff --git a/app/assets/stylesheets/search.scss.erb b/app/assets/stylesheets/search.scss.erb index 607a561f..0f806f96 100644 --- a/app/assets/stylesheets/search.scss.erb +++ b/app/assets/stylesheets/search.scss.erb @@ -19,12 +19,6 @@ } } -.explorePage .sidebarSearchField, -.explorePage .sidebarSearch .tt-hint { - width: 380px; - padding: 5px 10px 5px 10px; -} - .sidebarSearchIcon { float: left; width: 72px; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7e9339c3..79beb773 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -60,13 +60,13 @@ private end def admin? - current_user && current_user.admin + authenticated? && current_user.admin end def get_invite_link - unsafe_uri = request.env["REQUEST_URI"] + unsafe_uri = request.env["REQUEST_URI"] || 'https://metamaps.cc' valid_url = /^https?:\/\/([\w\.-]+)(:\d{1,5})?\/?$/ - safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : "//metamaps.cc/" + safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : '//metamaps.cc/' @invite_link = "#{safe_uri}join" + (current_user ? "?code=#{current_user.code}" : "") end end diff --git a/app/controllers/metacodes_controller.rb b/app/controllers/metacodes_controller.rb index 7a14f2a8..5d1e1367 100644 --- a/app/controllers/metacodes_controller.rb +++ b/app/controllers/metacodes_controller.rb @@ -1,5 +1,4 @@ class MetacodesController < ApplicationController - before_filter :require_admin, except: [:index] # GET /metacodes diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bb645614..063ab866 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -101,5 +101,4 @@ class UsersController < ApplicationController def user_params params.require(:user).permit(:name, :email, :image, :password, :password_confirmation) end - end diff --git a/app/models/map.rb b/app/models/map.rb index a8b00fd7..2ca3e3f0 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -15,6 +15,11 @@ class Map < ActiveRecord::Base }, :default_url => 'https://s3.amazonaws.com/metamaps-assets/site/missing-map.png' + validates :name, presence: true + validates :arranged, inclusion: { in: [true, false] } + validates :permission, presence: true + 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/ @@ -23,13 +28,7 @@ class Map < ActiveRecord::Base end def mk_permission - if self.permission == "commons" - "co" - elsif self.permission == "public" - "pu" - elsif self.permission == "private" - "pr" - end + Perm.short(permission) end #return an array of the contributors to the map @@ -111,14 +110,6 @@ class Map < ActiveRecord::Base return self end - # returns Boolean if user allowed to view Topic, Synapse, or Map - def authorize_to_view(user) - if (self.permission == "private" && self.user != user) - return false - end - return true - end - def decode_base64(imgBase64) decoded_data = Base64.decode64(imgBase64) diff --git a/app/models/synapse.rb b/app/models/synapse.rb index 2745106f..225485e5 100644 --- a/app/models/synapse.rb +++ b/app/models/synapse.rb @@ -10,6 +10,9 @@ class Synapse < ActiveRecord::Base validates :desc, length: { minimum: 0, allow_nil: false } + validates :permission, presence: true + validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) } + def user_name self.user.name end @@ -48,13 +51,4 @@ class Synapse < ActiveRecord::Base end return false end - - # returns Boolean if user allowed to view Topic, Synapse, or Map - def authorize_to_view(user) - if (self.permission == "private" && self.user != user) - return false - end - return true - end - end diff --git a/app/models/topic.rb b/app/models/topic.rb index f82bc256..e80d3df7 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -10,6 +10,9 @@ class Topic < ActiveRecord::Base has_many :mappings, as: :mappable, dependent: :destroy has_many :maps, :through => :mappings + + validates :permission, presence: true + validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) } # This method associates the attribute ":image" with a file attachment has_attached_file :image @@ -39,27 +42,27 @@ class Topic < ActiveRecord::Base belongs_to :metacode def user_name - self.user.name + user.name end def user_image - self.user.image.url + user.image.url end def map_count - self.maps.count + maps.count end def synapse_count - self.synapses.count + synapses.count end def inmaps - self.maps.map(&:name) + maps.map(&:name) end def inmapsLinks - self.maps.map(&:id) + maps.map(&:id) end def as_json(options={}) @@ -71,24 +74,18 @@ class Topic < ActiveRecord::Base end def mk_permission - if self.permission == "commons" - "co" - elsif self.permission == "public" - "pu" - elsif self.permission == "private" - "pr" - end + Perm.short(permission) end # has no viewable synapses helper function def has_viewable_synapses(current) result = false - self.synapses.each do |synapse| - if synapse.authorize_to_view(current) + synapses.each do |synapse| + if synapse.authorize_to_show(current) result = true end end - return result + result end ##### PERMISSIONS ###### @@ -117,12 +114,4 @@ class Topic < ActiveRecord::Base end return false end - - # returns Boolean if user allowed to view Topic, Synapse, or Map - def authorize_to_view(user) - if (self.permission == "private" && self.user != user) - return false - end - return true - end end diff --git a/app/models/user.rb b/app/models/user.rb index 7aafe7c9..39a5e00f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,7 +64,7 @@ class User < ActiveRecord::Base #generate a random 8 letter/digit code that they can use to invite people def generate_code - self.code = rand(36**8).to_s(36) + self.code ||= rand(36**8).to_s(36) $codes.push(self.code) self.generation = get_generation! end diff --git a/app/services/perm.rb b/app/services/perm.rb new file mode 100644 index 00000000..c18c26b7 --- /dev/null +++ b/app/services/perm.rb @@ -0,0 +1,37 @@ +class Perm + # e.g. Perm::ISSIONS + ISSIONS = [:commons, :public, :private] + + class << self + + def short(permission) + case permission + when :commons + "co" + when :public + "pu" + when :private + "pr" + else + fail "Invalid permission" + end + end + + def long(perm) + case perm + when "co" + :commons + when "pu" + :public + when "pr" + :private + else + fail "Invalid short permission" + end + end + + def valid?(permission) + ISSIONS.include? permission + end + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8057d576..e21a91c3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,7 +21,7 @@ @@ -66,7 +66,7 @@ -"> +"> <% if devise_error_messages? %>

<%= devise_error_messages! %>

diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index b40fb2a4..3c1319e0 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -47,7 +47,7 @@ Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>; Metamaps.currentSection = ""; Metamaps.currentPage = ""; - Metamaps.GlobalUI.Search.isOpen = true; + Metamaps.GlobalUI.Search.open(); Metamaps.GlobalUI.Search.lock(); <% end %> diff --git a/config/application.rb b/config/application.rb index 6bcfbe27..399b32c9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,9 +1,13 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' +require 'dotenv' Bundler.require(*Rails.groups) +ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" +Dotenv.load ".env.#{ENV["RAILS_ENV"]}", '.env' + module Metamaps class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. @@ -11,7 +15,7 @@ module Metamaps # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths << Rails.root.join('app', 'services') # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. @@ -45,6 +49,9 @@ module Metamaps # Version of your assets, change this if you want to expire all your assets config.assets.version = '2.0' + config.generators do |g| + g.test_framework :rspec + end config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 00000000..469ede34 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,21 @@ +default: &default + min_messages: WARNING + encoding: unicode + pool: 5 + adapter: postgresql + host: <%= ENV['DB_HOST'] %> + port: <%= ENV['DB_PORT'] %> + username: <%= ENV['DB_USERNAME'] %> + password: <%= ENV['DB_PASSWORD'] %> + +development: + <<: *default + database: <%= ENV['DB_NAME'] %>_development + +test: + <<: *default + database: <%= ENV['DB_NAME'] %>_test + +production: + <<: *default + database: <%= ENV['DB_NAME'] %>_production diff --git a/config/database.yml.default b/config/database.yml.default deleted file mode 100644 index 06bfae01..00000000 --- a/config/database.yml.default +++ /dev/null @@ -1,10 +0,0 @@ -development: - min_messages: WARNING - adapter: postgresql - host: 127.0.0.1 - port: 5432 - encoding: unicode - database: metamap002_development - pool: 5 - username: postgres - password: "3112" \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 55220ee3..9654962a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -42,7 +42,7 @@ Metamaps::Application.configure do authentication: 'plain', enable_starttls_auto: true, openssl_verify_mode: 'none' } - config.action_mailer.default_url_options = { :host => 'metamaps.herokuapp.com' } + 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 diff --git a/config/environments/test.rb b/config/environments/test.rb index 73003840..be83469c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,7 +10,7 @@ Metamaps::Application.configure do config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d01678be..6590fddf 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -11,18 +11,13 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = "team@metamaps.cc" + config.mailer_sender = ENV['DEVISE_MAILER_SENDER'] # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" - if Rails.env.development? # this is for Connors localhost - config.secret_key = 'f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614' - end - if Rails.env.production? # this is for the heroku staging environment - config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753' - end + config.secret_key = ENV['DEVISE_SECRET_KEY'] # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and diff --git a/configure.sh b/configure.sh index 13e18244..481ca907 100755 --- a/configure.sh +++ b/configure.sh @@ -11,7 +11,7 @@ vagrant ssh --command "cd /vagrant; gem install bundler"; vagrant ssh --command "cd /vagrant; bundle install"; # copy the db config -vagrant ssh --command "cd /vagrant; cp config/database.yml.default config/database.yml"; +vagrant ssh --command "cd /vagrant; cp .example-env .env"; # Rake all the things vagrant ssh --command "cd /vagrant; rake db:create; rake db:schema:load; rake db:fixtures:load" diff --git a/db/migrate/20151001024122_mapping_polymorphism.rb b/db/migrate/20151001024122_mapping_polymorphism.rb index e41233f6..e6bbd5fc 100644 --- a/db/migrate/20151001024122_mapping_polymorphism.rb +++ b/db/migrate/20151001024122_mapping_polymorphism.rb @@ -15,12 +15,16 @@ class MappingPolymorphism < ActiveRecord::Migration end unless mapping.synapse_id.nil? - mapping.mappable = Synapse.find(mapping.synapse_id) + mapping.mappable = Synapse.find_by(id: mapping.synapse_id) else - next if mapping.topic_id == 0 - mapping.mappable = Topic.find(mapping.topic_id) + mapping.mappable = Topic.find_by(id: mapping.topic_id) + end + + if mapping.mappable.nil? + mapping.delete + else + mapping.save end - mapping.save end end diff --git a/db/migrate/20151028061513_metacode_asset_path_update.rb b/db/migrate/20151028061513_metacode_asset_path_update.rb deleted file mode 100644 index be3607d1..00000000 --- a/db/migrate/20151028061513_metacode_asset_path_update.rb +++ /dev/null @@ -1,9 +0,0 @@ -class MetacodeAssetPathUpdate < ActiveRecord::Migration - def change - Metacode.all.each do |metacode| - if metacode.icon.start_with?("/assets/icons/") - metacode.update(icon: metacode.icon.gsub(/^\/assets\/icons/, "https://s3.amazonaws.com/metamaps-assets/metacodes")) - end - end - end -end diff --git a/db/migrate/20160120061513_metacode_asset_path_update.rb b/db/migrate/20160120061513_metacode_asset_path_update.rb new file mode 100644 index 00000000..a254597c --- /dev/null +++ b/db/migrate/20160120061513_metacode_asset_path_update.rb @@ -0,0 +1,15 @@ +class Metacode < ActiveRecord::Base +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") + metacode.icon = metacode.icon.sub('blueprint_96px', 'blueprint/96px') + metacode.icon = metacode.icon.sub('generics_96px', 'generics/96px') + metacode.save + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ebc8860e..e614b129 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151205205831) do +ActiveRecord::Schema.define(version: 20151028061513) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e85..3dbfab17 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,306 @@ # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) + +## USERS +User.new({ + name: 'user', + email: 'user@user.com', + password: 'toolsplusconsciousness', + code: 'qwertyui', + joinedwithcode: 'qwertyui', + admin: 'false' +}).save + +User.new({ + name: 'admin', + email: 'admin@admin.com', + password: 'toolsplusconsciousness', + code: 'iuytrewq', + joinedwithcode: 'iuytrewq', + admin: 'true' +}).save +## END USERS + +## METACODES +Metacode.create({ + name: 'Action', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png', + color: '#BD6C85' +}) + +Metacode.create({ + name: 'Activity', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png', + color: '#6EBF65' +}) + +Metacode.create({ + name: 'Catalyst', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png', + color: '#EF8964', +}) + +Metacode.create({ + name: 'Closed', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png', + color: '#ABB49F', +}) + +Metacode.create({ + name: 'Process', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png', + color: '#BDB25E', +}) + +Metacode.create({ + name: 'Future', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png', + color: '#25A17F', +}) + +Metacode.create({ + name: 'Group', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png', + color: '#7076BC', +}) + +Metacode.create({ + name: 'Implication', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png', + color: '#83DECA', +}) + +Metacode.create({ + name: 'Insight', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png', + color: '#B074AD', +}) + +Metacode.create({ + name: 'Intention', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png', + color: '#BAEAFF', +}) + +Metacode.create({ + name: 'Knowledge', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png', + color: '#60ACF7', +}) + +Metacode.create({ + name: 'Location', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png', + color: '#ABD9A7', +}) + +Metacode.create({ + name: 'Need', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png', + color: '#D2A7D4', +}) + +Metacode.create({ + name: 'Open', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png', + color: '#9BBF71', +}) + +Metacode.create({ + name: 'Opportunity', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png', + color: '#889F64', +}) + +Metacode.create({ + name: 'Person', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png', + color: '#DE925F', +}) + +Metacode.create({ + name: 'Platform', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png', + color: '#21C8FE', +}) + +Metacode.create({ + name: 'Problem', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png', + color: '#99CFC4', +}) + +Metacode.create({ + name: 'Resource', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png', + color: '#C98C63', +}) + +Metacode.create({ + name: 'Role', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png', + color: '#A8595D', +}) + +Metacode.create({ + name: 'Task', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png', + color: '#3397C4', +}) + +Metacode.create({ + name: 'Trajectory', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png', + color: '#D3AA4C', +}) + +Metacode.create({ + name: 'Argument', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png', + color: '#7FAEFD', +}) + +Metacode.create({ + name: 'Con', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png', + color: '#CF7C74', +}) + +Metacode.create({ + name: 'Subject', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png', + color: '#8293D8', +}) + +Metacode.create({ + name: 'Decision', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png', + color: '#CCA866', +}) + +Metacode.create({ + name: 'Event', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png', + color: '#F5854B', +}) + +Metacode.create({ + name: 'Example', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png', + color: '#618C61', +}) + +Metacode.create({ + name: 'Experience', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png', + color: '#BE995F', +}) + +Metacode.create({ + name: 'Feedback', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png', + color: '#54A19D', +}) + +Metacode.create({ + name: 'Aim', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png', + color: '#B0B0B0', +}) + +Metacode.create({ + name: 'Good', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png', + color: '#BD9E86', +}) + +Metacode.create({ + name: 'Idea', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png', + color: '#C4BC5E', +}) + +Metacode.create({ + name: 'List', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png', + color: '#B7A499', +}) + +Metacode.create({ + name: 'Media', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png', + color: '#6D94CC', +}) + +Metacode.create({ + name: 'Metamap', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png', + color: '#AEA9FD', +}) + +Metacode.create({ + name: 'Model', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png', + color: '#B385BA', +}) + +Metacode.create({ + name: 'Note', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png', + color: '#A389A1', +}) + +Metacode.create({ + name: 'Perspective', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png', + color: '#2EB6CC', +}) + +Metacode.create({ + name: 'Pro', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png', + color: '#89B879', +}) + +Metacode.create({ + name: 'Project', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png', + color: '#85A050', +}) + +Metacode.create({ + name: 'Question', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png', + color: '#5CB3B3', +}) + +Metacode.create({ + name: 'Reference', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png', + color: '#A7A7A7', +}) + +Metacode.create({ + name: 'Research', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png', + color: '#CD8E89', +}) + +Metacode.create({ + name: 'Status', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png', + color: '#EFA7C0', +}) + +Metacode.create({ + name: 'Tool', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png', + color: '#828282', +}) + +Metacode.create({ + name: 'Wildcard', + icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png', + color: '#73C7DE', +}) +## END METACODES diff --git a/doc/MacInstallation.md b/doc/MacInstallation.md index 2d36494e..2881f585 100644 --- a/doc/MacInstallation.md +++ b/doc/MacInstallation.md @@ -1,42 +1,43 @@ +# OSX Install + If you are doing an upgrade and or recent pull for changes you will need to change your default ruby package from 2.1.1 to ruby 2.1.2 -install homebrew +Some of these steps are pulled from http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/ + +Install homebrew \curl -sSL https://get.rvm.io | bash -s stable --rails - rvm install 2.1.3 --with-gcc=clang - rvm use 2.1.3 - gem install lunchy -(http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/) +Now install homebrew. + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +Then install nodejs + + brew install nodejs + +And postgresql: brew install postgresql ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents createuser metamaps -P -s -d -set a password +Set a password, then start the service: lunchy start postgres - -cd into the metamaps directory +Change directory to the metamaps git repository, and run: bundle install - -copy the database.yml.default file and rename it database.yml -make sure the username and password match the POSTGRES username and password you set - - -http://nodejs.org/ hit install, download, open, install - +Copy the .example-env file and rename it to .env. Then modify the DB_USERNAME and DB_PASSWORD values to match the postgres username and password you set rake db:create rake db:schema:load rake db:fixtures:load - rails s - -( to start the server) + rails server + +Now open a browser to http://localhost:3000! diff --git a/doc/RspecTesting.md b/doc/RspecTesting.md new file mode 100644 index 00000000..82cf74f7 --- /dev/null +++ b/doc/RspecTesting.md @@ -0,0 +1,53 @@ +## Testing with RSpec + +RSpec is a ruby gem that allows you to test your code base. This is great - +every time you make a change, you can do some basic sanity checks to make sure +you didn't break anything. + +To test Metamaps, run + + rspec + +in the top level directory. It will automatically search the `spec` directory +for files called `*_spec.rb`, and run them as tests. When it's done testing, it +will print a report telling you how many tests failed. With luck, the number +will be 0. + +Note that if your test database doesn't exist yet, you'll need to create it +first: + + RAILS_ENV=test rake db:create + +At the time of writing, there are four directories in the spec folder. One, +`support`, is for helper functions. `rails_helper.rb` and `spec_helper.rb` are +also for helper functions. + +`factories` is for a gem called [factory-girl][factory-girl]. This gem lets you +use the `create` and `build` functions to quickly create the simplest possible +valid version of a given model. For instance: + + let(:map1) { create :map } + let(:ronald) { create :user, name: "Ronald" } + let(:map2) { create :map, user: ronald } + +As you can see, you can also customize the factories. You can read the full +documentation at the link above or check the existing specs to see how it works. +It is worth reading through the factories to see how they are defined. If you +add a model to `app/models`, please also create a factory for it that defines +the minimum valid state for that model. + +Finally, `models` and `controllers` have the actual spec files. Writing specs is +usually fairly simple but you do need to understand the syntax. You can read +more at [rspec.info][rspec-docs]. + +If you modify the metamaps codebase, please consider adding tests verifying that +the added code works. This will help in a few ways: + + - Unrelated changes in the future that break your code will be spotted earlier + - Your changes will be more easily understood, since the *purpose* will be + described by the spec + +Happy testing! + +[factory-girl]: https://github.com/thoughtbot/factory_girl +[rspec-docs]: http://rspec.info diff --git a/doc/UbuntuInstallation.md b/doc/UbuntuInstallation.md index 54872124..77e2cb56 100644 --- a/doc/UbuntuInstallation.md +++ b/doc/UbuntuInstallation.md @@ -1,113 +1,97 @@ Firstly this walkthrough is done with a 14.04 32bit install of Ubuntu. - -All commands that I could are terminal based. - -Lets check if all updates for the system are installed first - -in terminal type +Let's check if all updates for the system are installed first. In a +terminal type: sudo apt-get update -now we need to install git +Now we need to install git: sudo apt-get install git -lets get our RVM installed (Ruby Version Manager) now this is fun because the package you will get from apt-get is outdated. - -so we are going to use CURL to get RVM +Now let's get our RVM installed (Ruby Version Manager). Now this is fun +because the package you will get from apt-get is outdated. So we are going +to use CURL to get RVM sudo apt-get install curl -then lets install RVM with curl like this - - curl -L get.rvm.io | bash -s stable +Then lets install RVM with curl like this + gpg --keyserver hkp://keys.gnupg.net \ + --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 + \curl -sSL https://get.rvm.io | bash -s stable PATH=$PATH:$HOME/.rvm/bin - [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" - [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" - source ~/.rvm/scripts/rvm -now we can actually install RVM +Now we can actually install RVM rvm requirements -running this will check your system for requirements as well so you will need to put your system password in. +Running this will check your system for requirements as well so you will need to put your system password in. -alright now we can download metamaps from the master using git +All right now we can download metamaps from the master using git git clone https://github.com/metamaps/metamaps_gen002.git -now there is a couple other things we are going to need which is nodejs, postgresql, libpq-dev and redis-server - - sudo apt-get install nodejs +Now there is a couple other things we are going to need which is nodejs, postgresql, libpq-dev and redis-server + sudo apt-get install nodejs npm + sudo ln -s /usr/bin/nodejs /usr/bin/node sudo apt-get install postgresql - sudo apt-get install libpq-dev - sudo apt-get install redis-server -Furthermore, if you want to be able to work on profile picture uploading, or use it -you'll need ImageMagick. On Ubuntu, you can just go find ImageMagick in the Ubuntu Software Centre +Furthermore, if you want to be able to work on profile picture uploading, +or use it you'll need ImageMagick. On Ubuntu, you can just go find +ImageMagick in the Ubuntu Software Centre Install the specific version of ruby needed this will take some time - rvm install ruby-2.1.3 + rvm install $(cat metamaps_gen002/.ruby-version) -Now we also need to rename your database file which is in ./config/database.default.yml to database.yml +Now we also need to copy .example-env to a new file named .env. Review the +configuration in here to see if you need any changes. -now run inside your metamaps_gen002 folder + cp .example-env .env +Now run inside your metamaps_gen002 folder: + + gem install bundle bundle install -in your top lvl directory for metamaps this is a lengthy process so you might want to go and make a coffee or something :) +in your top level directory for metamaps. This is a lengthy process so you might want to go and make a coffee or something :) -alright now we need to make sure your postgres password is the same as it is listed in the DB file so we are going to set it by +All right now we need to make sure your postgres password is the same as +it is listed in the .env file so we are going to set it by sudo -u postgres psql -Select postgres like this +Use these commands to set the password to 3112 and then quit: \password postgres - -set the password to 3112 - -Then to quit - \q -now we can run the rake install and db creation +now we can use rake to create, load the schema into, and load db/seeds.rb +into the postgres database: - rake db:create + rake db:setup - rake db:schema:load - - rake db:fixtures:load - -Execute the server: +Open a new terminal, navigate to the metamaps directory, and execute the +server: rails s and dont forget to run the other server for realtime... -open a new terminal -navigate to ./realtime and run - sudo apt-get install npm + cd realtime npm install - nodejs realtime-server.js + node realtime-server.js -Now you're all set enjoy your personal server of metamaps :) +Now you're all set enjoy your personal server of metamaps :) Navigate your browser to localhost:3000 once you have the server running. Sign in with the default account -Navigate your browser to localhost:3000 once you have the server running - -Sign in with the default account - -email: user@user.com - -password: toolsplusconsciousness + email: user@user.com + password: toolsplusconsciousness OR create a new account at /join, and use access code 'qwertyui' diff --git a/doc/WindowsInstallation.md b/doc/WindowsInstallation.md index da3527db..0446fab9 100644 --- a/doc/WindowsInstallation.md +++ b/doc/WindowsInstallation.md @@ -4,14 +4,12 @@ Ruby, Git, and Rails: http://railsinstaller.org/en PostgreSQL 9.2: http://www.enterprisedb.com/products-services-training/pgdownload nodejs: http://nodejs.org/download -During the installation of the PostgreSQL database, you'll need to choose a database password. Anything is fine, just note down what you choose. +During the installation of the PostgreSQL database, you'll need to choose a +database password. Anything is fine, just note down what you choose. -Once you are ready, create a new folder to hold this and any other git repositories. As an example, let's pretend you've chose C:\git, and made that folder writable by your user account. - -Open a command prompt ("cmd.exe"), and navigate to the folder you chose. Then use the gem command (which is part of Ruby) to install Ruby on Rails. - - cd .\git - gem install rails -v 4.2 +Once you are ready, create a new folder to hold this and any other git +repositories. As an example, let's pretend you've chose C:\git, and made that +folder writable by your user account. Now you are ready to clone the Metamaps git repository: @@ -19,19 +17,28 @@ Now you are ready to clone the Metamaps git repository: cd metamaps_gen002 bundle install -The third `bundle install` command downloads and installs the rubygem dependencies of Metamaps. +The third `bundle install` command downloads and installs the rubygem +dependencies of Metamaps. -At this point you should be in C:\git\metamaps_gen002, or whatever equivalent directory you've chosen. The next step is to set up your database configuration. From the metamaps_gen002 directory, run +At this point you should be in C:\git\metamaps_gen002, or whatever equivalent +directory you've chosen. The next step is to set up your database +configuration. From the metamaps_gen002 directory, run start config -This command will open a Windows Explorer window of the "config" directory of Metamaps. Copy database.yml.default, and rename the copy to database.yml. Edit the file and set the password to be whatever you set up with postgres earlier. Once you're done, then move back into the command prompt. The next few commands will fail unless database.yml is correctly configured and Postgres is running. +This command will open a Windows Explorer window of the "config" directory of +Metamaps. Copy `.example-env`, and rename the copy to `.env`. Edit the file and +set the DB_PASSWORD to be whatever you set up with postgres earlier. Once +you're done, then move back into the command prompt. The next few commands will +fail unless `.env` is correctly configured and Postgres is running. rake db:create rake db:schema:load rake db:fixtures:load -And you're set up! At this point, you should be able to run the server at any time with only one command; you don't need to repeat any of the previous steps again. The command to run the server is: +And you're set up! At this point, you should be able to run the server at any +time with only one command; you don't need to repeat any of the previous steps +again. The command to run the server is: rails s diff --git a/lib/tasks/heroku.rake b/lib/tasks/heroku.rake index af2dddf9..3e35fcbf 100644 --- a/lib/tasks/heroku.rake +++ b/lib/tasks/heroku.rake @@ -1,6 +1,8 @@ +require 'dotenv/tasks' + namespace :heroku do desc "Generate the Heroku gems manifest from gem dependencies" - task :gems do + task :gems => :dotenv do RAILS_ENV='production' Rake::Task[:environment].invoke list = Rails.configuration.gems.collect do |g| @@ -12,4 +14,4 @@ namespace :heroku do f.write(list) end end -end \ No newline at end of file +end diff --git a/realtime/README.md b/realtime/README.md index 468f526e..5c81979b 100644 --- a/realtime/README.md +++ b/realtime/README.md @@ -1 +1,18 @@ -'Real-Time' +## Node.js realtime server + +To run the server, you need to install the dependencies and run the server. +Please ensure you have followed the OS-specific instructions in doc/ to +install NodeJS. Once you have node, then you can proceed to install the +node packages for the realtime server: + + cd realtime + npm install #creates node_modules directory + node realtime-server.js + +That's it! + +To run the server as a daemon that will be re-run if it crashes, you can +use the forever node package. + + sudo npm install -g forever + forever start realtime-server.js diff --git a/realtime/package.json b/realtime/package.json index 71836c4f..5b5b08f4 100644 --- a/realtime/package.json +++ b/realtime/package.json @@ -2,6 +2,7 @@ "name": "RoR-real-time", "description": "providing real-time sychronization for ruby on rails", "version": "0.0.1", + "private": true, "dependencies": { "socket.io": "0.9.12", "node-uuid": "1.2.0" diff --git a/spec/controllers/mappings_controller_spec.rb b/spec/controllers/mappings_controller_spec.rb new file mode 100644 index 00000000..8a7acda5 --- /dev/null +++ b/spec/controllers/mappings_controller_spec.rb @@ -0,0 +1,160 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +RSpec.describe MappingsController, type: :controller do + # This should return the minimal set of attributes required to create a valid + # Mapping. As you add validations to Mapping, be sure to + # adjust the attributes here as well. + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end + + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # MappingsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe 'GET #index' do + it 'assigns all mappings as @mappings' do + mapping = Mapping.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:mappings)).to eq([mapping]) + end + end + + describe 'GET #show' do + it 'assigns the requested mapping as @mapping' do + mapping = Mapping.create! valid_attributes + get :show, { id: mapping.to_param }, valid_session + expect(assigns(:mapping)).to eq(mapping) + end + end + + describe 'GET #edit' do + it 'assigns the requested mapping as @mapping' do + mapping = Mapping.create! valid_attributes + get :edit, { id: mapping.to_param }, valid_session + expect(assigns(:mapping)).to eq(mapping) + end + end + + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Mapping' do + expect do + post :create, { mapping: valid_attributes }, valid_session + end.to change(Mapping, :count).by(1) + end + + it 'assigns a newly created mapping as @mapping' do + post :create, { mapping: valid_attributes }, valid_session + expect(assigns(:mapping)).to be_a(Mapping) + expect(assigns(:mapping)).to be_persisted + end + + it 'redirects to the created mapping' do + post :create, { mapping: valid_attributes }, valid_session + expect(response).to redirect_to(Mapping.last) + end + end + + context 'with invalid params' do + it 'assigns a newly created but unsaved mapping as @mapping' do + post :create, { mapping: invalid_attributes }, valid_session + expect(assigns(:mapping)).to be_a_new(Mapping) + end + + it "re-renders the 'new' template" do + post :create, { mapping: invalid_attributes }, valid_session + expect(response).to render_template('new') + end + end + end + + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') + end + + it 'updates the requested mapping' do + mapping = Mapping.create! valid_attributes + put :update, + { id: mapping.to_param, mapping: new_attributes }, + valid_session + mapping.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested mapping as @mapping' do + mapping = Mapping.create! valid_attributes + put :update, + { id: mapping.to_param, mapping: valid_attributes }, + valid_session + expect(assigns(:mapping)).to eq(mapping) + end + + it 'redirects to the mapping' do + mapping = Mapping.create! valid_attributes + put :update, + { id: mapping.to_param, mapping: valid_attributes }, + valid_session + expect(response).to redirect_to(mapping) + end + end + + context 'with invalid params' do + it 'assigns the mapping as @mapping' do + mapping = Mapping.create! valid_attributes + put :update, + { id: mapping.to_param, mapping: invalid_attributes }, + valid_session + expect(assigns(:mapping)).to eq(mapping) + end + + it "re-renders the 'edit' template" do + mapping = Mapping.create! valid_attributes + put :update, + { id: mapping.to_param, mapping: invalid_attributes }, + valid_session + expect(response).to render_template('edit') + end + end + end + + describe 'DELETE #destroy' do + it 'destroys the requested mapping' do + mapping = Mapping.create! valid_attributes + expect do + delete :destroy, { id: mapping.to_param }, valid_session + end.to change(Mapping, :count).by(-1) + end + + it 'redirects to the mappings list' do + mapping = Mapping.create! valid_attributes + delete :destroy, { id: mapping.to_param }, valid_session + expect(response).to redirect_to(mappings_url) + end + end +end diff --git a/spec/controllers/maps_controller_spec.rb b/spec/controllers/maps_controller_spec.rb new file mode 100644 index 00000000..fdaa064a --- /dev/null +++ b/spec/controllers/maps_controller_spec.rb @@ -0,0 +1,160 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +RSpec.describe MapsController, type: :controller do + # This should return the minimal set of attributes required to create a valid + # Map. As you add validations to Map, be sure to + # adjust the attributes here as well. + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end + + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # MapsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe 'GET #index' do + it 'assigns all maps as @maps' do + map = Map.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:maps)).to eq([map]) + end + end + + describe 'GET #show' do + it 'assigns the requested map as @map' do + map = Map.create! valid_attributes + get :show, { id: map.to_param }, valid_session + expect(assigns(:map)).to eq(map) + end + end + + describe 'GET #edit' do + it 'assigns the requested map as @map' do + map = Map.create! valid_attributes + get :edit, { id: map.to_param }, valid_session + expect(assigns(:map)).to eq(map) + end + end + + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Map' do + expect do + post :create, { map: valid_attributes }, valid_session + end.to change(Map, :count).by(1) + end + + it 'assigns a newly created map as @map' do + post :create, { map: valid_attributes }, valid_session + expect(assigns(:map)).to be_a(Map) + expect(assigns(:map)).to be_persisted + end + + it 'redirects to the created map' do + post :create, { map: valid_attributes }, valid_session + expect(response).to redirect_to(Map.last) + end + end + + context 'with invalid params' do + it 'assigns a newly created but unsaved map as @map' do + post :create, { map: invalid_attributes }, valid_session + expect(assigns(:map)).to be_a_new(Map) + end + + it "re-renders the 'new' template" do + post :create, { map: invalid_attributes }, valid_session + expect(response).to render_template('new') + end + end + end + + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') + end + + it 'updates the requested map' do + map = Map.create! valid_attributes + put :update, + { id: map.to_param, map: new_attributes }, + valid_session + map.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested map as @map' do + map = Map.create! valid_attributes + put :update, + { id: map.to_param, map: valid_attributes }, + valid_session + expect(assigns(:map)).to eq(map) + end + + it 'redirects to the map' do + map = Map.create! valid_attributes + put :update, + { id: map.to_param, map: valid_attributes }, + valid_session + expect(response).to redirect_to(map) + end + end + + context 'with invalid params' do + it 'assigns the map as @map' do + map = Map.create! valid_attributes + put :update, + { id: map.to_param, map: invalid_attributes }, + valid_session + expect(assigns(:map)).to eq(map) + end + + it "re-renders the 'edit' template" do + map = Map.create! valid_attributes + put :update, + { id: map.to_param, map: invalid_attributes }, + valid_session + expect(response).to render_template('edit') + end + end + end + + describe 'DELETE #destroy' do + it 'destroys the requested map' do + map = Map.create! valid_attributes + expect do + delete :destroy, { id: map.to_param }, valid_session + end.to change(Map, :count).by(-1) + end + + it 'redirects to the maps list' do + map = Map.create! valid_attributes + delete :destroy, { id: map.to_param }, valid_session + expect(response).to redirect_to(maps_url) + end + end +end diff --git a/spec/controllers/metacodes_controller_spec.rb b/spec/controllers/metacodes_controller_spec.rb new file mode 100644 index 00000000..6e1ba2b9 --- /dev/null +++ b/spec/controllers/metacodes_controller_spec.rb @@ -0,0 +1,172 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +RSpec.describe MetacodesController, type: :controller do + before :each do + @user = create(:user, admin: true) + sign_in @user + end + + # This should return the minimal set of attributes required to create a valid + # Metacode. As you add validations to Metacode, be sure to + # adjust the attributes here as well. + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end + + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # MetacodesController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe 'GET #index' do + it 'assigns all metacodes as @metacodes' do + metacode = Metacode.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:metacodes)).to eq([metacode]) + end + end + + describe 'GET #show' do + it 'assigns the requested metacode as @metacode' do + metacode = Metacode.create! valid_attributes + get :show, { id: metacode.to_param }, valid_session + expect(assigns(:metacode)).to eq(metacode) + end + end + + describe 'GET #new' do + it 'assigns a new metacode as @metacode' do + get :new, {}, valid_session + expect(assigns(:metacode)).to be_a_new(Metacode) + end + end + + describe 'GET #edit' do + it 'assigns the requested metacode as @metacode' do + metacode = Metacode.create! valid_attributes + get :edit, { id: metacode.to_param }, valid_session + expect(assigns(:metacode)).to eq(metacode) + end + end + + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Metacode' do + expect do + post :create, { metacode: valid_attributes }, valid_session + end.to change(Metacode, :count).by(1) + end + + it 'assigns a newly created metacode as @metacode' do + post :create, { metacode: valid_attributes }, valid_session + expect(assigns(:metacode)).to be_a(Metacode) + expect(assigns(:metacode)).to be_persisted + end + + it 'redirects to the created metacode' do + post :create, { metacode: valid_attributes }, valid_session + expect(response).to redirect_to(Metacode.last) + end + end + + context 'with invalid params' do + it 'assigns a newly created but unsaved metacode as @metacode' do + post :create, { metacode: invalid_attributes }, valid_session + expect(assigns(:metacode)).to be_a_new(Metacode) + end + + it "re-renders the 'new' template" do + post :create, { metacode: invalid_attributes }, valid_session + expect(response).to render_template('new') + end + end + end + + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') + end + + it 'updates the requested metacode' do + metacode = Metacode.create! valid_attributes + put :update, + { id: metacode.to_param, metacode: new_attributes }, + valid_session + metacode.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested metacode as @metacode' do + metacode = Metacode.create! valid_attributes + put :update, + { id: metacode.to_param, metacode: valid_attributes }, + valid_session + expect(assigns(:metacode)).to eq(metacode) + end + + it 'redirects to the metacode' do + metacode = Metacode.create! valid_attributes + put :update, + { id: metacode.to_param, metacode: valid_attributes }, + valid_session + expect(response).to redirect_to(metacode) + end + end + + context 'with invalid params' do + it 'assigns the metacode as @metacode' do + metacode = Metacode.create! valid_attributes + put :update, + { id: metacode.to_param, metacode: invalid_attributes }, + valid_session + expect(assigns(:metacode)).to eq(metacode) + end + + it "re-renders the 'edit' template" do + metacode = Metacode.create! valid_attributes + put :update, + { id: metacode.to_param, metacode: invalid_attributes }, + valid_session + expect(response).to render_template('edit') + end + end + end + + describe 'DELETE #destroy' do + it 'destroys the requested metacode' do + metacode = Metacode.create! valid_attributes + expect do + delete :destroy, { id: metacode.to_param }, valid_session + end.to change(Metacode, :count).by(-1) + end + + it 'redirects to the metacodes list' do + metacode = Metacode.create! valid_attributes + delete :destroy, { id: metacode.to_param }, valid_session + expect(response).to redirect_to(metacodes_url) + end + end +end diff --git a/spec/controllers/synapses_controller_spec.rb b/spec/controllers/synapses_controller_spec.rb new file mode 100644 index 00000000..ff05ea6f --- /dev/null +++ b/spec/controllers/synapses_controller_spec.rb @@ -0,0 +1,160 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +RSpec.describe SynapsesController, type: :controller do + # This should return the minimal set of attributes required to create a valid + # Synapse. As you add validations to Synapse, be sure to + # adjust the attributes here as well. + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end + + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # SynapsesController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe 'GET #index' do + it 'assigns all synapses as @synapses' do + synapse = Synapse.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:synapses)).to eq([synapse]) + end + end + + describe 'GET #show' do + it 'assigns the requested synapse as @synapse' do + synapse = Synapse.create! valid_attributes + get :show, { id: synapse.to_param }, valid_session + expect(assigns(:synapse)).to eq(synapse) + end + end + + describe 'GET #edit' do + it 'assigns the requested synapse as @synapse' do + synapse = Synapse.create! valid_attributes + get :edit, { id: synapse.to_param }, valid_session + expect(assigns(:synapse)).to eq(synapse) + end + end + + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Synapse' do + expect do + post :create, { synapse: valid_attributes }, valid_session + end.to change(Synapse, :count).by(1) + end + + it 'assigns a newly created synapse as @synapse' do + post :create, { synapse: valid_attributes }, valid_session + expect(assigns(:synapse)).to be_a(Synapse) + expect(assigns(:synapse)).to be_persisted + end + + it 'redirects to the created synapse' do + post :create, { synapse: valid_attributes }, valid_session + expect(response).to redirect_to(Synapse.last) + end + end + + context 'with invalid params' do + it 'assigns a newly created but unsaved synapse as @synapse' do + post :create, { synapse: invalid_attributes }, valid_session + expect(assigns(:synapse)).to be_a_new(Synapse) + end + + it "re-renders the 'new' template" do + post :create, { synapse: invalid_attributes }, valid_session + expect(response).to render_template('new') + end + end + end + + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') + end + + it 'updates the requested synapse' do + synapse = Synapse.create! valid_attributes + put :update, + { id: synapse.to_param, synapse: new_attributes }, + valid_session + synapse.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested synapse as @synapse' do + synapse = Synapse.create! valid_attributes + put :update, + { id: synapse.to_param, synapse: valid_attributes }, + valid_session + expect(assigns(:synapse)).to eq(synapse) + end + + it 'redirects to the synapse' do + synapse = Synapse.create! valid_attributes + put :update, + { id: synapse.to_param, synapse: valid_attributes }, + valid_session + expect(response).to redirect_to(synapse) + end + end + + context 'with invalid params' do + it 'assigns the synapse as @synapse' do + synapse = Synapse.create! valid_attributes + put :update, + { id: synapse.to_param, synapse: invalid_attributes }, + valid_session + expect(assigns(:synapse)).to eq(synapse) + end + + it "re-renders the 'edit' template" do + synapse = Synapse.create! valid_attributes + put :update, + { id: synapse.to_param, synapse: invalid_attributes }, + valid_session + expect(response).to render_template('edit') + end + end + end + + describe 'DELETE #destroy' do + it 'destroys the requested synapse' do + synapse = Synapse.create! valid_attributes + expect do + delete :destroy, { id: synapse.to_param }, valid_session + end.to change(Synapse, :count).by(-1) + end + + it 'redirects to the synapses list' do + synapse = Synapse.create! valid_attributes + delete :destroy, { id: synapse.to_param }, valid_session + expect(response).to redirect_to(synapses_url) + end + end +end diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb new file mode 100644 index 00000000..35b2156e --- /dev/null +++ b/spec/controllers/topics_controller_spec.rb @@ -0,0 +1,136 @@ +require 'rails_helper' + +RSpec.describe TopicsController, type: :controller do + let(:valid_attributes) do + skip('Add a hash of attributes valid for your model') + end + + let(:invalid_attributes) do + skip('Add a hash of attributes invalid for your model') + end + + let(:valid_session) { {} } + + describe 'GET #index' do + it 'assigns all topics as @topics' do + topic = Topic.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:topics)).to eq([topic]) + end + end + + describe 'GET #show' do + it 'assigns the requested topic as @topic' do + topic = Topic.create! valid_attributes + get :show, { id: topic.to_param }, valid_session + expect(assigns(:topic)).to eq(topic) + end + end + + describe 'GET #edit' do + it 'assigns the requested topic as @topic' do + topic = Topic.create! valid_attributes + get :edit, { id: topic.to_param }, valid_session + expect(assigns(:topic)).to eq(topic) + end + end + + describe 'POST #create' do + context 'with valid params' do + it 'creates a new Topic' do + expect do + post :create, { topic: valid_attributes }, valid_session + end.to change(Topic, :count).by(1) + end + + it 'assigns a newly created topic as @topic' do + post :create, { topic: valid_attributes }, valid_session + expect(assigns(:topic)).to be_a(Topic) + expect(assigns(:topic)).to be_persisted + end + + it 'redirects to the created topic' do + post :create, { topic: valid_attributes }, valid_session + expect(response).to redirect_to(Topic.last) + end + end + + context 'with invalid params' do + it 'assigns a newly created but unsaved topic as @topic' do + post :create, { topic: invalid_attributes }, valid_session + expect(assigns(:topic)).to be_a_new(Topic) + end + + it "re-renders the 'new' template" do + post :create, { topic: invalid_attributes }, valid_session + expect(response).to render_template('new') + end + end + end + + describe 'PUT #update' do + context 'with valid params' do + let(:new_attributes) do + skip('Add a hash of attributes valid for your model') + end + + it 'updates the requested topic' do + topic = Topic.create! valid_attributes + put :update, + { id: topic.to_param, topic: new_attributes }, + valid_session + topic.reload + skip('Add assertions for updated state') + end + + it 'assigns the requested topic as @topic' do + topic = Topic.create! valid_attributes + put :update, + { id: topic.to_param, topic: valid_attributes }, + valid_session + expect(assigns(:topic)).to eq(topic) + end + + it 'redirects to the topic' do + topic = Topic.create! valid_attributes + put :update, + { id: topic.to_param, topic: valid_attributes }, + valid_session + expect(response).to redirect_to(topic) + end + end + + context 'with invalid params' do + it 'assigns the topic as @topic' do + topic = Topic.create! valid_attributes + put :update, + { id: topic.to_param, topic: invalid_attributes }, + valid_session + expect(assigns(:topic)).to eq(topic) + end + + it "re-renders the 'edit' template" do + topic = Topic.create! valid_attributes + put :update, + { id: topic.to_param, topic: invalid_attributes }, + valid_session + expect(response).to render_template('edit') + end + end + end + + describe 'DELETE #destroy' do + it 'destroys the requested topic' do + topic = Topic.create! valid_attributes + expect do + delete :destroy, { id: topic.to_param }, valid_session + end.to change(Topic, :count).by(-1) + end + + it 'redirects to the topics list' do + topic = Topic.create! valid_attributes + delete :destroy, { id: topic.to_param }, valid_session + expect(response).to redirect_to(topics_url) + end + end +end diff --git a/spec/factories/maps.rb b/spec/factories/maps.rb new file mode 100644 index 00000000..a786d109 --- /dev/null +++ b/spec/factories/maps.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :map do + sequence(:name) { |n| "Cool Map ##{n}" } + permission :commons + arranged { false } + user + end +end diff --git a/spec/factories/metacodes.rb b/spec/factories/metacodes.rb new file mode 100644 index 00000000..5cfb38f6 --- /dev/null +++ b/spec/factories/metacodes.rb @@ -0,0 +1,4 @@ +FactoryGirl.define do + factory :metacode do + end +end diff --git a/spec/factories/synapses.rb b/spec/factories/synapses.rb new file mode 100644 index 00000000..b83a0073 --- /dev/null +++ b/spec/factories/synapses.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :synapse do + sequence(:desc) { |n| "Cool synapse ##{n}" } + category :to + permission :commons + association :topic1, factory: :topic + association :topic2, factory: :topic + end +end diff --git a/spec/factories/topics.rb b/spec/factories/topics.rb new file mode 100644 index 00000000..17c69a25 --- /dev/null +++ b/spec/factories/topics.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :topic do + sequence(:name) { |n| "Cool Topic ##{n}" } + permission :commons + user + metacode + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 00000000..91da1d1c --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,29 @@ +# +# This file supports three factories, because code and joinedwithcode +# make things complicated! +# +# Generally, use :simple_user to generate users. It's simplest. +# +# If you want to test code generation, or need a setup with users that +# have actual codes, you'll need to specify one simple_user and then you +# can specify other :code_user users based on the pre-existing user's code. + +FactoryGirl.define do + factory :code_user, class: User do + sequence(:name) { |n| "Cool User ##{n}" } + sequence(:email) { |n| "cooluser#{n}@cooldomain.com" } + password 'omgwtfbbq' + + factory :simple_user, aliases: [:user] do + joinedwithcode { "qwertyui" } + code { "qwertyui" } + + transient do + validate false + end + + # bypass validation of the joinedwithcode + to_create { |instance| instance.save(validate: instance.validate) } + end + end +end diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb new file mode 100644 index 00000000..d1486192 --- /dev/null +++ b/spec/models/map_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +RSpec.describe Map, type: :model do + it { is_expected.to belong_to :user } + it { is_expected.to validate_presence_of :name } + it { is_expected.to validate_presence_of :permission } + it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) } + + context 'permissions' do + let(:owner) { create :user } + let(:other_user) { create :user } + let(:map) { create :map, user: owner, permission: :commons } + let(:private_map) { create :map, user: owner, permission: :private } + let(:public_map) { create :map, user: owner, permission: :public } + + it 'prevents deletion by non-owner' do + expect(map.authorize_to_delete(other_user)).to eq false + expect(map.authorize_to_delete(owner)).to eq map + end + + it 'prevents visibility if private' do + expect(map.authorize_to_show(other_user)).to eq map + expect(map.authorize_to_show(owner)).to eq map + expect(private_map.authorize_to_show(owner)).to eq private_map + expect(private_map.authorize_to_show(other_user)).to eq false + end + + it 'only allows editing if commons or owned' do + expect(map.authorize_to_edit(other_user)).to eq map + expect(map.authorize_to_edit(owner)).to eq map + expect(private_map.authorize_to_edit(other_user)).to eq false + expect(private_map.authorize_to_edit(owner)).to eq private_map + expect(public_map.authorize_to_edit(other_user)).to eq false + expect(public_map.authorize_to_edit(owner)).to eq public_map + end + end +end + diff --git a/spec/models/mapping_spec.rb b/spec/models/mapping_spec.rb new file mode 100644 index 00000000..32d34796 --- /dev/null +++ b/spec/models/mapping_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Mapping, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/metacode_spec.rb b/spec/models/metacode_spec.rb new file mode 100644 index 00000000..10571a81 --- /dev/null +++ b/spec/models/metacode_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' + +RSpec.describe Metacode, type: :model do + pending "add some examples to (or delete) #{__FILE__}" + it { is_expected.to have_many(:topics) } +end diff --git a/spec/models/synapse_spec.rb b/spec/models/synapse_spec.rb new file mode 100644 index 00000000..a1069805 --- /dev/null +++ b/spec/models/synapse_spec.rb @@ -0,0 +1,41 @@ +require 'rails_helper' + +RSpec.describe Synapse, type: :model do + it { is_expected.to belong_to :user } + it { is_expected.to belong_to :topic1 } + it { is_expected.to belong_to :topic2 } + it { is_expected.to have_many :maps } + it { is_expected.to have_many :mappings } + 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_length_of(:desc).is_at_least(0) } # TODO don't allow nil + + context 'permissions' do + let(:owner) { create :user } + let(:other_user) { create :user } + let(:synapse) { create :synapse, user: owner, permission: :commons } + let(:private_synapse) { create :synapse, user: owner, permission: :private } + let(:public_synapse) { create :synapse, user: owner, permission: :public } + + it 'prevents deletion by non-owner' do + expect(synapse.authorize_to_delete(other_user)).to eq false + expect(synapse.authorize_to_delete(owner)).to eq synapse + end + + it 'prevents visibility if private' do + expect(synapse.authorize_to_show(other_user)).to eq synapse + expect(synapse.authorize_to_show(owner)).to eq synapse + expect(private_synapse.authorize_to_show(owner)).to eq private_synapse + expect(private_synapse.authorize_to_show(other_user)).to eq false + end + + it 'only allows editing if commons or owned' do + expect(synapse.authorize_to_edit(other_user)).to eq synapse + expect(synapse.authorize_to_edit(owner)).to eq synapse + expect(private_synapse.authorize_to_edit(other_user)).to eq false + expect(private_synapse.authorize_to_edit(owner)).to eq private_synapse + expect(public_synapse.authorize_to_edit(other_user)).to eq false + expect(public_synapse.authorize_to_edit(owner)).to eq public_synapse + end + end +end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb new file mode 100644 index 00000000..b499daac --- /dev/null +++ b/spec/models/topic_spec.rb @@ -0,0 +1,81 @@ +require 'rails_helper' + +RSpec.describe Topic, type: :model do + it { is_expected.to belong_to :user } + it { is_expected.to belong_to :metacode } + it { is_expected.to have_many :maps } + it { is_expected.to have_many :mappings } + it { is_expected.to validate_presence_of :permission } + it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) } + + context 'has_viewable_synapses function' do + let (:user) { create(:user) } + let (:other_user) { create(:user) } + + context 'topic with no synapses' do + let (:topic) { create(:topic) } + + it 'returns false' do + expect(topic.has_viewable_synapses(user)).to eq false + end + end + + context 'topic with one unpermitted synapse' do + let (:synapse) { create(:synapse, permission: :private, user: other_user) } + let (:topic) { create(:topic, synapses1: [synapse]) } + + it 'returns false' do + expect(topic.has_viewable_synapses(user)).to eq false + end + end + + context 'topic with one permitted synapse' do + let (:synapse) { create(:synapse, permission: :private, user: user) } + let(:topic) { create(:topic, synapses1: [synapse]) } + + it 'returns true' do + expect(topic.has_viewable_synapses(user)).to eq true + end + end + + context 'topic with one unpermitted, one permitted synapse' do + let (:synapse1) { create(:synapse, permission: :private, user: other_user) } + let (:synapse2) { create(:synapse, permission: :private, user: user) } + let (:topic) { create(:topic, synapses1: [synapse1, synapse2]) } + + it 'returns true' do + expect(topic.synapses.count).to eq 2 + expect(topic.has_viewable_synapses(user)).to eq true + end + end + end + + context 'permssions' do + let(:owner) { create :user } + let(:other_user) { create :user } + let(:topic) { create :topic, user: owner, permission: :commons } + let(:private_topic) { create :topic, user: owner, permission: :private } + let(:public_topic) { create :topic, user: owner, permission: :public } + + it 'prevents deletion by non-owner' do + expect(topic.authorize_to_delete(other_user)).to eq false + expect(topic.authorize_to_delete(owner)).to eq topic + end + + it 'prevents visibility if private' do + expect(topic.authorize_to_show(other_user)).to eq topic + expect(topic.authorize_to_show(owner)).to eq topic + expect(private_topic.authorize_to_show(owner)).to eq private_topic + expect(private_topic.authorize_to_show(other_user)).to eq false + end + + it 'only allows editing if commons or owned' do + expect(topic.authorize_to_edit(other_user)).to eq topic + expect(topic.authorize_to_edit(owner)).to eq topic + expect(private_topic.authorize_to_edit(other_user)).to eq false + expect(private_topic.authorize_to_edit(owner)).to eq private_topic + expect(public_topic.authorize_to_edit(other_user)).to eq false + expect(public_topic.authorize_to_edit(owner)).to eq public_topic + end + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..23f21101 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,45 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) + +# Prevent database truncation if the environment is production +if Rails.env.production? + abort('The Rails environment is running in production mode!') +end + +require 'spec_helper' +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# require all support files +Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + config.include Devise::TestHelpers, type: :controller + config.include ControllerHelpers, type: :controller + config.include Shoulda::Matchers::ActiveModel, type: :model + config.include Shoulda::Matchers::ActiveRecord, type: :model +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..a2b164b2 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,9 @@ +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end +end diff --git a/spec/support/controller_helpers.rb b/spec/support/controller_helpers.rb new file mode 100644 index 00000000..5fe34854 --- /dev/null +++ b/spec/support/controller_helpers.rb @@ -0,0 +1,17 @@ +# https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs +module ControllerHelpers + # rubocop:disable Metrics/AbcSize + def sign_in(user = create(:user)) + if user.nil? # simulate unauthenticated + allow(request.env['warden']).to( + receive(:authenticate!).and_throw(:warden, scope: :user) + ) + else # simulate authenticated + allow(request.env['warden']).to( + receive(:authenticate!).and_return(user) + ) + end + allow(controller).to receive(:current_user).and_return(user) + end + # rubocop:enable Metrics/AbcSize +end diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb new file mode 100644 index 00000000..afae617a --- /dev/null +++ b/spec/support/factory_girl.rb @@ -0,0 +1,4 @@ +# lets you type create(:user) instead of FactoryGirl.create(:user) +RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods +end diff --git a/test/fixtures/.gitkeep b/test/fixtures/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/in_metacode_sets.yml b/test/fixtures/in_metacode_sets.yml deleted file mode 100644 index 9879c73b..00000000 --- a/test/fixtures/in_metacode_sets.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -#one: -# metacode: -# metacode_set: - -#two: -# metacode: -# metacode_set: diff --git a/test/fixtures/mappings.yml b/test/fixtures/mappings.yml deleted file mode 100644 index 9cfe87b6..00000000 --- a/test/fixtures/mappings.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -#one: {} -# column: value -# -#two: {} -# column: value diff --git a/test/fixtures/metacode_sets.yml b/test/fixtures/metacode_sets.yml deleted file mode 100644 index 56bda62e..00000000 --- a/test/fixtures/metacode_sets.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -#one: -# name: MyString -# desc: MyText -# user: -# mapperContributed: false - -#two: -# name: MyString -# desc: MyText -# user: -# mapperContributed: false diff --git a/test/fixtures/metacodes.yml b/test/fixtures/metacodes.yml deleted file mode 100644 index 80780734..00000000 --- a/test/fixtures/metacodes.yml +++ /dev/null @@ -1,240 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: - name: Action - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png - color: #BD6C85 - -two: - name: Activity - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png - color: #6EBF65 - -three: - name: Catalyst - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png - color: #EF8964 - -four: - name: Closed - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png - color: #ABB49F - -five: - name: Process - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png - color: #BDB25E - -six: - name: Future Dev - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png - color: #25A17F - -seven: - name: Group - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png - color: #7076BC - -eight: - name: Implication - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png - color: #83DECA - -nine: - name: Insight - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png - color: #B074AD - -ten: - name: Intention - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png - color: #BAEAFF - -eleven: - name: Knowledge - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png - color: #60ACF7 - -twelve: - name: Location - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png - color: #ABD9A7 - -thirteen: - name: Need - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png - color: #D2A7D4 - -fourteen: - name: Open Issue - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png - color: #9BBF71 - -fifteen: - name: Opportunity - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png - color: #889F64 - -sixteen: - name: Person - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png - color: #DE925F - -seventeen: - name: Platform - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png - color: #21C8FE - -eighteen: - name: Problem - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png - color: #99CFC4 - -nineteen: - name: Resource - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png - color: #C98C63 - -twenty: - name: Role - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png - color: #A8595D - -twenty-one: - name: Task - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png - color: #3397C4 - -twenty-two: - name: Trajectory - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png - color: #D3AA4C - -twenty-three: - name: Argument - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png - color: #7FAEFD - -twenty-four: - name: Con - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png - color: #CF7C74 - -twenty-five: - name: Subject - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png - color: #8293D8 - -twenty-six: - name: Decision - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png - color: #CCA866 - -twenty-seven: - name: Event - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png - color: #F5854B - -twenty-eight: - name: Example - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png - color: #618C61 - -twenty-nine: - name: Experience - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png - color: #BE995F - -thirty: - name: Feedback - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png - color: #54A19D - -thirty-one: - name: Aim - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png - color: #B0B0B0 - -thirty-two: - name: Good Practice - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png - color: #BD9E86 - -thirty-three: - name: Idea - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png - color: #C4BC5E - -thirty-four: - name: List - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png - color: #B7A499 - -thirty-five: - name: Media - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png - color: #6D94CC - -thirty-six: - name: Metamap - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png - color: #AEA9FD - -thirty-seven: - name: Model - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png - color: #B385BA - -thirty-eight: - name: Note - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png - color: #A389A1 - -thirty-nine: - name: Perspective - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png - color: #2EB6CC - -forty: - name: Pro - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png - color: #89B879 - -forty-one: - name: Project - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png - color: #85A050 - -forty-two: - name: Question - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png - color: #5CB3B3 - -forty-three: - name: Reference - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png - color: #A7A7A7 - -forty-four: - name: Research - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png - color: #CD8E89 - -forty-five: - name: Status update - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png - color: #EFA7C0 - -forty-six: - name: Tool - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png - color: #828282 - -forty-seven: - name: Wildcard - icon: https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png - color: #73C7DE diff --git a/test/fixtures/topics.yml b/test/fixtures/topics.yml deleted file mode 100644 index 9cfe87b6..00000000 --- a/test/fixtures/topics.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -#one: {} -# column: value -# -#two: {} -# column: value diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml deleted file mode 100644 index 8a461a50..00000000 --- a/test/fixtures/users.yml +++ /dev/null @@ -1,17 +0,0 @@ -#password: toolsplusconsciousness - -user: - name: user - email: user@user.com - encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW - code: qwertyui - joinedwithcode: qwertyui - admin: false - -admin: - name: admin - email: admin@admin.com - encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW - code: iuytrewq - joinedwithcode: iuytrewq - admin: true diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/functional/in_metacode_sets_controller_test.rb b/test/functional/in_metacode_sets_controller_test.rb deleted file mode 100644 index f78ad458..00000000 --- a/test/functional/in_metacode_sets_controller_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class InMetacodeSetsControllerTest < ActionController::TestCase - setup do - @in_metacode_set = in_metacode_sets(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:in_metacode_sets) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create in_metacode_set" do - assert_difference('InMetacodeSet.count') do - post :create, in_metacode_set: { } - end - - assert_redirected_to in_metacode_set_path(assigns(:in_metacode_set)) - end - - test "should show in_metacode_set" do - get :show, id: @in_metacode_set - assert_response :success - end - - test "should get edit" do - get :edit, id: @in_metacode_set - assert_response :success - end - - test "should update in_metacode_set" do - put :update, id: @in_metacode_set, in_metacode_set: { } - assert_redirected_to in_metacode_set_path(assigns(:in_metacode_set)) - end - - test "should destroy in_metacode_set" do - assert_difference('InMetacodeSet.count', -1) do - delete :destroy, id: @in_metacode_set - end - - assert_redirected_to in_metacode_sets_path - end -end diff --git a/test/functional/main_controller_test.rb b/test/functional/main_controller_test.rb deleted file mode 100644 index b7ec6bfc..00000000 --- a/test/functional/main_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MainControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/mapping_controller_test.rb b/test/functional/mapping_controller_test.rb deleted file mode 100644 index 59fc534a..00000000 --- a/test/functional/mapping_controller_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -class MappingControllerTest < ActionController::TestCase - test "should get new" do - get :new - assert_response :success - end - -end diff --git a/test/functional/maps_controller_test.rb b/test/functional/maps_controller_test.rb deleted file mode 100644 index 9517ea55..00000000 --- a/test/functional/maps_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MapsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/metacode_sets_controller_test.rb b/test/functional/metacode_sets_controller_test.rb deleted file mode 100644 index ec06c1e4..00000000 --- a/test/functional/metacode_sets_controller_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class MetacodeSetsControllerTest < ActionController::TestCase - setup do - @metacode_set = metacode_sets(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:metacode_sets) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create metacode_set" do - assert_difference('MetacodeSet.count') do - post :create, metacode_set: { desc: @metacode_set.desc, mapperContributed: @metacode_set.mapperContributed, name: @metacode_set.name } - end - - assert_redirected_to metacode_set_path(assigns(:metacode_set)) - end - - test "should show metacode_set" do - get :show, id: @metacode_set - assert_response :success - end - - test "should get edit" do - get :edit, id: @metacode_set - assert_response :success - end - - test "should update metacode_set" do - put :update, id: @metacode_set, metacode_set: { desc: @metacode_set.desc, mapperContributed: @metacode_set.mapperContributed, name: @metacode_set.name } - assert_redirected_to metacode_set_path(assigns(:metacode_set)) - end - - test "should destroy metacode_set" do - assert_difference('MetacodeSet.count', -1) do - delete :destroy, id: @metacode_set - end - - assert_redirected_to metacode_sets_path - end -end diff --git a/test/functional/metacodes_controller_test.rb b/test/functional/metacodes_controller_test.rb deleted file mode 100644 index c15d468f..00000000 --- a/test/functional/metacodes_controller_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class MetacodesControllerTest < ActionController::TestCase - setup do - @metacode = metacodes(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:metacodes) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create metacode" do - assert_difference('Metacode.count') do - post :create, metacode: { icon: @metacode.icon, name: @metacode.name } - end - - assert_redirected_to metacode_path(assigns(:metacode)) - end - - test "should show metacode" do - get :show, id: @metacode - assert_response :success - end - - test "should get edit" do - get :edit, id: @metacode - assert_response :success - end - - test "should update metacode" do - put :update, id: @metacode, metacode: { icon: @metacode.icon, name: @metacode.name } - assert_redirected_to metacode_path(assigns(:metacode)) - end - - test "should destroy metacode" do - assert_difference('Metacode.count', -1) do - delete :destroy, id: @metacode - end - - assert_redirected_to metacodes_path - end -end diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb deleted file mode 100644 index d30ebc38..00000000 --- a/test/functional/sessions_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class SessionsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/synapses_controller_test.rb b/test/functional/synapses_controller_test.rb deleted file mode 100644 index 42d864b0..00000000 --- a/test/functional/synapses_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class SynapsesControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/topics_controller_test.rb b/test/functional/topics_controller_test.rb deleted file mode 100644 index dd41edd9..00000000 --- a/test/functional/topics_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class TopicsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb deleted file mode 100644 index d23f1829..00000000 --- a/test/functional/users_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UsersControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb deleted file mode 100644 index 3fea27b9..00000000 --- a/test/performance/browsing_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test_helper' -require 'rails/performance_test_help' - -class BrowsingTest < ActionDispatch::PerformanceTest - # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] - # :output => 'tmp/performance', :formats => [:flat] } - - def test_homepage - get '/' - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 8bf1192f..00000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unit/helpers/in_metacode_sets_helper_test.rb b/test/unit/helpers/in_metacode_sets_helper_test.rb deleted file mode 100644 index 64eb689a..00000000 --- a/test/unit/helpers/in_metacode_sets_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class InMetacodeSetsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/main_helper_test.rb b/test/unit/helpers/main_helper_test.rb deleted file mode 100644 index 22da3c40..00000000 --- a/test/unit/helpers/main_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MainHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/mapping_helper_test.rb b/test/unit/helpers/mapping_helper_test.rb deleted file mode 100644 index 5768ae1b..00000000 --- a/test/unit/helpers/mapping_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MappingHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/maps_helper_test.rb b/test/unit/helpers/maps_helper_test.rb deleted file mode 100644 index 0a0efccd..00000000 --- a/test/unit/helpers/maps_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MapsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/metacode_sets_helper_test.rb b/test/unit/helpers/metacode_sets_helper_test.rb deleted file mode 100644 index d1983654..00000000 --- a/test/unit/helpers/metacode_sets_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MetacodeSetsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/metacodes_helper_test.rb b/test/unit/helpers/metacodes_helper_test.rb deleted file mode 100644 index 2837d55f..00000000 --- a/test/unit/helpers/metacodes_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MetacodesHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/sessions_helper_test.rb b/test/unit/helpers/sessions_helper_test.rb deleted file mode 100644 index 7d44e096..00000000 --- a/test/unit/helpers/sessions_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class SessionsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/synapses_helper_test.rb b/test/unit/helpers/synapses_helper_test.rb deleted file mode 100644 index c7a530a0..00000000 --- a/test/unit/helpers/synapses_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class SynapsesHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/topics_helper_test.rb b/test/unit/helpers/topics_helper_test.rb deleted file mode 100644 index 12cc0b4f..00000000 --- a/test/unit/helpers/topics_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class TopicsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/users_helper_test.rb b/test/unit/helpers/users_helper_test.rb deleted file mode 100644 index 96af37a8..00000000 --- a/test/unit/helpers/users_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class UsersHelperTest < ActionView::TestCase -end diff --git a/test/unit/in_metacode_set_test.rb b/test/unit/in_metacode_set_test.rb deleted file mode 100644 index 1873f3d2..00000000 --- a/test/unit/in_metacode_set_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class InMetacodeSetTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/map_test.rb b/test/unit/map_test.rb deleted file mode 100644 index 033cf0ff..00000000 --- a/test/unit/map_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MapTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/mapping_test.rb b/test/unit/mapping_test.rb deleted file mode 100644 index 20115809..00000000 --- a/test/unit/mapping_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MappingTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/metacode_set_test.rb b/test/unit/metacode_set_test.rb deleted file mode 100644 index f92bc573..00000000 --- a/test/unit/metacode_set_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MetacodeSetTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/metacode_test.rb b/test/unit/metacode_test.rb deleted file mode 100644 index 7bfd318d..00000000 --- a/test/unit/metacode_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MetacodeTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/session_test.rb b/test/unit/session_test.rb deleted file mode 100644 index 2d1bc1b0..00000000 --- a/test/unit/session_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class SessionTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/synapse_test.rb b/test/unit/synapse_test.rb deleted file mode 100644 index 50a6fe66..00000000 --- a/test/unit/synapse_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class SynapseTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/topic_test.rb b/test/unit/topic_test.rb deleted file mode 100644 index 90522ee5..00000000 --- a/test/unit/topic_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class TopicTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb deleted file mode 100644 index 82f61e01..00000000 --- a/test/unit/user_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end