-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding shared ability tests for Fields, Positions, and Templates.
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'test_helper' | ||
|
||
class SharedFieldAbilityTest < ActiveSupport::TestCase | ||
def setup | ||
@user = users(:kristen) | ||
@screen = screens(:one) | ||
@field = fields(:one) | ||
end | ||
|
||
test "anyone can read fields" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.can?(:read, @field) | ||
end | ||
end | ||
|
||
test "no one can update / delete fields" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.cannot?(:update, @field) | ||
assert ability.cannot?(:delete, @field) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'test_helper' | ||
|
||
class SharedPositionAbilityTest < ActiveSupport::TestCase | ||
def setup | ||
@user = users(:kristen) | ||
@screen = screens(:one) | ||
@position = positions(:one) | ||
end | ||
|
||
test "anyone can read positions" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.can?(:read, @position) | ||
end | ||
end | ||
|
||
test "no one can update / delete positions" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.cannot?(:update, @position) | ||
assert ability.cannot?(:delete, @position) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'test_helper' | ||
|
||
class SharedTemplateAbilityTest < ActiveSupport::TestCase | ||
def setup | ||
@user = users(:kristen) | ||
@screen = screens(:one) | ||
@template = templates(:one) | ||
end | ||
|
||
test "anyone can read public templates" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.can?(:read, @template) | ||
end | ||
end | ||
|
||
test "noone can read public templates" do | ||
template = templates(:hidden) | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.cannot?(:read, template) | ||
end | ||
end | ||
|
||
test "no one can update / delete templates" do | ||
[@user, @screen].each do |thing| | ||
ability = Ability.new(thing) | ||
assert ability.cannot?(:update, @template) | ||
assert ability.cannot?(:delete, @template) | ||
end | ||
end | ||
end | ||
|