diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile index 6942706..922df12 100644 --- a/Gemfile +++ b/Gemfile @@ -25,12 +25,12 @@ gem 'uglifier', '>= 1.3.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production -# gem 'redis', '~> 4.0' +gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant -# gem 'mini_magick', '~> 4.8' +gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development @@ -39,6 +39,8 @@ gem 'jbuilder', '~> 2.5' gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do + gem 'rspec-rails' + gem 'factory_bot_rails' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end diff --git a/Gemfile.lock b/Gemfile.lock index d1183e6..dce889e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,8 +74,14 @@ GEM railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) + diff-lcs (1.3) erubi (1.8.0) execjs (2.7.0) + factory_bot (5.0.2) + activesupport (>= 4.2.0) + factory_bot_rails (5.0.2) + factory_bot (~> 5.0.2) + railties (>= 4.2.0) ffi (1.10.0) globalid (0.4.2) activesupport (>= 4.2.0) @@ -98,6 +104,7 @@ GEM mimemagic (~> 0.3.2) method_source (0.9.2) mimemagic (0.3.3) + mini_magick (4.9.3) mini_mime (1.0.1) mini_portile2 (2.4.0) minitest (5.11.3) @@ -141,10 +148,28 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) + redis (4.1.0) regexp_parser (1.4.0) responders (2.4.1) actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-rails (3.8.2) + 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) ruby_dep (1.5.0) rubyzip (1.2.2) selenium-webdriver (3.141.0) @@ -164,9 +189,6 @@ GEM sprockets (>= 3.0.0) thor (0.20.3) thread_safe (0.3.6) - turbolinks (5.2.0) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.20) @@ -193,15 +215,18 @@ DEPENDENCIES capybara (>= 2.15) chromedriver-helper devise + factory_bot_rails jbuilder (~> 2.5) listen (>= 3.0.5, < 3.2) + mini_magick (~> 4.8) mysql2 (>= 0.4.4, < 0.6.0) puma (~> 3.11) rails (~> 5.2.3) + redis (~> 4.0) + rspec-rails selenium-webdriver spring spring-watcher-listen (~> 2.0.0) - turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) diff --git a/app/models/course.rb b/app/models/course.rb new file mode 100644 index 0000000..25e8ed7 --- /dev/null +++ b/app/models/course.rb @@ -0,0 +1,2 @@ +class Course < ApplicationRecord +end diff --git a/app/models/course_landing_page.rb b/app/models/course_landing_page.rb new file mode 100644 index 0000000..63dec2a --- /dev/null +++ b/app/models/course_landing_page.rb @@ -0,0 +1,3 @@ +class CourseLandingPage < ApplicationRecord + belongs_to :course +end diff --git a/app/models/email_account.rb b/app/models/email_account.rb new file mode 100644 index 0000000..6bc1fa0 --- /dev/null +++ b/app/models/email_account.rb @@ -0,0 +1,3 @@ +class EmailAccount < ApplicationRecord + enum authentication: %i[plain login cram_md5] +end diff --git a/app/models/lead_email.rb b/app/models/lead_email.rb new file mode 100644 index 0000000..46e24d8 --- /dev/null +++ b/app/models/lead_email.rb @@ -0,0 +1,2 @@ +class LeadEmail < ApplicationRecord +end diff --git a/app/models/lesson.rb b/app/models/lesson.rb new file mode 100644 index 0000000..479023a --- /dev/null +++ b/app/models/lesson.rb @@ -0,0 +1,5 @@ +class Lesson < ApplicationRecord + belongs_to :course + belongs_to :week + belongs_to :video +end diff --git a/app/models/user.rb b/app/models/user.rb index d3d6985..45aa18a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,9 @@ class User < ApplicationRecord + validates :email, uniqueness: true # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable, # :registerable devise :database_authenticatable, :confirmable, :trackable, :timeoutable, :recoverable, :rememberable, :validatable, :lockable, :registerable + end diff --git a/app/models/user_activity.rb b/app/models/user_activity.rb new file mode 100644 index 0000000..c36ed1e --- /dev/null +++ b/app/models/user_activity.rb @@ -0,0 +1,3 @@ +class UserActivity < ApplicationRecord + belongs_to :user +end diff --git a/app/models/user_add.rb b/app/models/user_add.rb new file mode 100644 index 0000000..9acc81a --- /dev/null +++ b/app/models/user_add.rb @@ -0,0 +1,3 @@ +class UserAdd < ApplicationRecord + belongs_to :user +end diff --git a/app/models/video.rb b/app/models/video.rb new file mode 100644 index 0000000..41a00ae --- /dev/null +++ b/app/models/video.rb @@ -0,0 +1,3 @@ +class Video < ApplicationRecord + belongs_to :video_account +end diff --git a/app/models/video_account.rb b/app/models/video_account.rb new file mode 100644 index 0000000..c252ba9 --- /dev/null +++ b/app/models/video_account.rb @@ -0,0 +1,3 @@ +class VideoAccount < ApplicationRecord + belongs_to :account, polymorphic: true +end diff --git a/app/models/week.rb b/app/models/week.rb new file mode 100644 index 0000000..6f786dd --- /dev/null +++ b/app/models/week.rb @@ -0,0 +1,3 @@ +class Week < ApplicationRecord + belongs_to :course +end diff --git a/config/environments/development.rb b/config/environments/development.rb index c91354f..5ebfb91 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -31,9 +31,22 @@ Rails.application.configure do config.active_storage.service = :local # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - config.action_mailer.perform_caching = false + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'smtp.gmail.com', + port: 587, + domain: 'akademiatechnologii.pl', + user_name: 'akademiatechnologii@gmail.com', + password: '12345%$#@!Adi', + authentication: 'plain', + enable_starttls_auto: true + } + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = true + config.action_mailer.default_options = + { from: 'akademiatechnologii@gmail.com' } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/test.rb b/config/environments/test.rb index 0a38fd3..0d5d72f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -40,7 +40,7 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - + config.action_mailer.default_url_options = { host: 'localhost' } # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end diff --git a/db/migrate/20190502090709_create_user_activities.rb b/db/migrate/20190502090709_create_user_activities.rb new file mode 100644 index 0000000..75ece09 --- /dev/null +++ b/db/migrate/20190502090709_create_user_activities.rb @@ -0,0 +1,10 @@ +class CreateUserActivities < ActiveRecord::Migration[5.2] + def change + create_table :user_activities do |t| + t.references :user, foreign_key: true + t.integer :action + + t.timestamps + end + end +end diff --git a/db/migrate/20190502095358_create_user_adds.rb b/db/migrate/20190502095358_create_user_adds.rb new file mode 100644 index 0000000..6602681 --- /dev/null +++ b/db/migrate/20190502095358_create_user_adds.rb @@ -0,0 +1,16 @@ +class CreateUserAdds < ActiveRecord::Migration[5.2] + def change + create_table :user_adds do |t| + t.references :user, foreign_key: true + t.string :first_name + t.string :last_name + t.string :company_name + t.string :nip, limit: 30 + t.string :regon, limit: 30 + t.string :city + t.string :zip_code + + t.timestamps + end + end +end diff --git a/db/migrate/20190502100811_create_courses.rb b/db/migrate/20190502100811_create_courses.rb new file mode 100644 index 0000000..6dd1b2b --- /dev/null +++ b/db/migrate/20190502100811_create_courses.rb @@ -0,0 +1,10 @@ +class CreateCourses < ActiveRecord::Migration[5.2] + def change + create_table :courses do |t| + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20190502101457_create_weeks.rb b/db/migrate/20190502101457_create_weeks.rb new file mode 100644 index 0000000..0684a61 --- /dev/null +++ b/db/migrate/20190502101457_create_weeks.rb @@ -0,0 +1,11 @@ +class CreateWeeks < ActiveRecord::Migration[5.2] + def change + create_table :weeks do |t| + t.references :course, foreign_key: true + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20190502102021_create_active_storage_tables.active_storage.rb b/db/migrate/20190502102021_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..0b2ce25 --- /dev/null +++ b/db/migrate/20190502102021_create_active_storage_tables.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[5.2] + def change + create_table :active_storage_blobs do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false + t.datetime :created_at, null: false + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false + + t.datetime :created_at, null: false + + t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/migrate/20190502104000_create_course_landing_pages.rb b/db/migrate/20190502104000_create_course_landing_pages.rb new file mode 100644 index 0000000..a4c58a7 --- /dev/null +++ b/db/migrate/20190502104000_create_course_landing_pages.rb @@ -0,0 +1,13 @@ +class CreateCourseLandingPages < ActiveRecord::Migration[5.2] + def change + create_table :course_landing_pages do |t| + t.references :course, foreign_key: true + t.string :name + t.longtext :body + t.boolean :active + + t.timestamps + end + add_index :course_landing_pages, :active + end +end diff --git a/db/migrate/20190502104437_create_email_accounts.rb b/db/migrate/20190502104437_create_email_accounts.rb new file mode 100644 index 0000000..8af3a34 --- /dev/null +++ b/db/migrate/20190502104437_create_email_accounts.rb @@ -0,0 +1,17 @@ +class CreateEmailAccounts < ActiveRecord::Migration[5.2] + def change + create_table :email_accounts do |t| + t.string :name + t.string :presented_name + t.string :adress + t.integer :port + t.string :domain + t.string :user_name + t.string :password + t.integer :authentication + t.boolean :e_starttls_auto + + t.timestamps + end + end +end diff --git a/db/migrate/20190502113303_create_video_accounts.rb b/db/migrate/20190502113303_create_video_accounts.rb new file mode 100644 index 0000000..129dea5 --- /dev/null +++ b/db/migrate/20190502113303_create_video_accounts.rb @@ -0,0 +1,12 @@ +class CreateVideoAccounts < ActiveRecord::Migration[5.2] + def change + create_table :video_accounts do |t| + t.references :account, polymorphic: true + t.string :name + t.boolean :active + + t.timestamps + end + add_index :video_accounts, :active + end +end diff --git a/db/migrate/20190502113518_create_videos.rb b/db/migrate/20190502113518_create_videos.rb new file mode 100644 index 0000000..5e5d1bc --- /dev/null +++ b/db/migrate/20190502113518_create_videos.rb @@ -0,0 +1,13 @@ +class CreateVideos < ActiveRecord::Migration[5.2] + def change + create_table :videos do |t| + t.references :video_account, foreign_key: true + t.string :url + t.string :name + t.string :description + + t.timestamps + end + add_index :videos, :name + end +end diff --git a/db/migrate/20190502113533_create_lessons.rb b/db/migrate/20190502113533_create_lessons.rb new file mode 100644 index 0000000..a9868c4 --- /dev/null +++ b/db/migrate/20190502113533_create_lessons.rb @@ -0,0 +1,14 @@ +class CreateLessons < ActiveRecord::Migration[5.2] + def change + create_table :lessons do |t| + t.references :course, foreign_key: true + t.references :week, foreign_key: true + t.references :video, foreign_key: true + t.string :name + t.text :description + t.text :informations + + t.timestamps + end + end +end diff --git a/db/migrate/20190502114629_create_lead_emails.rb b/db/migrate/20190502114629_create_lead_emails.rb new file mode 100644 index 0000000..34454a0 --- /dev/null +++ b/db/migrate/20190502114629_create_lead_emails.rb @@ -0,0 +1,11 @@ +class CreateLeadEmails < ActiveRecord::Migration[5.2] + def change + create_table :lead_emails do |t| + t.string :name + t.boolean :active + + t.timestamps + end + add_index :lead_emails, :active + end +end diff --git a/db/schema.rb b/db/schema.rb index 3455946..677ed68 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,104 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_04_17_100642) do +ActiveRecord::Schema.define(version: 2019_05_02_114629) do + + create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.bigint "byte_size", null: false + t.string "checksum", null: false + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "course_landing_pages", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "course_id" + t.string "name" + t.text "body", limit: 4294967295 + t.boolean "active" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["active"], name: "index_course_landing_pages_on_active" + t.index ["course_id"], name: "index_course_landing_pages_on_course_id" + end + + create_table "courses", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "email_accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" + t.string "presented_name" + t.string "adress" + t.integer "port" + t.string "domain" + t.string "user_name" + t.string "password" + t.integer "authentication" + t.boolean "e_starttls_auto" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "lead_emails", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" + t.boolean "active" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["active"], name: "index_lead_emails_on_active" + end + + create_table "lessons", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "course_id" + t.bigint "week_id" + t.bigint "video_id" + t.string "name" + t.text "description" + t.text "informations" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["course_id"], name: "index_lessons_on_course_id" + t.index ["video_id"], name: "index_lessons_on_video_id" + t.index ["week_id"], name: "index_lessons_on_week_id" + end + + create_table "user_activities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "user_id" + t.integer "action" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_user_activities_on_user_id" + end + + create_table "user_adds", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "user_id" + t.string "first_name" + t.string "last_name" + t.string "company_name" + t.string "nip", limit: 30 + t.string "regon", limit: 30 + t.string "city" + t.string "zip_code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_user_adds_on_user_id" + end create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "email", default: "", null: false @@ -38,4 +135,44 @@ ActiveRecord::Schema.define(version: 2019_04_17_100642) do t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true end + create_table "video_accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "account_type" + t.bigint "account_id" + t.string "name" + t.boolean "active" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_type", "account_id"], name: "index_video_accounts_on_account_type_and_account_id" + t.index ["active"], name: "index_video_accounts_on_active" + end + + create_table "videos", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "video_account_id" + t.string "url" + t.string "name" + t.string "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["name"], name: "index_videos_on_name" + t.index ["video_account_id"], name: "index_videos_on_video_account_id" + end + + create_table "weeks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.bigint "course_id" + t.string "name" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["course_id"], name: "index_weeks_on_course_id" + end + + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "course_landing_pages", "courses" + add_foreign_key "lessons", "courses" + add_foreign_key "lessons", "videos" + add_foreign_key "lessons", "weeks" + add_foreign_key "user_activities", "users" + add_foreign_key "user_adds", "users" + add_foreign_key "videos", "video_accounts" + add_foreign_key "weeks", "courses" end diff --git a/db/seeds.rb b/db/seeds.rb index 1beea2a..b1e776b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,5 @@ # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) + +user = User.create(email: 'adhinz@gmail.com', password: 'qweqwe123') diff --git a/dox/projekt_platforma_kursow.docx b/dox/projekt_platforma_kursow.docx new file mode 100644 index 0000000..f2b2198 Binary files /dev/null and b/dox/projekt_platforma_kursow.docx differ diff --git a/spec/factories/course_landing_pages.rb b/spec/factories/course_landing_pages.rb new file mode 100644 index 0000000..4686e6a --- /dev/null +++ b/spec/factories/course_landing_pages.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :course_landing_page do + course { nil } + name { "MyString" } + body { "" } + active { false } + end +end diff --git a/spec/factories/courses.rb b/spec/factories/courses.rb new file mode 100644 index 0000000..aaa5272 --- /dev/null +++ b/spec/factories/courses.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :course do + name { "MyString" } + description { "MyText" } + end +end diff --git a/spec/factories/email_accounts.rb b/spec/factories/email_accounts.rb new file mode 100644 index 0000000..15018d4 --- /dev/null +++ b/spec/factories/email_accounts.rb @@ -0,0 +1,13 @@ +FactoryBot.define do + factory :email_account do + name { "MyString" } + presented_name { "MyString" } + adress { "MyString" } + port { 1 } + domain { "MyString" } + user_name { "MyString" } + password { "MyString" } + authentication { 1 } + e_starttls_auto { false } + end +end diff --git a/spec/factories/lead_emails.rb b/spec/factories/lead_emails.rb new file mode 100644 index 0000000..f4e409f --- /dev/null +++ b/spec/factories/lead_emails.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :lead_email do + name { "MyString" } + active { false } + end +end diff --git a/spec/factories/lessons.rb b/spec/factories/lessons.rb new file mode 100644 index 0000000..585aca4 --- /dev/null +++ b/spec/factories/lessons.rb @@ -0,0 +1,10 @@ +FactoryBot.define do + factory :lesson do + course { nil } + week { nil } + video { nil } + name { "MyString" } + description { "MyText" } + informations { "MyText" } + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 0000000..fc89d5e --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :user do + email { 'johndoe@gmail.com' } + password { 'blahblah' } + end +end diff --git a/spec/factories/video_accounts.rb b/spec/factories/video_accounts.rb new file mode 100644 index 0000000..d708e34 --- /dev/null +++ b/spec/factories/video_accounts.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :video_account do + account { nil } + name { "MyString" } + active { false } + end +end diff --git a/spec/factories/videos.rb b/spec/factories/videos.rb new file mode 100644 index 0000000..09d1ced --- /dev/null +++ b/spec/factories/videos.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :video do + video_account { nil } + url { "MyString" } + name { "MyString" } + description { "MyString" } + end +end diff --git a/spec/factories/weeks.rb b/spec/factories/weeks.rb new file mode 100644 index 0000000..63f24ef --- /dev/null +++ b/spec/factories/weeks.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :week do + course { nil } + name { "MyString" } + description { "MyText" } + end +end diff --git a/spec/models/course_landing_page_spec.rb b/spec/models/course_landing_page_spec.rb new file mode 100644 index 0000000..16ae1c2 --- /dev/null +++ b/spec/models/course_landing_page_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CourseLandingPage, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/course_spec.rb b/spec/models/course_spec.rb new file mode 100644 index 0000000..e7880d0 --- /dev/null +++ b/spec/models/course_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Course, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/email_account_spec.rb b/spec/models/email_account_spec.rb new file mode 100644 index 0000000..32281b8 --- /dev/null +++ b/spec/models/email_account_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EmailAccount, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/lead_email_spec.rb b/spec/models/lead_email_spec.rb new file mode 100644 index 0000000..8f235b4 --- /dev/null +++ b/spec/models/lead_email_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe LeadEmail, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/lesson_spec.rb b/spec/models/lesson_spec.rb new file mode 100644 index 0000000..2a54341 --- /dev/null +++ b/spec/models/lesson_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Lesson, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/user_activity_spec.rb b/spec/models/user_activity_spec.rb new file mode 100644 index 0000000..417dfa2 --- /dev/null +++ b/spec/models/user_activity_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserActivity, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/user_add_spec.rb b/spec/models/user_add_spec.rb new file mode 100644 index 0000000..d265d55 --- /dev/null +++ b/spec/models/user_add_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserAdd, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..6308ebd --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' +RSpec.describe User, type: :model do + before(:all) do + @user1 = create(:user) + end + + it 'is valid with valid attributes' do + expect(@user1).to be_valid + end + + it 'is not valid without an email' do + user2 = build(:user, email: nil) + expect(user2).to_not be_valid + end + + it 'is not valid with bad email' do + user2 = build(:user, email: 'email@') + expect(user2).to_not be_valid + end +end diff --git a/spec/models/video_account_spec.rb b/spec/models/video_account_spec.rb new file mode 100644 index 0000000..18dba11 --- /dev/null +++ b/spec/models/video_account_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe VideoAccount, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/video_spec.rb b/spec/models/video_spec.rb new file mode 100644 index 0000000..9ac8444 --- /dev/null +++ b/spec/models/video_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Video, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/week_spec.rb b/spec/models/week_spec.rb new file mode 100644 index 0000000..cd43cc0 --- /dev/null +++ b/spec/models/week_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Week, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..110fa07 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,62 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'support/factory_bot' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../config/environment', __dir__) +# Prevent database truncation if the environment is production +abort('The Rails environment is running in production mode!') if Rails.env.production? +require 'rspec/rails' +require 'devise' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..15a3872 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,94 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed +end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb new file mode 100644 index 0000000..51eaba1 --- /dev/null +++ b/spec/support/controller_macros.rb @@ -0,0 +1,11 @@ +module ControllerMacros + + def login_user + before(:each) do + @request.env["devise.mapping"] = Devise.mappings[:user] + user = FactoryBot.create(:user) + user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the "confirmable" module + sign_in user + end + end +end diff --git a/spec/support/devise.rb b/spec/support/devise.rb new file mode 100644 index 0000000..98de8be --- /dev/null +++ b/spec/support/devise.rb @@ -0,0 +1,10 @@ +require_relative 'support/controller_macros' +# or require_relative './controller_macros' if write in `spec/support/devise.rb` + +RSpec.configure do |config| + # For Devise > 4.1.1 + config.include Devise::Test::ControllerHelpers, type: :controller + # Use the following instead if you are on Devise <= 4.1.1 + # config.include Devise::TestHelpers, :type => :controller + config.extend ControllerMacros, type: :controller +end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 0000000..a089330 --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,4 @@ +require 'factory_bot' +RSpec.configure do |config| + config.include FactoryBot::Syntax::Methods +end