diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9f64845efa5edc4960a1a935779904d62794cda..5b556b71f532580f45d3b6907a8c4602ebbda405 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ -image: ruby:2.3.8 +image: ruby:2.7 services: - - postgres:9.5 + - postgres:11 - elasticsearch:6.5.1 - redis:latest diff --git a/.ruby-version b/.ruby-version index 2bf1c1ccf363acd53eaf92ef33a7f11f5f4557c2..cb2b00e4f7a7b959305c611112b7aac6ac4e9de7 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.1 +3.0.1 diff --git a/Gemfile b/Gemfile index 4bec0e8676762299d5117446535c22fe73298c45..9763dc26e46a323e9a4d0d0807cf190d2cf1040e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,15 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '5.0.0.1' +gem 'rails', '>=6.0.0' # Use postgresql as the database for Active Record gem 'pg' # bundle exec rake doc:rails generates the API under doc/api. -gem 'sdoc', '~> 0.4.0', group: :doc +gem 'sdoc', '>= 0.4.0', group: :doc # Use ActiveModel has_secure_password -gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '>= 3.1.7' # memcached gem 'dalli' @@ -30,10 +30,10 @@ gem 'whenever', require: false gem 'devise' # files -gem 'paperclip' +gem 'kt-paperclip', github: 'kreeti/kt-paperclip', branch: 'master' # enable login via rest -gem 'devise_token_auth' +gem 'devise_token_auth', github: 'lynndylanhurley/devise_token_auth', branch: 'master' gem 'rack-cors', require: 'rack/cors' gem 'rmagick' @@ -81,13 +81,13 @@ group :development do # reduce queries - https://github.com/flyerhzm/bullet gem 'bullet' - gem 'better_errors' + gem 'better_errors', '~>2.8.0' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' + gem 'web-console', '~>4.0.4' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' @@ -107,12 +107,12 @@ group :test do end group :development, :test do - gem 'rspec-rails', '~> 3.8' #original is 3.6 + gem 'rspec-rails', '>= 3.8' #original is 3.6 gem 'rspec_api_documentation' - gem 'factory_girl_rails' + gem 'factory_bot_rails' end -gem 'streamio-ffmpeg', '~> 1.0.0' +gem 'streamio-ffmpeg', '>= 1.0.0' # sidekiq gem 'sidekiq' @@ -120,13 +120,13 @@ gem 'sinatra', require: false gem 'slim' # CUrl -gem 'curb', '~> 0.8.8' +gem 'curb', '>= 0.8.8' # libArchive (Zip, Rar, ...) # C extension is required # For Mac OSX: brew install libarchive && bundle config build.libarchive "--with-opt-dir=/usr/local/opt/libarchive" # gem 'libarchive', '~> 0.1.2', :require => 'libarchive_ruby' -gem 'libarchive-static' +gem 'ffi-libarchive' gem 'gitlab' @@ -165,7 +165,8 @@ gem 'public_activity' # gem 'rails-observers' # soft-deleted for active record models -gem 'paranoia', github: 'rubysherpas/paranoia', branch: 'rails4' +#gem 'paranoia', github: 'rubysherpas/paranoia', branch: 'rails4' +gem 'paranoia' # models versioning gem 'paper_trail' diff --git a/Gemfile.lock b/Gemfile.lock index 2050cf5272e9e0e701932d8153bc8961badad682..fa48df2baec286a61ab54c658765c27dc9372390 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,134 +1,154 @@ GIT - remote: git://github.com/c3sl/dspace-rest-client.git - revision: e36c227f8b74b8593acc06ddd8ce6a4ef539769c + remote: https://github.com/c3sl/dspace-rest-client.git + revision: 07f49b52007160278e63b866a76e5f1cf800fa1b branch: master specs: dspace_rest_client (3.1.0) - activesupport (~> 5.0) + activesupport (>= 5.0) faraday (>= 1.0.0) - json (~> 1.8, >= 1.8.3) + json (>= 1.8.3, >= 1.8) net-http-persistent (>= 2.9.4) resource_kit (>= 0.1.4) GIT - remote: git://github.com/rubysherpas/paranoia.git - revision: bd3383729c790bf09e488f84221eaaea27c6597e - branch: rails4 + remote: https://github.com/kreeti/kt-paperclip.git + revision: ab1016d77336a8d7b9db72eb29b6bd19af4027fc + branch: master + specs: + kt-paperclip (6.4.1) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) + mime-types + mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) + +GIT + remote: https://github.com/lynndylanhurley/devise_token_auth.git + revision: 4c5245b88b39c1bb305e0cbdbfc2513eebdeda93 + branch: master specs: - paranoia (2.2.0.alpha) - activerecord (>= 4.0, < 5.1) + devise_token_auth (1.2.0) + bcrypt (~> 3.0) + devise (> 3.5.2, < 5) + rails (>= 4.2.0, < 6.2) GEM remote: https://rubygems.org/ specs: - actioncable (5.0.0.1) - actionpack (= 5.0.0.1) - nio4r (~> 1.2) - websocket-driver (~> 0.6.1) - actionmailer (5.0.0.1) - actionpack (= 5.0.0.1) - actionview (= 5.0.0.1) - activejob (= 5.0.0.1) + actioncable (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + mail (>= 2.7.1) + actionmailer (6.1.4) + actionpack (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activesupport (= 6.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.0.1) - actionview (= 5.0.0.1) - activesupport (= 5.0.0.1) - rack (~> 2.0) - rack-test (~> 0.6.3) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.0.1) - activesupport (= 5.0.0.1) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.4) + actionpack (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + nokogiri (>= 1.8.5) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - active_model_serializers (0.10.6) - actionpack (>= 4.1, < 6) - activemodel (>= 4.1, < 6) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + active_model_serializers (0.10.12) + actionpack (>= 4.1, < 6.2) + activemodel (>= 4.1, < 6.2) case_transform (>= 0.2) - jsonapi-renderer (>= 0.1.1.beta1, < 0.2) - activejob (5.0.0.1) - activesupport (= 5.0.0.1) + jsonapi-renderer (>= 0.1.1.beta1, < 0.3) + activejob (6.1.4) + activesupport (= 6.1.4) globalid (>= 0.3.6) - activemodel (5.0.0.1) - activesupport (= 5.0.0.1) - activerecord (5.0.0.1) - activemodel (= 5.0.0.1) - activesupport (= 5.0.0.1) - arel (~> 7.0) - activerecord-import (0.19.1) + activemodel (6.1.4) + activesupport (= 6.1.4) + activerecord (6.1.4) + activemodel (= 6.1.4) + activesupport (= 6.1.4) + activerecord-import (1.1.0) activerecord (>= 3.2) - activesupport (5.0.0.1) + activestorage (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activesupport (= 6.1.4) + marcel (~> 1.0.0) + mini_mime (>= 1.1.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) - minitest (~> 5.1) - tzinfo (~> 1.1) - acts_as_list (0.9.7) - activerecord (>= 3.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + acts_as_list (1.0.4) + activerecord (>= 4.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - annotate (2.7.2) - activerecord (>= 3.2, < 6.0) - rake (>= 10.4, < 13.0) + annotate (3.1.1) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) ansi (1.5.0) - arel (7.1.4) - ast (2.3.0) + ast (2.4.2) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.11) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) - benchmark-ips (2.7.2) - better_errors (2.2.0) + bcrypt (3.1.16) + benchmark-ips (2.9.1) + better_errors (2.8.3) coderay (>= 1.0.0) - erubis (>= 2.6.6) + erubi (>= 1.0.0) rack (>= 0.9.0) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - brakeman (3.7.0) - builder (3.2.3) - bullet (5.6.0) + bindex (0.8.1) + brakeman (5.0.1) + builder (3.2.4) + bullet (6.1.4) activesupport (>= 3.0.0) - uniform_notifier (~> 1.10.0) - byebug (9.0.6) + uniform_notifier (~> 1.11) + byebug (11.1.3) case_transform (0.2) activesupport choice (0.2.0) chronic (0.10.2) climate_control (0.2.0) - cocaine (0.5.8) - climate_control (>= 0.0.3, < 1.0) - codeclimate-engine-rb (0.4.0) - virtus (~> 1.0) - coderay (1.1.1) + coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - concurrent-ruby (1.1.6) - connection_pool (2.2.1) - curb (0.8.8) + concurrent-ruby (1.1.9) + connection_pool (2.2.5) + crass (1.0.6) + curb (0.9.11) cvss (0.99.0) - dalli (2.7.6) - data_mapper (1.2.0) - dm-aggregates (~> 1.2.0) - dm-constraints (~> 1.2.0) - dm-core (~> 1.2.0) - dm-migrations (~> 1.2.0) - dm-serializer (~> 1.2.0) - dm-timestamps (~> 1.2.0) - dm-transactions (~> 1.2.0) - dm-types (~> 1.2.0) - dm-validations (~> 1.2.0) - data_objects (0.10.17) - addressable (~> 2.1) - database_cleaner (1.6.1) - dawnscanner (1.6.8) + dalli (2.7.11) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.1) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + dawnscanner (1.6.9) cvss - data_mapper - dm-sqlite-adapter haml justify logger-colors @@ -137,379 +157,388 @@ GEM sqlite3 sys-uname terminal-table - debug_inspector (0.0.3) - derailed_benchmarks (1.3.2) + dead_end (1.1.7) + derailed_benchmarks (2.1.0) benchmark-ips (~> 2) + dead_end get_process_mem (~> 0) heapy (~> 0) - memory_profiler (~> 0) + memory_profiler (>= 0, < 2) + mini_histogram (>= 0.3.0) rack (>= 1) - rake (> 10, < 13) - thor (~> 0.19) + rack-test + rake (> 10, < 14) + ruby-statistics (>= 2.1) + thor (>= 0.19, < 2) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (4.3.0) + devise (4.8.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0) responders warden (~> 1.2.3) - devise_token_auth (0.1.42) - devise (> 3.5.2, <= 4.3) - rails (< 6) - diff-lcs (1.3) - dm-aggregates (1.2.0) - dm-core (~> 1.2.0) - dm-constraints (1.2.0) - dm-core (~> 1.2.0) - dm-core (1.2.1) - addressable (~> 2.3) - dm-do-adapter (1.2.0) - data_objects (~> 0.10.6) - dm-core (~> 1.2.0) - dm-migrations (1.2.0) - dm-core (~> 1.2.0) - dm-serializer (1.2.2) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - json_pure (~> 1.6) - multi_json (~> 1.0) - dm-sqlite-adapter (1.2.0) - dm-do-adapter (~> 1.2.0) - do_sqlite3 (~> 0.10.6) - dm-timestamps (1.2.0) - dm-core (~> 1.2.0) - dm-transactions (1.2.0) - dm-core (~> 1.2.0) - dm-types (1.2.2) - bcrypt-ruby (~> 3.0) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - multi_json (~> 1.0) - stringex (~> 1.4) - uuidtools (~> 2.1) - dm-validations (1.2.0) - dm-core (~> 1.2.0) - do_sqlite3 (0.10.17) - data_objects (= 0.10.17) - elasticsearch (6.1.0) - elasticsearch-api (= 6.1.0) - elasticsearch-transport (= 6.1.0) - elasticsearch-api (6.1.0) + diff-lcs (1.4.4) + docile (1.4.0) + elasticsearch (7.13.0) + elasticsearch-api (= 7.13.0) + elasticsearch-transport (= 7.13.0) + elasticsearch-api (7.13.0) multi_json - elasticsearch-transport (6.1.0) - faraday + elasticsearch-transport (7.13.0) + faraday (~> 1) multi_json equalizer (0.0.11) + erubi (1.10.0) erubis (2.7.0) - execjs (2.7.0) - factory_girl (4.8.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.8.0) - factory_girl (~> 4.8.0) - railties (>= 3.0.0) - faker (1.8.4) - i18n (~> 0.5) - faraday (1.0.1) + execjs (2.8.1) + factory_bot (6.2.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + faker (2.18.0) + i18n (>= 1.6, < 2) + faraday (1.4.2) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) multipart-post (>= 1.2, < 3) - fastercsv (1.5.5) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.1.0) feature (1.4.0) - ffi (1.9.18) + ffi (1.15.1) + ffi-libarchive (1.0.17) + ffi (~> 1.0) flamegraph (0.9.5) - flay (2.10.0) + flay (2.12.1) erubis (~> 2.7.0) path_expander (~> 1.0) ruby_parser (~> 3.0) sexp_processor (~> 4.0) - flog (4.6.1) + flog (4.6.4) path_expander (~> 1.0) ruby_parser (~> 3.1, > 3.1.0) sexp_processor (~> 4.8) - get_process_mem (0.2.1) - gitlab (4.2.0) - httparty - terminal-table - globalid (0.4.0) - activesupport (>= 4.2.0) - haml (5.0.1) + get_process_mem (0.2.7) + ffi (~> 1.0) + gitlab (4.17.0) + httparty (~> 0.18) + terminal-table (~> 1.5, >= 1.5.1) + globalid (0.5.1) + activesupport (>= 5.0) + haml (5.2.1) temple (>= 0.8.0) tilt - hashie (3.5.7) - heapy (0.1.2) - httparty (0.15.6) + hashie (4.1.0) + heapy (0.2.0) + thor + httparty (0.18.1) + mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (0.9.5) + i18n (1.8.10) concurrent-ruby (~> 1.0) ice_nine (0.11.2) immigrant (0.3.6) activerecord (>= 3.0) - json (1.8.6) - json_pure (1.8.6) - jsonapi-renderer (0.1.3) + json (2.5.1) + jsonapi-renderer (0.2.2) justify (1.0.2) - jwt (1.5.6) - launchy (2.4.3) - addressable (~> 2.3) - libarchive-static (1.0.5) + jwt (2.2.3) + kwalify (0.7.2) + launchy (2.5.0) + addressable (~> 2.7) logger-colors (1.0.0) - loofah (2.0.3) + loofah (2.10.0) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.6) - mime-types (>= 1.16, < 4) - memory_profiler (0.9.8) - method_source (0.8.2) - mime-types (3.1) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.1) + memory_profiler (1.0.0) + method_source (1.0.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mimemagic (0.3.2) - mina (1.0.6) + mime-types-data (3.2021.0225) + mimemagic (0.3.10) + nokogiri (~> 1) + rake + mina (1.2.3) open4 (~> 1.3.4) rake - mini_portile2 (2.2.0) - minitest (5.14.1) - minitest-reporters (1.1.14) + mini_histogram (0.3.1) + mini_mime (1.1.0) + mini_portile2 (2.5.3) + minitest (5.14.4) + minitest-reporters (1.4.3) ansi builder minitest (>= 5.0) ruby-progressbar - multi_json (1.14.1) + multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) - mustache (1.0.5) - mustermann (1.0.0) - net-http-persistent (4.0.0) + mustache (1.1.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + net-http-persistent (4.0.1) connection_pool (~> 2.2) - nio4r (1.2.1) - nokogiri (1.8.0) - mini_portile2 (~> 2.2.0) - oauth (0.5.3) - oauth2 (1.4.4) + nio4r (2.5.7) + nokogiri (1.11.7) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) + oauth (0.5.6) + oauth2 (1.4.7) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.6.1) - hashie (>= 3.4.6, < 3.6.0) + omniauth (2.0.4) + hashie (>= 3.4.6) rack (>= 1.6.2, < 3) - omniauth-facebook (4.0.0) + rack-protection + omniauth-facebook (8.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (0.5.2) - jwt (~> 1.5) - multi_json (~> 1.3) - omniauth (>= 1.1.1) - omniauth-oauth2 (>= 1.3.1) - omniauth-oauth (1.1.0) + omniauth-google-oauth2 (1.0.0) + jwt (>= 2.0) + oauth2 (~> 1.1) + omniauth (~> 2.0) + omniauth-oauth2 (~> 1.7.1) + omniauth-oauth (1.2.0) oauth - omniauth (~> 1.0) - omniauth-oauth2 (1.4.0) - oauth2 (~> 1.0) - omniauth (~> 1.2) + omniauth (>= 1.0, < 3) + omniauth-oauth2 (1.7.1) + oauth2 (~> 1.4) + omniauth (>= 1.9, < 3) omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack open4 (1.3.4) orm_adapter (0.5.0) - paper_trail (7.1.0) - activerecord (>= 4.0, < 5.2) + paper_trail (12.0.0) + activerecord (>= 5.2) request_store (~> 1.1) - paperclip (5.1.0) - activemodel (>= 4.2.0) - activesupport (>= 4.2.0) - cocaine (~> 0.5.5) - mime-types - mimemagic (~> 0.3.0) - parallel (1.12.0) - parser (2.4.0.0) - ast (~> 2.2) - path_expander (1.0.2) - pg (0.21.0) + parallel (1.20.1) + paranoia (2.4.3) + activerecord (>= 4.0, < 6.2) + parser (3.0.1.1) + ast (~> 2.4.1) + path_expander (1.1.0) + pg (1.2.3) phantomjs (2.1.1.0) - powerpack (0.1.1) - ptools (1.3.4) - public_activity (1.5.0) + psych (3.3.2) + ptools (1.4.2) + public_activity (1.6.4) actionpack (>= 3.0.0) activerecord (>= 3.0) i18n (>= 0.5.0) railties (>= 3.0.0) - public_suffix (4.0.5) - puma (3.9.1) - pundit (1.1.0) + public_suffix (4.0.6) + puma (5.3.2) + nio4r (~> 2.0) + pundit (2.1.0) activesupport (>= 3.0.0) - rack (2.2.2) - rack-attack (5.0.1) - rack - rack-cors (1.0.1) - rack-mini-profiler (0.10.5) + racc (1.5.2) + rack (2.2.3) + rack-attack (6.5.0) + rack (>= 1.0, < 3) + rack-cors (1.1.1) + rack (>= 2.0.0) + rack-mini-profiler (2.3.2) rack (>= 1.2.0) - rack-protection (2.0.0) + rack-protection (2.1.0) rack - rack-test (0.6.3) - rack (>= 1.0) - rails (5.0.0.1) - actioncable (= 5.0.0.1) - actionmailer (= 5.0.0.1) - actionpack (= 5.0.0.1) - actionview (= 5.0.0.1) - activejob (= 5.0.0.1) - activemodel (= 5.0.0.1) - activerecord (= 5.0.0.1) - activesupport (= 5.0.0.1) - bundler (>= 1.3.0, < 2.0) - railties (= 5.0.0.1) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.4) + actioncable (= 6.1.4) + actionmailbox (= 6.1.4) + actionmailer (= 6.1.4) + actionpack (= 6.1.4) + actiontext (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activemodel (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + bundler (>= 1.15.0) + railties (= 6.1.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-erd (1.5.2) - activerecord (>= 3.2) - activesupport (>= 3.2) + rails-erd (1.6.1) + activerecord (>= 4.2) + activesupport (>= 4.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.0.0.1) - actionpack (= 5.0.0.1) - activesupport (= 5.0.0.1) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (2.2.2) - rake - rake (12.0.0) - rdoc (4.3.0) - redis (3.3.3) - reek (4.7.2) - codeclimate-engine-rb (~> 0.4.0) - parser (>= 2.4.0.0, < 2.5) - rainbow (~> 2.0) - request_store (1.3.2) + rake (>= 0.13) + thor (~> 1.0) + rainbow (3.0.0) + rake (13.0.6) + rdoc (6.3.1) + redis (4.2.5) + reek (6.0.4) + kwalify (~> 0.7.0) + parser (~> 3.0.0) + psych (~> 3.1) + rainbow (>= 2.0, < 4.0) + regexp_parser (2.1.1) + request_store (1.5.0) + rack (>= 1.4) resource_kit (0.1.7) addressable (>= 2.3.6, < 3.0.0) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - rmagick (2.16.0) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.1) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rexml (3.2.5) + rmagick (4.2.2) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - rspec_api_documentation (5.0.0) + rspec-support (~> 3.10.0) + rspec-rails (5.0.1) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + rspec_api_documentation (6.1.0) activesupport (>= 3.0.0) mustache (~> 1.0, >= 0.99.4) rspec (~> 3.0) - rubocop (0.49.1) + rubocop (1.15.0) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + parser (>= 3.0.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.5.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-graphviz (1.2.3) - ruby-progressbar (1.8.1) - ruby_parser (3.10.1) - sexp_processor (~> 4.9) - rubycritic (3.2.3) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.6.0) + parser (>= 3.0.1.1) + ruby-graphviz (1.2.5) + rexml + ruby-progressbar (1.11.0) + ruby-statistics (2.1.3) + ruby2_keywords (0.0.4) + ruby_parser (3.16.0) + sexp_processor (~> 4.15, >= 4.15.1) + rubycritic (4.6.1) flay (~> 2.8) flog (~> 4.4) - launchy (= 2.4.3) - parser (~> 2.4.0) - rainbow (~> 2.1) - reek (~> 4.4) + launchy (>= 2.0.0) + parser (>= 2.6.0) + rainbow (~> 3.0) + reek (~> 6.0, < 7.0) ruby_parser (~> 3.8) + simplecov (>= 0.17.0) + tty-which (~> 0.4.0) virtus (~> 1.0) - rubyzip (1.2.1) + rubyzip (2.3.0) screencap (0.1.4) phantomjs - sdoc (0.4.2) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - searchkick (3.1.2) - activemodel (>= 4.2) - elasticsearch (>= 5) + sdoc (2.2.0) + rdoc (>= 5.0) + searchkick (4.4.4) + activemodel (>= 5) + elasticsearch (>= 6) hashie - sexp_processor (4.10.0) - shoulda (3.5.0) - shoulda-context (~> 1.0, >= 1.0.1) - shoulda-matchers (>= 1.4.1, < 3.0) - shoulda-context (1.2.2) - shoulda-matchers (2.8.0) - activesupport (>= 3.0.0) - sidekiq (5.0.4) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) - rack-protection (>= 1.5.0) - redis (~> 3.3, >= 3.3.3) - sinatra (2.0.0) - mustermann (~> 1.0) + sexp_processor (4.15.3) + shoulda (4.0.0) + shoulda-context (~> 2.0) + shoulda-matchers (~> 4.0) + shoulda-context (2.0.0) + shoulda-matchers (4.5.1) + activesupport (>= 4.2.0) + sidekiq (6.2.1) + connection_pool (>= 2.2.2) rack (~> 2.0) - rack-protection (= 2.0.0) + redis (>= 4.2.0) + simplecov (0.21.2) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.3) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - slim (3.0.8) + slim (4.1.0) temple (>= 0.7.6, < 0.9) - tilt (>= 1.3.3, < 2.1) - spring (2.0.2) - activesupport (>= 4.2) - sprockets (3.7.1) + tilt (>= 2.0.6, < 2.1) + spring (2.1.1) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) - stackprof (0.2.10) - streamio-ffmpeg (1.0.0) - stringex (1.5.1) - sys-uname (1.0.3) - ffi (>= 1.0.0) - temple (0.8.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.19.4) + sqlite3 (1.4.2) + stackprof (0.2.17) + streamio-ffmpeg (3.0.2) + multi_json (~> 1.8) + sys-uname (1.2.2) + ffi (~> 1.1) + temple (0.8.2) + terminal-table (1.6.0) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) + thor (1.1.0) thread_safe (0.3.6) - tilt (2.0.8) - tzinfo (1.2.7) - thread_safe (~> 0.1) - unicode-display_width (1.3.0) - uniform_notifier (1.10.0) - uuidtools (2.1.5) + tilt (2.0.10) + tty-which (0.4.2) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (2.0.0) + uniform_notifier (1.14.2) virtus (1.0.5) axiom-types (~> 0.1) coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) - warden (1.2.7) - rack (>= 1.0) - web-console (2.3.0) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) - websocket-driver (0.6.5) + warden (1.2.9) + rack (>= 2.0.9) + web-console (4.0.4) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) - whenever (0.9.7) + websocket-extensions (0.1.5) + whenever (1.0.0) chronic (>= 0.6.3) + zeitwerk (2.4.2) PLATFORMS ruby @@ -519,28 +548,29 @@ DEPENDENCIES activerecord-import acts_as_list annotate - bcrypt (~> 3.1.7) - better_errors + bcrypt (>= 3.1.7) + better_errors (~> 2.8.0) brakeman bullet byebug connection_pool - curb (~> 0.8.8) + curb (>= 0.8.8) dalli database_cleaner dawnscanner derailed_benchmarks devise - devise_token_auth + devise_token_auth! dspace_rest_client! execjs - factory_girl_rails + factory_bot_rails faker feature + ffi-libarchive flamegraph gitlab immigrant - libarchive-static + kt-paperclip! mimemagic mina minitest-reporters @@ -548,8 +578,7 @@ DEPENDENCIES omniauth-google-oauth2 omniauth-twitter paper_trail - paperclip - paranoia! + paranoia pg public_activity puma @@ -557,18 +586,18 @@ DEPENDENCIES rack-attack rack-cors rack-mini-profiler - rails (= 5.0.0.1) + rails (>= 6.0.0) rails-erd rainbow rdoc rmagick - rspec-rails (~> 3.8) + rspec-rails (>= 3.8) rspec_api_documentation rubocop rubycritic rubyzip screencap - sdoc (~> 0.4.0) + sdoc (>= 0.4.0) searchkick shoulda sidekiq @@ -576,9 +605,9 @@ DEPENDENCIES slim spring stackprof - streamio-ffmpeg (~> 1.0.0) - web-console (~> 2.0) + streamio-ffmpeg (>= 1.0.0) + web-console (~> 4.0.4) whenever BUNDLED WITH - 1.17.3 + 2.2.15 diff --git a/README.md b/README.md index f697318aeb881e58324c8faec05070db758edaa4..a3d16f219ee0b7cc0cc671c25b5ad7c17b6fbda0 100644 --- a/README.md +++ b/README.md @@ -23,29 +23,24 @@ along with portalmec. If not, see <http://www.gnu.org/licenses/>. ## Requirements * rvm - * Using rvm you will install ruby "2.3.1" - * ruby "2.3.1" + * Using rvm you will install ruby "3.0.1" + * ruby "3.0.1" * Dspace server "6.x" - * Postgres (>= 9.6) - * If you will install Dspace, it is recommended to use Postgres "9.6" + * Postgres "13" * Elasticsearch "6.8.13" - * Redis + * Redis ">=5.0" * nvm - * Using nvm you will install Node.js "8.10.0" + * Using nvm you will install Node.js "14.15.1" ## NVM and Node.js For install NVM and Node.js, use this follwing commands: ``` -$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash +$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash ``` ``` -$ source ~/.bashrc -``` - -``` -$ nvm install 8.10.0 +$ nvm install 14.15.1 ``` ## Postgres @@ -60,14 +55,13 @@ After the first install, you can run this commands: Note: You can ask for the database dump for someone in the project. -You need to modify the file "/etc/postgresql/10/main/pg_hba.conf", the modification is +You need to modify the file "/etc/postgresql/11/main/pg_hba.conf", the modification is * comment the 1st and 2nd lines with "peer" and copy them replacing "peer" with "md5". After this, run this command: -* ``` systemctl stop postgresql ``` -* ``` systemctl start postgresql ``` +* ``` systemctl restart postgresql ``` ## Rvm @@ -155,13 +149,18 @@ For tests, run this commands: * ``` bundle exec rake spec:acceptance ``` ### Production environment -As you set development and test environment vars, now production vars will be needed to be set. -For that, open the file config/env_vars.sh and set them. After, run: -``` ./config/env_vars.sh ``` +When working in the production environment, the environment variables must be set in the file config/env_vars.sh. +After setting the variables in the file, you must include the following line into your user's .bashrc file: +* ``` source /home/portalmec/portalmec/config/env_vars.sh ``` - * Redis vars need to be set on config/sidekiq.yml - * In config/initializers/devise.rb, change the emails addresses. (Ex.: config.mailer_sender = 'suporte@c3sl.ufpr.br') - -Now that your application is ready, you can run it using sames commands used in the install section. +You will also need to make some other configurations: -After the setup, link your webserver to the app. Some OS services are in root of the project and can be used. + * Redis vars need to be set on config/sidekiq.yml + * In config/initializers/devise.rb, change the e-mail addresses. (Ex.: config.mailer_sender = 'suporte@suporte.com') + * In app/services/learning_object_publisher.rb, in the create_dspace_item change the DSpace collection where the items are gonna be created. + * Change the paths in the *.sh and *.service files in the root of the project to the absolute path of the project in the production server. + * As root, copy the *.service files to the server's systemd directory (Ex.: /lib/systemd/system), then run systemctl enable portalmec and systemctl enable portalmec-sidekiq. + * As root, copy the sidekiq_log.conf file to the rsyslog directory (/etc/rsyslog.d/) and give the shared/logs/sidekiq.log file the same permissions and ownership as the /var/log/syslog file. + +Now that your application is ready, you can run it with: +* ``` systemctl start portalmec portalmec-sidekiq ``` diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9db44f7a1adecccb1545b35e9845b7aba599804c..7d8ea4cded332be1ef2e742db89cef19020aeae2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,6 +27,7 @@ class ApplicationController < ActionController::API before_action :set_paper_trail_whodunnit rescue_from Exception do |exception| + logger.fatal "The request raised an exception:" logger.fatal exception logger.fatal exception.backtrace.first(10).join("\n") unless response_body diff --git a/app/controllers/v1/learning_objects_controller.rb b/app/controllers/v1/learning_objects_controller.rb index 118f866802e469c8b5e64b6f124115289bb52797..7d606b3fbb8f6966e876c1cd115bdb2914983d78 100644 --- a/app/controllers/v1/learning_objects_controller.rb +++ b/app/controllers/v1/learning_objects_controller.rb @@ -62,8 +62,8 @@ class V1::LearningObjectsController < ApplicationController learning_object = LearningObject.new(learning_object_params) authorize learning_object publisher = LearningObjectPublisher.new(DspaceService.create_client) - - if publisher.create_draft(learning_object, current_user) + learning_object = publisher.create_draft(learning_object, current_user) + if learning_object.errors.errors.blank? learning_object_associations(learning_object, false) render json: learning_object, status: :created else diff --git a/app/controllers/v1/omniauth_callbacks_controller.rb b/app/controllers/v1/omniauth_callbacks_controller.rb index 161ca6d2fd6c5a249c70bd581dd912332586458d..4c833a696d45d1efe71f57b0ccf3ed5087880263 100644 --- a/app/controllers/v1/omniauth_callbacks_controller.rb +++ b/app/controllers/v1/omniauth_callbacks_controller.rb @@ -18,86 +18,13 @@ # along with portalmec. If not, see <http://www.gnu.org/licenses/>. require 'open-uri' - class V1::OmniauthCallbacksController < DeviseTokenAuth::ApplicationController - - attr_reader :auth_params - skip_before_action :set_user_by_token, raise: false - skip_after_action :update_auth_header - - # intermediary route for successful omniauth authentication. omniauth does - # not support multiple models, so we must resort to this terrible hack. - def redirect_callbacks - - # derive target redirect route from 'resource_class' param, which was set - # before authentication. - devise_mapping = [request.env['omniauth.params']['namespace_name'], - request.env['omniauth.params']['resource_class'].underscore.gsub('/', '_')].compact.join('_') - redirect_route = "#{request.protocol}#{request.host_with_port}/#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback" - - # preserve omniauth info for success route. ignore 'extra' in twitter - # auth response to avoid CookieOverflow. - session['dta.omniauth.auth'] = request.env['omniauth.auth'].except('extra') - session['dta.omniauth.params'] = request.env['omniauth.params'] - - redirect_to redirect_route - end - - def omniauth_success - get_resource_from_auth_hash - create_token_info - set_token_on_resource - create_auth_params - - if resource_class.devise_modules.include?(:confirmable) - # don't send confirmation email!!! - @resource.skip_confirmation! - end - - sign_in(:user, @resource, store: false, bypass: false) - - @resource.save! - - yield @resource if block_given? - - render_data_or_redirect('deliverCredentials', @auth_params.as_json, @resource.as_json) - end - - def omniauth_failure - @error = params[:message] - render_data_or_redirect('authFailure', {error: @error}) - end + class V1::OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController protected - # this will be determined differently depending on the action that calls - # it. redirect_callbacks is called upon returning from successful omniauth - # authentication, and the target params live in an omniauth-specific - # request.env variable. this variable is then persisted thru the redirect - # using our own dta.omniauth.params session var. the omniauth_success - # method will access that session var and then destroy it immediately - # after use. In the failure case, finally, the omniauth params - # are added as query params in our monkey patch to OmniAuth in engine.rb - def omniauth_params - if !defined?(@_omniauth_params) - if request.env['omniauth.params'] && request.env['omniauth.params'].any? - @_omniauth_params = request.env['omniauth.params'] - elsif session['dta.omniauth.params'] && session['dta.omniauth.params'].any? - @_omniauth_params ||= session.delete('dta.omniauth.params') - @_omniauth_params - elsif params['omniauth_window_type'] - @_omniauth_params = params.slice('omniauth_window_type', 'auth_origin_url', 'resource_class', 'origin') - else - @_omniauth_params = {} - end - end - @_omniauth_params - - end - # break out provider attribute assignment for easy method extension def assign_provider_attrs(user, auth_hash) - - avatar = open(auth_hash['info']['image']) + avatar = URI.parse(open(auth_hash['info']['image'])).open user.assign_attributes({ nickname: auth_hash['info']['nickname'], @@ -107,171 +34,4 @@ require 'open-uri' }) end - # derive allowed params from the standard devise parameter sanitizer - def whitelisted_params - whitelist = params_for_resource(:sign_up) - - whitelist.inject({}){|coll, key| - param = omniauth_params[key.to_s] - if param - coll[key] = param - end - coll - } - end - - def resource_class(mapping = nil) - if omniauth_params['resource_class'] - omniauth_params['resource_class'].constantize - elsif params['resource_class'] - params['resource_class'].constantize - else - raise "No resource_class found" - end - end - - def resource_name - resource_class - end - - def omniauth_window_type - omniauth_params['omniauth_window_type'] - end - - def auth_origin_url - omniauth_params['auth_origin_url'] || omniauth_params['origin'] - end - - # in the success case, omniauth_window_type is in the omniauth_params. - # in the failure case, it is in a query param. See monkey patch above - def omniauth_window_type - omniauth_params.nil? ? params['omniauth_window_type'] : omniauth_params['omniauth_window_type'] - end - - # this sesison value is set by the redirect_callbacks method. its purpose - # is to persist the omniauth auth hash value thru a redirect. the value - # must be destroyed immediatly after it is accessed by omniauth_success - def auth_hash - @_auth_hash ||= session.delete('dta.omniauth.auth') - @_auth_hash - end - - # ensure that this controller responds to :devise_controller? conditionals. - # this is used primarily for access to the parameter sanitizers. - def assert_is_devise_resource! - true - end - - # necessary for access to devise_parameter_sanitizers - def devise_mapping - if omniauth_params - Devise.mappings[[omniauth_params['namespace_name'], - omniauth_params['resource_class'].underscore].compact.join('_').to_sym] - else - request.env['devise.mapping'] - end - end - - def set_random_password - # set crazy password for new oauth users. this is only used to prevent - # access via email sign-in. - p = SecureRandom.urlsafe_base64(nil, false) - @resource.password = p - @resource.password_confirmation = p - end - - def create_token_info - # create token info - @client_id = SecureRandom.urlsafe_base64(nil, false) - @token = SecureRandom.urlsafe_base64(nil, false) - @expiry = (Time.now + DeviseTokenAuth.token_lifespan).to_i - @config = omniauth_params['config_name'] - end - - def create_auth_params - @auth_params = { - auth_token: @token, - client_id: @client_id, - uid: @resource.uid, - expiry: @expiry, - config: @config - } - @auth_params.merge!(oauth_registration: true) if @oauth_registration - @auth_params - end - - def set_token_on_resource - @resource.tokens[@client_id] = { - token: BCrypt::Password.create(@token), - expiry: @expiry - } - end - - def render_data(message, data) - @data = data.merge({ - message: message - }) - render :layout => nil, :template => "devise_token_auth/omniauth_external_window" - end - - def render_data_or_redirect(message, data, user_data = {}) - - # We handle inAppBrowser and newWindow the same, but it is nice - # to support values in case people need custom implementations for each case - # (For example, nbrustein does not allow new users to be created if logging in with - # an inAppBrowser) - # - # See app/views/devise_token_auth/omniauth_external_window.html.erb to understand - # why we can handle these both the same. The view is setup to handle both cases - # at the same time. - if ['inAppBrowser', 'newWindow'].include?(omniauth_window_type) - render_data(message, user_data.merge(data)) - - elsif auth_origin_url # default to same-window implementation, which forwards back to auth_origin_url - - # build and redirect to destination url - redirect_to DeviseTokenAuth::Url.generate(auth_origin_url, data.merge(blank: true)) - else - - # there SHOULD always be an auth_origin_url, but if someone does something silly - # like coming straight to this url or refreshing the page at the wrong time, there may not be one. - # In that case, just render in plain text the error message if there is one or otherwise - # a generic message. - fallback_render data[:error] || 'An error occurred' - end - end - - def fallback_render(text) - render inline: %Q| - - <html> - <head></head> - <body> - #{text} - </body> - </html>| - end - - def get_resource_from_auth_hash - # find or create user by provider and provider uid - @resource = resource_class.where({ - uid: auth_hash['uid'], - provider: auth_hash['provider'] - }).first_or_initialize - - if @resource.new_record? - @oauth_registration = true - set_random_password - end - - # sync user info with provider, update/generate auth token - assign_provider_attrs(@resource, auth_hash) - - # assign any additional (whitelisted) attributes - extra_params = whitelisted_params - @resource.assign_attributes(extra_params) if extra_params - - @resource - end - end diff --git a/app/controllers/v1/packages_controller.rb b/app/controllers/v1/packages_controller.rb index b224132aa4863e4013d95a4fe88c0cc1dfb3dbb1..1e953ca8084b7a891869a771896ba5324b0f1ed3 100644 --- a/app/controllers/v1/packages_controller.rb +++ b/app/controllers/v1/packages_controller.rb @@ -21,12 +21,16 @@ class V1::PackagesController < ApplicationController before_action :set_objects def link - response = PackageService.link(@objects) - - if response.nil? + if @objects.blank? render status: :not_found else - render json: { url: response }, status: :found + response = PackageService.link(@objects) + + if response.nil? + render status: :not_found + else + render json: { url: response }, status: :found + end end end @@ -34,11 +38,10 @@ class V1::PackagesController < ApplicationController def set_objects allowed = PackageService.allowed_classes - @objects = objects_params[:object].map do |o| next unless allowed.include? o['type'] obj = o['type'].constantize.where(id: o['id']).first - render status: :not_found if @obj.blank? + break if obj.blank? obj end end diff --git a/app/controllers/v1/sessions_controller.rb b/app/controllers/v1/sessions_controller.rb index 11579e05b2c337b4b0696f342f77d6a6d860680f..4f8004aedcbb2f8a124fc76e34db6963712717f9 100644 --- a/app/controllers/v1/sessions_controller.rb +++ b/app/controllers/v1/sessions_controller.rb @@ -25,35 +25,17 @@ require 'open-uri' @resource = nil if field - q_value = resource_params[field] + q_value = get_case_insensitive_field_from_resource_params(field) - if resource_class.case_insensitive_keys.include?(field) - q_value.downcase! - end - - q = "#{field.to_s} = ? AND provider='email'" - - if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql' - q = "BINARY " + q - end - - @resource = resource_class.where(q, q_value).first + @resource = find_resource(field, q_value) end if @resource && valid_params?(field, q_value) && (!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?) valid_password = @resource.valid_password?(resource_params[:password]) if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password - render_create_error_bad_credentials - return + return render_create_error_bad_credentials end - # create client id - @client_id = SecureRandom.urlsafe_base64(nil, false) - @token = SecureRandom.urlsafe_base64(nil, false) - - @resource.tokens[@client_id] = { - token: BCrypt::Password.create(@token), - expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i - } + @token = @resource.create_token @resource.save sign_in(:user, @resource, store: false, bypass: false) @@ -74,7 +56,6 @@ require 'open-uri' end end - def render_create_error_banished render json: { success: false, diff --git a/app/models/collection.rb b/app/models/collection.rb index 076436722ef54fd0b2ca11f8a5d35c2fe6580dc7..1a4d039e32677b0a993810c643d33302ac71e67d 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -58,9 +58,9 @@ class Collection < ApplicationRecord acts_as_paranoid has_many :collection_items, -> { order("position ASC") }, as: :collectionable, dependent: :destroy + has_many :collection_items has_many :collections, through: :collection_items, source: :collectionable, source_type: 'Collection' has_many :learning_objects, through: :collection_items, source: :collectionable, source_type: 'LearningObject' - has_many :collection_items belongs_to :owner, polymorphic: true, counter_cache: true diff --git a/app/models/concerns/stageable.rb b/app/models/concerns/stageable.rb index bbdf8d83c7886ad4d0ccd1b9d5f62cd107a37df9..4c536c2a349cfcda81996e35f430fc3d03d2acef 100644 --- a/app/models/concerns/stageable.rb +++ b/app/models/concerns/stageable.rb @@ -21,8 +21,8 @@ module Stageable extend ActiveSupport::Concern included do - has_many :educational_stages, through: :stage_relations, dependent: :destroy has_many :stage_relations, as: :stageable, dependent: :destroy + has_many :educational_stages, through: :stage_relations, dependent: :destroy end # A stageable can add educational stages diff --git a/app/models/concerns/subjectable.rb b/app/models/concerns/subjectable.rb index 46183c2c798463db7ca869e9f7b306935da2a6b2..544af2a090c1abdc0becc440f839ad3581e71568 100644 --- a/app/models/concerns/subjectable.rb +++ b/app/models/concerns/subjectable.rb @@ -21,8 +21,8 @@ module Subjectable extend ActiveSupport::Concern included do - has_many :subjects, through: :subject_relations, dependent: :destroy has_many :subject_relations, as: :subjectable, dependent: :destroy + has_many :subjects, through: :subject_relations, dependent: :destroy end # A subjectable can add subjects diff --git a/app/models/concerns/trackable.rb b/app/models/concerns/trackable.rb index b4ae126640ea81adf13952901f62ec34813d8d41..debab1e936ba955ebf07231c6128ab9d8ae58465 100644 --- a/app/models/concerns/trackable.rb +++ b/app/models/concerns/trackable.rb @@ -29,9 +29,9 @@ module Trackable end def new_update_activity - return nil if changed.blank? + return nil if previous_changes.blank? return new_activity(:update) if ignore_changes == %w(updated_at) - filtered = changed.reject { |x| ignore_changes.include?(x) } + filtered = previous_changes.reject { |x| ignore_changes.include?(x) } new_activity(:update) unless filtered.empty? end diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index 1b7903efdc9ad59ea837599155b847d396f56030..10451b6f8921f176769180890aa8b6f38b8be3ac 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -76,12 +76,12 @@ class LearningObject < ApplicationRecord has_and_belongs_to_many :language belongs_to :publisher, polymorphic: true, counter_cache: true - belongs_to :license - belongs_to :object_type - belongs_to :attachment, class_name: 'LearningObject::Attachment' - has_one :submission, dependent: :destroy + belongs_to :license, optional: true + belongs_to :object_type, optional: true + belongs_to :attachment, class_name: 'LearningObject::Attachment', optional: true + has_one :submission - validates :name, :publisher, :object_type, :author, unless: :draft?, presence: true + validates :name, :publisher, :object_type, :author, presence: true, unless: :draft? validates :language, unless: :draft?, :length => { :minimum => 1 } validates :id_dspace, presence: true, uniqueness: true, unless: :published? diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb index d07deee4759ee3d7f87e6a0dd2f9aac83cd7be66..12bb34aed965d817ce3dd78f3d71e58da90fd8ff 100644 --- a/app/models/learning_object/attachment.rb +++ b/app/models/learning_object/attachment.rb @@ -46,7 +46,7 @@ class LearningObject::Attachment < ApplicationRecord belongs_to :learning_object scope :unknown_mime_type, ->() { where(format: 'Unknown') } has_one :learning_object_attachment, as: :learning_object_attachment_id_son - belongs_to :learning_object_attachment + belongs_to :learning_object_attachment, optional: true def retrieve_url diff --git a/app/models/search.rb b/app/models/search.rb index 36fe471cc9049fa47ca90d5a588f0fec3cfa3f9e..8cafb243cfe29dded09b6b31484dbc20c9b8009a 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -20,7 +20,7 @@ class Search < ApplicationRecord attr_accessor :page, :results_per_page, :order, :tags, :and_fields - belongs_to :user + belongs_to :user, optional: true has_and_belongs_to_many :tags has_and_belongs_to_many :subjects has_and_belongs_to_many :educational_stages diff --git a/app/models/submission.rb b/app/models/submission.rb index 70fdfc2c6c2844e787804e1211b5e470966407df..98bdd8a575ae9e89ea0308d6f3a7ecc0377736f2 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -36,7 +36,7 @@ class Submission < ApplicationRecord enum status: [:submitted, :rejected, :accepted] belongs_to :submitter, class_name: "User" - belongs_to :curator, class_name: "User" + belongs_to :curator, class_name: "User", optional: true belongs_to :learning_object has_many :curator_assignments, dependent: :destroy has_many :assignees, through: :curator_assignments, source: :user @@ -49,7 +49,7 @@ class Submission < ApplicationRecord after_update :update_status def update_status - if curator_id_changed? + if curator_id_previously_changed? curator_assignments.each do |ca| if ca.user == curator ca.answered! diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb index 3ac84cc8526385d93effaba95eb0158f1dd9c143..82fa9ecc7ff8e119b8a631bc402a34b5e848c890 100644 --- a/app/models/suggestion.rb +++ b/app/models/suggestion.rb @@ -28,5 +28,5 @@ # status :integer # class Suggestion < ApplicationRecord - enum status: { created: 0, accepted: 1, rejected: 2, loaded: 3 } + enum status: { created: 0, accepted: 1, rejected: 2, loadded: 3 } end diff --git a/app/models/user.rb b/app/models/user.rb index 4e67c1d4a368897f4d69ed7f3521638eab99e1bc..fd7756204827b4690366214de65beea23577ba20 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -70,15 +70,15 @@ class User < ApplicationRecord include DeviseTokenAuth::Concerns::User - belongs_to :school + belongs_to :school, optional: true has_and_belongs_to_many :roles has_and_belongs_to_many :institutions + has_many :bookmarks has_many :bookmarks, as: :bookmarkable has_many :bookmark_collections, through: :bookmarks, source: :bookmarkable, source_type: 'Collection' has_many :bookmark_learning_objects, through: :bookmarks, source: :bookmarkable, source_type: 'LearningObject' - has_many :bookmarks #has_many :collections, as: :owner #has_many :learning_objects, as: :publisher has_many :views diff --git a/app/services/search_service/learning_object.rb b/app/services/search_service/learning_object.rb index c933bfe0d41657500c98c0269a5d0a4027a751a7..b78b7c7eabe7c23a9b842891bc6bc8d7f6add049 100644 --- a/app/services/search_service/learning_object.rb +++ b/app/services/search_service/learning_object.rb @@ -27,7 +27,7 @@ module SearchService def autocomplete params = { where: { state: validate_object }, fields: ['name^10', 'description', 'author'] } - result = ::LearningObject.search(@search.query, autocomplete_params.merge(params)) + result = ::LearningObject.search(@search.query, **autocomplete_params.merge(params)) thumbnail = proc { |obj| obj.default_thumbnail } type = proc { |obj| obj.object_type.try(:name) } diff --git a/app/workers/package_worker.rb b/app/workers/package_worker.rb index 4c9e27565b52ae475d0325e0b383d2ae6a80bfdd..81787f950e22388504c53df6b71a41af1ef35ed1 100644 --- a/app/workers/package_worker.rb +++ b/app/workers/package_worker.rb @@ -54,7 +54,7 @@ class PackageWorker end end - if @parc.blank? + if !@parc.blank? @parc = "Se você está vendo esse arquivo significa que você tentou baixar conteúdos que não estão hospedados em nossos servidores, entretanto como essa ação não é possível você pode acessar esses conteúdos com os links abaixo:\n\n#{@parc}" tx = File.new(Rails.root.join("tmp",'links.txt'), 'w+') tx.write(@parc) diff --git a/config/application.rb b/config/application.rb index a60586938948bea3cdc6ae5aed721700034739a6..a045b9cacfc052cd12987fb40426fa71096c4a80 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,27 +39,26 @@ module Portalmec # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' - + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - + + + # loading lib files config.autoload_paths << Rails.root.join('lib') config.autoload_paths << Rails.root.join('app/builders') - + config.eager_load_paths += Dir["#{Rails.root}/lib/**/"] - + # protection against attacks config.middleware.use Rack::Attack - + # CORS for login via rest # config.middleware.use Rack::Cors do # config.middleware.insert_before 0, "Rack::Cors", :debug => true, :logger => (-> { Rails.logger }) do @@ -101,5 +100,6 @@ module Portalmec config.middleware.use ActionDispatch::Cookies config.middleware.use ActionDispatch::Session::CookieStore + end end diff --git a/config/boot.rb b/config/boot.rb index f56eeb9241200f5a1f4c72f57a488c838b3b717b..df6b8b7fe1360f51b0e7d93dc0be00dd79bc5463 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ - # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana # diff --git a/config/environment.rb b/config/environment.rb index 41ac408095fb6923318a27137910a50955125bd5..0c960cd7757123aae27b9cd98bfa0038bd61f2c9 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -22,3 +22,4 @@ require_relative 'application' # Initialize the Rails application. Rails.application.initialize! +# Portalmec::Application.initialize! \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index b1be052351a538d043de7b74ebb5ec615f05ce30..68ac047334152309fb469f9e31aa6c25f8ead0c4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -95,7 +95,10 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - config.cache_store = :dalli_store, nil, { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 } + cache_store_servers = nil + cache_store_options = { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 } + cache_store_args = [cache_store_servers, cache_store_options].compact + config.cache_store = :mem_cache_store, *cache_store_args # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. diff --git a/config/initializers/callback_terminator.rb b/config/initializers/callback_terminator.rb index 15c47256e3d78b4f9044b0ddafae0d7da8bdcecf..dc52b7dec59a15d7ae34506b6abf2e54fadff722 100644 --- a/config/initializers/callback_terminator.rb +++ b/config/initializers/callback_terminator.rb @@ -17,4 +17,4 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -ActiveSupport.halt_callback_chains_on_return_false = false +#ActiveSupport.halt_callback_chains_on_return_false = false diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 1202fa9d27fadfd39a0f17a3b174edbe4b8156d0..23b7a77e8e15bb4ea423099677e756a265615a70 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -33,4 +33,4 @@ ActiveSupport.to_time_preserves_timezone = false Rails.application.config.active_record.belongs_to_required_by_default = false # Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = true +#ActiveSupport.halt_callback_chains_on_return_false = false diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index e31df4a910c49d055336e969014fb585a19338a3..130cb78a3536fbdcce4ddf88312458eceeee5c3f 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -27,3 +27,5 @@ Rails.application.config.middleware.use OmniAuth::Builder do } provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'] end + +OmniAuth.config.allowed_request_methods = [:post, :get] diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb index a89d9211233db2abd53f4bc085de5d419994f9c3..27c929807d3207b0c76a4e237ae5236d9c822bcb 100644 --- a/config/initializers/paper_trail.rb +++ b/config/initializers/paper_trail.rb @@ -17,4 +17,4 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -PaperTrail.config.track_associations = false \ No newline at end of file +# PaperTrail.config.track_associations = false \ No newline at end of file diff --git a/test/fixtures/complaint_reasons.yml b/config/initializers/paperclip.rb similarity index 89% rename from test/fixtures/complaint_reasons.yml rename to config/initializers/paperclip.rb index ff35dffba1548a27694bdfe9eb0a924a1742a1a9..5ac9a46d3012ab3462e75cc878ffdfd95a5aa359 100644 --- a/test/fixtures/complaint_reasons.yml +++ b/config/initializers/paperclip.rb @@ -1,4 +1,3 @@ - # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana # @@ -17,5 +16,6 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -reason_1: - reason: 'inapropriado' +Paperclip::DataUriAdapter +Paperclip::HttpUrlProxyAdapter +Paperclip::DataUriAdapter.register diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 6d819658e607ced6c474c249ab5857fdf7faa9b8..079c82281fcecaf57fb70a35ac002e7d5b3d428b 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -17,7 +17,8 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -Sidekiq::Logging.logger.level = Logger::WARN +Sidekiq.logger.level = Logger::WARN + url = ENV['REDIS_HOST'] diff --git a/db/migrate/20170307133059_add_attachment_cover_to_users.rb b/db/migrate/20170307133059_add_attachment_cover_to_users.rb index 33d4f2d77ddde7220938c0f22b065c359fb75bcf..92b32caf5496b1cabdd3bcc4539b82cc348b7490 100644 --- a/db/migrate/20170307133059_add_attachment_cover_to_users.rb +++ b/db/migrate/20170307133059_add_attachment_cover_to_users.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -class AddAttachmentCoverToUsers < ActiveRecord::Migration +class AddAttachmentCoverToUsers < ActiveRecord::Migration[6.0] def self.up change_table :users do |t| t.attachment :cover diff --git a/db/migrate/20170503134230_add_attachment_avatar_to_institutions.rb b/db/migrate/20170503134230_add_attachment_avatar_to_institutions.rb index bbd60d8435f6ddd9f62f574eba90faf64e96eae6..8d0312ef97924bbb41b5d5e568ad068a792423ae 100644 --- a/db/migrate/20170503134230_add_attachment_avatar_to_institutions.rb +++ b/db/migrate/20170503134230_add_attachment_avatar_to_institutions.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -class AddAttachmentAvatarToInstitutions < ActiveRecord::Migration +class AddAttachmentAvatarToInstitutions < ActiveRecord::Migration[6.0] def self.up change_table :institutions do |t| t.attachment :avatar diff --git a/test/fixtures/collections.yml b/export_env_vars.sh old mode 100644 new mode 100755 similarity index 80% rename from test/fixtures/collections.yml rename to export_env_vars.sh index be81dfa54682ffec9c1a0dfed9cebf1648babe19..1cb2df65dda872cc4d875fa4d1763759ee8bfb6b --- a/test/fixtures/collections.yml +++ b/export_env_vars.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana @@ -17,12 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -ufpr: - name: 'UFPR collection' - owner: john (User) - privacy: 'public' +ENV_VARS_PATH=/home/portalmec/portalmec/config/env_vars.sh +EXPORT_PATH=/home/portalmec/portalmec/env_vars.txt -private: - name: 'UFPR collection' - owner: john (User) - privacy: 'private' +grep -o '^[^#]*' $ENV_VARS_PATH | cut -d ' ' -f1 --complement > $EXPORT_PATH diff --git a/lib/log/logging.rb b/lib/log/logging.rb index 3038010838a02c2bd5580a9f18f7ffca0b7948fa..80d22c5e8e5ea3a61e6e7451fe03c909ebe54d2e 100644 --- a/lib/log/logging.rb +++ b/lib/log/logging.rb @@ -19,7 +19,6 @@ module Log module Logging - def logger Logging.logger end diff --git a/lib/portalmec/sociable_tests.rb b/lib/portalmec/sociable_tests.rb index 6eda3d5aa781f63578cb483371d57d342622b9ea..d14964562eaf9e40428ae5a5411da66367bc2c09 100644 --- a/lib/portalmec/sociable_tests.rb +++ b/lib/portalmec/sociable_tests.rb @@ -1,91 +1,91 @@ -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'active_support' - -module Portalmec::SociableTests - extend ActiveSupport::Testing::Declarative - - test 'should like a sociable object' do - assert_kind_of Like, sociable_object.like(sociable_user) - end - - test 'should not like two times same collection' do - assert_count 0, sociable_object.likes - assert_kind_of Like, sociable_object.like(sociable_user) - assert_count 1, sociable_object.likes - assert_kind_of Like, sociable_object.like(sociable_user) - assert_count 1, sociable_object.likes - end - - test 'should check if user liked a sociable object' do - assert_not sociable_object.liked?(sociable_user) - assert_kind_of Like, sociable_object.like(sociable_user) - assert sociable_object.liked?(sociable_user) - end - - test 'should user disliked a sociable object' do - assert_kind_of Like, sociable_object.like(sociable_user) - assert sociable_object.liked?(sociable_user) - assert sociable_object.dislike(sociable_user) - end - - test 'should user download a sociable object' do - assert_kind_of Download, sociable_object.download(sociable_user) - assert_count 1, sociable_object.downloads - end - - test 'should check if user downloaded a sociable object' do - assert_not sociable_object.downloaded?(sociable_user) - assert_kind_of Download, sociable_object.download(sociable_user) - assert sociable_object.downloaded?(sociable_user) - end - - test 'should user share a sociable object' do - assert_kind_of Share, sociable_object.share(sociable_user) - assert_count 1, sociable_object.shares - end - - test 'should user check if shared a sociable object' do - assert_not sociable_object.shared?(sociable_user) - assert_kind_of Share, sociable_object.share(sociable_user) - assert sociable_object.shared?(sociable_user) - end - - test 'should user view a sociable object' do - assert_kind_of View, sociable_object.view(sociable_user) - assert_count 1, sociable_object.views - end - - test 'should check if user viewed a sociable object' do - assert_not sociable_object.viewed?(sociable_user) - assert_kind_of View, sociable_object.view(sociable_user) - assert sociable_object.viewed?(sociable_user) - end - - protected - - def sociable_object - raise NotImplementedError - end - - def sociable_user - users(:john) - end -end \ No newline at end of file +# # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre +# # Departamento de Informatica - Universidade Federal do Parana +# # +# # This file is part of portalmec. +# # +# # portalmec is free software: you can redistribute it and/or modify +# # it under the terms of the GNU Affero General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # portalmec is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU Affero General Public License for more details. +# # +# # You should have received a copy of the GNU Affero General Public License +# # along with portalmec. If not, see <http://www.gnu.org/licenses/>. + +# require 'active_support' + +# module Portalmec::SociableTests +# extend ActiveSupport::Testing::Declarative + +# test 'should like a sociable object' do +# assert_kind_of Like, sociable_object.like(sociable_user) +# end + +# test 'should not like two times same collection' do +# assert_count 0, sociable_object.likes +# assert_kind_of Like, sociable_object.like(sociable_user) +# assert_count 1, sociable_object.likes +# assert_kind_of Like, sociable_object.like(sociable_user) +# assert_count 1, sociable_object.likes +# end + +# test 'should check if user liked a sociable object' do +# assert_not sociable_object.liked?(sociable_user) +# assert_kind_of Like, sociable_object.like(sociable_user) +# assert sociable_object.liked?(sociable_user) +# end + +# test 'should user disliked a sociable object' do +# assert_kind_of Like, sociable_object.like(sociable_user) +# assert sociable_object.liked?(sociable_user) +# assert sociable_object.dislike(sociable_user) +# end + +# test 'should user download a sociable object' do +# assert_kind_of Download, sociable_object.download(sociable_user) +# assert_count 1, sociable_object.downloads +# end + +# test 'should check if user downloaded a sociable object' do +# assert_not sociable_object.downloaded?(sociable_user) +# assert_kind_of Download, sociable_object.download(sociable_user) +# assert sociable_object.downloaded?(sociable_user) +# end + +# test 'should user share a sociable object' do +# assert_kind_of Share, sociable_object.share(sociable_user) +# assert_count 1, sociable_object.shares +# end + +# test 'should user check if shared a sociable object' do +# assert_not sociable_object.shared?(sociable_user) +# assert_kind_of Share, sociable_object.share(sociable_user) +# assert sociable_object.shared?(sociable_user) +# end + +# test 'should user view a sociable object' do +# assert_kind_of View, sociable_object.view(sociable_user) +# assert_count 1, sociable_object.views +# end + +# test 'should check if user viewed a sociable object' do +# assert_not sociable_object.viewed?(sociable_user) +# assert_kind_of View, sociable_object.view(sociable_user) +# assert sociable_object.viewed?(sociable_user) +# end + +# protected + +# def sociable_object +# raise NotImplementedError +# end + +# def sociable_user +# users(:john) +# end +# end \ No newline at end of file diff --git a/portalmec-sidekiq.service b/portalmec-sidekiq.service index 7ba676923a838bd58113b203c753c1ae21fb9e53..cc7f4a8722348c7770fd7a649712043914469075 100644 --- a/portalmec-sidekiq.service +++ b/portalmec-sidekiq.service @@ -1,9 +1,78 @@ +# +# This file tells systemd how to run Sidekiq as a 24/7 long-running daemon. +# +# Customize this file based on your bundler location, app directory, etc. +# Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system or /etc/systemd/system (Debian). +# Then run: +# - systemctl enable sidekiq +# - systemctl {start,stop,restart} sidekiq +# +# This file corresponds to a single Sidekiq process. Add multiple copies +# to run multiple processes (sidekiq-1, sidekiq-2, etc). +# +# Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output. +# [Unit] Description=Control sidekiq for portalmec +# start us only once the network and logging subsystems are available, +# consider adding redis-server.service if Redis is local and systemd-managed. +After=syslog.target network.target +# See these pages for lots of options: +# +# https://www.freedesktop.org/software/systemd/man/systemd.service.html +# https://www.freedesktop.org/software/systemd/man/systemd.exec.html +# +# THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple +# times! systemd is a critical tool for all developers to know and understand. +# [Service] -ExecStart=/portalmec/sidekiq.sh start -ExecStop=/portalmec/sidekiq.sh stop +# +# !!!! !!!! !!!! +# +# As of v6.0.6, Sidekiq automatically supports systemd's `Type=notify` and watchdog service +# monitoring. If you are using an earlier version of Sidekiq, change this to `Type=simple` +# and remove the `WatchdogSec` line. +# +# !!!! !!!! !!!! +# +Type=notify +NotifyAccess=all +# If your Sidekiq process locks up, systemd's watchdog will restart it within seconds. +WatchdogSec=10 + +WorkingDirectory=/home/portalmec/portalmec + +# Export the environment variables in a readable format for systemd +ExecStartPre=/home/portalmec/portalmec/export_env_vars.sh + +# If you use rbenv: +# ExecStart=/bin/bash -lc 'exec /home/deploy/.rbenv/shims/bundle exec sidekiq -e production' +# If you use the system's ruby: +# ExecStart=/usr/local/bin/bundle exec sidekiq -e production +# If you use rvm: +ExecStart=/home/portalmec/.rvm/gems/default/wrappers/bundle exec sidekiq -e production + +# Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process +ExecStop=/bin/kill -s TSTP $MAINPID + +# Greatly reduce Ruby memory fragmentation and heap usage +# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/ +Environment=MALLOC_ARENA_MAX=2 + +# Load the envinroment variables exported in the ExecStartPre script +EnvironmentFile=/home/portalmec/portalmec/env_vars.txt + +# if we crash, restart +RestartSec=10 +Restart=on-failure + +# output goes to /var/log/syslog (Debian) or /var/log/messages (CentOS) +StandardOutput=syslog +StandardError=syslog + +# This will default to "bundler" if we don't specify it +SyslogIdentifier=sidekiq [Install] -WantedBy=multi-user.target +WantedBy=multi-user.target \ No newline at end of file diff --git a/sidekiq.sh b/sidekiq.sh deleted file mode 100644 index b3af902197588631b768fa9709a735fb0384fdfb..0000000000000000000000000000000000000000 --- a/sidekiq.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -source /home/.rvm/scripts/rvm - -export PUMA_APP_DIR=/portalmec - -source $PUMA_APP_DIR/config/env_vars.sh 2>/dev/null - -option="${1}" - -case ${option} in - start) - cd $PUMA_APP_DIR - exec bundle exec sidekiq - ;; - stop) - cd $PUMA_APP_DIR - bundle exec sidekiqctl stop shared/pids/sidekiq.pid - ;; - *) - echo "`basename ${0}`:usage: [start] | [stop]" - exit 1 # Command to come out of the program with status 1 - ;; -esac diff --git a/sidekiq_log.conf b/sidekiq_log.conf new file mode 100644 index 0000000000000000000000000000000000000000..61368d0187fe7709cddc145269f783ca65ffbef5 --- /dev/null +++ b/sidekiq_log.conf @@ -0,0 +1,4 @@ +# Redirects sidekiq's service log from syslog to the sidekiq.log file +# Copy this file to /etc/rsyslog.d/sidekiq_log.conf + +:programname, isequal, "sidekiq" /home/portalmec/portalmec/shared/logs/sidekiq.log diff --git a/spec/acceptance/learning_objects_spec.rb b/spec/acceptance/learning_objects_spec.rb index cd9571dc98ceb0e3112fb66cfed5cc7dd8141443..45900264dc46c38a942cb48d1d78028e4ab834dc 100644 --- a/spec/acceptance/learning_objects_spec.rb +++ b/spec/acceptance/learning_objects_spec.rb @@ -81,7 +81,7 @@ resource 'Learning Objects' do let(:author) { Faker::Name.name } let(:name) { Faker::Name.name } let(:curator) { Faker::Name.name } - let(:thumbnail) { Faker::Avatar.image } + let(:thumbnail) { "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iNiIgY3k9IjYiIHI9IjUiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4K" } let(:description) { Faker::Lorem.paragraph } let(:object_type_id) { object_types.first.id } let(:license_id) { licenses.first.id } diff --git a/spec/factories/answers.rb b/spec/factories/answers.rb index 35d5e7ac5edd0351575db9e06d0aeea966b4d50d..8308a6f44be7fad1c57574c29a6ba0e4798136b4 100644 --- a/spec/factories/answers.rb +++ b/spec/factories/answers.rb @@ -18,10 +18,10 @@ # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :answer do question submission - answer true + answer { true } end end diff --git a/spec/factories/applications.rb b/spec/factories/applications.rb index 8cb1c27e6a8dcb3bbd8aec36d03d7fb95b84b7ec..16f9c6f1c99be7beb196ecf2f74a54aa66b22ced 100644 --- a/spec/factories/applications.rb +++ b/spec/factories/applications.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :application do |f| user diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb index a15496db7c3e4ebcae886d0ac757dfe9f5408f1c..3d460d286485a00874ac6fbb225ad96381b1be2b 100644 --- a/spec/factories/attachments.rb +++ b/spec/factories/attachments.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :attachment, class: LearningObject::Attachment do |f| f.name { Faker::Name.name } diff --git a/spec/factories/bookmarks.rb b/spec/factories/bookmarks.rb index 662edfe626d62cdc12c862b79e2581494eebce07..0e65331d231586c69fe529156d18f27dfefaa93a 100644 --- a/spec/factories/bookmarks.rb +++ b/spec/factories/bookmarks.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :bookmark do bookmarkable user diff --git a/spec/factories/collection_items.rb b/spec/factories/collection_items.rb index b426b4b9090a712340d25bca9b74150cb4442d04..eeccfbd162eef63313a63d7212747623764bb6cd 100644 --- a/spec/factories/collection_items.rb +++ b/spec/factories/collection_items.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :collection_item do collection collectionable diff --git a/spec/factories/collections.rb b/spec/factories/collections.rb index c3ad4022a3e5e3b6215a33e8bafcc7912fb0d097..7860cdc7d9279a7538bc338b28278cdfd3a12294 100644 --- a/spec/factories/collections.rb +++ b/spec/factories/collections.rb @@ -17,18 +17,19 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :collection do |f| owner f.name { Faker::University.name } f.description { Faker::Lorem.sentence } - f.privacy 'public' + f.privacy { "public" } transient do - tags_count 5 - subjects_count 2 - educational_stages_count 1 - collection_items_count 3 + tags_count { 5 } + subjects_count { 2 } + educational_stages_count { 1 } + collection_items_count { 3 } + end after(:create) do |collection, evaluator| diff --git a/spec/factories/complaint_reasons.rb b/spec/factories/complaint_reasons.rb index 0401ef1a307bc4801686865a2e4a93b0056c9184..477ba4c71aaba714bd82ce44c946f0e37b9049d2 100644 --- a/spec/factories/complaint_reasons.rb +++ b/spec/factories/complaint_reasons.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :complaint_reason do reason { Faker::Lorem.sentence } end diff --git a/spec/factories/complaints.rb b/spec/factories/complaints.rb index 8977c9933f34b255ca0338b75f851979ba18a5a1..d208054bab83fe61d17085b397a9bf7c06493d32 100644 --- a/spec/factories/complaints.rb +++ b/spec/factories/complaints.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :complaint do user complaint_reason diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb index cfb889a1c60d6adf7cf4ea7c39eaa551b46ffc3f..9ddf534141b7b73e0688127d7668a8cb7111c55a 100644 --- a/spec/factories/contacts.rb +++ b/spec/factories/contacts.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :contact do |f| f.name { Faker::Name.name } f.email { Faker::Internet.email } diff --git a/spec/factories/curator_assignments.rb b/spec/factories/curator_assignments.rb index 426094b2aac4bf229177246886dfd4ca1ca7fc40..073b64ba53d3be32554155d954944bef70f39cf6 100644 --- a/spec/factories/curator_assignments.rb +++ b/spec/factories/curator_assignments.rb @@ -17,10 +17,10 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :curator_assignment do submission user - status 0 + status { 0 } end end diff --git a/spec/factories/downloads.rb b/spec/factories/downloads.rb index 07c04bc1c96472f493dd4722f995aec016d8abd1..4f170014c5bd95e743cb1709a0e8503215fc7b75 100644 --- a/spec/factories/downloads.rb +++ b/spec/factories/downloads.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :download do |f| f.ip { Faker::Internet.ip_v4_address } diff --git a/spec/factories/educational_stages.rb b/spec/factories/educational_stages.rb index 638dbf8445bdd772c33153f2579ab7b750f464e5..6b76697023b96a4b8efdf4114c4bbd39e52f7585 100644 --- a/spec/factories/educational_stages.rb +++ b/spec/factories/educational_stages.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :educational_stage do sequence(:name) { |i| "EducationalStage #{i}" } end diff --git a/spec/factories/follows.rb b/spec/factories/follows.rb index 5345c62292b2f0af4b8e26beab383da800d0ed93..4013f93e7a3862d304831ba0505e6183dae70e3a 100644 --- a/spec/factories/follows.rb +++ b/spec/factories/follows.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :follow do user followable diff --git a/spec/factories/institutions.rb b/spec/factories/institutions.rb index 30ebe300e87a83a50018dfc521121dc4c3b5ca84..e0b10257be6508af5b19a6bab64637001ae4ced3 100644 --- a/spec/factories/institutions.rb +++ b/spec/factories/institutions.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :institution do name { Faker::Name.name } description { Faker::Lorem.paragraph } diff --git a/spec/factories/languages.rb b/spec/factories/languages.rb index 805d86ca6f55b6e018ebc7c43685e08fae15f1f8..37a1df48853d3e9f7833c2c671ec50dcb7bf4907 100644 --- a/spec/factories/languages.rb +++ b/spec/factories/languages.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :language do |l| l.name { Faker::Address.country } l.code { Faker::Address.country_code } diff --git a/spec/factories/learning_objects.rb b/spec/factories/learning_objects.rb index da849ac405cf63e6d4b65eccafa377f21a5725d8..61ac9d5c78ec2711d18b8ba6b71935423b2b505a 100644 --- a/spec/factories/learning_objects.rb +++ b/spec/factories/learning_objects.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :learning_object, aliases: [:downloadable, :reviewable, :stageable, :subjectable, :likeable, :collectionable, :bookmarkable] do sequence(:name) { |i| "LearningObject #{i}" } sequence(:id_dspace) { |i| i } @@ -27,13 +27,13 @@ FactoryGirl.define do object_type { ObjectType.all.sample } language { [Language.all.sample] } author { Faker::Name.name } - state LearningObject.states[:published] + state { LearningObject.states[:published] } transient do - tags_count 5 - subjects_count 2 - educational_stages_count 1 - reviews_count 2 + tags_count { 5 } + subjects_count { 2 } + educational_stages_count { 1 } + reviews_count { 2 } end after(:create) do |learning_object, evaluator| diff --git a/spec/factories/likes.rb b/spec/factories/likes.rb index 66272811454c78c75cecb1e4ee40d64e01072d2d..8cf8f587751a052f0b372fe07d64c9bd9c455639 100644 --- a/spec/factories/likes.rb +++ b/spec/factories/likes.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :like do likeable user diff --git a/spec/factories/mime_types.rb b/spec/factories/mime_types.rb index 5c69ca7fa30d0f8f72e4b04560ffa3031e1d9752..626beb73f7239779081c20b537c32b0a2ebf3921 100644 --- a/spec/factories/mime_types.rb +++ b/spec/factories/mime_types.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :mime_type do |m| m.mime_type { Faker::File.mime_type} m.extension { Faker::File.extension} diff --git a/spec/factories/object_types.rb b/spec/factories/object_types.rb index 71f185b2db705ad3231f6553af6b5cc9899426c3..f58ac1a203dde5ef598377c21ef10acab8212361 100644 --- a/spec/factories/object_types.rb +++ b/spec/factories/object_types.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :object_type do |m| m.name { Faker::Name::name} m.mime_types { Faker::File.mime_types} diff --git a/spec/factories/questions.rb b/spec/factories/questions.rb index a193e456869ecb242836e4295575c322f206af62..c1cb4c55bbcd47600094dc82c9a67e41e02a7d69 100644 --- a/spec/factories/questions.rb +++ b/spec/factories/questions.rb @@ -17,9 +17,9 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :question do description { Faker::Lorem.sentence } - status "active" + status { "active" } end end diff --git a/spec/factories/ratings.rb b/spec/factories/ratings.rb index a90a75d0c545c49db8cea90efea63ad14ebf5898..ddff7ba24f54c16bca5b5f9bb92085c5e8523e27 100644 --- a/spec/factories/ratings.rb +++ b/spec/factories/ratings.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :rating do name { Faker::Lorem.word } description { Faker::Lorem.sentence } diff --git a/spec/factories/review_ratings.rb b/spec/factories/review_ratings.rb index 811afdbb9318a65ff630c5c51090e8ad20447eef..cdf20b6386ed15de818c34e52b94a9b001adee5b 100644 --- a/spec/factories/review_ratings.rb +++ b/spec/factories/review_ratings.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :review_rating do rating value { rand(1..5) } diff --git a/spec/factories/reviews.rb b/spec/factories/reviews.rb index 8a6955a5df1fe7c82717a183d62dca52fa6b93c4..6ae17a6f0a77cf16f9b0a403d3133f29b1c6d3f9 100644 --- a/spec/factories/reviews.rb +++ b/spec/factories/reviews.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :review do user reviewable diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 6a40c66b8dceb31aa0a70dadd5d0b21e5c68ca05..4d86f27dc4004ba80f6892fc7fd1ef0d37d7ff37 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -17,12 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :teacher_role, class: Role do |r| - r.name 'teacher' + r.name { "teacher" } end factory :admin_role, class: Role do |r| - r.name 'admin' + r.name { "admin" } end end diff --git a/spec/factories/schools.rb b/spec/factories/schools.rb index 209788d7ce2e3cd83d7cb10486e7450b0906d9d0..cf5b5935f4006ef0920b2a36468f64b31fd9588a 100644 --- a/spec/factories/schools.rb +++ b/spec/factories/schools.rb @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :school do inep_id { Faker::IDNumber.valid } name { Faker::Name.name } diff --git a/spec/factories/stages_relation.rb b/spec/factories/stages_relation.rb index 99d9e7fb824fe59aa2253a2900739a207ae5227e..1bf0ab04a3466e56f7a41a8a00425411cb7ca4e6 100644 --- a/spec/factories/stages_relation.rb +++ b/spec/factories/stages_relation.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :stage_relation do stageable educational_stage diff --git a/spec/factories/subjects.rb b/spec/factories/subjects.rb index 7703552bb5a01a904e0939476b020ce09b215e9b..faa993a3b47d9b135c68dcf233c2855498aa887f 100644 --- a/spec/factories/subjects.rb +++ b/spec/factories/subjects.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :subject do name { Faker::Name.name } end diff --git a/spec/factories/subjects_relation.rb b/spec/factories/subjects_relation.rb index f4ad39257d1195e46636fccb65490fb2052b4ba2..c4ce69a9e4e4181bd90b95a600e4b1e61a71c6df 100644 --- a/spec/factories/subjects_relation.rb +++ b/spec/factories/subjects_relation.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :subject_relation do subjectable subject diff --git a/spec/factories/submissions.rb b/spec/factories/submissions.rb index 4b010e795f993d3dfa6f1ce63e6f4678d2cfad7b..e33bd2f317abf16d790b155c22bc23ac3f80ad7d 100644 --- a/spec/factories/submissions.rb +++ b/spec/factories/submissions.rb @@ -18,11 +18,11 @@ # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :submission do - justification "MyString" - status "submitted" - answered_at "2019-01-15 10:03:40" + justification { "MyString" } + status { "submitted" } + answered_at { "2019-01-15 10:03:40" } submitter learning_object end diff --git a/spec/factories/suggestions.rb b/spec/factories/suggestions.rb index 3e740fb39eab4246654e44da9ede356d01fe4d90..15ddd72ae3a7c94ee30ef991cdd636fa183e9e2b 100644 --- a/spec/factories/suggestions.rb +++ b/spec/factories/suggestions.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :suggestion do |f| f.name { Faker::Lorem.word } f.link { Faker::Lorem.word } diff --git a/spec/factories/taggings.rb b/spec/factories/taggings.rb index 4b07f589896c1404c5330e793c3146ff75795c30..95eb78c7df946c7a6877f234a829559223d305c8 100644 --- a/spec/factories/taggings.rb +++ b/spec/factories/taggings.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :tagging do tag tagger diff --git a/spec/factories/tags.rb b/spec/factories/tags.rb index f0ebfbdc84e1fced6e405af37959e7845090c2f0..036f4751c0fae82846f8cc0efc3bf08335fcfad5 100644 --- a/spec/factories/tags.rb +++ b/spec/factories/tags.rb @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :tag do sequence(:name) { |i| "Tag #{i}" } end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 81f976adfb85784aaad068d0051e447067f4504f..e39af555f7c8a82d6545c3d8c8d8f9d8e753b1dd 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -17,14 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -FactoryGirl.define do +FactoryBot.define do factory :user, aliases: [:owner, :publisher, :tagger, :followable, :submitter, :curator] do name { Faker::Name.name } email { Faker::Internet.email } description { Faker::Lorem.sentence } education { Faker::Lorem.sentence } - password '12345678' - confirmed_at { Faker::Date.between(2.years.ago, Time.zone.today) } + password { "12345678" } + confirmed_at { Faker::Date.between(from: 2.years.ago, to: Time.zone.today) } school end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b77afee327c60deb6b5b44a3f94e3ff126f6dcbf..bb8e9b1a886add13068ceb32ba4a973833c71bf7 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -79,7 +79,7 @@ RSpec.configure do |config| config.include Devise::TestHelpers, type: :controller config.include ControllerHelpers, type: :controller - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.before(:suite) do DatabaseCleaner.strategy = :transaction diff --git a/test/fixtures/educational_stages.yml b/spec/support/factory_bot.rb similarity index 91% rename from test/fixtures/educational_stages.yml rename to spec/support/factory_bot.rb index a1efd635dca0ac70db868e959f2c5b04fac15707..e725a3231e285658014ab1f72b9fb6a0cb25bfc7 100644 --- a/test/fixtures/educational_stages.yml +++ b/spec/support/factory_bot.rb @@ -1,4 +1,3 @@ - # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana # @@ -17,5 +16,6 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -stage_teste: - name: "teste" +RSpec.configure do |config| + config.include FactoryBot::Syntax::Methods +end \ No newline at end of file diff --git a/test/controllers/.keep b/test/controllers/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/controllers/v1/collections_controller_test.rb b/test/controllers/v1/collections_controller_test.rb deleted file mode 100644 index b3e4c483a3df37596c3716d4469c35b9409d29c0..0000000000000000000000000000000000000000 --- a/test/controllers/v1/collections_controller_test.rb +++ /dev/null @@ -1,206 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::CollectionsControllerTest < ActionController::TestCase - tests V1::CollectionsController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should user post collection to create and return :created code' do - auth_request users(:jack) - post :create, params: { - collection: { - name: 'my collection', - description: 'testing collection', - owner_type: 'User', - owner_id: users(:jack).id, - items: [{ id: learning_objects(:user_lo).id, type: 'LearningObject' }], - tags: [{ "name": "teste" }, { "name": "tag de teste" }], - subjects: [subjects(:subject_one).id], - educational_stages: [educational_stages(:stage_teste).id] - } - } - assert_response :created - end - - test 'should institution post collection to create and return :created code' do - auth_request users(:jack) - post :create, params: { - collection: { - name: 'my collection', - description: 'testing collection', - owner_type: 'Institution', - owner_id: institutions(:ufpr).id, - items: [{ id: learning_objects(:user_lo).id, type: "LearningObject" }], - subjects: [subjects(:subject_one).id], - tags: [{ "name": "teste" }, { "name": "tag de teste" }], - educational_stages: [educational_stages(:stage_teste).id] - } - } - assert_response :created - end - - test 'should user post collection to create and return :unauthorized code' do - post :create, params: { - collection: { - name: 'my collection', - description: 'testing collection', - owner_type: 'Institution', - owner_id: institutions(:ufpr).id - } - } - assert_response :unauthorized - end - - test 'should user deleting collection to destroy and return :ok' do - auth_request users(:john) - delete :destroy, params: { id: collections(:ufpr).id } - assert_response :ok - end - - test 'should user deleting collection to destroy and return :unauthorized' do - delete :destroy, params: { id: collections(:ufpr).id } - assert_response :unauthorized - end - - test 'should user patch collection to update and return :ok code' do - auth_request users(:john) - post :update, params: { - id: collections(:ufpr).id, - collection: { - name: 'my updated collection', - description: 'testing to update collection', - owner_type: 'User', owner_id: users(:john).id, - items: - [ - { id: learning_objects(:one).id, type: "LearningObject", order: 1 }, - { id: collections(:ufpr).id, type: "Collection", order: 3 } - ] - } - } - assert_response :ok - end - - test 'should user patch collection to update and return :unauthorized code' do - auth_request users(:jack) - post :update, params: { - id: collections(:ufpr).id, - collection: { - name: 'my updated collection', - description: 'testing to update collection', - owner_type: 'User', owner_id: users(:john).id, - items: - [ - { id: learning_objects(:one).id, type: "LearningObject", order: 1 }, - { id: collections(:ufpr).id, type: "Collection", order: 3 } - ] - } - } - assert_response :unauthorized - end - - - test 'should anyone show public collection and return :ok' do - auth_request users(:jack) - get :show, params: { id: collections(:ufpr).id } - assert_response :ok - end - - test 'should anyone show private collection and return :unauthorized' do - auth_request users(:jack) - get :show, params: { id: collections(:private).id } - assert_response :unauthorized - end - - - test 'should user add items to collection and return :ok code' do - auth_request users(:john) - post :add_object, params: { id: collections(:ufpr).id, collection: {items: [{id: learning_objects(:lo_metadata2).id, type: 'LearningObject'}] }} - - assert_response :ok - end - - test 'should user remove items to collection and return :ok code' do - auth_request users(:john) - post :delete_object, params: { id: collections(:ufpr).id, collection: { items: [{id: learning_objects(:lo_metadata).id, type: 'LearningObject'}] }} - assert_response :ok - end - - test 'should user add items to collection and return :unprocessable_entity code' do - auth_request users(:john) - post :add_object, params: { id: collections(:ufpr).id, collection: {items: [] }} - assert_response :unprocessable_entity - end - - test 'should user remove items to collection and return :unprocessable_entity code' do - auth_request users(:john) - post :delete_object, params: { id: collections(:ufpr).id, collection: { items: [] } } - assert_response :unprocessable_entity - end - - test 'should user tagging a collection' do - auth_request users(:jack) - tag = tags(:tag_three).name - - post :tagging, params: { id: collections(:ufpr).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :created - end - - - test 'should user untagging a collection' do - auth_request users(:john) - tag = tags(:tag_one).name - - post :untagging, params: { id: collections(:ufpr).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :ok - end - - - test 'should institution tagging a collection' do - auth_request users(:jack) - institution = institutions(:ufpr) - institution.users << users(:jack) - tag = tags(:tag_one).name - - post :tagging, params: { id: collections(:ufpr).id, tags: { name: tag, owner_id: institutions(:ufpr).id, owner_type: 'Institution' } } - assert_response :created - end - - test 'should institution untagging a collection' do - auth_request users(:john) - institution = institutions(:ufpr) - institution.users << users(:john) - tag = tags(:tag_two).name - - post :untagging, params: { id: collections(:ufpr).id, tags: { name: tag, owner_id: institutions(:ufpr).id, owner_type: 'Institution' } } - assert_response :ok - end - - - private - - def ensure_collection_is_persisted!(collection) - collection.save! - end -end diff --git a/test/controllers/v1/complaints_controller_test.rb b/test/controllers/v1/complaints_controller_test.rb deleted file mode 100644 index 48da143340959b09cd8f0085fd7f1c189c829b94..0000000000000000000000000000000000000000 --- a/test/controllers/v1/complaints_controller_test.rb +++ /dev/null @@ -1,62 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::ComplaintControllerTest < ActionController::TestCase - tests V1::ComplaintsController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should create complaint and return :created code' do - jack = users(:jack) - - auth_request jack - - post :create, params: { complaint: { - user_id: jack.id, - description: 'description of complaint', - complainable_id: learning_objects(:one).id, - complaint_reason_id: complaint_reasons(:reason_1).id, - complainable_type: 'LearningObject' - } - } - assert_response :created - end - - test 'should unprocessable_entity complaint and return :created code' do - jack = users(:jack) - - auth_request jack - - post :create, params: { complaint: { - user_id: nil, - description: 'description of complaint', - complainable_id: learning_objects(:one).id, - complaint_reason_id: complaint_reasons(:reason_1).id, - complainable_type: 'LearningObject' - } - } - assert_response :unprocessable_entity - end - -end diff --git a/test/controllers/v1/feed_controller_test.rb b/test/controllers/v1/feed_controller_test.rb deleted file mode 100644 index 9331a53708c9ca6087f23354550f3ec321aa59e1..0000000000000000000000000000000000000000 --- a/test/controllers/v1/feed_controller_test.rb +++ /dev/null @@ -1,36 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::FeedControllerTest < ActionController::TestCase - tests V1::FeedController - include Devise::Test::ControllerHelpers - - test 'should get index' do - auth_request users(:jack) - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should not get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - assert_response :unauthorized - end - -end diff --git a/test/controllers/v1/institutions_controller_test.rb b/test/controllers/v1/institutions_controller_test.rb deleted file mode 100644 index a8a3b3bc973b7290b1409f97207041c5b30f93c6..0000000000000000000000000000000000000000 --- a/test/controllers/v1/institutions_controller_test.rb +++ /dev/null @@ -1,90 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::InstitutionControllerTest < ActionController::TestCase - tests V1::InstitutionsController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should user show institution' do - auth_application - ufpr = institutions(:ufpr) - get :show, params: { id: ufpr.id } - assert_response :ok - end - - test 'should user post institution to create and return :unauthorized' do - post :create, params: { institution: {name: 'my institution', - description: 'testing institution', - address: 'politecnico', - city: 'Curitiba', - country: 'Brasil' - } - } - skip assert_response :unauthorized - end - - test 'should user post institution to create and return :created code' do - auth_request users(:jack) - post :create, params: { institution: {name: 'my institution', - description: 'testing institution', - address: 'politecnico', - city: 'Curitiba', - country: 'Brasil' - } - } - skip assert_response :created - end - - test 'should user put institution to update and return :ok' do - auth_request users(:jack) - ufpr = institutions(:ufpr) - put :update, params: { id: ufpr.id, institution: { description: 'testing institution' } } - assert_response :ok - end - - test 'should user put institution to update and return :unauthorized' do - ufpr = institutions(:ufpr) - put :update, params: { id: ufpr.id, institution: { description: 'testing institution' } } - assert_response :unauthorized - end - - test 'should user delete institution to destroy and return :ok' do - auth_request users(:jack) - ufpr = institutions(:ufpr) - delete :destroy, params: { id: ufpr.id } - assert_response :ok - end - - test 'should user delete institution to destroy and return :unauthorized' do - ufpr = institutions(:ufpr) - delete :destroy, params: { id: ufpr.id } - assert_response :unauthorized - end - - test 'should user show institution users' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - -end diff --git a/test/controllers/v1/languages_controller_test.rb b/test/controllers/v1/languages_controller_test.rb deleted file mode 100644 index 3c024a8d8ecd6646ecc4e234832c645e7d9f4326..0000000000000000000000000000000000000000 --- a/test/controllers/v1/languages_controller_test.rb +++ /dev/null @@ -1,45 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::LanguagesControllerTest < ActionController::TestCase - tests V1::LanguagesController - include Devise::Test::ControllerHelpers - - test 'should put update to language with admin user and return :ok code' do - auth_request users(:admin) - language = languages(:portuguese) - put :update, params: { language: { - name: 'English', - code: 'en' - }, id: language.id } - assert_response :ok - end - - test 'should not put update to language if user is not logged in and then return :unauthorized code' do - language = languages(:portuguese) - put :update, params: { language: { - name: 'English', - code: 'en' - }, id: language.id } - assert_response :unauthorized - end - -end diff --git a/test/controllers/v1/learning_objects_controller_test.rb b/test/controllers/v1/learning_objects_controller_test.rb deleted file mode 100644 index 12accaaafd68c2e050cbf33d7039411391e8a1e9..0000000000000000000000000000000000000000 --- a/test/controllers/v1/learning_objects_controller_test.rb +++ /dev/null @@ -1,62 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::LearningObjectsControllerTest < ActionController::TestCase - tests V1::LearningObjectsController - include Devise::Test::ControllerHelpers - - test 'should user tagging a learning object' do - auth_request users(:jack) - tag = tags(:tag_three).name - - post :tagging, params: { id: learning_objects(:user_lo).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :created - end - - test 'should user untagging a learning object' do - auth_request users(:jack) - tag = tags(:tag_three).name - - post :untagging, params: { id: learning_objects(:user_lo).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :ok - end - - test 'should institution tagging a learning object' do - auth_request users(:jack) - institution = institutions(:ufpr) - institution.users << users(:jack) - tag = tags(:tag_one).name - - post :tagging, params: { id: learning_objects(:institution_lo).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :created - end - - test 'should institution untagging a learning object' do - auth_request users(:jack) - institution = institutions(:ufpr) - institution.users << users(:jack) - tag = tags(:tag_one).name - - post :untagging, params: { id: learning_objects(:institution_lo).id, tags: { name: tag, owner_id: users(:jack).id, owner_type: 'User' } } - assert_response :ok - end - -end diff --git a/test/controllers/v1/licenses_controller_test.rb b/test/controllers/v1/licenses_controller_test.rb deleted file mode 100644 index 9fffd5a93d73605075efa5675632634bfc63228d..0000000000000000000000000000000000000000 --- a/test/controllers/v1/licenses_controller_test.rb +++ /dev/null @@ -1,69 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::LicensesControllerTest < ActionController::TestCase - tests V1::LicensesController - include Devise::Test::ControllerHelpers - - setup do - @license = licenses(:one) - end - - test "should get index" do - skip - get :index - assert_response :success - assert_not_nil assigns(:licenses) - end - - test "should create license" do - auth_request users(:admin) - - assert_difference('License.count') do - post :create, params: { license: { description: @license.description, name: @license.name, url: @license.url, image_url: @license.image_url } } - end - - assert_response 201 - end - - test "should show license" do - skip - get :show, id: @license - assert_response :success - end - - test "should update license" do - auth_request users(:admin) - - put :update, params: { id: @license, license: { description: @license.description, name: @license.name, url: @license.url, image_url: @license.image_url } } - assert_response 204 - end - - test "should destroy license" do - auth_request users(:admin) - - assert_difference('License.count', -1) do - delete :destroy, params: { id: @license } - end - - assert_response 204 - end -end diff --git a/test/controllers/v1/mime_types_controller_test.rb b/test/controllers/v1/mime_types_controller_test.rb deleted file mode 100644 index 22f723b665325cb947306532325885f9b9883d60..0000000000000000000000000000000000000000 --- a/test/controllers/v1/mime_types_controller_test.rb +++ /dev/null @@ -1,45 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::MimeTypesControllerTest < ActionController::TestCase - tests V1::MimeTypesController - include Devise::Test::ControllerHelpers - - test 'should put update to mime_type with admin user and return :ok code' do - auth_request users(:admin) - mime_type = mime_types(:mp4) - put :update, params: { mime_type: { - extension: '.mp45', - mime_type: 'video/mp45' - }, id: mime_type.id } - assert_response :ok - end - - test 'should not put update to mime_type if user is not logged in and then return :unauthorized code' do - mime_type = mime_types(:mp4) - put :update, params: { mime_type: { - extension: '.mp45', - mime_type: 'video/mp45' - }, id: mime_type.id } - assert_response :unauthorized - end - -end diff --git a/test/controllers/v1/object_types_controller_test.rb b/test/controllers/v1/object_types_controller_test.rb deleted file mode 100644 index a96ccd9d979f06b3d7407765f13a31e1813c9604..0000000000000000000000000000000000000000 --- a/test/controllers/v1/object_types_controller_test.rb +++ /dev/null @@ -1,47 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::ObjectTypesControllerTest < ActionController::TestCase - tests V1::ObjectTypesController - include Devise::Test::ControllerHelpers - - test 'should put update to object_type with admin user and return :ok code' do - auth_request users(:admin) - object_type = object_types(:image) - mime_type = mime_types(:mp4) - put :update, params: { object_type: { - name: 'Vídeo', - mime_types: [mime_type.id] - }, id: object_type.id } - assert_response :ok - end - - test 'should not put update to object_type if user is not logged in and then return :unauthorized code' do - object_type = object_types(:image) - mime_type = mime_types(:mp4) - put :update, params: { object_type: { - name: 'Vídeo', - mime_types: [mime_type.id] - }, id: object_type.id } - assert_response :unauthorized - end - -end diff --git a/test/controllers/v1/ratings_controller_test.rb b/test/controllers/v1/ratings_controller_test.rb deleted file mode 100644 index de2a84af3035b63f4e6581f217d15d46742891a4..0000000000000000000000000000000000000000 --- a/test/controllers/v1/ratings_controller_test.rb +++ /dev/null @@ -1,73 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::RatingControllerTest < ActionController::TestCase - tests V1::RatingsController - include Devise::TestHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should user show rating' do - auth_application - usability = ratings(:usability) - get :show, params: { id: usability.id } - assert_response :ok - end - - test 'should user post rating to create and return :unauthorized' do - post :create, params: { rating: {name: 'my rating', description: 'testing rating' } } - assert_response :unauthorized - end - - test 'should user post rating to create and return :created code' do - auth_request users(:jack) - post :create, params: { rating: {name: 'my rating', description: 'testing rating' } } - assert_response :created - end - - test 'should user put rating to update and return :ok' do - auth_request users(:jack) - usability = ratings(:usability) - put :update, params: { id: usability.id, rating: { description: 'testing rating' } } - assert_response :ok - end - - test 'should user put rating to update and return :unauthorized' do - usability = ratings(:usability) - put :update, params: { id: usability.id, rating: { description: 'testing rating' } } - assert_response :unauthorized - end - - test 'should user delete rating to destroy and return :ok' do - auth_request users(:jack) - usability = ratings(:usability) - delete :destroy, params: { id: usability.id } - assert_response :ok - end - - test 'should user delete rating to destroy and return :unauthorized' do - usability = ratings(:usability) - delete :destroy, params: { id: usability.id } - assert_response :unauthorized - end -end diff --git a/test/controllers/v1/reviews_controller_test.rb b/test/controllers/v1/reviews_controller_test.rb deleted file mode 100644 index f21467d47d7f2ee31a72af117aace2fbb2232fda..0000000000000000000000000000000000000000 --- a/test/controllers/v1/reviews_controller_test.rb +++ /dev/null @@ -1,67 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::ReviewsControllerTest < ActionController::TestCase - tests V1::ReviewsController - include Devise::Test::ControllerHelpers - - test 'should user review a learning object and return :created code' do - auth_request users(:admin) - assert learning_objects(:user_lo).id > 0 - create_review learning_objects(:user_lo) - assert_response :created - end - - test 'should user review a collection and return :created code' do - auth_request users(:admin) - create_review collections(:ufpr) - assert_response :created - end - - test 'should guest user review a collection and return :unauthorized code' do - create_review collections(:ufpr) - assert_response :unauthorized - end - - test 'should user delete review withou permission and return :unauthorized code' do - auth_request users(:john) - delete :destroy, params: { collection_id: collections(:ufpr).id, id: reviews(:collection).id } - assert_response :unauthorized - end - - private - - def create_review(object) - object_param_name = "#{object.class.to_s.downcase}_id".to_sym - object_param_name = 'learning_object_id' if LearningObject == object.class - post :create, params: { review: { - name: 'Test of review', - description: 'testing', - pros: 'my pros', - cons: 'my cons', - review_ratings_attributes: [ - { rating_id: ratings(:usability).id, value: 3 }, - { rating_id: ratings(:application_context).id, value: 3 }, - { rating_id: ratings(:content).id, value: 3 } - ] - }, object_param_name => object.id } - end -end diff --git a/test/controllers/v1/scores_controller_test.rb b/test/controllers/v1/scores_controller_test.rb deleted file mode 100644 index 631bcad4690d1187f6ffb6ee177e32d72edf9f8a..0000000000000000000000000000000000000000 --- a/test/controllers/v1/scores_controller_test.rb +++ /dev/null @@ -1,68 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::ScoresControllerTest < ActionController::TestCase - tests V1::ScoresController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip - end - - test 'should show score' do - auth_application - score = scores(:score_19) - get :show, params: { id: score.id } - assert_response :ok - end - - test 'should put score to update and return :ok code' do - auth_request users(:jack) - score = scores(:score_19) - put :update, params: { score: {name: 'testing', - weight: 10, - active: true, - score_type: ['LearningObject'] - }, id: score.id } - assert_response :ok - end - - test 'do not should put score to update if user is not authenticated and then return :unauthorized code' do - score = scores(:score_19) - put :update, params: { score: {name: 'testing', - weight: 10, - active: true, - score_type: ['LearningObject'] - }, id: score.id } - assert_response :unauthorized - end - - test 'should put invalid score to update and return :unprocessable_entity code' do - auth_request users(:jack) - score = scores(:score_19) - put :update, params: { score: {name: 'testing', - weight: 'addasd', - score_type: ['LearningObject'] - }, id: score.id } - assert_response :unprocessable_entity - end - -end diff --git a/test/controllers/v1/search_controller_test.rb b/test/controllers/v1/search_controller_test.rb deleted file mode 100644 index 0d671ec4dd251e1ca895ff5214c7a913fc8bf715..0000000000000000000000000000000000000000 --- a/test/controllers/v1/search_controller_test.rb +++ /dev/null @@ -1,54 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::SearchControllerTest < ActionController::TestCase - tests V1::SearchController - - setup do - SearchService::SEARCH_CLASSES.each { |search_class| reindex search_class.constantize } - auth_application - end - - test 'should search return :ok' do - SearchService::SEARCH_CLASSES.each do |search_class| - get :index, params: { search_class: search_class } - assert_response :ok - end - end - - test 'should search with invalid class and return :bad_request' do - get :index, params: { search_class: 'invalid' } - assert_response :bad_request - end - - test 'should autocomplete with invalid class and return :bad_request' do - get :autocomplete, params: { search_class: 'invalid' } - assert_response :bad_request - end - - private - - def reindex(klass) - klass.reindex - klass.searchkick_index.refresh - end - -end diff --git a/test/controllers/v1/users/bookmarks_controller_test.rb b/test/controllers/v1/users/bookmarks_controller_test.rb deleted file mode 100644 index 8ce1e26fc1de528b1b9163cff3fc19fb8822463e..0000000000000000000000000000000000000000 --- a/test/controllers/v1/users/bookmarks_controller_test.rb +++ /dev/null @@ -1,66 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::Users::BookmarksControllerTest < ActionController::TestCase - tests V1::Users::BookmarksController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should user append learning object in bookmarks and return :created code' do - auth_request users(:jack) - lo = learning_objects(:one) - post :create, params: { id: users(:jack).id, bookmarks: { id: lo.id, - type: "LearningObject" } - } - assert_response :created - end - - test 'should user append collection in bookmarks and return :created code' do - auth_request users(:jack) - collection = collections(:ufpr) - post :create, params: { id: users(:jack).id, bookmarks: { id: collection.id, - type: "Collection" } - } - assert_response :created - end - - test 'should user undo bookmark of learning object to destroy and return :ok' do - auth_request users(:jack) - lo = learning_objects(:one) - delete :destroy, params: { id: users(:jack).id, bookmarks: { id: lo.id, - type: "LearningObject" } - } - assert_response :ok - end - - test 'should user undo bookmark of collection to destroy and return :ok' do - auth_request users(:jack) - collection = collections(:ufpr) - delete :destroy, params: { id: users(:jack).id, bookmarks: { id: collection.id, - type: "Collection" } - } - assert_response :ok - end - -end diff --git a/test/controllers/v1/users_controller_test.rb b/test/controllers/v1/users_controller_test.rb deleted file mode 100644 index c050a5505bac87514dbdb15843614d2763290f40..0000000000000000000000000000000000000000 --- a/test/controllers/v1/users_controller_test.rb +++ /dev/null @@ -1,108 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class V1::UsersControllerTest < ActionController::TestCase - tests V1::UsersController - include Devise::Test::ControllerHelpers - - test 'should get index' do - skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)') - end - - test 'should post user to create and return :created code' do - auth_request users(:jack) - post :create, params: { user: { name: 'mauricio', - email: 'testando@inf.ufpr.br', - password: 'test123455', - description: 'usuario super legal', - password_confirmation: 'test123455', - terms_of_service: '1' } } - assert_response :created - end - - test 'should post invalid user to create and return :unprocessable_entity code' do - auth_request users(:jack) - post :create, params: { user: { name: 'mauricio', email: '', password: 'test123455', password_confirmation: 'test123455', - terms_of_service: false, role_ids: [] } } - assert_response :unprocessable_entity - end - - test 'should put user to update and return :ok code' do - auth_request users(:jack) - user = users(:john) - put :update, params: { user: { name: 'mauricio', - email: 'testando@inf.ufpr.br', - password: 'test123455', - description: 'sou legal', - password_confirmation: 'test123455', - terms_of_service: '1' - }, id: user.id } - assert_response :ok - end - - test 'should put invalid user to update and return :unprocessable_entity code' do - auth_request users(:jack) - user = users(:john) - put :update, params: { user: { name: 'mauricio', email: '', password: 'test123455', password_confirmation: 'test123455', - terms_of_service: false }, id: user.id } - assert_response :unprocessable_entity - end - - test 'should delete an user and return :ok code' do - auth_request users(:jack) - user = users(:john) - delete :destroy, params: { id: user.id } - assert_response :ok - end - - test 'should not current user delete yourself' do - auth_request users(:john) - user = users(:john) - delete :destroy, params: { id: user.id } - assert_response :forbidden - end - - test 'should user follow an user jack' do - auth_request users(:john) - post :follow, params: { id: users(:jack).id } - assert_response :created - end - - test 'should user follow an already followed user and return :forbidden code' do - auth_request users(:john) - - post :follow, params: { id: users(:jack).id } - assert_response :created - - post :follow, params: { id: users(:jack).id } - assert_response :forbidden - end - - test 'should user unfollow an user jack' do - auth_request users(:john) - post :follow, params: { id: users(:jack).id } - assert_response :created - - delete :unfollow, params: { id: users(:jack).id } - assert_response :ok - end - -end diff --git a/test/fixtures/.keep b/test/fixtures/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/fixtures/applications.yml b/test/fixtures/applications.yml deleted file mode 100644 index 881e2ec4803a6c4bceff61225b74113541b61bc4..0000000000000000000000000000000000000000 --- a/test/fixtures/applications.yml +++ /dev/null @@ -1,24 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -test_app: - name: 'test app' - domain: 'test.host' - application_id: 'ffcb31a0-bacc-4f37-925c-656b3805095a' - user_id: john (User) \ No newline at end of file diff --git a/test/fixtures/collection_item.yml b/test/fixtures/collection_item.yml deleted file mode 100644 index 0b2ba19660401ca6446d5387cedb5ddccd5f1ee1..0000000000000000000000000000000000000000 --- a/test/fixtures/collection_item.yml +++ /dev/null @@ -1,23 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -item1: - collectionable_id: :user_lo.id (User) - collectionable_type: 'LearningObject' - order: 1 diff --git a/test/fixtures/institutions.yml b/test/fixtures/institutions.yml deleted file mode 100644 index 435b8ce0fc2c3e30851fe672a84082c8446eca89..0000000000000000000000000000000000000000 --- a/test/fixtures/institutions.yml +++ /dev/null @@ -1,24 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -ufpr: - name: 'UFPR institution' - address: 'politecnico' - city: 'curitiba' - country: 'brasil' \ No newline at end of file diff --git a/test/fixtures/languages.yml b/test/fixtures/languages.yml deleted file mode 100644 index 90d250779e0555d6689e33c1f5d25c841a4d4173..0000000000000000000000000000000000000000 --- a/test/fixtures/languages.yml +++ /dev/null @@ -1,22 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -portuguese: - name: 'Português' - code: 'pt_BR' \ No newline at end of file diff --git a/test/fixtures/learning_objects.yml b/test/fixtures/learning_objects.yml deleted file mode 100644 index fe00d0b2d3fecf53e78dba828e95456d7620a134..0000000000000000000000000000000000000000 --- a/test/fixtures/learning_objects.yml +++ /dev/null @@ -1,98 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: learning_objects -# -# id :integer not null, primary key -# id_dspace :integer -# name :string -# author :string -# description :text -# published_at :datetime -# score :float default("0.0") -# school_level :integer -# metadata :jsonb default("{}") -# keywords :text -# publisher_id :integer -# publisher_type :string -# object_type_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# views_count :integer default("0") -# downloads_count :integer default("0") -# likes_count :integer default("0") -# shares_count :integer default("0") -# state :string default("published") -# thumbnail_file_name :string -# thumbnail_content_type :string -# thumbnail_file_size :integer -# thumbnail_updated_at :datetime -# attachment_id :integer -# - -one: - name: 'Object 1' - description: 'Testing' - -user_lo: - name: 'Object 1' - description: 'Testing' - author: 'Mauricio' - publisher: john (User) - -institution_lo: - name: 'Institution Object 1' - description: 'Testing' - author: 'Mauricio' - publisher: ufpr (Institution) - -lo_complete: - name: 'Institution Object 1' - description: 'Testing' - author: 'Mauricio' - id_dspace: '1' - object_type: image - language: portuguese - -lo_metadata: - name: 'Institution Object 1' - description: 'Testing' - author: 'Mauricio' - id_dspace: '2' - object_type: image - language: portuguese - metadata: '{"dc.creator": "ufpr"}' - -lo_metadata2: - name: 'Institution Object 2' - description: 'Testing' - author: 'Mauricio' - id_dspace: '3' - object_type: image - language: portuguese - metadata: '{"dc.creator": "ufpr"}' - -search: - name: 'Teste' - description: 'Testing' - author: 'Israel' - publisher: ufpr (Institution) - object_type: image diff --git a/test/fixtures/licenses.yml b/test/fixtures/licenses.yml deleted file mode 100644 index 23515d6e300e700b0ce4a8c8829746a189eadce4..0000000000000000000000000000000000000000 --- a/test/fixtures/licenses.yml +++ /dev/null @@ -1,32 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - name: MyString - description: MyText - url: MyString - image_url: MyString - -two: - name: MyString - description: MyText - url: MyString - image_url: MyString diff --git a/test/fixtures/mime_types.yml b/test/fixtures/mime_types.yml deleted file mode 100644 index 084c802612a63f0a9eea4a29ce43d85236e5b8af..0000000000000000000000000000000000000000 --- a/test/fixtures/mime_types.yml +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -jpg: - extension: '.jpg' - mime_type: 'image/jpg' - -mp4: - extension: '.mp4' - mime_type: 'video/mp4' diff --git a/test/fixtures/object_types.yml b/test/fixtures/object_types.yml deleted file mode 100644 index d7672dc694521cff6c4d25c414d11e8a695bf2a9..0000000000000000000000000000000000000000 --- a/test/fixtures/object_types.yml +++ /dev/null @@ -1,22 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -image: - name: 'Imagem' - mime_types: jpg (MimeType) diff --git a/test/fixtures/ratings.yml b/test/fixtures/ratings.yml deleted file mode 100644 index 1dbb1efb688a0f8f325833f1edf01f072fc782bf..0000000000000000000000000000000000000000 --- a/test/fixtures/ratings.yml +++ /dev/null @@ -1,27 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -usability: - name: 'usability' - -application_context: - name: 'application context' - -content: - name: 'content quality' \ No newline at end of file diff --git a/test/fixtures/review_ratings.yml b/test/fixtures/review_ratings.yml deleted file mode 100644 index 4507865151110d0060abec0a63d8a4b3d554bb84..0000000000000000000000000000000000000000 --- a/test/fixtures/review_ratings.yml +++ /dev/null @@ -1,49 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -one_collection_review_rating: - review: collection (Review) - rating: usability (Rating) - value: 5 - -two_collection_review_rating: - review: collection (Review) - rating: application_context (Rating) - value: 5 - -three_collection_review_rating: - review: collection (Review) - rating: content (Rating) - value: 5 - - -one_lo_review_rating: - review: learning_object (Review) - rating: usability (Rating) - value: 2 - -two_lo_review_rating: - review: learning_object (Review) - rating: application_context (Rating) - value: 3 - -three_lo_review_rating: - review: learning_object (Review) - rating: content (Rating) - value: 4 \ No newline at end of file diff --git a/test/fixtures/reviews.yml b/test/fixtures/reviews.yml deleted file mode 100644 index 53b151424a3cc82ca3fde98b6590f3f7b99b75ee..0000000000000000000000000000000000000000 --- a/test/fixtures/reviews.yml +++ /dev/null @@ -1,34 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -collection: - name: 'my collection review' - description: 'testing a review about collection' - pros: 'my pros' - cons: 'my cons' - reviewable: ufpr (Collection) - user: admin (User) - -learning_object: - name: 'my learning object review' - description: 'testing a review about learning object' - pros: 'my pros' - cons: 'my cons' - reviewable: user_lo (LearningObject) - user: admin (User) \ No newline at end of file diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml deleted file mode 100644 index b951e66576b7256dd44f9dc6da9d74c89e2aeb8a..0000000000000000000000000000000000000000 --- a/test/fixtures/roles.yml +++ /dev/null @@ -1,24 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -teacher: - name: 'teacher' - -admin: - name: 'admin' diff --git a/test/fixtures/score_user_categories.yml b/test/fixtures/score_user_categories.yml deleted file mode 100644 index 01506650b5fb65d8902df94ea0b8a05a541d0a01..0000000000000000000000000000000000000000 --- a/test/fixtures/score_user_categories.yml +++ /dev/null @@ -1,49 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: score_user_categories -# -# id :integer not null, primary key -# score_id :integer -# user_category_id :integer -# value :float -# created_at :datetime not null -# updated_at :datetime not null -# - -<% -values = [ - [ 0, 0, 0, 0, 0, 0, 0, 0, 0], # Iniciante - [ 25, 3.0, 10, 500, 250, 70, 50, 5, 400], # Novato - [ 50, 3.8, 20, 550, 350, 85, 250, 15, 600], # Amador - [ 100, 4.2, 40, 600, 450, 90, 1000, 25, 750], # Profissional - [ 250, 4.9, 80, 680, 550, 95, 5000, 35, 800] # Expert -] -%> - -<% 1.upto(values.first.size) do |i| %> - <% 1.upto(values.size) do |j| %> - <%= i %>_<%= j %>: - score: <%= i %> - user_category: <%= j %> - value: <%= values[j-1][i-1] %> - <% end %> -<% end %> diff --git a/test/fixtures/scores.yml b/test/fixtures/scores.yml deleted file mode 100644 index f6fc54e970bf8fc06662c37a34b00cbec44a2063..0000000000000000000000000000000000000000 --- a/test/fixtures/scores.yml +++ /dev/null @@ -1,172 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: scores -# -# id :integer not null, primary key -# name :string -# code :string -# weight :float -# active :boolean default("true") -# created_at :datetime not null -# updated_at :datetime not null -# score_type :string default("{}"), is an Array -# - -1: - name: 'Quantidade de envio de objetos' - code: 'submitted_objects' - weight: 4 - active: true - score_type: ['User'] - -2: - name: 'Avaliação média dos seus objetos' - code: 'reviews_score_average' - weight: 9 - active: true - score_type: ['User'] - -3: - name: 'Adições a coleções bem avaliadas' - code: 'learning_objects_in_best_collections' - weight: 7 - active: true - score_type: ['User'] - -4: - name: 'Melhor score' - code: 'learning_objects_best_score' - weight: 3 - active: true - score_type: ['User'] - -5: - name: 'Score médio' - code: 'learning_objects_average_score' - weight: 7 - active: true - score_type: ['User'] - -6: - name: 'Aprovação das avaliações em objetos de terceiros (% de sim)' - code: 'review_approval_average' - weight: 10 - active: true - score_type: ['User'] - -# reputation_confirmed_complaints: -# name: 'Denúncias confirmadas' -# code: 'reputation_confirmed_complaints' -# weight: 0 -# active: true -# score_type: ['User'] - -7: - name: 'Quantidade de seguidores' - code: 'followers_count' - weight: 6 - active: true - score_type: ['User'] - -8: - name: 'Submissões recentes' - code: 'learning_objects_recently_submitted' - weight: 4 - active: true - score_type: ['User'] - -9: - name: 'Score das coleções públicas' - code: 'collections_score_average' - weight: 3 - active: true - score_type: ['User'] - -10: - name: 'Média das avaliações' - code: 'normalized_review_average' - weight: 10 - active: true - score_type: ['LearningObject', 'Collection'] - -11: - name: 'Thumbnail' - code: 'normalized_thumbnail' - weight: 3 - active: true - score_type: ['LearningObject', 'Collection'] - -12: - name: 'Quantidade de visualizações' - code: 'normalized_views' - weight: 3 - active: true - score_type: ['LearningObject', 'Collection'] - -13: - name: 'Quantidade de likes' - code: 'normalized_likes' - weight: 3 - active: true - score_type: ['LearningObject', 'Collection'] - -14: - name: 'Quantidade de downloads' - code: 'normalized_downloads' - weight: 3 - active: true - score_type: ['LearningObject', 'Collection'] - -15: - name: 'Quantidade de compartilhamento' - code: 'normalized_shares' - weight: 2 - active: true - score_type: ['LearningObject', 'Collection'] - -16: - name: 'Descrição' - code: 'normalized_description' - weight: 2 - active: true - score_type: ['LearningObject', 'Collection'] - -17: - name: 'Categoria do usuário criador' - code: 'user_category' - weight: 7 - active: true - score_type: ['LearningObject', 'Collection'] - -18: - name: 'Adições à coleções' - code: 'normalized_collected' - weight: 4 - active: true - score_type: ['LearningObject', 'Collection'] - -score_19: - name: 'Adições à favoritos' - code: 'normalized_bookmarked' - weight: 6 - active: true - score_type: ['LearningObject', 'Collection'] \ No newline at end of file diff --git a/test/fixtures/subjects.yml b/test/fixtures/subjects.yml deleted file mode 100644 index 294f9e54cbe438969067b59613e7b1fc0599a77e..0000000000000000000000000000000000000000 --- a/test/fixtures/subjects.yml +++ /dev/null @@ -1,21 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -subject_one: - name: 'teste' diff --git a/test/fixtures/taggings.yml b/test/fixtures/taggings.yml deleted file mode 100644 index 1f670e4ae6ff7939c3a3e7bfa5e73e75e1c5d680..0000000000000000000000000000000000000000 --- a/test/fixtures/taggings.yml +++ /dev/null @@ -1,38 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -tagging_one: - tag: tag_one - tagger: john (User) - taggable: ufpr (Collection) - -tagging_two: - tag: tag_one - tagger: jack (User) - taggable: one (LearningObject) - -tagging_three: - tag: tag_two - tagger: ufpr (Institution) - taggable: ufpr (Collection) - -tagging_four: - tag: tag_two - tagger: ufpr (Institution) - taggable: search (LearningObject) \ No newline at end of file diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml deleted file mode 100644 index 4937b2a429c1579b6006680f7cbbcd5b643ca5f3..0000000000000000000000000000000000000000 --- a/test/fixtures/tags.yml +++ /dev/null @@ -1,25 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -tag_one: - name: 'Português' -tag_two: - name: 'Matemática' -tag_three: - name: 'Biologia' \ No newline at end of file diff --git a/test/fixtures/user_categories.yml b/test/fixtures/user_categories.yml deleted file mode 100644 index 1ab7cb19c8c7052d72ecf463834c40cb9004863b..0000000000000000000000000000000000000000 --- a/test/fixtures/user_categories.yml +++ /dev/null @@ -1,49 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: user_categories -# -# id :integer not null, primary key -# name :string -# reference :float -# created_at :datetime not null -# updated_at :datetime not null -# - -1: - name: 'Iniciante' - reference: 0.0 - -2: - name: 'Novato' - reference: 0.408919891329286 - -3: - name: 'Amador' - reference: 0.558910604053845 - -4: - name: 'Profissional' - reference: 0.708149893070887 - -5: - name: 'Expert' - reference: 1.0 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml deleted file mode 100644 index b4d1a1d4fe49328bc254af218aa7fbc09920df0f..0000000000000000000000000000000000000000 --- a/test/fixtures/users.yml +++ /dev/null @@ -1,37 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -john: - name: 'John' - email: 'john@test.com' - confirmed_at: '2015-10-10 15:30:22' - -jack: - name: 'Jack' - email: 'jack@rackan.com' - confirmed_at: '2015-10-10 15:30:22' - -one: - name: 'John' - email: 'john@test1.com' - -admin: - name: 'Admin' - email: 'admin@admin.com' - roles: admin diff --git a/test/helpers/.keep b/test/helpers/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/integration/.keep b/test/integration/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/mailers/.keep b/test/mailers/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/models/.keep b/test/models/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/models/application_test.rb b/test/models/application_test.rb deleted file mode 100644 index da2a27f28f74a82ef12f6840fbcbc63d4ede1e29..0000000000000000000000000000000000000000 --- a/test/models/application_test.rb +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class ApplicationTest < ActiveSupport::TestCase - should belong_to :user - should validate_presence_of(:domain) - should validate_presence_of(:application_id) -end diff --git a/test/models/bookmark_test.rb b/test/models/bookmark_test.rb deleted file mode 100644 index 416bc02032f8a491f9ffb27382889ea0d286ad7e..0000000000000000000000000000000000000000 --- a/test/models/bookmark_test.rb +++ /dev/null @@ -1,43 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: bookmarks -# -# id :integer not null, primary key -# user_id :integer -# bookmarkable_id :integer -# bookmarkable_type :string -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class BookmarkTest < ActiveSupport::TestCase - should belong_to(:user).counter_cache(true) - should belong_to(:bookmarkable) - - should validate_presence_of(:user) - should validate_presence_of(:bookmarkable) - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user_id).scoped_to([:bookmarkable_id, :bookmarkable_type]).case_insensitive -end diff --git a/test/models/carousel_test.rb b/test/models/carousel_test.rb deleted file mode 100644 index f05dbb41de51139b0942254d08c5f9c11b50a6a0..0000000000000000000000000000000000000000 --- a/test/models/carousel_test.rb +++ /dev/null @@ -1,41 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: carousels -# -# id :integer not null, primary key -# title :string -# url :text -# created_at :datetime not null -# updated_at :datetime not null -# image_file_name :string -# image_content_type :string -# image_file_size :integer -# image_updated_at :datetime -# - -require 'test_helper' - -class CarouselTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/collection_item_test.rb b/test/models/collection_item_test.rb deleted file mode 100644 index 2f51b589ae374f0e0acb1d10102b8a632fc92548..0000000000000000000000000000000000000000 --- a/test/models/collection_item_test.rb +++ /dev/null @@ -1,41 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: collection_items -# -# id :integer not null, primary key -# collectionable_id :integer -# collectionable_type :string -# collection_id :integer -# order :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class CollectionItemTest < ActiveSupport::TestCase - should belong_to :collection - should belong_to :collectionable - - should validate_presence_of(:collection) - should validate_presence_of(:collectionable) -end diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb deleted file mode 100644 index f12719030c19974dfa9f2bb796d20a325a5c8625..0000000000000000000000000000000000000000 --- a/test/models/collection_test.rb +++ /dev/null @@ -1,86 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: collections -# -# id :integer not null, primary key -# name :string -# description :text -# privacy :string default("private") -# owner_id :integer -# owner_type :string -# created_at :datetime not null -# updated_at :datetime not null -# views_count :integer default("0") -# downloads_count :integer default("0") -# likes_count :integer default("0") -# shares_count :integer default("0") -# score :float default("0.0") -# follows_count :integer default("0") -# thumbnail_file_name :string -# thumbnail_content_type :string -# thumbnail_file_size :integer -# thumbnail_updated_at :datetime -# - -require 'test_helper' - -class CollectionTest < ActiveSupport::TestCase - should have_many :collection_items - should have_many(:collections).through(:collection_items).source(:collectionable) - should have_many(:learning_objects).through(:collection_items).source(:collectionable) - - should belong_to :owner - - should validate_presence_of(:name) - should validate_presence_of(:owner) - should validate_inclusion_of(:privacy).in_array(%w(public private)).with_message('Privacy must be public or private') - - #sociable - should have_many :views - should have_many :downloads - should have_many :likes - should have_many :shares - - #taggable - should have_many :taggings - should have_many(:tags).through(:taggings) - - include ::Portalmec::SociableTests - - test 'should get all collections created this week' do - Collection.this_week.each {|o| assert_instance_of Collection, o} - end - - test 'should get all collections created this month' do - Collection.this_month.each {|o| assert_instance_of Collection, o} - end - - protected - - def sociable_object - collections(:ufpr) - end - - def sociable_user - users(:john) - end -end diff --git a/test/models/complaint_reason_test.rb b/test/models/complaint_reason_test.rb deleted file mode 100644 index 1356a995349902f34670c55acc61c0b9edd702a0..0000000000000000000000000000000000000000 --- a/test/models/complaint_reason_test.rb +++ /dev/null @@ -1,36 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: complaint_reasons -# -# id :integer not null, primary key -# reason :text -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ComplaintReasonTest < ActiveSupport::TestCase - should have_many(:complaints) - - should validate_presence_of(:reason) -end diff --git a/test/models/complaint_test.rb b/test/models/complaint_test.rb deleted file mode 100644 index cbfdde9ea368e1beeca46ea2d06ec9832af62bd5..0000000000000000000000000000000000000000 --- a/test/models/complaint_test.rb +++ /dev/null @@ -1,48 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: complaints -# -# id :integer not null, primary key -# description :text -# user_id :integer -# complainable_id :integer -# complainable_type :string -# complaint_reason_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ComplaintTest < ActiveSupport::TestCase - should belong_to :complaint_reason - should belong_to :user - should belong_to :complainable - - should validate_presence_of(:user) - should validate_presence_of(:complainable) - should validate_presence_of(:description) - should validate_presence_of(:complaint_reason) - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user_id).scoped_to([:complaintable_id, :complaintable_type]).case_insensitive -end diff --git a/test/models/download_test.rb b/test/models/download_test.rb deleted file mode 100644 index 08c4d084b8a40ce69db6fbd00e62ad9d606dd541..0000000000000000000000000000000000000000 --- a/test/models/download_test.rb +++ /dev/null @@ -1,40 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: downloads -# -# id :integer not null, primary key -# downloadable_id :integer -# downloadable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class DownloadTest < ActiveSupport::TestCase - should belong_to :user - should belong_to(:downloadable).counter_cache(true) - - should validate_presence_of(:user) - should validate_presence_of(:downloadable) -end diff --git a/test/models/follow_test.rb b/test/models/follow_test.rb deleted file mode 100644 index 73c93c0a5c820bd6613707a0967a7cab09f7c562..0000000000000000000000000000000000000000 --- a/test/models/follow_test.rb +++ /dev/null @@ -1,43 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: follows -# -# id :integer not null, primary key -# followable_id :integer -# followable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class FollowTest < ActiveSupport::TestCase - should belong_to :user - should belong_to(:followable).counter_cache(true) - - should validate_presence_of(:user) - should validate_presence_of(:followable) - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user_id).scoped_to([:followable_id, :followable_type]).case_insensitive -end diff --git a/test/models/institution_test.rb b/test/models/institution_test.rb deleted file mode 100644 index 5ca28aee668aa4720ff3b379fa7329263d6f5841..0000000000000000000000000000000000000000 --- a/test/models/institution_test.rb +++ /dev/null @@ -1,42 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: institutions -# -# id :integer not null, primary key -# name :string -# address :string -# city :string -# country :string -# description :text -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class InstitutionTest < ActiveSupport::TestCase - should have_and_belong_to_many :users - - should have_many :learning_objects - - should validate_presence_of(:name) -end diff --git a/test/models/language_test.rb b/test/models/language_test.rb deleted file mode 100644 index 6a1433625607ebac8b2bdb06397863806abe0d43..0000000000000000000000000000000000000000 --- a/test/models/language_test.rb +++ /dev/null @@ -1,40 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: languages -# -# id :integer not null, primary key -# name :string -# created_at :datetime not null -# updated_at :datetime not null -# code :string -# - -require 'test_helper' - -class LanguageTest < ActiveSupport::TestCase - should have_many :learning_objects - - should validate_presence_of(:name) - should validate_presence_of(:code) - - should validate_uniqueness_of(:code) -end diff --git a/test/models/learning_object/attachment_test.rb b/test/models/learning_object/attachment_test.rb deleted file mode 100644 index dcfe1b5591aa95b112e7f5bf9bf80436a0da98eb..0000000000000000000000000000000000000000 --- a/test/models/learning_object/attachment_test.rb +++ /dev/null @@ -1,48 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: learning_object_attachments -# -# id :integer not null, primary key -# name :string -# link :string -# retrieve_link :string -# description :text -# format :string -# mime_type :string -# size :integer -# bundle_name :string -# learning_object_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# id_dspace :integer -# thumbnail_file_name :string -# thumbnail_content_type :string -# thumbnail_file_size :integer -# thumbnail_updated_at :datetime -# cache_link :string -# - -require 'test_helper' - -class LearningObject::AttachmentTest < ActiveSupport::TestCase - should belong_to :learning_object -end diff --git a/test/models/learning_object_test.rb b/test/models/learning_object_test.rb deleted file mode 100644 index f7295e6a1191aad222765d024b039ce1c9314890..0000000000000000000000000000000000000000 --- a/test/models/learning_object_test.rb +++ /dev/null @@ -1,111 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: learning_objects -# -# id :integer not null, primary key -# id_dspace :integer -# name :string -# author :string -# description :text -# published_at :datetime -# score :float default("0.0") -# school_level :integer -# metadata :jsonb default("{}") -# keywords :text -# publisher_id :integer -# publisher_type :string -# object_type_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# views_count :integer default("0") -# downloads_count :integer default("0") -# likes_count :integer default("0") -# shares_count :integer default("0") -# state :string default("published") -# thumbnail_file_name :string -# thumbnail_content_type :string -# thumbnail_file_size :integer -# thumbnail_updated_at :datetime -# attachment_id :integer -# - -require 'test_helper' - -class LearningObjectTest < ActiveSupport::TestCase - - should have_many :collection_items - should have_many(:collections).through(:collection_items) - should have_many :complaints - should have_many(:attachments).class_name('LearningObject::Attachment') - - should belong_to :publisher - should have_and_belong_to_many :language - should belong_to(:attachment).class_name('LearningObject::Attachment') - should belong_to :object_type - - #sociable - should have_many :views - should have_many :downloads - should have_many :likes - should have_many :shares - - #taggable - should have_many :taggings - should have_many(:tags).through(:taggings) - - include ::Portalmec::SociableTests - - test 'should search data return a hash' do - learning_object = learning_objects(:lo_complete) - assert_equal learning_object.search_data, { - name: 'Institution Object 1', - description: 'Testing', - author: 'Mauricio', - object_type: 'Imagem', - score: learning_object.score, - published_at: learning_object.published_at, - tags: learning_object.tags.map(&:name), - subjects: learning_object.subjects.pluck(:id), - educational_stages: learning_object.educational_stages.pluck(:id), - source: nil, - state: LearningObject.states[learning_object.state] - } - end - - test 'should get all learning objects created this week' do - LearningObject.this_week.each { |o| assert_instance_of LearningObject, o } - end - - test 'should get all learning objects created this month' do - LearningObject.this_month.each { |o| assert_instance_of LearningObject, o } - end - - protected - - def sociable_object - learning_objects(:user_lo) - end - - def sociable_user - users(:john) - end -end diff --git a/test/models/license_test.rb b/test/models/license_test.rb deleted file mode 100644 index 3d0a691733766d23a0b3d5a413e1ffc4ffaec3b1..0000000000000000000000000000000000000000 --- a/test/models/license_test.rb +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class LicenseTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/like_test.rb b/test/models/like_test.rb deleted file mode 100644 index ec489f7299cd606d4c9ec73f6d60aa038b78ba8a..0000000000000000000000000000000000000000 --- a/test/models/like_test.rb +++ /dev/null @@ -1,43 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: likes -# -# id :integer not null, primary key -# likeable_id :integer -# likeable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class LikeTest < ActiveSupport::TestCase - should belong_to :user - should belong_to(:likeable).counter_cache(true) - - should validate_presence_of(:user) - should validate_presence_of(:likeable) - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user_id).scoped_to([:likeable_id, :likeable_type]).case_insensitive -end diff --git a/test/models/object_type_test.rb b/test/models/object_type_test.rb deleted file mode 100644 index 52e719b2a7e9ff8d4c9f67980a467e5f42832309..0000000000000000000000000000000000000000 --- a/test/models/object_type_test.rb +++ /dev/null @@ -1,35 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: object_types -# -# id :integer not null, primary key -# name :string -# - -require 'test_helper' - -class ObjectTypeTest < ActiveSupport::TestCase - should have_many :learning_objects - - should validate_presence_of(:name) - should validate_uniqueness_of(:name) -end diff --git a/test/models/rate_test.rb b/test/models/rate_test.rb deleted file mode 100644 index 1bc6d9ba00ba495b133eb9a23c4cfa2ac28406e2..0000000000000000000000000000000000000000 --- a/test/models/rate_test.rb +++ /dev/null @@ -1,46 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: rates -# -# id :integer not null, primary key -# approves :boolean -# user_id :integer -# review_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class RateTest < ActiveSupport::TestCase - should belong_to :user - should belong_to :review - - # TODO: need to stub review.user in cannot_rate_your_own method - # should validate_presence_of(:user) - # should validate_presence_of(:review) - # should validate_inclusion_of(:approves).in_array([true, false]) - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user).scoped_to(:review) - -end diff --git a/test/models/rating_test.rb b/test/models/rating_test.rb deleted file mode 100644 index e19beea2c18946a40233a792e667726e697b38f5..0000000000000000000000000000000000000000 --- a/test/models/rating_test.rb +++ /dev/null @@ -1,36 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: ratings -# -# id :integer not null, primary key -# name :string -# created_at :datetime not null -# updated_at :datetime not null -# description :string -# - -require 'test_helper' - -class RatingTest < ActiveSupport::TestCase - should have_many :review_ratings - should have_many(:reviews).through(:review_ratings) -end diff --git a/test/models/review_rating_test.rb b/test/models/review_rating_test.rb deleted file mode 100644 index d5ae313c76126d4f865f792d72ff6962c7617b04..0000000000000000000000000000000000000000 --- a/test/models/review_rating_test.rb +++ /dev/null @@ -1,43 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: review_ratings -# -# id :integer not null, primary key -# review_id :integer -# rating_id :integer -# value :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ReviewRatingTest < ActiveSupport::TestCase - should belong_to :review - should belong_to :rating - - should validate_presence_of(:rating) - should validate_inclusion_of(:value).in_array(Array(1..5)).with_message('Review Rating must be between 1 and 5.') - - # TODO: shoulda try to insert user with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:rating).scoped_to(:review_id) -end diff --git a/test/models/review_test.rb b/test/models/review_test.rb deleted file mode 100644 index 4e3174a569041a83972d417ad9bd8714ef5e2a48..0000000000000000000000000000000000000000 --- a/test/models/review_test.rb +++ /dev/null @@ -1,52 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: reviews -# -# id :integer not null, primary key -# name :string -# description :text -# pros :text -# cons :text -# reviewable_id :integer -# reviewable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# rates_count :integer default("0") -# - -require 'test_helper' - -class ReviewTest < ActiveSupport::TestCase - should have_many :review_ratings - should have_many(:ratings).through(:review_ratings) - should have_many :rates - - should have_many :complaints - - should belong_to :reviewable - should belong_to :user - - should validate_presence_of(:user) - should validate_presence_of(:reviewable) - should validate_inclusion_of(:reviewable_type).in_array(%w(LearningObject Collection)).with_message('Only LearningObjects and Collections are reviewable.') -end diff --git a/test/models/role_test.rb b/test/models/role_test.rb deleted file mode 100644 index 37a8c86196f8aaaf76c6e5b39851f846de83997d..0000000000000000000000000000000000000000 --- a/test/models/role_test.rb +++ /dev/null @@ -1,37 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: roles -# -# id :integer not null, primary key -# name :string -# description :text -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class RoleTest < ActiveSupport::TestCase - # should have_and_belong_to_many(:users) - # should validate_uniqueness_of(:name) - # should validate_presence_of(:name) -end diff --git a/test/models/score_test.rb b/test/models/score_test.rb deleted file mode 100644 index 55a5fa18fcdae57f45c717acc65769358c3bffad..0000000000000000000000000000000000000000 --- a/test/models/score_test.rb +++ /dev/null @@ -1,45 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: scores -# -# id :integer not null, primary key -# name :string -# code :string -# weight :float -# active :boolean default("true") -# created_at :datetime not null -# updated_at :datetime not null -# score_type :string default("{}"), is an Array -# - -require 'test_helper' - -class ScoreTest < ActiveSupport::TestCase - should have_many :score_user_categories - should have_many(:user_categories).through(:score_user_categories) - - should validate_presence_of(:name) - should validate_presence_of(:code) - should validate_presence_of(:weight) - - should validate_uniqueness_of(:code) -end diff --git a/test/models/score_user_category_test.rb b/test/models/score_user_category_test.rb deleted file mode 100644 index ed33dd21073a9e1801340f32e00829f491c42fa6..0000000000000000000000000000000000000000 --- a/test/models/score_user_category_test.rb +++ /dev/null @@ -1,44 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: score_user_categories -# -# id :integer not null, primary key -# score_id :integer -# user_category_id :integer -# value :float -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ScoreUserCategoryTest < ActiveSupport::TestCase - should belong_to :score - should belong_to :user_category - - should validate_presence_of(:score) - should validate_presence_of(:user_category) - should validate_presence_of(:value) - - # TODO: shoulda try to insert user_category with id 0, but that's non existent and not allowed by database - # should validate_uniqueness_of(:user_category).scoped_to(:score) -end diff --git a/test/models/search_test.rb b/test/models/search_test.rb deleted file mode 100644 index c538fb2de9e4609ec12158817d75d0166a444255..0000000000000000000000000000000000000000 --- a/test/models/search_test.rb +++ /dev/null @@ -1,33 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class SearchTest < ActiveSupport::TestCase - should validate_presence_of(:query) - should validate_presence_of(:results_per_page) - should validate_presence_of(:order) - should validate_presence_of(:search_class) - - test 'should validate search_class' do - search = Search.new(:search_class => 'invalid') - assert_not search.valid? - end - -end diff --git a/test/models/share_test.rb b/test/models/share_test.rb deleted file mode 100644 index 4f44835d077c255409fcf31942eabe321725559f..0000000000000000000000000000000000000000 --- a/test/models/share_test.rb +++ /dev/null @@ -1,40 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: shares -# -# id :integer not null, primary key -# shareable_id :integer -# shareable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ShareTest < ActiveSupport::TestCase - should belong_to :user - should belong_to(:shareable).counter_cache(true) - - should validate_presence_of(:user) - should validate_presence_of(:shareable) -end diff --git a/test/models/stage_relation_test.rb b/test/models/stage_relation_test.rb deleted file mode 100644 index 83807d20e6f298f80f3b983c29ec030eeab49fda..0000000000000000000000000000000000000000 --- a/test/models/stage_relation_test.rb +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class StageRelationTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/subject_test.rb b/test/models/subject_test.rb deleted file mode 100644 index 6fbc6c71ac359b6d809df3f433ceb9f07c84cd18..0000000000000000000000000000000000000000 --- a/test/models/subject_test.rb +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class SubjectTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/tag_test.rb b/test/models/tag_test.rb deleted file mode 100644 index 65dc09cc2dedac8f835b7065b5a7520374471810..0000000000000000000000000000000000000000 --- a/test/models/tag_test.rb +++ /dev/null @@ -1,67 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class TagTest < ActiveSupport::TestCase - should have_many :taggings - should validate_presence_of :name - - test 'an user can tag a learning object' do - john = users(:john) - lo = learning_objects(:one) - assert john.tag(lo, with: ['Tag']) - - # check lo_one tags - assert_count 2, lo.tags - assert_count 2, john.taggings - end - - test 'an user can untag a learning object' do - john = users(:john) - lo = learning_objects(:one) - assert john.untag(lo, 'Tag') - - # check lo_one tags - assert_count 1, lo.tags - assert_count 1, john.taggings - end - - test 'an user can tag a collection' do - john = users(:john) - collection = collections(:ufpr) - assert john.tag(collection, with: ['Tag']) - - # check ufpr tags - assert_count 3, collection.tags - assert_count 2, john.taggings - end - - test 'an user can untag a collection' do - john = users(:john) - collection = collections(:ufpr) - assert john.untag(collection, 'Tag') - - # check ufpr tags - assert_count 2, collection.tags - assert_count 1, john.taggings - end - - -end diff --git a/test/models/tagging_test.rb b/test/models/tagging_test.rb deleted file mode 100644 index 87cb4e6f977467d66a75e77923113583dde1c860..0000000000000000000000000000000000000000 --- a/test/models/tagging_test.rb +++ /dev/null @@ -1,26 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class TaggingTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/user_category_test.rb b/test/models/user_category_test.rb deleted file mode 100644 index 9b3d0f9bca6b4accc6d15b984c38c929f78d4b06..0000000000000000000000000000000000000000 --- a/test/models/user_category_test.rb +++ /dev/null @@ -1,39 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: user_categories -# -# id :integer not null, primary key -# name :string -# reference :float -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class UserCategoryTest < ActiveSupport::TestCase - should have_many :score_user_categories - should have_many(:scores).through(:score_user_categories) - - should validate_presence_of(:name) - should validate_uniqueness_of(:name) -end diff --git a/test/models/user_test.rb b/test/models/user_test.rb deleted file mode 100644 index 0904c45dee95647c2b51b3f97c8bc77ff57d5400..0000000000000000000000000000000000000000 --- a/test/models/user_test.rb +++ /dev/null @@ -1,114 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: users -# -# id :integer not null, primary key -# email :string default(""), not null -# encrypted_password :string default(""), not null -# reset_password_token :string -# reset_password_sent_at :datetime -# remember_created_at :datetime -# sign_in_count :integer default("0"), not null -# current_sign_in_at :datetime -# last_sign_in_at :datetime -# current_sign_in_ip :string -# last_sign_in_ip :string -# created_at :datetime not null -# updated_at :datetime not null -# provider :string default("email"), not null -# uid :string default(""), not null -# confirmation_token :string -# confirmed_at :datetime -# confirmation_sent_at :datetime -# unconfirmed_email :string -# tokens :text -# name :string -# avatar_file_name :string -# avatar_content_type :string -# avatar_file_size :integer -# avatar_updated_at :datetime -# bookmarks_count :integer default("0") -# user_category_id :integer -# score :float default("0.0") -# follows_count :integer default("0") -# - -require 'test_helper' - -class UserTest < ActiveSupport::TestCase - should have_and_belong_to_many(:roles) - should have_and_belong_to_many(:institutions) - - should have_many :bookmarks - should have_many(:bookmark_collections).through(:bookmarks).source(:bookmarkable) - should have_many(:bookmark_learning_objects).through(:bookmarks).source(:bookmarkable) - should have_many :taggings - should have_many :collections - should have_many :learning_objects - should have_many :views - should have_many :downloads - should have_many :likes - should have_many :shares - should have_many :follows - should have_many :reviews - should have_many :applications - - test 'an user can follow another user' do - john = users(:john) - jack = users(:jack) - assert john.follow(jack) - - # check jack followers - assert_count 1, jack.followers - assert_count 1, john.follows - assert john.following? jack - end - - test 'an user can follow a collection' do - john = users(:john) - ufpr_collection = collections(:ufpr) - assert john.follow(ufpr_collection) - - # check ufpr followers - assert_count 1, ufpr_collection.followers - assert_count 1, john.follows - assert john.following? ufpr_collection - end - - test 'an user can unfollow a collection' do - john = users(:john) - ufpr_collection = collections(:ufpr) - assert john.follow(ufpr_collection) - - # check ufpr followers - assert_count 1, ufpr_collection.followers - assert_count 1, john.follows - assert john.following? ufpr_collection - - john.unfollow(ufpr_collection) - - # check ufpr followers - assert_count 0, ufpr_collection.followers - assert_count 0, john.follows - assert_not john.following? ufpr_collection - end -end diff --git a/test/models/view_test.rb b/test/models/view_test.rb deleted file mode 100644 index fdf88a6e0697674c76697aac656d3ba86da406cc..0000000000000000000000000000000000000000 --- a/test/models/view_test.rb +++ /dev/null @@ -1,40 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -# == Schema Information -# -# Table name: views -# -# id :integer not null, primary key -# viewable_id :integer -# viewable_type :string -# user_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# - -require 'test_helper' - -class ViewTest < ActiveSupport::TestCase - should belong_to :user - should belong_to(:viewable).counter_cache(true) - - should validate_presence_of(:user) - should validate_presence_of(:viewable) -end diff --git a/test/services/feedback_service_test.rb b/test/services/feedback_service_test.rb deleted file mode 100644 index f84a200f0a8d73a0beaf4b4677bfb0eb9e8435a3..0000000000000000000000000000000000000000 --- a/test/services/feedback_service_test.rb +++ /dev/null @@ -1,40 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class FeedbackServiceTest < ActiveSupport::TestCase - PORTALMEC_PROJECT_ID = 633 - mock = MiniTest::Mock.new - report_service = GitlabBugreporterService.new(mock) - feedback = FeedbackService.new(report_service) - - test 'initializing bug reporter service' do - assert_equal feedback.get_report_service, report_service - end - - test 'reporting bug' do - bug = Bug.new - bug.title = 'Título' - bug.description = 'Descrição do bug' - - mock.expect(:create_issue, nil, [PORTALMEC_PROJECT_ID, bug.title, description: bug.description]) - assert feedback.report_bug(bug) - end -end diff --git a/test/services/institution_importer_test.rb b/test/services/institution_importer_test.rb deleted file mode 100644 index ca3668c25d4b1235cfad5eaba9f79e20fc6261b9..0000000000000000000000000000000000000000 --- a/test/services/institution_importer_test.rb +++ /dev/null @@ -1,49 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class InstitutionImporterTest < ActiveSupport::TestCase - - test 'importing learning object with metadata publisher = nil' do - importer = InstitutionImporter.new() - lo = learning_objects(:lo_complete) - importer.items = [lo] - importer.import - assert_not_nil Institution.find_by_name(lo.publisher.name) - end - - test 'importing learning object with metadata publisher != nil' do - importer = InstitutionImporter.new() - lo = learning_objects(:lo_metadata) - importer.items = [lo] - importer.import - assert_not_nil Institution.find_by_name(lo.publisher.name) - end - - test 'importing learning object with institution that already exists' do - importer = InstitutionImporter.new() - lo1 = learning_objects(:lo_metadata) - lo2 = learning_objects(:lo_metadata2) - importer.items = [lo1, lo2] - importer.import - assert_equal Institution.find_by_name(lo1.publisher.name), Institution.find_by_name(lo2.publisher.name) - end - -end diff --git a/test/services/score_calculator_service_test.rb b/test/services/score_calculator_service_test.rb deleted file mode 100644 index 35f3b761376ef97357b546ea873e5ed8d2b8bd3d..0000000000000000000000000000000000000000 --- a/test/services/score_calculator_service_test.rb +++ /dev/null @@ -1,64 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class ScoreCalculatorServiceTest < ActiveSupport::TestCase - - test 'reputation calculation' do - hash_stub = { - 'submitted_objects': 60, - 'reviews_score_average': 4.8, - 'learning_objects_in_best_collections': 4, - 'learning_objects_best_score': 736, - 'learning_objects_average_score': 680, - 'review_approval_average': 98, - 'followers_count': 300, - 'learning_objects_recently_submitted': 5, - 'collections_score_average': 700 - } - - calculator = ScoreCalculatorService.new(users(:one)) - - calculator.stub :object_hash, hash_stub do - assert_equal 0.677361, calculator.calculate - end - end - - test 'score calculation' do - hash_stub = { - 'normalized_review_average': (5.0 / 5.0), - 'normalized_thumbnail': 1, - 'normalized_views': 0.1, - 'normalized_likes': 0.9311, - 'normalized_downloads': 0.125, - 'normalized_shares': 0.1, - 'normalized_description': 1, - 'user_category': (3.0 / 5.0), - 'normalized_collected': 0.5, - 'normalized_bookmarked': 0.56 - } - - calculator = ScoreCalculatorService.new(learning_objects(:one)) - - calculator.stub :object_hash, hash_stub do - assert_equal 0.656472, calculator.calculate - end - end -end \ No newline at end of file diff --git a/test/services/search_service_test.rb b/test/services/search_service_test.rb deleted file mode 100644 index 5368c211cf871df36b3e65ed3d1ecc76ad548c34..0000000000000000000000000000000000000000 --- a/test/services/search_service_test.rb +++ /dev/null @@ -1,100 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -require 'test_helper' - -class SearchServiceTest < ActiveSupport::TestCase - test 'fetch learning object with all search params' do - reindex LearningObject - - search = SearchService.search(Search.new(los_complete_search), users(:john)) - search.each {|o| assert_instance_of LearningObject, o} - end - - test 'fetch all public collections' do - reindex Collection - - search = SearchService.search(Search.new(collections_search), users(:john)) - search.each {|o| assert_instance_of Collection, o} - end - - test 'fetch users named john' do - reindex User - - search = SearchService.search(Search.new(users_john_search), users(:john)) - assert_equal [users(:john), users(:one)], search - end - - test 'autocomplete users named john' do - reindex User - - search = SearchService.autocomplete(Search.new(users_john), users(:john)) - assert_equal users_autocomplete_hashes([users(:john), users(:one)]), search - end - - private - - def los_complete_search - default_params.merge( - query: 'teste', - search_class: 'LearningObject', - tags: 'Matemática', - types: 'Imagem' - ) - end - - def collections_search - default_params.merge(search_class: 'Collection') - end - - def users_john_search - default_params.merge(users_john) - end - - def users_john - { - query: 'John', - search_class: 'User' - } - end - - def default_params - { - page: 1, - results_per_page: 10, - order: 'score' - } - end - - def reindex(klass) - klass.reindex - klass.searchkick_index.refresh - end - - def users_autocomplete_hashes(users = []) - users.map do |user| - { - id: user.id, - name: user.name, - type: 'User', - thumbnail: user.avatar.url(:thumb) - } - end - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index eb89f935e35ef4ea570f0f86798c242dc12441d4..0000000000000000000000000000000000000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,64 +0,0 @@ - -# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre -# Departamento de Informatica - Universidade Federal do Parana -# -# This file is part of portalmec. -# -# portalmec is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# portalmec is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with portalmec. If not, see <http://www.gnu.org/licenses/>. - -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' -require 'minitest/mock' -require 'minitest/reporters' - -# disable public activity gem for testing purpouses -require 'public_activity/testing' - -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # load seeds - # Rails.application.load_seed - - # Add more helper methods to be used by all tests here... - - def assert_count(expected, actual = 0) - assert_equal expected.to_i, actual.count - end - - # authenticate requests using devise_token_auth - def auth_request(user) - auth_application - sign_in user - @request.headers.merge!(user.create_new_auth_token) - end - - def auth_application - @request.headers['PortalMEC-AppID'] = applications(:test_app).application_id - end - - def mock - MiniTest::Mock.new - end - - # config.after :all do - # ActiveRecord::Base.subclasses.each(&:delete_all) - # end - - Minitest::Reporters.use! - - PublicActivity.enabled = false -end