-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathsingle_table_inheritance_spec.rb
39 lines (31 loc) · 1.1 KB
/
single_table_inheritance_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'
describe "PaperclipDatabase" do
describe "Single table inheritance" do
before(:example) do
create_model_tables :users, :avatars
build_model 'User', nil, :avatar, {}
Object.const_set('SuperUser', Class.new(User))
@model = SuperUser.new
file = File.open(fixture_file('5k.png'))
@model.avatar = file
@model.save
end
after(:example) do
reset_activerecord
reset_database :users, :avatars
Object.send(:remove_const, 'SuperUser')
end
it "has correct association name" do
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq 'user_avatar_paperclip_files'
end
it "has correct model constant" do
expect(@model.avatar.instance_variable_get(:@paperclip_file_model).to_s).to eq 'User::UserAvatarPaperclipFile'
end
it "has correct table name" do
expect(@model.avatar.instance_variable_get(:@database_table)).to eq 'avatars'
end
it "has association" do
expect(@model.methods.include?(:user_avatar_paperclip_files)).to be_truthy
end
end
end