File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,20 @@ class DiaryTest < ActiveSupport::TestCase
2020 assert_not diary . creatable_by? ( diary . owner . account ) ;
2121 assert diary . save ( ) , "Diary model were not saved" ;
2222 end
23+
24+ test "only admin and moderator can update a diary" do
25+ diary = diaries ( :lorem ) ;
26+ assert_not diary . updatable_by? ( accounts ( :visitor_1 ) ) ;
27+ assert_not diary . updatable_by? ( accounts ( :maintainer_1 ) ) ;
28+ assert diary . updatable_by? ( accounts ( :moderator_1 ) ) ;
29+ assert diary . updatable_by? ( accounts ( :admin_1 ) ) ;
30+ end
31+
32+ test "only admin and moderator can destroy a diary" do
33+ diary = diaries ( :lorem ) ;
34+ assert_not diary . destroyable_by? ( accounts ( :visitor_1 ) ) ;
35+ assert_not diary . destroyable_by? ( accounts ( :maintainer_1 ) ) ;
36+ assert diary . destroyable_by? ( accounts ( :moderator_1 ) ) ;
37+ assert diary . destroyable_by? ( accounts ( :admin_1 ) ) ;
38+ end
2339end
You can’t perform that action at this time.
0 commit comments