Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dzmitry Monich - Hw 3 #56

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

describe Definition, type: :model do
describe 'Validate uniquness' do
before { create(:definition) }

it { should validate_uniqueness_of(:word) }
end

describe 'Associacion' do
it { should have_many(:users).through(:learned_words) }
it { should have_many(:learned_words).dependent(:destroy) }
end

describe 'Validation presence' do
context 'with not valid' do
before { record.validate }

context 'word' do
let(:record) { build(:definition, word: '') }

it 'is no valid' do
expect(record.errors[:word]).to include("can't be blank")
end
end

context 'description' do
let(:record) { build(:definition, description: '') }

it 'is no valid' do
expect(record.errors[:description]).to include("can't be blank")
end
end
end

context 'when is valid' do
let(:record) { build(:definition) }

it 'word and description' do
expect(record).to be_valid
end
end
end
end
12 changes: 12 additions & 0 deletions Dzmitry-Monich/3/fasteng/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.bundle/
/vendor/bundle
.DS_Store
*.gem
/tmp/
/.rubocop.yml
.env
.solargraph.yml
/log/*
!/log/.keep
/bin/*
!/bin/bot
3 changes: 3 additions & 0 deletions Dzmitry-Monich/3/fasteng/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--require spec_helper
--color
--format documentation
41 changes: 41 additions & 0 deletions Dzmitry-Monich/3/fasteng/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'telegram-bot-ruby', '~> 0.15.0'

gem 'dotenv', '~> 2.7'

gem 'rspec', '~> 3.10'

gem 'activerecord', '~> 6.0'

gem 'standalone_migrations', '~> 6.0'

gem 'rake', '~> 13.0'

gem 'pg', '~> 1.2'

gem 'pry', '~> 0.14.1'

gem 'shoulda-matchers', require: false

gem 'factory_bot'

gem 'database_cleaner-active_record'

gem 'whenever', require: false
gem 'whenever-test'

gem 'timecop', '~> 0.9.4'

gem 'faker', git: 'https://github.com/faker-ruby/faker.git', branch: 'master'

gem 'sinatra'
gem 'thin'

gem 'rack', '~> 2.2'
gem 'aasm'
gem 'after_commit_everywhere', '~> 1.0'
186 changes: 186 additions & 0 deletions Dzmitry-Monich/3/fasteng/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
GIT
remote: https://github.com/faker-ruby/faker.git
revision: 1c1b56178cf6aabddfdaffcf879bbf94b2725812
branch: master
specs:
faker (2.18.0)
i18n (>= 1.6, < 2)

GEM
remote: https://rubygems.org/
specs:
aasm (5.2.0)
concurrent-ruby (~> 1.0)
actionpack (6.0.3.7)
actionview (= 6.0.3.7)
activesupport (= 6.0.3.7)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.0.3.7)
activesupport (= 6.0.3.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activemodel (6.0.3.7)
activesupport (= 6.0.3.7)
activerecord (6.0.3.7)
activemodel (= 6.0.3.7)
activesupport (= 6.0.3.7)
activesupport (6.0.3.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
after_commit_everywhere (1.0.0)
activerecord (>= 4.2)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
builder (3.2.4)
chronic (0.10.2)
coderay (1.1.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.1.8)
crass (1.0.6)
daemons (1.4.0)
database_cleaner-active_record (2.0.1)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.4.4)
dotenv (2.7.6)
equalizer (0.0.11)
erubi (1.10.0)
eventmachine (1.2.7)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
faraday (1.4.1)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
inflecto (0.0.2)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
minitest (5.14.4)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nokogiri (1.11.3-x86_64-darwin)
racc (~> 1.4)
pg (1.2.3)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.5.2)
rack (2.2.3)
rack-protection (2.1.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.7)
actionpack (= 6.0.3.7)
activesupport (= 6.0.3.7)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.3)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
ruby2_keywords (0.0.4)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
standalone_migrations (6.0.0)
activerecord (>= 4.2.7, < 6.1.0, != 5.2.3.rc1, != 5.2.3)
railties (>= 4.2.7, < 6.1.0, != 5.2.3.rc1, != 5.2.3)
rake (>= 10.0)
telegram-bot-ruby (0.15.0)
faraday
inflecto
virtus
thin (1.8.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.4)
tzinfo (1.2.9)
thread_safe (~> 0.1)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
whenever (1.0.0)
chronic (>= 0.6.3)
whenever-test (1.0.1)
whenever
zeitwerk (2.4.2)

PLATFORMS
x86_64-darwin-18

DEPENDENCIES
aasm
activerecord (~> 6.0)
after_commit_everywhere (~> 1.0)
database_cleaner-active_record
dotenv (~> 2.7)
factory_bot
faker!
pg (~> 1.2)
pry (~> 0.14.1)
rack (~> 2.2)
rake (~> 13.0)
rspec (~> 3.10)
shoulda-matchers
sinatra
standalone_migrations (~> 6.0)
telegram-bot-ruby (~> 0.15.0)
thin
timecop (~> 0.9.4)
whenever
whenever-test

BUNDLED WITH
2.2.16
31 changes: 31 additions & 0 deletions Dzmitry-Monich/3/fasteng/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
install:
bundle install

run:
bin/bot

server:
ruby lib/server.rb

test:
bundle exec rspec

tasks:
bundle exec rake --tasks

db-migrate:
bundle exec rake db:migrate

db-create:
bundle exec rake db:new_migration name=$(N)

# cron-setup:
# bundle exec whenever

cron-start:
bundle exec whenever --update-crontab --set environment=development

cron-stop:
bundle exec whenever --clear-crontab

.PHONY: test
1 change: 1 addition & 0 deletions Dzmitry-Monich/3/fasteng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Bot
18 changes: 18 additions & 0 deletions Dzmitry-Monich/3/fasteng/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Rails/RakeEnvironment

require 'standalone_migrations'
StandaloneMigrations::Tasks.load_tasks

require_relative 'lib/fasteng'

namespace :cron do
task :notify do
Fasteng::NotifyHandler.call
end
end

# rubocop:enable Rails/RakeEnvironment
# rubocop:enable Lint/RedundantCopDisableDirective
10 changes: 10 additions & 0 deletions Dzmitry-Monich/3/fasteng/bin/bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require_relative '../lib/fasteng'

# Fasteng.config.url = ENV['URL']
# Fasteng.config.controller = 'webhook'

Fasteng::App.run
12 changes: 12 additions & 0 deletions Dzmitry-Monich/3/fasteng/config/schedule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

set :output, 'log/cron.log'

every '0 0-23 * * 0-6' do
rake 'cron:notify'
end

# test
# every '0-59 * * * 0-6' do
# rake 'cron:notify'
# end
Loading