Skip to content

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
gadimbaylisahil committed Jun 26, 2020
1 parent 67acec1 commit 74552b1
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 15 deletions.
19 changes: 18 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ jobs:
build:
docker:
- image: circleci/ruby:2.6.3-stretch-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root

- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: acts_as_tracked_test

executor: ruby/default
steps:
- checkout
Expand All @@ -23,13 +33,20 @@ jobs:
name: Bundle Install
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
- run: sudo apt install -y postgresql-client || true

- save_cache:
name: Store bundle cache
paths:
- ./vendor/bundle
key: hermes-dependencies
key: acts-as-tracked-dependencies

- run:
name: Rubocop check
command: bundle exec rubocop

- run:
name: Test Suite
command: PREPARE_COMBUSTION_DB_USING_SCHEMA=true bundle exec rspec

1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ source 'https://rubygems.org'
gemspec

gem 'rake', '~> 12.0'
gem 'rspec', '~> 3.0'
78 changes: 72 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ PATH
remote: .
specs:
acts_as_tracked (1.0.0)
actionview (>= 4.2)
activerecord (>= 4.2)
activesupport (>= 4.2)

GEM
remote: https://rubygems.org/
specs:
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
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.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
Expand All @@ -20,22 +34,53 @@ GEM
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
ast (2.4.1)
builder (3.2.4)
codecov (0.1.17)
json
simplecov
url
combustion (1.3.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
thor (>= 0.14.6)
concurrent-ruby (1.1.6)
diff-lcs (1.3)
crass (1.0.6)
diff-lcs (1.4.2)
docile (1.3.2)
erubi (1.9.0)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
json (2.3.0)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.4.0)
minitest (5.14.1)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pg (1.2.3)
rack (2.2.3)
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.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (12.3.3)
regexp_parser (1.7.1)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
Expand All @@ -44,6 +89,14 @@ GEM
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-rails (4.0.1)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (0.85.1)
parallel (~> 1.10)
Expand All @@ -57,20 +110,33 @@ GEM
rubocop-ast (0.0.3)
parser (>= 2.7.0.1)
ruby-progressbar (1.10.1)
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
url (0.3.2)
with_model (2.1.4)
activerecord (>= 5.2, < 6.1)
zeitwerk (2.3.0)

PLATFORMS
ruby

DEPENDENCIES
acts_as_tracked!
codecov
combustion (~> 1.3)
pg
rake (~> 12.0)
rspec (~> 3.0)
rspec-rails
rubocop
simplecov
with_model

BUNDLED WITH
2.1.4
7 changes: 7 additions & 0 deletions acts_as_tracked.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'actionview', '>= 4.2'
spec.add_dependency 'activerecord', '>= 4.2'
spec.add_dependency 'activesupport', '>= 4.2'

spec.add_development_dependency 'codecov'
spec.add_development_dependency 'combustion', '~> 1.3'
spec.add_development_dependency 'pg'
spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'with_model'
end
6 changes: 4 additions & 2 deletions lib/acts_as_tracked.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

require 'acts_as_tracked/version'
require 'acts_as_tracked/extenders/trackable'
require 'acts_as_tracked/activity'

require 'active_record'
require 'active_support'

require 'acts_as_tracked/activity'
require 'acts_as_tracked/extenders/trackable'

module ActsAsTracked
ActiveRecord::Base.extend ActsAsTracked::Extenders::Trackable
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_tracked/activity.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module ActsAsTracked
class Activity < ActiveRecord::Base
class Activity < ::ActiveRecord::Base
belongs_to :actor, polymorphic: true
belongs_to :subject, polymorphic: true
belongs_to :parent, polymorphic: true
Expand Down
4 changes: 0 additions & 4 deletions spec/acts_as_tracked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
it 'has a version number' do
expect(ActsAsTracked::VERSION).not_to be nil
end

it 'does something useful' do
expect(false).to eq(true)
end
end
Empty file.
3 changes: 3 additions & 0 deletions spec/internal/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
adapter: postgresql
database: acts_as_tracked_test
5 changes: 5 additions & 0 deletions spec/internal/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

Rails.application.routes.draw do
# Add your own routes here, or remove this file if you don't have need for it.
end
23 changes: 23 additions & 0 deletions spec/internal/config/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

ActiveRecord::Schema.define do
# These are extensions that must be enabled in order to support this database
enable_extension 'plpgsql'

create_table 'activities', force: :cascade do |t|
t.integer 'actor_id'
t.string 'actor_type'
t.integer 'subject_id'
t.string 'subject_type'
t.integer 'parent_id'
t.string 'parent_type'
t.text 'attribute_changes'
t.string 'activity_type'
t.string 'human_description'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index ['actor_id'], name: 'index_activities_on_actor_id'
t.index ['parent_id'], name: 'index_activities_on_parent_id'
t.index ['subject_id'], name: 'index_activities_on_subject_id'
end
end
3 changes: 3 additions & 0 deletions spec/internal/config/storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
service: Disk
root: /home/sgadimbayli/development/opensource/acts_as_tracked/tmp/storage
23 changes: 23 additions & 0 deletions spec/internal/db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

ActiveRecord::Schema.define do
# These are extensions that must be enabled in order to support this database
enable_extension 'plpgsql'

create_table 'activities', force: :cascade do |t|
t.integer 'actor_id'
t.string 'actor_type'
t.integer 'subject_id'
t.string 'subject_type'
t.integer 'parent_id'
t.string 'parent_type'
t.text 'attribute_changes'
t.string 'activity_type'
t.string 'human_description'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index ['actor_id'], name: 'index_activities_on_actor_id'
t.index ['parent_id'], name: 'index_activities_on_parent_id'
t.index ['subject_id'], name: 'index_activities_on_subject_id'
end
end
1 change: 1 addition & 0 deletions spec/internal/log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
Empty file.
Loading

0 comments on commit 74552b1

Please sign in to comment.