@@ -26,7 +26,9 @@ class TestModel < ActiveRecord::Base
26
26
:class_name => "TestAttrThrough" , :source => :test_attr_throughs ,
27
27
:conditions => "test_attrs.attr = 1"
28
28
29
- attr_accessible :content , :test_attr_through_id , :country_id
29
+ if Rails . version < "4"
30
+ attr_accessible :content , :test_attr_through_id , :country_id
31
+ end
30
32
31
33
# TODO currently not working in Rails 3
32
34
if Rails . version < "3"
@@ -75,9 +77,11 @@ class TestAttr < ActiveRecord::Base
75
77
has_many :test_attr_throughs
76
78
has_many :test_model_security_model_with_finds
77
79
attr_reader :role_symbols
78
- attr_accessible :test_model , :test_another_model , :attr , :branch , :company , :test_attr ,
79
- :test_a_third_model , :n_way_join_item , :n_way_join_item_id , :test_attr_through_id ,
80
- :test_model_id , :test_another_model_id
80
+ if Rails . version < "4"
81
+ attr_accessible :test_model , :test_another_model , :attr , :branch , :company , :test_attr ,
82
+ :test_a_third_model , :n_way_join_item , :n_way_join_item_id , :test_attr_through_id ,
83
+ :test_model_id , :test_another_model_id
84
+ end
81
85
def initialize ( *args )
82
86
@role_symbols = [ ]
83
87
super ( *args )
@@ -91,7 +95,9 @@ class TestAttrThrough < ActiveRecord::Base
91
95
class TestModelSecurityModel < ActiveRecord ::Base
92
96
has_many :test_attrs
93
97
using_access_control
94
- attr_accessible :attr , :attr_2 , :test_attrs
98
+ if Rails . version < "4"
99
+ attr_accessible :attr , :attr_2 , :test_attrs
100
+ end
95
101
end
96
102
class TestModelSecurityModelWithFind < ActiveRecord ::Base
97
103
if Rails . version < "3.2"
@@ -103,19 +109,25 @@ class TestModelSecurityModelWithFind < ActiveRecord::Base
103
109
belongs_to :test_attr
104
110
using_access_control :include_read => true ,
105
111
:context => :test_model_security_models
106
- attr_accessible :test_attr , :attr
112
+ if Rails . version < "4"
113
+ attr_accessible :test_attr , :attr
114
+ end
107
115
end
108
116
109
117
class Branch < ActiveRecord ::Base
110
118
has_many :test_attrs
111
119
belongs_to :company
112
- attr_accessible :name , :company
120
+ if Rails . version < "4"
121
+ attr_accessible :name , :company
122
+ end
113
123
end
114
124
class Company < ActiveRecord ::Base
115
125
has_many :test_attrs
116
126
has_many :branches
117
127
belongs_to :country
118
- attr_accessible :name , :country , :country_id
128
+ if Rails . version < "4"
129
+ attr_accessible :name , :country , :country_id
130
+ end
119
131
end
120
132
class SmallCompany < Company
121
133
def self . decl_auth_context
@@ -125,7 +137,9 @@ def self.decl_auth_context
125
137
class Country < ActiveRecord ::Base
126
138
has_many :test_models
127
139
has_many :companies
128
- attr_accessible :name
140
+ if Rails . version < "4"
141
+ attr_accessible :name
142
+ end
129
143
end
130
144
131
145
class NamedScopeModelTest < Test ::Unit ::TestCase
@@ -781,7 +795,13 @@ def test_with_contains
781
795
user = MockUser . new ( :test_role ,
782
796
:id => test_model_1 . test_attrs . first . id )
783
797
assert_equal 1 , TestModel . with_permissions_to ( :read , :user => user ) . length
784
- assert_equal 1 , TestModel . with_permissions_to ( :read , :user => user ) . find ( :all , :conditions => { :id => test_model_1 . id } ) . length
798
+ if Rails . version < "4"
799
+ assert_equal 1 , TestModel . with_permissions_to ( :read , :user => user ) .
800
+ find ( :all , :conditions => { :id => test_model_1 . id } ) . length
801
+ else
802
+ assert_equal 1 , TestModel . with_permissions_to ( :read , :user => user ) .
803
+ where ( :id => test_model_1 . id ) . length
804
+ end
785
805
786
806
TestModel . delete_all
787
807
TestAttr . delete_all
0 commit comments