Skip to content

Commit

Permalink
Merge pull request #5 from Liooo/fix-test-n-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Liooo authored Jan 16, 2022
2 parents 3ee09d4 + c6dc1a3 commit 49830c8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test

on:
pull_request:
branches:
- master
push:
branches:
- master

env:
RUBY_VERSION: 2.7.2
RAILS_ENV: test

jobs:
test:
name: run test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: setup db
working-directory: spec/dummy
run: |
bundle exec rake db:create
bundle exec rake db:migrate
- name: Run RSpec
run: bundle exec rspec
4 changes: 2 additions & 2 deletions dynabute.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'activerecord', ['>= 4.2.8']

s.add_development_dependency "rails"
s.add_development_dependency "rails", '~> 5'
s.add_development_dependency "sqlite3"
s.add_development_dependency "pry-byebug"
s.add_development_dependency "pry-rails"
s.add_development_dependency "rspec-rails"
s.add_development_dependency "rspec-rails", '~> 5'
end
9 changes: 0 additions & 9 deletions lib/dynabute/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ def self.value_types
TYPES
end

def self.<<(records)
if records.respond_to? :each
records.each {|r| r.update!(target_model: get_parent_class_name) }
else
records.update!(target_model: get_parent_class_name)
end
all
end

private
def self.get_parent_class_name
all.where_clause.binds.detect{|w| w.name == 'target_model'}.try(:value)
Expand Down
4 changes: 3 additions & 1 deletion spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
# CI was failing with `NoMethodError: undefined method `perform_caching=' for ActionMailer::Base:Class`
# https://stackoverflow.com/a/53669026/1330926
# config.action_controller.perform_caching = false

config.cache_store = :null_store
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/spec/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
end
end

describe 'Model.dynabutes <<' do
describe 'Model.dynabutes create' do
it 'works' do
expect { User.dynabutes << Dynabute::Field.new(name: 'int field', value_type: :integer) }.to(
expect { User.dynabutes.create(name: 'int field', value_type: :integer) }.to(
change{ Dynabute::Field.where(target_model: User.to_s).count }.from(0).to(1)
)
end
Expand Down

0 comments on commit 49830c8

Please sign in to comment.