Class: ActiveRecordPermissionsTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



54
55
56
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb', line 54

def setup
  @model = PermissionModel.new
end

#test_method_combinations_with_default_falseObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb', line 103

def test_method_combinations_with_default_false
  ActiveRecordPermissions.default_permission = false

  fail(@model.authorized_for?(:column => :a3), '_a_')
  fail(@model.authorized_for?(:column => :a2), '_f_')
  pass(@model.authorized_for?(:column => :a1), '_t_')

  fail(@model.authorized_for?(:action => :create), 'a__')
  fail(@model.authorized_for?(:action => :update), 'f__')
  pass(@model.authorized_for?(:action => :read), 't__')

  fail(@model.authorized_for?(:action => :create, :column => :c3), 'aaa')
  fail(@model.authorized_for?(:action => :create, :column => :b3), 'aaf')
  pass(@model.authorized_for?(:action => :create, :column => :a3), 'aat')
  fail(@model.authorized_for?(:action => :create, :column => :c2), 'afa')
  fail(@model.authorized_for?(:action => :create, :column => :b2), 'aff')
  fail(@model.authorized_for?(:action => :create, :column => :a2), 'aft')
  pass(@model.authorized_for?(:action => :create, :column => :c1), 'ata')
  fail(@model.authorized_for?(:action => :create, :column => :b1), 'atf')
  pass(@model.authorized_for?(:action => :create, :column => :a1), 'att')

  fail(@model.authorized_for?(:action => :update, :column => :c3), 'faa')
  fail(@model.authorized_for?(:action => :update, :column => :b3), 'faf')
  fail(@model.authorized_for?(:action => :update, :column => :a3), 'fat')
  fail(@model.authorized_for?(:action => :update, :column => :c2), 'ffa')
  fail(@model.authorized_for?(:action => :update, :column => :b2), 'fff')
  fail(@model.authorized_for?(:action => :update, :column => :a2), 'fft')
  fail(@model.authorized_for?(:action => :update, :column => :c1), 'fta')
  fail(@model.authorized_for?(:action => :update, :column => :b1), 'ftf')
  fail(@model.authorized_for?(:action => :update, :column => :a1), 'ftt')

  pass(@model.authorized_for?(:action => :read, :column => :c3), 'taa')
  fail(@model.authorized_for?(:action => :read, :column => :b3), 'taf')
  pass(@model.authorized_for?(:action => :read, :column => :a3), 'tat')
  fail(@model.authorized_for?(:action => :read, :column => :c2), 'tfa')
  fail(@model.authorized_for?(:action => :read, :column => :b2), 'tff')
  fail(@model.authorized_for?(:action => :read, :column => :a2), 'tft')
  pass(@model.authorized_for?(:action => :read, :column => :c1), 'tta')
  fail(@model.authorized_for?(:action => :read, :column => :b1), 'ttf')
  pass(@model.authorized_for?(:action => :read, :column => :a1), 'ttt')
end

#test_method_combinations_with_default_trueObject

Combinations Legend:

columns are: action method, column method, action/column method
symbols are: is (a)bsent, returns (f)alse, returns (t)rue, or n/a (_)


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb', line 61

def test_method_combinations_with_default_true
  ActiveRecordPermissions.default_permission = true

  pass(@model.authorized_for?(:column => :a3), '_a_')
  fail(@model.authorized_for?(:column => :a2), '_f_')
  pass(@model.authorized_for?(:column => :a1), '_t_')

  pass(@model.authorized_for?(:action => :create), 'a__')
  fail(@model.authorized_for?(:action => :update), 'f__')
  pass(@model.authorized_for?(:action => :read), 't__')

  pass(@model.authorized_for?(:action => :create, :column => :c3), 'aaa')
  fail(@model.authorized_for?(:action => :create, :column => :b3), 'aaf')
  pass(@model.authorized_for?(:action => :create, :column => :a3), 'aat')
  fail(@model.authorized_for?(:action => :create, :column => :c2), 'afa')
  fail(@model.authorized_for?(:action => :create, :column => :b2), 'aff')
  fail(@model.authorized_for?(:action => :create, :column => :a2), 'aft')
  pass(@model.authorized_for?(:action => :create, :column => :c1), 'ata')
  fail(@model.authorized_for?(:action => :create, :column => :b1), 'atf')
  pass(@model.authorized_for?(:action => :create, :column => :a1), 'att')

  fail(@model.authorized_for?(:action => :update, :column => :c3), 'faa')
  fail(@model.authorized_for?(:action => :update, :column => :b3), 'faf')
  fail(@model.authorized_for?(:action => :update, :column => :a3), 'fat')
  fail(@model.authorized_for?(:action => :update, :column => :c2), 'ffa')
  fail(@model.authorized_for?(:action => :update, :column => :b2), 'fff')
  fail(@model.authorized_for?(:action => :update, :column => :a2), 'fft')
  fail(@model.authorized_for?(:action => :update, :column => :c1), 'fta')
  fail(@model.authorized_for?(:action => :update, :column => :b1), 'ftf')
  fail(@model.authorized_for?(:action => :update, :column => :a1), 'ftt')

  pass(@model.authorized_for?(:action => :read, :column => :c3), 'taa')
  fail(@model.authorized_for?(:action => :read, :column => :b3), 'taf')
  pass(@model.authorized_for?(:action => :read, :column => :a3), 'tat')
  fail(@model.authorized_for?(:action => :read, :column => :c2), 'tfa')
  fail(@model.authorized_for?(:action => :read, :column => :b2), 'tff')
  fail(@model.authorized_for?(:action => :read, :column => :a2), 'tft')
  pass(@model.authorized_for?(:action => :read, :column => :c1), 'tta')
  fail(@model.authorized_for?(:action => :read, :column => :b1), 'ttf')
  pass(@model.authorized_for?(:action => :read, :column => :a1), 'ttt')
end