enju_library 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/app/controllers/shelves_controller.rb +2 -1
- data/app/helpers/shelves_helper.rb +9 -5
- data/app/models/library.rb +1 -2
- data/app/models/library_group.rb +7 -1
- data/app/models/shelf.rb +1 -0
- data/app/views/accepts/index.html.erb +2 -2
- data/app/views/bookstores/index.html.erb +3 -3
- data/app/views/bookstores/show.html.erb +1 -1
- data/app/views/budget_types/index.html.erb +2 -2
- data/app/views/libraries/_form.html.erb +1 -1
- data/app/views/libraries/index.html.erb +3 -3
- data/app/views/libraries/show.html.erb +1 -1
- data/app/views/library_groups/index.html.erb +1 -1
- data/app/views/request_status_types/index.html.erb +2 -2
- data/app/views/request_types/index.html.erb +2 -2
- data/app/views/search_engines/index.html.erb +2 -2
- data/app/views/shelves/_library_facet.html.erb +1 -4
- data/app/views/shelves/index.html.erb +2 -2
- data/app/views/shelves/show.mobile.erb +33 -0
- data/app/views/subscribes/index.html.erb +2 -2
- data/app/views/subscriptions/index.html.erb +2 -2
- data/app/views/subscriptions/show.html.erb +1 -1
- data/lib/enju_library/engine.rb +0 -8
- data/lib/enju_library/version.rb +1 -1
- data/lib/enju_library.rb +0 -2
- data/spec/controllers/bookstores_controller_spec.rb +447 -0
- data/spec/controllers/budget_types_controller_spec.rb +167 -0
- data/spec/controllers/libraries_controller_spec.rb +517 -0
- data/spec/controllers/library_groups_controller_spec.rb +133 -0
- data/spec/controllers/request_status_types_controller_spec.rb +447 -0
- data/spec/controllers/request_types_controller_spec.rb +447 -0
- data/spec/controllers/search_engines_controller_spec.rb +447 -0
- data/spec/controllers/shelves_controller_spec.rb +437 -0
- data/spec/controllers/subscribes_controller_spec.rb +441 -0
- data/spec/controllers/subscriptions_controller_spec.rb +442 -0
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +59 -0
- data/spec/dummy/app/helpers/application_helper.rb +13 -0
- data/spec/dummy/app/models/ability.rb +51 -0
- data/spec/dummy/app/models/picture_file.rb +49 -0
- data/spec/dummy/app/models/role.rb +46 -0
- data/spec/dummy/app/models/user.rb +94 -0
- data/spec/dummy/app/models/user_group.rb +40 -0
- data/spec/dummy/app/models/user_has_role.rb +5 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/{test → spec}/dummy/config/application.rb +3 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/devise.rb +205 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/secret_token.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +2 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +58 -0
- data/spec/dummy/db/migrate/005_create_manifestations.rb +61 -0
- data/spec/dummy/db/migrate/006_create_items.rb +31 -0
- data/spec/dummy/db/migrate/012_create_owns.rb +12 -0
- data/spec/dummy/db/migrate/015_create_creates.rb +12 -0
- data/spec/dummy/db/migrate/047_create_produces.rb +12 -0
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +11 -0
- data/spec/dummy/db/migrate/077_create_user_groups.rb +16 -0
- data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +13 -0
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +13 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +12 -0
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +28 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +23 -0
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +16 -0
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +15 -0
- data/spec/dummy/db/migrate/20090812151902_create_patron_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +27 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -0
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100606073747_create_patron_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20100814091104_add_position_to_patron_relationship.rb +11 -0
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +9 -0
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb +11 -0
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +13 -0
- data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +9 -0
- data/{db → spec/dummy/db}/migrate/20110620173525_add_bookstore_id_to_item.rb +0 -0
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +9 -0
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +12 -0
- data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +13 -0
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +13 -0
- data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +13 -0
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20110918161853_rename_series_statement_manifestation_id_to_root_manifestation_id.rb +13 -0
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +7 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +16 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +44 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +5 -0
- data/spec/dummy/db/schema.rb +642 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/{test → spec}/dummy/script/rails +0 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/_k.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_k.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_k.fnm +3 -0
- data/spec/dummy/solr/data/test/index/_k.frq +1 -0
- data/spec/dummy/solr/data/test/index/_k.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_k.prx +0 -0
- data/spec/dummy/solr/data/test/index/_k.tii +0 -0
- data/spec/dummy/solr/data/test/index/_k.tis +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_18 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/dummy/tmp/cache/4AD/470/country_all +0 -0
- data/spec/factories/bookstore.rb +5 -0
- data/spec/factories/budget_types.rb +5 -0
- data/spec/factories/carrier_types.yml +51 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/manifestation.rb +6 -0
- data/spec/factories/request_status_type.rb +5 -0
- data/spec/factories/request_type.rb +5 -0
- data/spec/factories/search_engine.rb +9 -0
- data/spec/factories/shelf.rb +6 -0
- data/spec/factories/subscribe.rb +8 -0
- data/spec/factories/subscription.rb +6 -0
- data/spec/factories/user.rb +37 -0
- data/spec/fixtures/bookstores.yml +107 -0
- data/spec/fixtures/budget_types.yml +29 -0
- data/spec/fixtures/carrier_types.yml +51 -0
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/libraries.yml +102 -0
- data/spec/fixtures/library_groups.yml +33 -0
- data/spec/fixtures/manifestations.yml +2022 -0
- data/spec/fixtures/request_status_types.yml +63 -0
- data/spec/fixtures/request_types.yml +55 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/search_engines.yml +41 -0
- data/spec/fixtures/shelves.yml +47 -0
- data/spec/fixtures/subscribes.yml +45 -0
- data/spec/fixtures/subscriptions.yml +27 -0
- data/spec/fixtures/user_groups.yml +31 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +129 -0
- data/spec/models/bookstore_spec.rb +26 -0
- data/spec/models/budget_type_spec.rb +22 -0
- data/spec/models/library_group_spec.rb +33 -0
- data/spec/models/library_spec.rb +47 -0
- data/spec/models/request_status_type_spec.rb +21 -0
- data/spec/models/request_type_spec.rb +21 -0
- data/spec/models/search_engine_spec.rb +29 -0
- data/spec/models/shelf_spec.rb +29 -0
- data/spec/models/subscribe_spec.rb +21 -0
- data/spec/models/subscription_spec.rb +26 -0
- data/spec/routing/budget_types_routing_spec.rb +35 -0
- data/spec/routing/libraries_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/support/controller_macros.rb +46 -0
- data/spec/support/devise.rb +4 -0
- data/spec/support/vcr.rb +9 -0
- data/spec/views/budget_types/edit.html.erb_spec.rb +23 -0
- data/spec/views/budget_types/index.html.erb_spec.rb +28 -0
- data/spec/views/budget_types/new.html.erb_spec.rb +23 -0
- data/spec/views/budget_types/show.html.erb_spec.rb +24 -0
- metadata +372 -198
- data/lib/enju_library/master_model.rb +0 -19
- data/lib/enju_library/url_validator.rb +0 -10
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +0 -0
- data/test/enju_library_test.rb +0 -7
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
@@ -0,0 +1,442 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sunspot/rails/spec_helper'
|
3
|
+
|
4
|
+
describe SubscriptionsController do
|
5
|
+
fixtures :all
|
6
|
+
|
7
|
+
def valid_attributes
|
8
|
+
FactoryGirl.attributes_for(:subscription)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET index", :solr => true do
|
12
|
+
before do
|
13
|
+
Subscription.reindex
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "When logged in as Administrator" do
|
17
|
+
login_admin
|
18
|
+
|
19
|
+
it "assigns all subscriptions as @subscriptions" do
|
20
|
+
get :index
|
21
|
+
assigns(:subscriptions).should eq(Subscription.page(1))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "When logged in as Librarian" do
|
26
|
+
login_librarian
|
27
|
+
|
28
|
+
it "assigns all subscriptions as @subscriptions" do
|
29
|
+
get :index
|
30
|
+
assigns(:subscriptions).should eq(Subscription.page(1))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "When logged in as User" do
|
35
|
+
login_user
|
36
|
+
|
37
|
+
it "assigns all subscriptions as @subscriptions" do
|
38
|
+
get :index
|
39
|
+
assigns(:subscriptions).should be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "When not logged in" do
|
44
|
+
it "assigns all subscriptions as @subscriptions" do
|
45
|
+
get :index
|
46
|
+
assigns(:subscriptions).should be_empty
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "GET show" do
|
52
|
+
describe "When logged in as Administrator" do
|
53
|
+
login_admin
|
54
|
+
|
55
|
+
it "assigns the requested subscription as @subscription" do
|
56
|
+
subscription = FactoryGirl.create(:subscription)
|
57
|
+
get :show, :id => subscription.id
|
58
|
+
assigns(:subscription).should eq(subscription)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "When logged in as Librarian" do
|
63
|
+
login_librarian
|
64
|
+
|
65
|
+
it "assigns the requested subscription as @subscription" do
|
66
|
+
subscription = FactoryGirl.create(:subscription)
|
67
|
+
get :show, :id => subscription.id
|
68
|
+
assigns(:subscription).should eq(subscription)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "When logged in as User" do
|
73
|
+
login_user
|
74
|
+
|
75
|
+
it "assigns the requested subscription as @subscription" do
|
76
|
+
subscription = FactoryGirl.create(:subscription)
|
77
|
+
get :show, :id => subscription.id
|
78
|
+
assigns(:subscription).should eq(subscription)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "When not logged in" do
|
83
|
+
it "assigns the requested subscription as @subscription" do
|
84
|
+
subscription = FactoryGirl.create(:subscription)
|
85
|
+
get :show, :id => subscription.id
|
86
|
+
assigns(:subscription).should eq(subscription)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "GET new" do
|
92
|
+
describe "When logged in as Administrator" do
|
93
|
+
login_admin
|
94
|
+
|
95
|
+
it "assigns the requested subscription as @subscription" do
|
96
|
+
get :new
|
97
|
+
assigns(:subscription).should_not be_valid
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "When logged in as Librarian" do
|
102
|
+
login_librarian
|
103
|
+
|
104
|
+
it "assigns the requested subscription as @subscription" do
|
105
|
+
get :new
|
106
|
+
assigns(:subscription).should_not be_valid
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "When logged in as User" do
|
111
|
+
login_user
|
112
|
+
|
113
|
+
it "should not assign the requested subscription as @subscription" do
|
114
|
+
get :new
|
115
|
+
assigns(:subscription).should_not be_valid
|
116
|
+
response.should be_forbidden
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "When not logged in" do
|
121
|
+
it "should not assign the requested subscription as @subscription" do
|
122
|
+
get :new
|
123
|
+
assigns(:subscription).should_not be_valid
|
124
|
+
response.should redirect_to(new_user_session_url)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "GET edit" do
|
130
|
+
describe "When logged in as Administrator" do
|
131
|
+
login_admin
|
132
|
+
|
133
|
+
it "assigns the requested subscription as @subscription" do
|
134
|
+
subscription = FactoryGirl.create(:subscription)
|
135
|
+
get :edit, :id => subscription.id
|
136
|
+
assigns(:subscription).should eq(subscription)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "When logged in as Librarian" do
|
141
|
+
login_librarian
|
142
|
+
|
143
|
+
it "assigns the requested subscription as @subscription" do
|
144
|
+
subscription = FactoryGirl.create(:subscription)
|
145
|
+
get :edit, :id => subscription.id
|
146
|
+
assigns(:subscription).should eq(subscription)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "When logged in as User" do
|
151
|
+
login_user
|
152
|
+
|
153
|
+
it "assigns the requested subscription as @subscription" do
|
154
|
+
subscription = FactoryGirl.create(:subscription)
|
155
|
+
get :edit, :id => subscription.id
|
156
|
+
response.should be_forbidden
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "When not logged in" do
|
161
|
+
it "should not assign the requested subscription as @subscription" do
|
162
|
+
subscription = FactoryGirl.create(:subscription)
|
163
|
+
get :edit, :id => subscription.id
|
164
|
+
response.should redirect_to(new_user_session_url)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "POST create" do
|
170
|
+
before(:each) do
|
171
|
+
@attrs = valid_attributes
|
172
|
+
@invalid_attrs = {:title => ''}
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "When logged in as Administrator" do
|
176
|
+
login_admin
|
177
|
+
|
178
|
+
describe "with valid params" do
|
179
|
+
it "assigns a newly created subscription as @subscription" do
|
180
|
+
post :create, :subscription => @attrs
|
181
|
+
assigns(:subscription).should be_valid
|
182
|
+
end
|
183
|
+
|
184
|
+
it "redirects to the created subscription" do
|
185
|
+
post :create, :subscription => @attrs
|
186
|
+
response.should redirect_to(subscription_url(assigns(:subscription)))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "with invalid params" do
|
191
|
+
it "assigns a newly created but unsaved subscription as @subscription" do
|
192
|
+
post :create, :subscription => @invalid_attrs
|
193
|
+
assigns(:subscription).should_not be_valid
|
194
|
+
end
|
195
|
+
|
196
|
+
it "re-renders the 'new' template" do
|
197
|
+
post :create, :subscription => @invalid_attrs
|
198
|
+
response.should render_template("new")
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "When logged in as Librarian" do
|
204
|
+
login_librarian
|
205
|
+
|
206
|
+
describe "with valid params" do
|
207
|
+
it "assigns a newly created subscription as @subscription" do
|
208
|
+
post :create, :subscription => @attrs
|
209
|
+
assigns(:subscription).should be_valid
|
210
|
+
end
|
211
|
+
|
212
|
+
it "redirects to the created subscription" do
|
213
|
+
post :create, :subscription => @attrs
|
214
|
+
response.should redirect_to(subscription_url(assigns(:subscription)))
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "with invalid params" do
|
219
|
+
it "assigns a newly created but unsaved subscription as @subscription" do
|
220
|
+
post :create, :subscription => @invalid_attrs
|
221
|
+
assigns(:subscription).should_not be_valid
|
222
|
+
end
|
223
|
+
|
224
|
+
it "re-renders the 'new' template" do
|
225
|
+
post :create, :subscription => @invalid_attrs
|
226
|
+
response.should render_template("new")
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "When logged in as User" do
|
232
|
+
login_user
|
233
|
+
|
234
|
+
describe "with valid params" do
|
235
|
+
it "assigns a newly created subscription as @subscription" do
|
236
|
+
post :create, :subscription => @attrs
|
237
|
+
assigns(:subscription).should be_valid
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should be forbidden" do
|
241
|
+
post :create, :subscription => @attrs
|
242
|
+
response.should be_forbidden
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe "with invalid params" do
|
247
|
+
it "assigns a newly created but unsaved subscription as @subscription" do
|
248
|
+
post :create, :subscription => @invalid_attrs
|
249
|
+
assigns(:subscription).should_not be_valid
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should be forbidden" do
|
253
|
+
post :create, :subscription => @invalid_attrs
|
254
|
+
response.should be_forbidden
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "When not logged in" do
|
260
|
+
describe "with valid params" do
|
261
|
+
it "assigns a newly created subscription as @subscription" do
|
262
|
+
post :create, :subscription => @attrs
|
263
|
+
assigns(:subscription).should be_valid
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should be forbidden" do
|
267
|
+
post :create, :subscription => @attrs
|
268
|
+
response.should redirect_to(new_user_session_url)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "with invalid params" do
|
273
|
+
it "assigns a newly created but unsaved subscription as @subscription" do
|
274
|
+
post :create, :subscription => @invalid_attrs
|
275
|
+
assigns(:subscription).should_not be_valid
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should be forbidden" do
|
279
|
+
post :create, :subscription => @invalid_attrs
|
280
|
+
response.should redirect_to(new_user_session_url)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe "PUT update" do
|
287
|
+
before(:each) do
|
288
|
+
@subscription = FactoryGirl.create(:subscription)
|
289
|
+
@attrs = valid_attributes
|
290
|
+
@invalid_attrs = {:title => ''}
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "When logged in as Administrator" do
|
294
|
+
login_admin
|
295
|
+
|
296
|
+
describe "with valid params" do
|
297
|
+
it "updates the requested subscription" do
|
298
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
299
|
+
end
|
300
|
+
|
301
|
+
it "assigns the requested subscription as @subscription" do
|
302
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
303
|
+
assigns(:subscription).should eq(@subscription)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "with invalid params" do
|
308
|
+
it "assigns the requested subscription as @subscription" do
|
309
|
+
put :update, :id => @subscription.id, :subscription => @invalid_attrs
|
310
|
+
response.should render_template("edit")
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
describe "When logged in as Librarian" do
|
316
|
+
login_librarian
|
317
|
+
|
318
|
+
describe "with valid params" do
|
319
|
+
it "updates the requested subscription" do
|
320
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
321
|
+
end
|
322
|
+
|
323
|
+
it "assigns the requested subscription as @subscription" do
|
324
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
325
|
+
assigns(:subscription).should eq(@subscription)
|
326
|
+
response.should redirect_to(@subscription)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
describe "with invalid params" do
|
331
|
+
it "assigns the subscription as @subscription" do
|
332
|
+
put :update, :id => @subscription, :subscription => @invalid_attrs
|
333
|
+
assigns(:subscription).should_not be_valid
|
334
|
+
end
|
335
|
+
|
336
|
+
it "re-renders the 'edit' template" do
|
337
|
+
put :update, :id => @subscription, :subscription => @invalid_attrs
|
338
|
+
response.should render_template("edit")
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe "When logged in as User" do
|
344
|
+
login_user
|
345
|
+
|
346
|
+
describe "with valid params" do
|
347
|
+
it "updates the requested subscription" do
|
348
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
349
|
+
end
|
350
|
+
|
351
|
+
it "assigns the requested subscription as @subscription" do
|
352
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
353
|
+
assigns(:subscription).should eq(@subscription)
|
354
|
+
response.should be_forbidden
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
describe "with invalid params" do
|
359
|
+
it "assigns the requested subscription as @subscription" do
|
360
|
+
put :update, :id => @subscription.id, :subscription => @invalid_attrs
|
361
|
+
response.should be_forbidden
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
describe "When not logged in" do
|
367
|
+
describe "with valid params" do
|
368
|
+
it "updates the requested subscription" do
|
369
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should be forbidden" do
|
373
|
+
put :update, :id => @subscription.id, :subscription => @attrs
|
374
|
+
response.should redirect_to(new_user_session_url)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
describe "with invalid params" do
|
379
|
+
it "assigns the requested subscription as @subscription" do
|
380
|
+
put :update, :id => @subscription.id, :subscription => @invalid_attrs
|
381
|
+
response.should redirect_to(new_user_session_url)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
describe "DELETE destroy" do
|
388
|
+
before(:each) do
|
389
|
+
@subscription = FactoryGirl.create(:subscription)
|
390
|
+
end
|
391
|
+
|
392
|
+
describe "When logged in as Administrator" do
|
393
|
+
login_admin
|
394
|
+
|
395
|
+
it "destroys the requested subscription" do
|
396
|
+
delete :destroy, :id => @subscription.id
|
397
|
+
end
|
398
|
+
|
399
|
+
it "redirects to the subscriptions list" do
|
400
|
+
delete :destroy, :id => @subscription.id
|
401
|
+
response.should redirect_to(subscriptions_url)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe "When logged in as Librarian" do
|
406
|
+
login_librarian
|
407
|
+
|
408
|
+
it "destroys the requested subscription" do
|
409
|
+
delete :destroy, :id => @subscription.id
|
410
|
+
end
|
411
|
+
|
412
|
+
it "should be forbidden" do
|
413
|
+
delete :destroy, :id => @subscription.id
|
414
|
+
response.should redirect_to(subscriptions_url)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
describe "When logged in as User" do
|
419
|
+
login_user
|
420
|
+
|
421
|
+
it "destroys the requested subscription" do
|
422
|
+
delete :destroy, :id => @subscription.id
|
423
|
+
end
|
424
|
+
|
425
|
+
it "should be forbidden" do
|
426
|
+
delete :destroy, :id => @subscription.id
|
427
|
+
response.should be_forbidden
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
describe "When not logged in" do
|
432
|
+
it "destroys the requested subscription" do
|
433
|
+
delete :destroy, :id => @subscription.id
|
434
|
+
end
|
435
|
+
|
436
|
+
it "should be forbidden" do
|
437
|
+
delete :destroy, :id => @subscription.id
|
438
|
+
response.should redirect_to(new_user_session_url)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
rescue_from CanCan::AccessDenied, :with => :render_403
|
5
|
+
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
|
6
|
+
|
7
|
+
enju_biblio
|
8
|
+
enju_library
|
9
|
+
|
10
|
+
private
|
11
|
+
def render_403
|
12
|
+
return if performed?
|
13
|
+
if user_signed_in?
|
14
|
+
respond_to do |format|
|
15
|
+
format.html {render :template => 'page/403', :status => 403}
|
16
|
+
format.xml {render :template => 'page/403', :status => 403}
|
17
|
+
format.json
|
18
|
+
end
|
19
|
+
else
|
20
|
+
respond_to do |format|
|
21
|
+
format.html {redirect_to new_user_session_url}
|
22
|
+
format.xml {render :template => 'page/403', :status => 403}
|
23
|
+
format.json
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def render_404
|
29
|
+
return if performed?
|
30
|
+
respond_to do |format|
|
31
|
+
format.html {render :template => 'page/404', :status => 404}
|
32
|
+
format.mobile {render :template => 'page/404', :status => 404}
|
33
|
+
format.xml {render :template => 'page/404', :status => 404}
|
34
|
+
format.json
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def access_denied
|
39
|
+
raise CanCan::AccessDenied
|
40
|
+
end
|
41
|
+
|
42
|
+
def current_ability
|
43
|
+
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
44
|
+
end
|
45
|
+
|
46
|
+
def solr_commit
|
47
|
+
Sunspot.commit
|
48
|
+
end
|
49
|
+
|
50
|
+
def move_position(resource, direction, redirect = true)
|
51
|
+
if ['higher', 'lower'].include?(direction)
|
52
|
+
resource.send("move_#{direction}")
|
53
|
+
if redirect
|
54
|
+
redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
|
55
|
+
return
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
def back_to_index(options = {})
|
3
|
+
if options == nil
|
4
|
+
options = {}
|
5
|
+
else
|
6
|
+
options.reject!{|key, value| value.blank?}
|
7
|
+
options.delete(:page) if options[:page].to_i == 1
|
8
|
+
end
|
9
|
+
unless controller_name == 'test'
|
10
|
+
link_to t('page.listing', :model => t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(:controller => controller_name, :action => :index, :id => nil, :only_path => true).merge(options))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Ability
|
2
|
+
include CanCan::Ability
|
3
|
+
|
4
|
+
def initialize(user, ip_address = nil)
|
5
|
+
case user.try(:role).try(:name)
|
6
|
+
when 'Administrator'
|
7
|
+
can [:read, :create, :update], Bookstore
|
8
|
+
can :manage, BudgetType
|
9
|
+
can :destroy, Bookstore do |bookstore|
|
10
|
+
if defined?(EnjuPurchaseRequest)
|
11
|
+
bookstore.order_lists.empty? and bookstore.items.empty?
|
12
|
+
else
|
13
|
+
bookstore.items.empty?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
can [:read, :create, :update], Library
|
17
|
+
can :destroy, Library do |library|
|
18
|
+
library.shelves.empty? and !library.web?
|
19
|
+
end
|
20
|
+
can [:read, :update], LibraryGroup
|
21
|
+
can [:read, :update], RequestStatusType
|
22
|
+
can [:read, :update], RequestType
|
23
|
+
can [:read, :create, :update], Shelf
|
24
|
+
can :destroy, Shelf do |shelf|
|
25
|
+
shelf.items.empty?
|
26
|
+
end
|
27
|
+
can :manage, SearchEngine
|
28
|
+
can :manage, Subscribe
|
29
|
+
can :manage, Subscription
|
30
|
+
when 'Librarian'
|
31
|
+
can :read, Bookstore
|
32
|
+
can :read, BudgetType
|
33
|
+
can :read, Library
|
34
|
+
can :read, LibraryGroup
|
35
|
+
can :read, RequestStatusType
|
36
|
+
can :read, RequestType
|
37
|
+
can :read, Shelf
|
38
|
+
can :read, SearchEngine
|
39
|
+
can :manage, Subscribe
|
40
|
+
can :manage, Subscription
|
41
|
+
when 'User'
|
42
|
+
can :read, Shelf
|
43
|
+
can :read, Library
|
44
|
+
can :read, LibraryGroup
|
45
|
+
else
|
46
|
+
can :read, Library
|
47
|
+
can :read, LibraryGroup
|
48
|
+
can :read, Shelf
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class PictureFile < ActiveRecord::Base
|
2
|
+
attr_accessible :picture, :picture_attachable_id,
|
3
|
+
:picture_attachable_type
|
4
|
+
scope :attached, where('picture_attachable_id > 0')
|
5
|
+
belongs_to :picture_attachable, :polymorphic => true, :validate => true
|
6
|
+
|
7
|
+
if configatron.uploaded_file.storage == :s3
|
8
|
+
has_attached_file :picture, :storage => :s3, :styles => { :medium => "600x600>", :thumb => "100x100>" },
|
9
|
+
:s3_credentials => "#{Rails.root.to_s}/config/s3.yml", :path => "picture_files/:id/:filename"
|
10
|
+
else
|
11
|
+
has_attached_file :picture, :styles => { :medium => "600x600>", :thumb => "100x100>" }, :path => ":rails_root/private:url"
|
12
|
+
end
|
13
|
+
validates_attachment_presence :picture
|
14
|
+
validates_attachment_content_type :picture, :content_type => ["image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/svg+xml"], :on => :create
|
15
|
+
|
16
|
+
validates :picture_attachable_type, :presence => true, :inclusion => {:in => ['Event', 'Manifestation', 'Patron', 'Shelf']}
|
17
|
+
validates_associated :picture_attachable
|
18
|
+
default_scope :order => 'picture_files.position'
|
19
|
+
# http://railsforum.com/viewtopic.php?id=11615
|
20
|
+
acts_as_list :scope => 'picture_attachable_type=\'#{picture_attachable_type}\''
|
21
|
+
normalize_attributes :picture_attachable_type
|
22
|
+
|
23
|
+
def self.per_page
|
24
|
+
10
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# == Schema Information
|
29
|
+
#
|
30
|
+
# Table name: picture_files
|
31
|
+
#
|
32
|
+
# id :integer not null, primary key
|
33
|
+
# picture_attachable_id :integer
|
34
|
+
# picture_attachable_type :string(255)
|
35
|
+
# content_type :string(255)
|
36
|
+
# title :text
|
37
|
+
# filename :text
|
38
|
+
# thumbnail :string(255)
|
39
|
+
# position :integer
|
40
|
+
# created_at :datetime not null
|
41
|
+
# updated_at :datetime not null
|
42
|
+
# picture_file_name :string(255)
|
43
|
+
# picture_content_type :string(255)
|
44
|
+
# picture_file_size :integer
|
45
|
+
# picture_updated_at :datetime
|
46
|
+
# picture_fingerprint :string(255)
|
47
|
+
# picture_meta :text
|
48
|
+
#
|
49
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Role < ActiveRecord::Base
|
2
|
+
include MasterModel
|
3
|
+
default_scope :order => "roles.position"
|
4
|
+
has_many :user_has_roles
|
5
|
+
has_many :users, :through => :user_has_roles
|
6
|
+
after_save :clear_all_cache
|
7
|
+
after_destroy :clear_all_cache
|
8
|
+
|
9
|
+
extend FriendlyId
|
10
|
+
friendly_id :name
|
11
|
+
|
12
|
+
def localized_name
|
13
|
+
display_name.localize
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all_cache
|
17
|
+
if Rails.env == 'production'
|
18
|
+
Rails.cache.fetch('role_all'){Role.select(:name).all}
|
19
|
+
else
|
20
|
+
Role.select(:name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear_all_cache
|
25
|
+
Rails.cache.delete('role_all')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.default_role
|
29
|
+
Rails.cache.fetch('default_role'){Role.find('Guest')}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# == Schema Information
|
34
|
+
#
|
35
|
+
# Table name: roles
|
36
|
+
#
|
37
|
+
# id :integer not null, primary key
|
38
|
+
# name :string(255) not null
|
39
|
+
# display_name :string(255)
|
40
|
+
# note :text
|
41
|
+
# created_at :datetime
|
42
|
+
# updated_at :datetime
|
43
|
+
# score :integer default(0), not null
|
44
|
+
# position :integer
|
45
|
+
#
|
46
|
+
|