Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • portalmec/portalmec
  • rfhferreira/cleanning-portalmec
2 results
Show changes
Showing
with 0 additions and 446 deletions
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
require 'test_helper'
class ApplicationTest < ActiveSupport::TestCase
should belong_to :user
should validate_presence_of(:domain)
should validate_presence_of(:application_id)
end
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
should belong_to :complaint_reason
should belong_to :user
should belong_to :complaintable
should validate_presence_of(:user)
should validate_presence_of(:complaintable)
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
# == 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
# == 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
# == 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
# == 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
# == 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
# == 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
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 belong_to :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),
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
require 'test_helper'
class LicenseTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
# == 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