Skip to content

Commit

Permalink
Fix for missing class variable in development environment, added sett…
Browse files Browse the repository at this point in the history
…ing-less model test
  • Loading branch information
stex committed Jul 23, 2015
1 parent 5c99a57 commit f3cc5e5
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/setting_accessors/internal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def self.add_setting_accessor_name(klass, setting_name)
# @return [Array<String>] all setting accessor names defined in the given +class+
#
def self.setting_accessor_names(klass)
@@setting_accessor_names ||= {}
self.lookup_nested_hash(@@setting_accessor_names, klass.to_s) || []
end

Expand Down
2 changes: 1 addition & 1 deletion lib/setting_accessors/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SettingAccessors
VERSION = '0.0.6'
VERSION = '0.0.7'
end
2 changes: 2 additions & 0 deletions test/dummy/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Post < ActiveRecord::Base
end
11 changes: 11 additions & 0 deletions test/dummy/db/migrate/20150723114600_create_posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.belongs_to :user
t.string :title
t.string :text

t.timestamps null: false
end
end
end
10 changes: 9 additions & 1 deletion test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150102115329) do
ActiveRecord::Schema.define(version: 20150723114600) do

create_table "posts", force: :cascade do |t|
t.integer "user_id"
t.string "title"
t.string "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "settings", force: :cascade do |t|
t.integer "assignable_id"
Expand Down
Binary file modified test/dummy/db/test.sqlite3
Binary file not shown.
11 changes: 11 additions & 0 deletions test/dummy/test/fixtures/posts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
19 changes: 19 additions & 0 deletions test/dummy/test/models/post_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative '../../../test_helper'

class PostTest < ActiveSupport::TestCase
context 'JSON serialization' do
setup do
@post = Post.new(:title => 'a post', :text => 'a content')
end

should 'work without having any setting_accessors defined' do
assert @post.as_json
end

should 'contain all original public attributes' do
[:title, :text, :id, :created_at, :updated_at].each do |attr|
assert_includes @post.as_json.keys, attr.to_s
end
end
end
end
2 changes: 2 additions & 0 deletions test/dummy/test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require_relative '../../../test_helper'

class UserTest < ActiveSupport::TestCase
context 'JSON serialization' do
setup do
Expand Down

0 comments on commit f3cc5e5

Please sign in to comment.