diff --git a/.gitignore b/.gitignore index 8046438f921cc0a67d6bc5669f2f65ca132a96e5..05b8fd85d331fa539da4cad93551ce90f9fdb16d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ Gemfile.lock /public/assets /config/orientdb.yml /config/dspace.yml + # ignore server scripts puma.sh start_puma.sh @@ -30,3 +31,7 @@ portalmec.service portalmec-sidekiq.service sidekiq.sh autocomplete-server.service + +# ignore configs +/config/database.yml +/config/sidekiq.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f5a273dd3aff2a1278261d9d2f99ffdbf727d0c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM ruby:2.2.0 +RUN apt-get update -qq && apt-get install -y build-essential nodejs + +RUN mkdir /app + +WORKDIR /tmp +COPY Gemfile Gemfile +COPY Gemfile.lock Gemfile.lock +RUN bundle install -j 3 + +WORKDIR /app + +CMD ["rails", "server", "-b", "0.0.0.0"] diff --git a/Gemfile b/Gemfile index 507850a0fb87fe7f1e4a705c0928c73f860d024e..dd32613bb91cf343d5cefea2cdf7531f8add1c54 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.5.1' +gem 'rails', '4.2.6' # Use postgresql as the database for Active Record gem 'pg' # Use SCSS for stylesheets @@ -90,6 +90,8 @@ gem 'stackprof' gem 'font-awesome-rails' group :development do + gem 'annotate' + gem 'immigrant' # mute assets in log @@ -126,6 +128,7 @@ end group :test do gem 'shoulda' + gem 'minitest-reporters' end gem 'streamio-ffmpeg', '~> 1.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index b62bcf9210790bae96ccc68e9b49277f74c4d477..36a29235253aae55ec171f2ee179c8789645a866 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,47 +1,48 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5.1) - actionpack (= 4.2.5.1) - actionview (= 4.2.5.1) - activejob (= 4.2.5.1) + actionmailer (4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5.1) - actionview (= 4.2.5.1) - activesupport (= 4.2.5.1) + actionpack (4.2.6) + actionview (= 4.2.6) + activesupport (= 4.2.6) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5.1) - activesupport (= 4.2.5.1) + actionview (4.2.6) + activesupport (= 4.2.6) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5.1) - activesupport (= 4.2.5.1) + activejob (4.2.6) + activesupport (= 4.2.6) globalid (>= 0.3.0) - activemodel (4.2.5.1) - activesupport (= 4.2.5.1) + activemodel (4.2.6) + activesupport (= 4.2.6) builder (~> 3.1) - activerecord (4.2.5.1) - activemodel (= 4.2.5.1) - activesupport (= 4.2.5.1) + activerecord (4.2.6) + activemodel (= 4.2.6) + activesupport (= 4.2.6) arel (~> 6.0) activerecord-import (0.12.0) activerecord (>= 3.0) - activesupport (4.2.5.1) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) + ansi (1.5.0) arel (6.0.3) ast (2.2.0) - autoprefixer-rails (6.3.3.1) + autoprefixer-rails (6.3.4) execjs axiom-types (0.1.1) descendants_tracker (~> 0.0.4) @@ -175,7 +176,7 @@ GEM dm-core (~> 1.2.0) do_sqlite3 (0.10.17) data_objects (= 0.10.17) - dspace_rest_client (2.2.5) + dspace_rest_client (2.2.6) activesupport (~> 4.2, >= 4.2.0) faraday (~> 0.9.2) json (~> 1.8, >= 1.8.3) @@ -265,6 +266,11 @@ GEM rake mini_portile2 (2.0.0) minitest (5.8.4) + minitest-reporters (1.1.8) + ansi + builder + minitest (>= 5.0) + ruby-progressbar multi_json (1.11.2) multi_xml (0.5.5) multipart-post (2.0.0) @@ -310,7 +316,7 @@ GEM pg (0.18.4) phantomjs (2.1.1.0) ptools (1.3.3) - puma (3.1.0) + puma (3.2.0) pundit (1.1.0) activesupport (>= 3.0.0) quiet_assets (1.1.0) @@ -323,16 +329,16 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.5.1) - actionmailer (= 4.2.5.1) - actionpack (= 4.2.5.1) - actionview (= 4.2.5.1) - activejob (= 4.2.5.1) - activemodel (= 4.2.5.1) - activerecord (= 4.2.5.1) - activesupport (= 4.2.5.1) + rails (4.2.6) + actionmailer (= 4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) + activemodel (= 4.2.6) + activerecord (= 4.2.6) + activesupport (= 4.2.6) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5.1) + railties (= 4.2.6) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -342,14 +348,14 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.5.1) - actionpack (= 4.2.5.1) - activesupport (= 4.2.5.1) + railties (4.2.6) + actionpack (= 4.2.6) + activesupport (= 4.2.6) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.1.0) rake (11.1.1) - rake-compiler (0.9.6) + rake-compiler (0.9.7) rake rdoc (4.2.2) json (~> 1.4) @@ -359,13 +365,14 @@ GEM parser (~> 2.3, >= 2.3.0.6) rainbow (~> 2.0) ref (2.0.0) - resource_kit (0.1.4) + resource_kit (0.1.5) addressable (~> 2.3.6) - responders (2.1.1) + responders (2.1.2) railties (>= 4.2.0, < 5.1) resumablejs-rails (1.1) railties (> 3.1, < 5) rmagick (2.15.4) + ruby-progressbar (1.7.5) ruby2ruby (2.3.0) ruby_parser (~> 3.1) sexp_processor (~> 4.0) @@ -504,6 +511,7 @@ DEPENDENCIES meta-tags mimemagic mina + minitest-reporters omniauth-facebook omniauth-google-oauth2 omniauth-twitter @@ -514,7 +522,7 @@ DEPENDENCIES quiet_assets rack-cors rack-mini-profiler - rails (= 4.2.5.1) + rails (= 4.2.6) rainbow rdoc resumablejs-rails diff --git a/README.md b/README.md index 39badc22b6abec3a8bf9c33cc007812125df8927..e601b62d932b21da1b00610250c070ec666ff8c1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ After this setup, open the config files and update some vars: * config/initializers/gitlab.rb: change your gitlab host for bug reports and set env var with private token. ( $ export GITLAB_PORTALMEC_PRIVATE_TOKEN=131237128937128937 ) ### Development environment + + #### Using docker for development env + You can use docker for your development environment. For that, run: + ``` ./bin/docker-setup ``` + Now, redis, elasticsearch and postgres are running as services and linked to PortalMEC application. Database migrations were execute and the configs (database.yml, sidekiq.yml was replaced by config/docker/...). + If all development and test vars are set, run: ``` ./bin/setup ``` This command will install the rubygems, create/reset your database schema, seed some default data and import all dspace data. @@ -25,7 +31,7 @@ This command will install the rubygems, create/reset your database schema, seed After this, your application is ready to use and you can access it with: ``` bundle exec rails s ``` -### Test environment +### Running tests suite For tests, TestUnit is used, and to run it: ``` bundle exec rake test ``` diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index fd8ca3a098e7745f3b1dbaf67f006f3e7cdaed41..67a16f0f3e9cdd8f39ee7ab3c28d62008e380126 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -56,7 +56,7 @@ class CollectionsController < ApplicationController # POST /collections.json def create @collection = Collection.new(collection_params) - @collection.owner = current_user if collection_params[:owner].blank? + @collection.owner = params[:collection][:owner].blank? ? current_user : Institution.find(params[:collection][:owner]) respond_to do |format| if @collection.save @@ -117,14 +117,14 @@ class CollectionsController < ApplicationController def me @new_collection = Collection.new - @publishers = publishers_for current_user + @publishers = current_user.institutions @bookmark = (current_user.bookmarks.nil? || current_user.bookmarks.first.nil?) ? [] : [current_user.bookmarks.first] @groups = [ CollectionsGroup.new(title: 'Coleções Automáticas', collections: @bookmark ), CollectionsGroup.new(title: 'Coleções Adicionadas', - collections: current_user.collections.includes(:owner)) + collections: current_user.associated_collections) ] end @@ -132,12 +132,12 @@ class CollectionsController < ApplicationController # POST /collections/1/learning_object def add_learning_object @collections.each do |collection| - if collection.owner?(current_user) - @learning_objects.each do |learning_object| - collection.learning_objects << learning_object - end - collection.save + next unless collection.owner?(current_user) + + @learning_objects.each do |learning_object| + collection.learning_objects << learning_object end + collection.save end render json: { status: true } if request.xhr? @@ -146,12 +146,12 @@ class CollectionsController < ApplicationController # DELETE /collections/1/learning_object def remove_learning_object @collections.each do |collection| - if collection.owner?(current_user) - @learning_objects.each do |learning_object| - collection.learning_objects.destroy(learning_object) - end - collection.save + next unless collection.owner?(current_user) + + @learning_objects.each do |learning_object| + collection.learning_objects.destroy(learning_object) end + collection.save end render json: { status: true } if request.xhr? @@ -195,17 +195,9 @@ class CollectionsController < ApplicationController end end - def publishers_for(user) - user_new = Institution.new() - user_new.id = user.id - user_new.name = user.name - - [user_new] + user.institutions - end - # Never trust parameters from the scary internet, only allow the white list through. def collection_params - params.require(:collection).permit(:name, :description, :owner, learning_objects: []) + params.require(:collection).permit(:name, :description, learning_objects: []) end def user_not_authorized diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index de19b6ff8bbc4a8c49a829b0a38605bfebd744ad..548b3ddc2a2fc9100f01475449af7ea34ba4aeaa 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Bookmark < ActiveRecord::Base belongs_to :user, counter_cache: true belongs_to :bookmarkable, polymorphic: true diff --git a/app/models/carousel.rb b/app/models/carousel.rb index e8a81d995ee3d9d870b2e3915ac5032f5cc35ab6..e44675b5c95350bc06b265bc90645b9c75812bd9 100644 --- a/app/models/carousel.rb +++ b/app/models/carousel.rb @@ -1,3 +1,18 @@ +# == 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 +# + class Carousel < ActiveRecord::Base has_attached_file :image, styles: { larger: "600x600>", diff --git a/app/models/collection.rb b/app/models/collection.rb index 1eab50e15dea07141b6e6ead2f94fa1a39ccafc2..b9fd656e24f2e2109d36a8536304787941063cd2 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,3 +1,27 @@ +# == 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 +# + class Collection < ActiveRecord::Base include Reviewable include Sociable diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb index 5aba4c6d945baf546d28cde15fd3060dbd811353..aa4659532dd1ae8cf63b4b06148565f088bfebf5 100644 --- a/app/models/collection_item.rb +++ b/app/models/collection_item.rb @@ -1,3 +1,16 @@ +# == 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 +# + class CollectionItem < ActiveRecord::Base belongs_to :collection diff --git a/app/models/complaint.rb b/app/models/complaint.rb index 7011367cc74df24a87e8392141dc69036a8c4f9c..a8f3567cf163bdaec30b13677476e16385875969 100644 --- a/app/models/complaint.rb +++ b/app/models/complaint.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: complaints +# +# id :integer not null, primary key +# description :text +# user_id :integer +# complaintable_id :integer +# complaintable_type :string +# complaint_reason_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Complaint < ActiveRecord::Base belongs_to :complaint_reason belongs_to :user diff --git a/app/models/complaint_reason.rb b/app/models/complaint_reason.rb index 9994f39bb230df80d872fd29d390e2795c1f3b07..26ee8777f0c3631591f4d29ba5a7b34da7cd51e4 100644 --- a/app/models/complaint_reason.rb +++ b/app/models/complaint_reason.rb @@ -1,3 +1,13 @@ +# == Schema Information +# +# Table name: complaint_reasons +# +# id :integer not null, primary key +# reason :text +# created_at :datetime not null +# updated_at :datetime not null +# + class ComplaintReason < ActiveRecord::Base has_many :complaints diff --git a/app/models/download.rb b/app/models/download.rb index 9dc3563f6892601b3f0bdb7d6a6c7bc0da85dc33..b2687da8dd1917b887c8de3331ecb2f9625a6b8d 100644 --- a/app/models/download.rb +++ b/app/models/download.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Download < ActiveRecord::Base belongs_to :downloadable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/follow.rb b/app/models/follow.rb index 44c4ad86729a2d6ce6b4210dbaa852a545a1db62..59d125fb24de39aae8821431e1bb5045a2a8125a 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Follow < ActiveRecord::Base belongs_to :followable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/institution.rb b/app/models/institution.rb index e474c9a0c91834ec8a11d6422d4ea731e6d2d155..5903d6b3a4985713ebb7e7f3097828eebed73dd6 100644 --- a/app/models/institution.rb +++ b/app/models/institution.rb @@ -1,7 +1,22 @@ +# == 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 +# + class Institution < ActiveRecord::Base has_and_belongs_to_many :users has_many :learning_objects, as: :publisher + has_many :collections, as: :owner validates_presence_of :name end diff --git a/app/models/language.rb b/app/models/language.rb index f95d7ed7cc5cb1785ffd3d57624c525bef846aac..b9370bc7df571cd556d97bc011b92f7d6a453fe5 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,3 +1,14 @@ +# == 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 +# + class Language < ActiveRecord::Base has_many :learning_objects diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index ee386fd9f997ade131abfb6971752707ba8c4d8e..7e1e9811450453670438a88700045066f394304a 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -1,3 +1,35 @@ +# == 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 +# language_id :integer +# 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 +# + class LearningObject < ActiveRecord::Base include Metadatable include Reviewable diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb index 168e5f5cc020249f562b940b7248e66c10910813..e1435b65879cf2002be0e7cddbce7afc0ab675e8 100644 --- a/app/models/learning_object/attachment.rb +++ b/app/models/learning_object/attachment.rb @@ -1,3 +1,27 @@ +# == 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 +# + class LearningObject::Attachment < ActiveRecord::Base include ::Thumbnailable belongs_to :learning_object diff --git a/app/models/learning_object/draft.rb b/app/models/learning_object/draft.rb index 36c59c60019d40172a1b44314d67ac5f7f035b1b..e5bd5c94159956ad823a789d7e09e9d8478c675b 100644 --- a/app/models/learning_object/draft.rb +++ b/app/models/learning_object/draft.rb @@ -1,3 +1,35 @@ +# == 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 +# language_id :integer +# 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 +# + class LearningObject::Draft < LearningObject ##overwrites initialize method to force @state value as draft @@ -6,4 +38,4 @@ class LearningObject::Draft < LearningObject @state = 'draft' end -end \ No newline at end of file +end diff --git a/app/models/like.rb b/app/models/like.rb index 112b6063094f506bd10715eb2be570c4a76ebfc5..f30976e61fda0f28b7b182120c37628bddc61488 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Like < ActiveRecord::Base belongs_to :likeable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/mime_type.rb b/app/models/mime_type.rb index 4aa9f72fc04926d9e63f56e978b7ca7e57644311..6c6baa1acb6a9d75f3d582c7c937fd6342d82393 100644 --- a/app/models/mime_type.rb +++ b/app/models/mime_type.rb @@ -1,3 +1,12 @@ +# == Schema Information +# +# Table name: mime_types +# +# id :integer not null, primary key +# extension :string +# mime_type :string +# + class MimeType < ActiveRecord::Base has_and_belongs_to_many :object_types end diff --git a/app/models/object_type.rb b/app/models/object_type.rb index 0aedd137ed47c2fdb9b1b9dbb8a797c498a5bfa0..1153bd9cbb4755e792bd3ecf60ee2bdf2c85757f 100644 --- a/app/models/object_type.rb +++ b/app/models/object_type.rb @@ -1,3 +1,11 @@ +# == Schema Information +# +# Table name: object_types +# +# id :integer not null, primary key +# name :string +# + class ObjectType < ActiveRecord::Base has_many :learning_objects has_and_belongs_to_many :mime_types diff --git a/app/models/rate.rb b/app/models/rate.rb index 88ebc8b782935ed460d2b177b626f219709289e9..b2bc26f33b26b6cc04465c63a378b63fffa70d82 100644 --- a/app/models/rate.rb +++ b/app/models/rate.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Rate < ActiveRecord::Base belongs_to :user belongs_to :review diff --git a/app/models/rating.rb b/app/models/rating.rb index a8a63a00385218a107c257a88a15f3509be78bbb..a28b192f5a8b3f440154cbde5ab075df466c7cfd 100644 --- a/app/models/rating.rb +++ b/app/models/rating.rb @@ -1,3 +1,14 @@ +# == 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 +# + class Rating < ActiveRecord::Base has_many :review_ratings has_many :reviews, through: :review_ratings diff --git a/app/models/review.rb b/app/models/review.rb index 8a70f670021e8446a4718b1596f3b9313d2f585f..9567a9b9e797fb9ac83ec9cb6337d015efd7d3fb 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,3 +1,20 @@ +# == 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") +# + class Review < ActiveRecord::Base belongs_to :reviewable, polymorphic: true belongs_to :user diff --git a/app/models/review_rating.rb b/app/models/review_rating.rb index a554ef971c3b917c6054f45aa11e9d1f469081e6..3b5cab5cc218c5c7feeb098a2eec2e569ef8f4e5 100644 --- a/app/models/review_rating.rb +++ b/app/models/review_rating.rb @@ -1,3 +1,15 @@ +# == 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 +# + class ReviewRating < ActiveRecord::Base belongs_to :review belongs_to :rating diff --git a/app/models/role.rb b/app/models/role.rb index 21202003872571477b285008b79f74aee0568487..7302eac54aa9e3b8e4e6935fba25e632cd515a97 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,3 +1,14 @@ +# == 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 +# + class Role < ActiveRecord::Base has_and_belongs_to_many :users diff --git a/app/models/score.rb b/app/models/score.rb index aea63b8f9536aa2bb9dd7b31480dded369cc303d..d2031038913696ba2cc061971ee7587b2ee04d26 100644 --- a/app/models/score.rb +++ b/app/models/score.rb @@ -1,3 +1,17 @@ +# == 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 +# + class Score < ActiveRecord::Base has_many :score_user_categories has_many :user_categories, through: :score_user_categories diff --git a/app/models/score_user_category.rb b/app/models/score_user_category.rb index b7b864266ac4a3dc5e8c7806c96b0e8abf353b21..f249ec23cf02005b4c2c68777e50cd83ab627be0 100644 --- a/app/models/score_user_category.rb +++ b/app/models/score_user_category.rb @@ -1,3 +1,15 @@ +# == 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 +# + class ScoreUserCategory < ActiveRecord::Base belongs_to :score belongs_to :user_category diff --git a/app/models/share.rb b/app/models/share.rb index f40e60fc467ad03b92594cec226f02505bd03844..67e365cf005921d7baa1e30df9721d1bbdbe87f4 100644 --- a/app/models/share.rb +++ b/app/models/share.rb @@ -1,3 +1,15 @@ +# == 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 +# + class Share < ActiveRecord::Base belongs_to :shareable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/topic.rb b/app/models/topic.rb index d7a6326ab604ed04b77e7521fa20b8da7ac50353..3b0013dd40e0b69326e4ad39f02a8f333a9482ce 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# default :boolean default("false") +# + class Topic < ActiveRecord::Base has_and_belongs_to_many :learning_objects diff --git a/app/models/topic_highlight.rb b/app/models/topic_highlight.rb index 1fba48bccbc578e378a41ed4271e51f32a56a9a3..e59a26428f7b5e5d117a0a9bd4a7bc38db202819 100644 --- a/app/models/topic_highlight.rb +++ b/app/models/topic_highlight.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_highlights +# +# id :integer not null, primary key +# topic_id :integer +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class TopicHighlight < ActiveRecord::Base belongs_to :topic belongs_to :learning_object diff --git a/app/models/topic_relationship.rb b/app/models/topic_relationship.rb index c5007d12988ade58cc2cd036f90fcd1aabed0b71..82fd29386160749bbb05bac1999d803edf661208 100644 --- a/app/models/topic_relationship.rb +++ b/app/models/topic_relationship.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_relationships +# +# id :integer not null, primary key +# parent_id :integer +# child_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class TopicRelationship < ActiveRecord::Base belongs_to :parent, class_name: 'Topic' belongs_to :child, class_name: 'Topic' diff --git a/app/models/user.rb b/app/models/user.rb index 1c32e107597ae2fdf4f9d2005552d6fa5b8b6a36..0b8815ec4a7125a1bdbae4efda920d91a9ff7dd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,38 @@ +# == 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") +# + class User < ActiveRecord::Base include Followable include Reputationable @@ -54,6 +89,11 @@ class User < ActiveRecord::Base false end + def associated_collections + c = collections.blank? ? [] : collections.includes(:owner) + c + Collection.where(owner: institutions).includes(:owner) + end + private def default_role diff --git a/app/models/user_category.rb b/app/models/user_category.rb index 845710a3415b9b79ad82c6b3ce182ade35e58dc2..d4603f14fb70376f16fff61bcb8f29834a7e7254 100644 --- a/app/models/user_category.rb +++ b/app/models/user_category.rb @@ -1,3 +1,14 @@ +# == 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 +# + class UserCategory < ActiveRecord::Base has_many :score_user_categories has_many :scores, through: :score_user_categories diff --git a/app/models/view.rb b/app/models/view.rb index 53cd81b0a71a4ace75ea2ca1eb893440ba965f87..72579609f1fc97f0a61283772ed71c0789c9ee46 100644 --- a/app/models/view.rb +++ b/app/models/view.rb @@ -1,3 +1,15 @@ +# == 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 +# + class View < ActiveRecord::Base belongs_to :viewable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/policies/institution_policy.rb b/app/policies/institution_policy.rb index cac5c618de79be31c3631ff9d04e1321e1f5cd66..0a9fd33439e5ae30939be78b647c24ed1589bc9a 100644 --- a/app/policies/institution_policy.rb +++ b/app/policies/institution_policy.rb @@ -1,5 +1,4 @@ class InstitutionPolicy < ApplicationPolicy - def create? record if user.is_admin? end @@ -16,4 +15,7 @@ class InstitutionPolicy < ApplicationPolicy record if user.is_admin? end + def users? + record if user.is_admin? + end end diff --git a/app/views/collections/_form.html.erb b/app/views/collections/_form.html.erb index c96b8ab2e320f4f1bd10eb5d4216f59732869070..003e6bd36a168a5835c4f0c839bc3b1c35c3803b 100644 --- a/app/views/collections/_form.html.erb +++ b/app/views/collections/_form.html.erb @@ -3,10 +3,10 @@ <%= f.label :name, 'Nome' %> <%= f.text_field :name, required: true, style: 'width: 250px;' %> - <% if publishers.length > 1 %> + <% unless publishers.blank? %> <br><br> <label>Criar como:</label> - <%= f.collection_select :owner, publishers, :id, :name %> + <%= f.collection_select :owner, publishers, :id, :name, prompt: "Usuário" %> <br><br> <% end %> diff --git a/app/views/learning_objects/_learning_object_horizontal.erb b/app/views/learning_objects/_learning_object_horizontal.erb index c2e5cc26308e4a198ec7caaa82da7eec0a001f4e..074787ddddf50294cd0cd29e047d846fe8042535 100644 --- a/app/views/learning_objects/_learning_object_horizontal.erb +++ b/app/views/learning_objects/_learning_object_horizontal.erb @@ -23,7 +23,7 @@ <h4 class="learning-object-heading"><%= learning_object_title learning_object %></h4> <% end %> - <span class="author-label">Por <%= learning_object.get_metadata_value_of("dc.contributor.author") %></span><br/> + <span class="author-label">Por <%= learning_object.author || learning_object.publisher.name %></span><br/> <i class="fa fa-eye" data-toggle="tooltip" data-placement="bottom" title="Visualizações"></i><%= learning_object.views.count %> <i class="fa fa-thumbs-up" data-toggle="tooltip" data-placement="bottom" title="Curtidas"></i><span data-id="<%= learning_object.id %>" class="votes-count"><%= learning_object.likes.count %></span><br> diff --git a/app/views/learning_objects/_learning_object_vertical.erb b/app/views/learning_objects/_learning_object_vertical.erb index 5319ca6735e835e96ae00b41db508fa07681cd81..eb6f9e61bf49a384073af8861f6d349bef69fb05 100644 --- a/app/views/learning_objects/_learning_object_vertical.erb +++ b/app/views/learning_objects/_learning_object_vertical.erb @@ -15,7 +15,7 @@ <h4 class="media-heading"><%= learning_object_title(learning_object) %></h4> <i class="fa fa-eye" data-toggle="tooltip" data-placement="bottom" title="Visualizações"></i><%= learning_object.views.size %> <i class="fa fa-thumbs-up" data-toggle="tooltip" data-placement="bottom" title="Curtidas"></i><span data-id="<%= learning_object.id %>" class="votes-count"><%= learning_object.likes.size %></span> - <span class="author-label">Por <%= learning_object.get_metadata_value_of("dc.contributor.author") %></span> + <span class="author-label">Por <%= learning_object.author || learning_object.publisher.name %></span> </div> </div> </div> diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index adcaa8a9eb8b2575f2f5798b9ad2d38596249a10..419849b37fa9454d5c053b9eeb9f51f09eb9dab5 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -24,17 +24,15 @@ <div class="col-md-5"> <div class="rightbar"> - <% author = @learning_object.get_metadata_value_of("dc.contributor.author") %> - <% unless author.blank? %> + <% unless @learning_object.author.blank? %> <div class="media"> <div class="media-left"> <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> </div> <div class="media-body"> <h5>Autor</h5> - <h3><%= author %></h3> + <h3><%= @learning_object.author %></h3> </div> - </div> <% end %> <% unless @learning_object.publisher.nil? %> <div class="media"> @@ -119,6 +117,7 @@ </div> <% end %> </div> + </div> </div> </div> </div> @@ -133,12 +132,11 @@ <h4 class="modal-title" id="extra_metadata_modal_label">Metadados Adicionais</h4> </div> <div class="modal-body" style="text-align:justify"> - <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <ul> - <li><b>Autor:</b> <%= @learning_object.get_metadata_value_of("dc.contributor.author") %></li> + <li><b>Autor:</b> <%= @learning_object.author %></li> <li><b>Tipo:</b> <%= @learning_object.get_metadata_value_of("dc.type") %></li> <li><b>Data:</b> <%= @learning_object.get_metadata_value_of("dc.date.available") %></li> <li><b>Linguagem:</b> <%= @learning_object.get_metadata_value_of("dc.language") %></li> diff --git a/bin/docker-setup b/bin/docker-setup new file mode 100755 index 0000000000000000000000000000000000000000..69560962062acd88bae0187fd4f0f5639999b9a7 --- /dev/null +++ b/bin/docker-setup @@ -0,0 +1,21 @@ +# bin/docker-setup +#!/bin/bash + +set -e + +# overwrite default configs for docker +# cp -f config/docker/* config/ + +# build app image +docker-compose build + +# start mysql and redis in background +# docker-compose start db +# docker-compose start redis +# docker-compose start elasticsearch + +# setup database +docker-compose run web rake db:create db:migrate + +# ensure all containers are up and running +docker-compose up \ No newline at end of file diff --git a/config/docker/database.yml b/config/docker/database.yml new file mode 100644 index 0000000000000000000000000000000000000000..9698fdbf7ea210284fe421ad2aaa2cc091528254 --- /dev/null +++ b/config/docker/database.yml @@ -0,0 +1,28 @@ +default: &defaults + adapter: postgresql + encoding: unicode + +development: &default + adapter: postgresql + encoding: unicode + database: postgres + pool: 5 + username: postgres + password: + host: db + +test: + <<: *defaults + pool: 5 + database: portalmec_test + username: portalmec + password: 123mudar + host: postgres + +production: + <<: *defaults + host: <%= ENV['PORTALMEC_DB_HOST'] %> + pool: <%= ENV['PORTALMEC_DB_POOL'] %> + database: <%= ENV['PORTALMEC_DB_NAME'] %> + username: <%= ENV['PORTALMEC_DB_USERNAME'] %> + password: <%= ENV['PORTALMEC_DB_PASSWORD'] %> diff --git a/config/docker/sidekiq.yml b/config/docker/sidekiq.yml new file mode 100644 index 0000000000000000000000000000000000000000..9b3e3c8ec1a39623d3d4c2895374f804d1cdec4d --- /dev/null +++ b/config/docker/sidekiq.yml @@ -0,0 +1,30 @@ +# +# IMPORTANT: +# If you plan to run workers on different machines, use the full hostname, +# instead of just "localhost". And remember to use the exactly same configs +# on all of the machines, including database's configs and +# environment type (development, test, production). +# +:pidfile: ./shared/pids/sidekiq.pid +:logfile: ./shared/logs/sidekiq.log +:queues: + - default + - score + - convert_video + - searchkick + - [attachment_cache, 2] + - [high_priority, 5] +# :daemon: true + +development: &development + :concurrency: 8 + host: redis + port: 6379 + +test: + host: portalmecdev1.c3sl.ufpr.br + port: 6379 + +production: + host: portalmecdev1.c3sl.ufpr.br + port: 6379 diff --git a/config/env_vars.sh b/config/env_vars.sh index 47d12764c176201ce947943d8cd9e23a53e586d4..4d251f130d865005cac9f1505466489b086c9316 100644 --- a/config/env_vars.sh +++ b/config/env_vars.sh @@ -24,6 +24,9 @@ export ACTION_MAILER_HOST= export SMTP_ADDRESS= export SMTP_PORT= +# Gitlab +export GITLAB_PORTALMEC_PRIVATE_TOKEN= + ### Rails environment export RAILS_SERVE_STATIC_FILES=FALSE export RAILS_ENV=production diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 024ab5f708da10d7d2734b26042f684c90d8062d..83f6a8e69ea3846fcbd2d028f3a9acdd23fb4d70 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -165,7 +165,7 @@ pt-BR: feedback: report_bug: notice: - sucess: "Problema relatado com sucesso!" + success: "Problema relatado com sucesso!" institution: create: notice: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..30949bc2f0c097cf57601245dfe95020b912cb49 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +web: + build: . + volumes: + - .:/app + ports: + - "3000:3000" + links: + - db + - redis + - elasticsearch + +db: + image: postgres + +redis: + image: redis + +elasticsearch: + image: elasticsearch \ No newline at end of file diff --git a/test/fixtures/learning_objects.yml b/test/fixtures/learning_objects.yml index 369e22d2c81dc68d01dcf8543c97289c8488f67c..67ad40a31b8f2bb1b745b936be9c0c29da8d2fa8 100644 --- a/test/fixtures/learning_objects.yml +++ b/test/fixtures/learning_objects.yml @@ -1,3 +1,35 @@ +# == 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 +# language_id :integer +# 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' diff --git a/test/fixtures/score_user_categories.yml b/test/fixtures/score_user_categories.yml index dd1a50ef51f7a63eb6ddca2675a58efb262ca82d..12393cb656b20318d332711f1d09561dc0d0f867 100644 --- a/test/fixtures/score_user_categories.yml +++ b/test/fixtures/score_user_categories.yml @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/fixtures/scores.yml b/test/fixtures/scores.yml index ce46d73db1aa79645dbea2b1de678922dd42199a..b7ed2273b747e09dac016999b37ce4465b4fbd4c 100644 --- a/test/fixtures/scores.yml +++ b/test/fixtures/scores.yml @@ -1,3 +1,17 @@ +# == 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' diff --git a/test/fixtures/user_categories.yml b/test/fixtures/user_categories.yml index af786e20410f61d164cebe9dc38a9e55b4006761..b3b825ff71bc0fb75730ce2760883d921f23c442 100644 --- a/test/fixtures/user_categories.yml +++ b/test/fixtures/user_categories.yml @@ -1,3 +1,14 @@ +# == 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 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 798e181807bf4626b7a5bec657f665f0cc70daa5..2f387beb582c41549ce12b512348205bc83fac20 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,3 +1,38 @@ +# == 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") +# + one: name: 'John' email: 'john@test.com' diff --git a/test/models/bookmark_test.rb b/test/models/bookmark_test.rb index 2c739dca1a030bf397ff8a50bfd2f6c34461f69b..41533dbb3191d7939a99dcc20ce5bb6ca75ff03e 100644 --- a/test/models/bookmark_test.rb +++ b/test/models/bookmark_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/carousel_test.rb b/test/models/carousel_test.rb index 26c20b1e122e221fdec4d8ab8789e1a060cbeb11..663ca53b191aceb35dbdd19681d1bc9aca0177ce 100644 --- a/test/models/carousel_test.rb +++ b/test/models/carousel_test.rb @@ -1,3 +1,18 @@ +# == 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 diff --git a/test/models/collection_item_test.rb b/test/models/collection_item_test.rb index b037df012ac2ab01ad0c2d656c7dfe75e362a779..26cf5e85756c1e52375525d4150e09fc6a698582 100644 --- a/test/models/collection_item_test.rb +++ b/test/models/collection_item_test.rb @@ -1,3 +1,16 @@ +# == 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 diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb index 22288ef0b23563f795b36eeadc901ef384308a61..650f1b60dfb1c55c773131b4a884e2813971f5d2 100644 --- a/test/models/collection_test.rb +++ b/test/models/collection_test.rb @@ -1,3 +1,27 @@ +# == 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 diff --git a/test/models/complaint_reason_test.rb b/test/models/complaint_reason_test.rb index 09bcb0abdce3fc052df43fc7dde0c4729a705769..e283642fe0b29c3774de639dec23a4008996c79d 100644 --- a/test/models/complaint_reason_test.rb +++ b/test/models/complaint_reason_test.rb @@ -1,3 +1,13 @@ +# == 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 diff --git a/test/models/complaint_test.rb b/test/models/complaint_test.rb index cdafb092d34794d2b3b6bb8ea8bf77922151937e..5e9714c680f059c4bc83177a973ea6aaa1848c6b 100644 --- a/test/models/complaint_test.rb +++ b/test/models/complaint_test.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: complaints +# +# id :integer not null, primary key +# description :text +# user_id :integer +# complaintable_id :integer +# complaintable_type :string +# complaint_reason_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ComplaintTest < ActiveSupport::TestCase diff --git a/test/models/download_test.rb b/test/models/download_test.rb index 68692b44973d1e3b2beceaa88ab69d46f8328995..207c3afb3029fb68d3efa82592c6b2346eb01e05 100644 --- a/test/models/download_test.rb +++ b/test/models/download_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/follow_test.rb b/test/models/follow_test.rb index aff2aaab9ac5084e6894c5d05ac1c0fb034aa36c..c4a512a8f6d503384d5ab4d1a8c43fb407e726fd 100644 --- a/test/models/follow_test.rb +++ b/test/models/follow_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/institution_test.rb b/test/models/institution_test.rb index d3aac9f68f188f0ec5a5e2a9665af45b33652035..1fa31ccab4bd96b27ea3f1578a0ee4b94884013b 100644 --- a/test/models/institution_test.rb +++ b/test/models/institution_test.rb @@ -1,3 +1,17 @@ +# == 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 diff --git a/test/models/language_test.rb b/test/models/language_test.rb index 1d4315f9fec45981bece6110d363aa334469bcd4..03d2bdf92e7d47e9a2a289549644732b71894a71 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -1,3 +1,14 @@ +# == 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 diff --git a/test/models/learning_object/attachment_test.rb b/test/models/learning_object/attachment_test.rb index 93a755513df8f0cceefca77238d685a37066ff80..bc9898cd7143f294a6ea396e8b02c5163c62ab96 100644 --- a/test/models/learning_object/attachment_test.rb +++ b/test/models/learning_object/attachment_test.rb @@ -1,3 +1,27 @@ +# == 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 diff --git a/test/models/learning_object_test.rb b/test/models/learning_object_test.rb index 5f2eb2802556654e295407602320c1adccc842ab..c669b8c7d3304993f1c6382375b218451ff70cfd 100644 --- a/test/models/learning_object_test.rb +++ b/test/models/learning_object_test.rb @@ -1,3 +1,35 @@ +# == 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 +# language_id :integer +# 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 diff --git a/test/models/like_test.rb b/test/models/like_test.rb index 3599608c1f6d0252408e31ae8063508acf659cf4..3f9bf0015f5f0f891673c02549db929a07f7d801 100644 --- a/test/models/like_test.rb +++ b/test/models/like_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/object_type_test.rb b/test/models/object_type_test.rb index 1c38bb21727897fbf05d25280016f1d6a8bd3047..3c230dbac08b6a22ccbe31d4dedc4fc6300214eb 100644 --- a/test/models/object_type_test.rb +++ b/test/models/object_type_test.rb @@ -1,3 +1,11 @@ +# == Schema Information +# +# Table name: object_types +# +# id :integer not null, primary key +# name :string +# + require 'test_helper' class ObjectTypeTest < ActiveSupport::TestCase diff --git a/test/models/rate_test.rb b/test/models/rate_test.rb index d3206371d58b90815faab622d162d73cdd92bcd4..367e667c0eebdfd1e381cb5d99eb87df43f1fa8e 100644 --- a/test/models/rate_test.rb +++ b/test/models/rate_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/rating_test.rb b/test/models/rating_test.rb index a5101a2ebc89c678b2e8e9ca84ed399c03fba2c6..b93e91847982c008f47fb461d34f0e4eced3b169 100644 --- a/test/models/rating_test.rb +++ b/test/models/rating_test.rb @@ -1,3 +1,14 @@ +# == 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 diff --git a/test/models/review_rating_test.rb b/test/models/review_rating_test.rb index 92ce397bbf11379215abe3c02f8cd695b6a0f6be..992c89b612c6798fe2d72bf02949058b32c45bce 100644 --- a/test/models/review_rating_test.rb +++ b/test/models/review_rating_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/review_test.rb b/test/models/review_test.rb index a5dddfa3a2f07f6c8120b1c86b1f969002d19cd8..df6d552cadaef4201fc80ec11ed0ed8fe7bc69cc 100644 --- a/test/models/review_test.rb +++ b/test/models/review_test.rb @@ -1,3 +1,20 @@ +# == 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 diff --git a/test/models/role_test.rb b/test/models/role_test.rb index 51158b48da07bb19ff03df5b85b2aef351ebef6a..ff22856a5adcc14b26eb1db0cfa9429292583cdd 100644 --- a/test/models/role_test.rb +++ b/test/models/role_test.rb @@ -1,3 +1,14 @@ +# == 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 diff --git a/test/models/score_test.rb b/test/models/score_test.rb index 1f04b2c60f6ae61b384d638779180ad3a0296057..36d87062747df6efe7cc28f5a7a5a117e82d13ff 100644 --- a/test/models/score_test.rb +++ b/test/models/score_test.rb @@ -1,3 +1,17 @@ +# == 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 diff --git a/test/models/score_user_category_test.rb b/test/models/score_user_category_test.rb index 1aa74a18e7e7f894b13b8c75dc3215b1d7693013..3eaa66bb8d9cff3ac18c0c73f66283ec3e261135 100644 --- a/test/models/score_user_category_test.rb +++ b/test/models/score_user_category_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/share_test.rb b/test/models/share_test.rb index a6b64cd67a4ed99f72eba85148667da19898aaf0..f4eaeb542b9d4b13e511c4366b1c1d8acdfff0be 100644 --- a/test/models/share_test.rb +++ b/test/models/share_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/models/topic_highlight_test.rb b/test/models/topic_highlight_test.rb index e8c04d66898834960c659a09961e230720ca3c37..dfbe143a77ec26762827006161aff4ce3d9a5af4 100644 --- a/test/models/topic_highlight_test.rb +++ b/test/models/topic_highlight_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_highlights +# +# id :integer not null, primary key +# topic_id :integer +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class TopicHighlightTest < ActiveSupport::TestCase diff --git a/test/models/topic_relationship_test.rb b/test/models/topic_relationship_test.rb index 71086030dcbc0ea44d31c7cd36d584d92c4decb9..3a9d6b3640f6e256326b92f2cd45217cf374b45d 100644 --- a/test/models/topic_relationship_test.rb +++ b/test/models/topic_relationship_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_relationships +# +# id :integer not null, primary key +# parent_id :integer +# child_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class TopicRelationshipTest < ActiveSupport::TestCase diff --git a/test/models/topic_test.rb b/test/models/topic_test.rb index 2c9e974d79ed76578324891c65589442ecf6968c..bb50914dd436dff9ac90ab5ed6024541f2904369 100644 --- a/test/models/topic_test.rb +++ b/test/models/topic_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# default :boolean default("false") +# + require 'test_helper' class TopicTest < ActiveSupport::TestCase diff --git a/test/models/user_category_test.rb b/test/models/user_category_test.rb index d057ea32489085a176c12120d074c6cd5b9b69a9..379129a8f7e8a9af849acc9e84941627c2af27eb 100644 --- a/test/models/user_category_test.rb +++ b/test/models/user_category_test.rb @@ -1,3 +1,14 @@ +# == 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 diff --git a/test/models/user_test.rb b/test/models/user_test.rb index cab668434eedc452fce840879fabd203d3c88a1a..9916390f3c35643ce8e406c199f552fdc9657a93 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,3 +1,38 @@ +# == 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 diff --git a/test/models/view_test.rb b/test/models/view_test.rb index 76631e9931f5e2311d9e935309e355aae9258783..201fae5305c3b93f57458e22f71b3c0784719c5a 100644 --- a/test/models/view_test.rb +++ b/test/models/view_test.rb @@ -1,3 +1,15 @@ +# == 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index bdf790ce69a68760e7d56175acd8e66d2c58cd74..6a870e6884d5c232d224ee6b7eccdbe389f2e22f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'minitest/mock' +require 'minitest/reporters' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. @@ -24,4 +25,5 @@ class ActiveSupport::TestCase # ActiveRecord::Base.subclasses.each(&:delete_all) # end + Minitest::Reporters.use! end