hydra-head 4.0.0.rc6 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -4
- data/Gemfile.lock +54 -57
- data/README.textile +8 -16
- data/app/assets/stylesheets/hydra/html_refactor.css +3 -9
- data/app/assets/stylesheets/hydra/styles.css +5 -120
- data/app/helpers/facets_helper.rb +4 -0
- data/app/helpers/hydra/blacklight_helper_behavior.rb +9 -41
- data/app/helpers/hydra/facets_helper_behavior.rb +27 -0
- data/app/models/hydra/ability.rb +48 -41
- data/app/models/hydra/role_mapper_behavior.rb +32 -0
- data/app/models/role_mapper.rb +1 -20
- data/config/jetty.yml +6 -0
- data/hydra-head.gemspec +4 -5
- data/lib/generators/hydra/assets_generator.rb +0 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/access_controls_enforcement.rb +4 -64
- data/test_support/etc/Gemfile +1 -0
- data/test_support/features/absent_model_search_result.feature +2 -2
- data/test_support/features/default_partials_search_result.feature +3 -3
- data/test_support/features/generic_content_search_result.feature +3 -3
- data/test_support/features/generic_image_search_result.feature +3 -3
- data/test_support/features/mods_asset_search_result.feature +1 -1
- data/test_support/features/mods_asset_show.feature +1 -1
- data/test_support/features/step_definitions/edit_metadata_steps.rb +1 -1
- data/test_support/features/step_definitions/html_validity_steps.rb +11 -1
- data/test_support/features/view_catalog_index.feature +1 -1
- data/test_support/spec/controllers/catalog_controller_spec.rb +4 -2
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +2 -4
- data/test_support/spec/controllers/catalog_valid_html_spec.rb +4 -7
- data/test_support/spec/controllers/file_assets_controller_spec.rb +1 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +0 -59
- data/test_support/spec/helpers/access_controls_evaluation_spec.rb +2 -2
- data/test_support/spec/helpers/blacklight_helper_spec.rb +1 -17
- data/test_support/spec/models/ability_spec.rb +34 -4
- data/vendor/cache/actionmailer-3.2.3.gem +0 -0
- data/vendor/cache/actionpack-3.2.3.gem +0 -0
- data/vendor/cache/{active-fedora-4.0.0.rc20.gem → active-fedora-4.0.0.gem} +0 -0
- data/vendor/cache/activemodel-3.2.3.gem +0 -0
- data/vendor/cache/activerecord-3.2.3.gem +0 -0
- data/vendor/cache/activeresource-3.2.3.gem +0 -0
- data/vendor/cache/activesupport-3.2.3.gem +0 -0
- data/vendor/cache/{blacklight-3.3.1.gem → blacklight-3.3.2.gem} +0 -0
- data/vendor/cache/factory_girl-3.1.1.gem +0 -0
- data/vendor/cache/fssm-0.2.9.gem +0 -0
- data/vendor/cache/libwebsocket-0.1.3.gem +0 -0
- data/vendor/cache/mocha-0.11.0.gem +0 -0
- data/vendor/cache/multi_json-1.3.2.gem +0 -0
- data/vendor/cache/{rails-3.2.2.gem → rails-3.2.3.gem} +0 -0
- data/vendor/cache/railties-3.2.3.gem +0 -0
- data/vendor/cache/rdf-0.3.5.2.gem +0 -0
- data/vendor/cache/rsolr-1.0.8.gem +0 -0
- data/vendor/cache/rspec-expectations-2.9.1.gem +0 -0
- data/vendor/cache/rubydora-0.5.8.gem +0 -0
- data/vendor/cache/rubyzip-0.9.7.gem +0 -0
- data/vendor/cache/sass-3.1.16.gem +0 -0
- data/vendor/cache/selenium-webdriver-2.21.2.gem +0 -0
- data/vendor/cache/solrizer-fedora-2.0.0.gem +0 -0
- data/vendor/cache/sqlite3-1.3.6.gem +0 -0
- data/vendor/cache/tzinfo-0.3.33.gem +0 -0
- metadata +158 -76
- data/Tools.textile +0 -72
- data/app/views/catalog/_search_form.html.erb +0 -12
- data/vendor/cache/actionmailer-3.2.2.gem +0 -0
- data/vendor/cache/actionpack-3.2.2.gem +0 -0
- data/vendor/cache/activemodel-3.2.2.gem +0 -0
- data/vendor/cache/activerecord-3.2.2.gem +0 -0
- data/vendor/cache/activeresource-3.2.2.gem +0 -0
- data/vendor/cache/activesupport-3.2.2.gem +0 -0
- data/vendor/cache/factory_girl-3.0.0.gem +0 -0
- data/vendor/cache/fssm-0.2.8.1.gem +0 -0
- data/vendor/cache/mocha-0.10.5.gem +0 -0
- data/vendor/cache/multi_json-1.2.0.gem +0 -0
- data/vendor/cache/railties-3.2.2.gem +0 -0
- data/vendor/cache/rdf-0.3.5.1.gem +0 -0
- data/vendor/cache/rsolr-1.0.6.gem +0 -0
- data/vendor/cache/rspec-expectations-2.9.0.gem +0 -0
- data/vendor/cache/rubydora-0.5.7.gem +0 -0
- data/vendor/cache/rubyzip-0.9.6.1.gem +0 -0
- data/vendor/cache/sass-3.1.15.gem +0 -0
- data/vendor/cache/selenium-webdriver-2.20.0.gem +0 -0
- data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
- data/vendor/cache/solrizer-fedora-1.2.5.gem +0 -0
- data/vendor/cache/sqlite3-1.3.5.gem +0 -0
- data/vendor/cache/tzinfo-0.3.32.gem +0 -0
data/test_support/etc/Gemfile
CHANGED
@@ -6,13 +6,13 @@ Feature: Objects Without Models - Search Results
|
|
6
6
|
Scenario: html5 valid - unauthenticated
|
7
7
|
When I am on the home page
|
8
8
|
And I fill in "q" with "test"
|
9
|
-
And I press "
|
9
|
+
And I press "search"
|
10
10
|
Then I should not see a link to "the show document page for hydra:test_no_model"
|
11
11
|
|
12
12
|
Scenario: html5 valid - authenticated
|
13
13
|
Given I am logged in as "archivist1@example.com"
|
14
14
|
And I am on the home page
|
15
15
|
And I fill in "q" with "test"
|
16
|
-
When I press "
|
16
|
+
When I press "search"
|
17
17
|
Then the page should be HTML5 valid
|
18
18
|
|
@@ -4,19 +4,19 @@ Feature: Default Partials in Search Results
|
|
4
4
|
Scenario: Have a Search Result that is an Object That Uses Default Partials
|
5
5
|
Given I am on the home page
|
6
6
|
And I fill in "q" with "default"
|
7
|
-
When I press "
|
7
|
+
When I press "search"
|
8
8
|
Then I should see a link to "the show document page for hydra:test_default_partials"
|
9
9
|
|
10
10
|
Scenario: html5 valid - unauthenticated
|
11
11
|
Given I am on the home page
|
12
12
|
And I fill in "q" with "default"
|
13
|
-
When I press "
|
13
|
+
When I press "search"
|
14
14
|
Then the page should be HTML5 valid
|
15
15
|
|
16
16
|
Scenario: html5 valid - authenticated
|
17
17
|
Given I am logged in as "archivist1@example.com"
|
18
18
|
And I am on the home page
|
19
19
|
And I fill in "q" with "default"
|
20
|
-
When I press "
|
20
|
+
When I press "search"
|
21
21
|
Then I should see a link to "the show document page for hydra:test_default_partials"
|
22
22
|
And the page should be HTML5 valid
|
@@ -4,19 +4,19 @@ Feature: GenericContent Search Results
|
|
4
4
|
Scenario: Have a GenericContent Search Result
|
5
5
|
Given I am on the home page
|
6
6
|
And I fill in "q" with "generic content"
|
7
|
-
When I press "
|
7
|
+
When I press "search"
|
8
8
|
Then I should see a link to "the show document page for hydra:test_generic_content"
|
9
9
|
|
10
10
|
Scenario: html5 valid - unauthenticated
|
11
11
|
Given I am on the home page
|
12
12
|
And I fill in "q" with "generic content"
|
13
|
-
When I press "
|
13
|
+
When I press "search"
|
14
14
|
Then the page should be HTML5 valid
|
15
15
|
|
16
16
|
Scenario: html5 valid - authenticated
|
17
17
|
Given I am logged in as "archivist1@example.com"
|
18
18
|
And I am on the home page
|
19
19
|
And I fill in "q" with "generic content"
|
20
|
-
When I press "
|
20
|
+
When I press "search"
|
21
21
|
Then the page should be HTML5 valid
|
22
22
|
|
@@ -4,19 +4,19 @@ Feature: GenericImage Search Results
|
|
4
4
|
Scenario: Have a GenericImage Search Result
|
5
5
|
Given I am on the home page
|
6
6
|
And I fill in "q" with "generic image"
|
7
|
-
When I press "
|
7
|
+
When I press "search"
|
8
8
|
Then I should see a link to "the show document page for hydra:test_generic_image"
|
9
9
|
|
10
10
|
Scenario: html5 valid - unauthenticated
|
11
11
|
Given I am on the home page
|
12
12
|
And I fill in "q" with "generic image"
|
13
|
-
When I press "
|
13
|
+
When I press "search"
|
14
14
|
Then the page should be HTML5 valid
|
15
15
|
|
16
16
|
Scenario: html5 valid - authenticated
|
17
17
|
Given I am logged in as "archivist1@example.com"
|
18
18
|
And I am on the home page
|
19
19
|
And I fill in "q" with "generic image"
|
20
|
-
When I press "
|
20
|
+
When I press "search"
|
21
21
|
Then the page should be HTML5 valid
|
22
22
|
|
@@ -6,7 +6,7 @@ Feature: ModsAsset Search Result
|
|
6
6
|
Scenario: Search Results have ModsAsset info
|
7
7
|
Given I am on the home page
|
8
8
|
And I fill in "q" with "1234-5678"
|
9
|
-
When I press "
|
9
|
+
When I press "search"
|
10
10
|
Then I should see a link to "the show document page for hydrangea:fixture_mods_article3"
|
11
11
|
And I should see "Test Article"
|
12
12
|
And I should see "Aug. 1, 1998"
|
@@ -30,7 +30,7 @@ Feature: ModsAsset Show View
|
|
30
30
|
Scenario: Public visit Document Show Page for a private document
|
31
31
|
Given I am on the show document page for hydrangea:fixture_archivist_only_mods_article
|
32
32
|
Then I should be on the search page
|
33
|
-
And I should see "You do not have sufficient access privileges to read this document, which has been marked private" within ".
|
33
|
+
And I should see "You do not have sufficient access privileges to read this document, which has been marked private" within ".alert"
|
34
34
|
|
35
35
|
@overwritten
|
36
36
|
Scenario: Superuser visits Document Show Page for a private document
|
@@ -47,7 +47,7 @@ Then /^I should see a "([^"]*)" button(?: within "([^"]*)")?$/ do |button_locato
|
|
47
47
|
end
|
48
48
|
|
49
49
|
Given /^that "([^"]*)" has been loaded into fedora$/ do |pid|
|
50
|
-
ActiveFedora::FixtureLoader.new('
|
50
|
+
ActiveFedora::FixtureLoader.new(File.dirname(__FILE__) + '/../../fixtures').reload(pid)
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -19,6 +19,9 @@ def response_is_html_valid?(resp)
|
|
19
19
|
rescue SocketError, RestClient::BadGateway #meaning we're either not connected to the internet or we were throttled by the validator.
|
20
20
|
puts "WARNING: No connection to W3C validator. Page may not be HTML5 valid!"
|
21
21
|
return true
|
22
|
+
rescue RestClient::RequestTimeout
|
23
|
+
puts "WARNING: Timeout connecting to W3C validator. Page may not be HTML5 valid!"
|
24
|
+
return true
|
22
25
|
end
|
23
26
|
|
24
27
|
xml = Nokogiri::XML(validator_response)
|
@@ -26,6 +29,13 @@ def response_is_html_valid?(resp)
|
|
26
29
|
#removing namespaces because we really don't care
|
27
30
|
xml.remove_namespaces!
|
28
31
|
|
32
|
+
fault = xml.xpath("//Fault/Code/Subcode/Value").text
|
33
|
+
if fault.present?
|
34
|
+
puts "WARNING: There was an error with the W3C validator. Page may not be HTML5 valid!"
|
35
|
+
puts "FAULT: #{fault}"
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
|
29
39
|
# "true" or "false"
|
30
40
|
valid = xml.xpath("//validity").text
|
31
41
|
error_list = xml.xpath("//errors/errorlist/error")
|
@@ -54,4 +64,4 @@ def response_is_html_valid?(resp)
|
|
54
64
|
puts text unless errors == []
|
55
65
|
return false
|
56
66
|
end
|
57
|
-
end
|
67
|
+
end
|
@@ -11,7 +11,7 @@ Feature: Catalog Index
|
|
11
11
|
Scenario: Executing a search
|
12
12
|
Given I am on the catalog index page
|
13
13
|
And I fill in "q" with "hydrangea"
|
14
|
-
And I press "
|
14
|
+
And I press "search"
|
15
15
|
Then I should see "Title"
|
16
16
|
And I should see "Author"
|
17
17
|
And I should see "Work"
|
@@ -72,12 +72,14 @@ describe CatalogController do
|
|
72
72
|
assigns(:document_list).count.should == @public_only_results.docs.count
|
73
73
|
end
|
74
74
|
it "should return all documents if role does have permissions" do
|
75
|
-
|
76
|
-
mock_user = User.new
|
75
|
+
mock_user = FactoryGirl.create(:user, :email=>"BigWig@example.com")
|
77
76
|
# session[:superuser_mode] = true
|
78
77
|
mock_user.stubs(:is_being_superuser?).returns(true)
|
78
|
+
#sign_in mock_user
|
79
79
|
controller.stubs(:current_user).returns(mock_user)
|
80
80
|
get :index
|
81
|
+
### This fails when there are more than 10 public documents in the solr index
|
82
|
+
### TODO: instead, expect a certain query(especially the :fq component) to solr
|
81
83
|
assigns(:document_list).count.should > @public_only_results.docs.count
|
82
84
|
end
|
83
85
|
end
|
@@ -41,10 +41,8 @@ describe CatalogController do
|
|
41
41
|
|
42
42
|
describe "edit" do
|
43
43
|
it "should enforce edit permissions, redirecting to show action and resetting session context if user does not have edit permissions" do
|
44
|
-
mock_user =
|
45
|
-
mock_user
|
46
|
-
mock_user.stubs(:is_being_superuser?).returns(false)
|
47
|
-
controller.stubs(:current_user).returns(mock_user)
|
44
|
+
mock_user = FactoryGirl.build(:user, :email => "patron1@example.com")
|
45
|
+
sign_in mock_user
|
48
46
|
|
49
47
|
get :edit, :id=>"hydrangea:fixture_mods_article1"
|
50
48
|
response.should redirect_to(:action => 'show')
|
@@ -42,13 +42,11 @@ describe CatalogController do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "Should have Valid HTML when I'm logged in" do
|
45
|
-
|
46
|
-
mock_user = mock("User")
|
47
|
-
mock_user.stubs(:email).returns("archivist1@example.com")
|
45
|
+
mock_user = FactoryGirl.build(:user, :email=>"archivist1@example.com")
|
48
46
|
mock_user.stubs(:can_be_superuser?).returns(true)
|
49
47
|
mock_user.stubs(:is_being_superuser?).returns(true)
|
50
48
|
|
51
|
-
|
49
|
+
sign_in mock_user
|
52
50
|
get("index", "controller"=>"catalog")
|
53
51
|
document_check(response.body)
|
54
52
|
end
|
@@ -57,11 +55,10 @@ describe CatalogController do
|
|
57
55
|
describe "Document Pages" do
|
58
56
|
|
59
57
|
before(:each) do
|
60
|
-
mock_user =
|
61
|
-
mock_user.stubs(:email).returns("archivist1@example.com")
|
58
|
+
mock_user = FactoryGirl.build(:user, :email=>"archivist1@example.com")
|
62
59
|
mock_user.stubs(:can_be_superuser?).returns(true)
|
63
60
|
mock_user.stubs(:is_being_superuser?).returns(true)
|
64
|
-
|
61
|
+
sign_in mock_user
|
65
62
|
end
|
66
63
|
|
67
64
|
#Article Data Type
|
@@ -59,6 +59,7 @@ describe Hydra::FileAssetsController do
|
|
59
59
|
mock_user = mock("User")
|
60
60
|
mock_user.stubs(:email).returns("fake_user@example.com")
|
61
61
|
mock_user.stubs(:is_being_superuser?).returns(false)
|
62
|
+
mock_user.stubs(:new_record?).returns(false)
|
62
63
|
controller.stubs(:current_user).returns(mock_user)
|
63
64
|
get(:show, :id=>"hydrangea:fixture_file_asset1")
|
64
65
|
response.should redirect_to(:action => 'index')
|
@@ -89,65 +89,6 @@ describe Hydra::AccessControlsEnforcement do
|
|
89
89
|
@solr_parameters[:fq].should include("-has_model_s:\"info:fedora/afmodel:FileAsset\"")
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
93
|
-
describe "build_lucene_query" do
|
94
|
-
|
95
|
-
it "should return fields for all roles the user is a member of checking against the discover, access, read fields" do
|
96
|
-
stub_user = User.new :email=>'archivist1@example.com'
|
97
|
-
stub_user.stubs(:is_being_superuser?).returns false
|
98
|
-
helper.stubs(:current_user).returns(stub_user)
|
99
|
-
# This example assumes that archivist1 is in the archivist and researcher groups.
|
100
|
-
# Tried stubbing RoleMapper.roles instead, but that broke 26 other tests because mocha fails to release the expectation.
|
101
|
-
# RoleMapper.stubs(:roles).with(stub_user.email).returns(["archivist", "researcher"])
|
102
|
-
query = helper.send(:build_lucene_query, "query_string")
|
103
|
-
# RoleMapper.stubs(:roles).with(stub_user.email).returns(["archivist", "researcher"])
|
104
|
-
# query = helper.send(:build_lucene_query, "string")
|
105
|
-
|
106
|
-
["discover","edit","read"].each do |type|
|
107
|
-
query.should match(/_query_\:\"#{type}_access_group_t\:archivist/) and
|
108
|
-
query.should match(/_query_\:\"#{type}_access_group_t\:researcher/)
|
109
|
-
end
|
110
|
-
query.should match /^_query_:"\{!dismax qf=\$qf_dismax pf=\$pf_dismax\}query_string" AND NOT _query_:"info\\\\:fedora\/afmodel\\\\:FileAsset"/
|
111
|
-
end
|
112
|
-
it "should not have dismax clause if no user_query is suplied" do
|
113
|
-
stub_user = User.new
|
114
|
-
stub_user.stubs(:is_being_superuser?).returns false
|
115
|
-
helper.stubs(:current_user).returns(stub_user)
|
116
|
-
query = helper.send(:build_lucene_query, nil)
|
117
|
-
query.should match /^NOT _query_:"info\\\\:fedora\/afmodel\\\\:FileAsset"/
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should return fields for all the person specific discover, access, read fields" do
|
121
|
-
stub_user = User.new
|
122
|
-
stub_user.stubs(:is_being_superuser?).returns false
|
123
|
-
helper.stubs(:current_user).returns(stub_user)
|
124
|
-
query = helper.send(:build_lucene_query, "string")
|
125
|
-
["discover","edit","read"].each do |type|
|
126
|
-
query.should match(/_query_\:\"#{type}_access_person_t\:#{stub_user.email}/)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
describe "for superusers" do
|
130
|
-
it "should return superuser access level" do
|
131
|
-
stub_user = User.new
|
132
|
-
stub_user.stubs(:is_being_superuser?).returns true
|
133
|
-
helper.stubs(:current_user).returns(stub_user)
|
134
|
-
query = helper.send(:build_lucene_query, "string")
|
135
|
-
["discover","edit","read"].each do |type|
|
136
|
-
query.should match(/_query_\:\"#{type}_access_person_t\:\[\* TO \*\]/)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
it "should not return superuser access to non-superusers" do
|
140
|
-
stub_user = User.new
|
141
|
-
stub_user.stubs(:is_being_superuser?).returns false
|
142
|
-
helper.stubs(:current_user).returns(stub_user)
|
143
|
-
query = helper.send(:build_lucene_query, "string")
|
144
|
-
["discover","edit","read"].each do |type|
|
145
|
-
query.should_not match(/_query_\:\"#{type}_access_person_t\:\[\* TO \*\]/)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
92
|
end
|
152
93
|
|
153
94
|
|
@@ -4,8 +4,7 @@ describe Hydra::AccessControlsEvaluation do
|
|
4
4
|
|
5
5
|
describe "editor?" do
|
6
6
|
it "should return true if current_user.is_being_superuser? is true" do
|
7
|
-
mock_user =
|
8
|
-
mock_user.stubs(:email).returns "BigWig@example.com"
|
7
|
+
mock_user = FactoryGirl.build(:user, :email => "BigWig@example.com")
|
9
8
|
mock_user.stubs(:is_being_superuser?).returns true
|
10
9
|
controller.stubs(:current_user).returns mock_user
|
11
10
|
helper.editor?.should be_true
|
@@ -18,6 +17,7 @@ describe Hydra::AccessControlsEvaluation do
|
|
18
17
|
mock_user = mock("User")
|
19
18
|
mock_user.stubs(:email).returns "nobody_special@example.com"
|
20
19
|
mock_user.stubs(:is_being_superuser?).returns(false)
|
20
|
+
mock_user.stubs(:new_record?).returns(false)
|
21
21
|
controller.stubs(:current_user).returns(mock_user)
|
22
22
|
helper.editor?.should be_false
|
23
23
|
end
|
@@ -5,12 +5,6 @@ describe BlacklightHelper do
|
|
5
5
|
BlacklightHelper.included_modules.should include(HydraHelper)
|
6
6
|
end
|
7
7
|
|
8
|
-
describe "Application Name Sanity Check" do
|
9
|
-
it "should have the application correct name" do
|
10
|
-
helper.application_name.should == "A Hydra Head"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
8
|
describe "Overridden blacklight methods" do
|
15
9
|
describe "document_partial_name" do
|
16
10
|
|
@@ -28,20 +22,10 @@ describe BlacklightHelper do
|
|
28
22
|
item = stub("item", :value=>'two', :hits=>9)
|
29
23
|
|
30
24
|
ret_val = helper.render_selected_facet_value("one", item)
|
31
|
-
ret_val.should == "<span class=\"selected
|
25
|
+
ret_val.should == "<span class=\"selected\">two <span class=\"count\">(9)</span></span>"
|
32
26
|
ret_val.should be_html_safe
|
33
27
|
end
|
34
28
|
end
|
35
|
-
describe "render_head_content" do
|
36
|
-
before (:each) do
|
37
|
-
helper.expects(:content_for).with(:head).returns("My added content")
|
38
|
-
head_stuff = ["Something extra", "Stuff for unapi-server"]
|
39
|
-
helper.expects(:extra_head_content).twice().returns(head_stuff)
|
40
|
-
end
|
41
|
-
it "adds the content of content_for(:head) to the output" do
|
42
|
-
helper.render_head_content.should == "Something extraMy added content"
|
43
|
-
end
|
44
|
-
end
|
45
29
|
|
46
30
|
describe "link back to catalog" do
|
47
31
|
it "should return the view parameter in the link back to catalog method if there is one in the users previous search session" do
|
@@ -1,10 +1,40 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe Ability do
|
4
|
-
|
5
4
|
it "should call custom_permissions" do
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
Ability.any_instance.expects(:custom_permissions)
|
6
|
+
subject = Ability.new(nil)
|
7
|
+
subject.can?(:delete, 7)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "for a not-signed in user" do
|
11
|
+
subject { Ability.new(nil) }
|
12
|
+
it "should be able to read objects that are public" do
|
13
|
+
public_object = ModsAsset.new
|
14
|
+
public_object.rightsMetadata.update_permissions("group"=>{'public'=>'read'})
|
15
|
+
public_object.save
|
16
|
+
subject.can?(:read, public_object).should be_true
|
17
|
+
end
|
18
|
+
it "should not be able to read objects that are registered" do
|
19
|
+
registered_object = ModsAsset.new
|
20
|
+
registered_object.rightsMetadata.update_permissions("group"=>{'registered'=>'read'})
|
21
|
+
registered_object.save
|
22
|
+
subject.can?(:read, registered_object).should_not be_true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context "for a signed in user" do
|
26
|
+
subject { Ability.new(FactoryGirl.create(:user)) }
|
27
|
+
it "should be able to read objects that are public" do
|
28
|
+
public_object = ModsAsset.new
|
29
|
+
public_object.rightsMetadata.update_permissions("group"=>{'public'=>'read'})
|
30
|
+
public_object.save
|
31
|
+
subject.can?(:read, public_object).should be_true
|
32
|
+
end
|
33
|
+
it "should be able to read objects that are registered" do
|
34
|
+
registered_object = ModsAsset.new
|
35
|
+
registered_object.rightsMetadata.update_permissions("group"=>{'registered'=>'read'})
|
36
|
+
registered_object.save
|
37
|
+
subject.can?(:read, registered_object).should be_true
|
38
|
+
end
|
9
39
|
end
|
10
40
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|