enju_message 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/config/locales/translation_en.yml +51 -0
- data/config/locales/translation_ja.yml +51 -0
- data/lib/enju_message/version.rb +1 -1
- data/spec/controllers/message_requests_controller_spec.rb +275 -0
- data/spec/controllers/message_templates_controller_spec.rb +443 -0
- data/spec/controllers/messages_controller_spec.rb +439 -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 +45 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/mailers/notifier.rb +28 -0
- data/spec/dummy/app/models/ability.rb +30 -0
- data/spec/dummy/app/models/library_group.rb +86 -0
- data/spec/dummy/app/models/patron.rb +167 -0
- data/spec/dummy/app/models/patron_type.rb +19 -0
- data/spec/dummy/app/models/role.rb +8 -0
- data/spec/dummy/app/models/user.rb +53 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -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 +1 -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 +209 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +1 -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/{test/dummy/public/favicon.ico → spec/dummy/db/development.sqlite3} +0 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201121636_create_languages.rb +16 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +225 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/enju_leaf/localized_name.rb +13 -0
- data/spec/dummy/lib/enju_leaf/master_model.rb +41 -0
- data/spec/dummy/lib/enju_leaf/url_validator.rb +10 -0
- data/spec/dummy/lib/enju_leaf.rb +4 -0
- data/spec/dummy/log/development.log +106 -0
- data/spec/dummy/log/sunspot-solr-test.log +232 -0
- data/spec/dummy/log/test.log +145040 -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/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/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +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/factories/message.rb +8 -0
- data/spec/factories/message_request.rb +7 -0
- data/spec/factories/message_template.rb +7 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/library_groups.yml +34 -0
- data/spec/fixtures/message_requests.yml +30 -0
- data/spec/fixtures/message_templates.yml +65 -0
- data/spec/fixtures/messages.yml +62 -0
- data/spec/fixtures/patrons.yml +338 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/message_request_spec.rb +24 -0
- data/spec/models/message_spec.rb +59 -0
- data/spec/models/message_template_spec.rb +24 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +273 -220
- data/app/views/baskets/edit.html.erb +0 -30
- data/app/views/baskets/index.html.erb +0 -31
- data/app/views/baskets/new.html.erb +0 -29
- data/app/views/baskets/show.html.erb +0 -23
- data/app/views/carrier_type_has_checkout_types/_form.html.erb +0 -19
- data/app/views/carrier_type_has_checkout_types/edit.html.erb +0 -13
- data/app/views/carrier_type_has_checkout_types/index.html.erb +0 -33
- data/app/views/carrier_type_has_checkout_types/new.html.erb +0 -12
- data/app/views/carrier_type_has_checkout_types/show.html.erb +0 -29
- data/app/views/checked_items/_checkouts.html.erb +0 -20
- data/app/views/checked_items/_list.html.erb +0 -39
- data/app/views/checked_items/edit.html.erb +0 -21
- data/app/views/checked_items/index.html.erb +0 -32
- data/app/views/checked_items/index.js.erb +0 -1
- data/app/views/checked_items/new.html.erb +0 -20
- data/app/views/checked_items/show.html.erb +0 -24
- data/app/views/checkins/_form.html.erb +0 -24
- data/app/views/checkins/_list.html.erb +0 -51
- data/app/views/checkins/edit.html.erb +0 -26
- data/app/views/checkins/index.html.erb +0 -16
- data/app/views/checkins/index.js.erb +0 -1
- data/app/views/checkins/new.html.erb +0 -14
- data/app/views/checkins/show.html.erb +0 -24
- data/app/views/checkout_stat_has_manifestations/_form.html.erb +0 -15
- data/app/views/checkout_stat_has_manifestations/edit.html.erb +0 -13
- data/app/views/checkout_stat_has_manifestations/index.html.erb +0 -33
- data/app/views/checkout_stat_has_manifestations/new.html.erb +0 -12
- data/app/views/checkout_stat_has_manifestations/show.html.erb +0 -28
- data/app/views/checkout_stat_has_users/_form.html.erb +0 -15
- data/app/views/checkout_stat_has_users/edit.html.erb +0 -13
- data/app/views/checkout_stat_has_users/index.html.erb +0 -33
- data/app/views/checkout_stat_has_users/new.html.erb +0 -12
- data/app/views/checkout_stat_has_users/show.html.erb +0 -28
- data/app/views/checkout_types/_form.html.erb +0 -19
- data/app/views/checkout_types/edit.html.erb +0 -13
- data/app/views/checkout_types/index.html.erb +0 -50
- data/app/views/checkout_types/new.html.erb +0 -12
- data/app/views/checkout_types/show.html.erb +0 -38
- data/app/views/checkouts/_form.html.erb +0 -28
- data/app/views/checkouts/_index.html.erb +0 -23
- data/app/views/checkouts/_index_overdue.html.erb +0 -33
- data/app/views/checkouts/_index_user.html.erb +0 -44
- data/app/views/checkouts/_list.html.erb +0 -45
- data/app/views/checkouts/edit.html.erb +0 -51
- data/app/views/checkouts/index.atom.builder +0 -14
- data/app/views/checkouts/index.csv.erb +0 -4
- data/app/views/checkouts/index.html.erb +0 -11
- data/app/views/checkouts/index.ics.erb +0 -13
- data/app/views/checkouts/index.rss.builder +0 -38
- data/app/views/checkouts/new.html.erb +0 -20
- data/app/views/checkouts/show.html.erb +0 -35
- data/app/views/circulation_statuses/_form.html.erb +0 -19
- data/app/views/circulation_statuses/edit.html.erb +0 -13
- data/app/views/circulation_statuses/index.html.erb +0 -43
- data/app/views/circulation_statuses/new.html.erb +0 -12
- data/app/views/circulation_statuses/show.html.erb +0 -29
- data/app/views/item_has_use_restrictions/edit.html.erb +0 -27
- data/app/views/item_has_use_restrictions/index.html.erb +0 -32
- data/app/views/item_has_use_restrictions/new.html.erb +0 -25
- data/app/views/item_has_use_restrictions/show.html.erb +0 -29
- data/app/views/lending_policies/_form.html.erb +0 -41
- data/app/views/lending_policies/edit.html.erb +0 -13
- data/app/views/lending_policies/index.html.erb +0 -42
- data/app/views/lending_policies/new.html.erb +0 -12
- data/app/views/lending_policies/show.html.erb +0 -50
- data/app/views/manifestation_checkout_stats/_form.html.erb +0 -19
- data/app/views/manifestation_checkout_stats/edit.html.erb +0 -13
- data/app/views/manifestation_checkout_stats/index.html.erb +0 -35
- data/app/views/manifestation_checkout_stats/new.html.erb +0 -12
- data/app/views/manifestation_checkout_stats/show.csv.erb +0 -4
- data/app/views/manifestation_checkout_stats/show.html.erb +0 -55
- data/app/views/manifestation_reserve_stats/_form.html.erb +0 -19
- data/app/views/manifestation_reserve_stats/edit.html.erb +0 -13
- data/app/views/manifestation_reserve_stats/index.html.erb +0 -35
- data/app/views/manifestation_reserve_stats/new.html.erb +0 -12
- data/app/views/manifestation_reserve_stats/show.csv.erb +0 -4
- data/app/views/manifestation_reserve_stats/show.html.erb +0 -55
- data/app/views/reserve_stat_has_manifestations/_form.html.erb +0 -15
- data/app/views/reserve_stat_has_manifestations/edit.html.erb +0 -13
- data/app/views/reserve_stat_has_manifestations/index.html.erb +0 -33
- data/app/views/reserve_stat_has_manifestations/new.html.erb +0 -12
- data/app/views/reserve_stat_has_manifestations/show.html.erb +0 -28
- data/app/views/reserve_stat_has_users/_form.html.erb +0 -15
- data/app/views/reserve_stat_has_users/edit.html.erb +0 -13
- data/app/views/reserve_stat_has_users/index.html.erb +0 -33
- data/app/views/reserve_stat_has_users/new.html.erb +0 -12
- data/app/views/reserve_stat_has_users/show.html.erb +0 -28
- data/app/views/reserves/_form.html.erb +0 -49
- data/app/views/reserves/_new.html.erb +0 -44
- data/app/views/reserves/_new_user.html.erb +0 -50
- data/app/views/reserves/_title.html.erb +0 -19
- data/app/views/reserves/edit.html.erb +0 -42
- data/app/views/reserves/index.atom.builder +0 -14
- data/app/views/reserves/index.csv.erb +0 -4
- data/app/views/reserves/index.html.erb +0 -75
- data/app/views/reserves/index.rss.builder +0 -41
- data/app/views/reserves/new.html.erb +0 -5
- data/app/views/reserves/show.html.erb +0 -61
- data/app/views/use_restrictions/_form.html.erb +0 -19
- data/app/views/use_restrictions/edit.html.erb +0 -13
- data/app/views/use_restrictions/index.html.erb +0 -43
- data/app/views/use_restrictions/new.html.erb +0 -12
- data/app/views/use_restrictions/show.html.erb +0 -29
- data/app/views/user_checkout_stats/_form.html.erb +0 -19
- data/app/views/user_checkout_stats/edit.html.erb +0 -13
- data/app/views/user_checkout_stats/index.html.erb +0 -35
- data/app/views/user_checkout_stats/new.html.erb +0 -12
- data/app/views/user_checkout_stats/show.csv.erb +0 -4
- data/app/views/user_checkout_stats/show.html.erb +0 -55
- data/app/views/user_group_has_checkout_types/edit.html.erb +0 -63
- data/app/views/user_group_has_checkout_types/index.html.erb +0 -32
- data/app/views/user_group_has_checkout_types/new.html.erb +0 -62
- data/app/views/user_group_has_checkout_types/show.html.erb +0 -64
- data/app/views/user_reserve_stats/_form.html.erb +0 -19
- data/app/views/user_reserve_stats/edit.html.erb +0 -13
- data/app/views/user_reserve_stats/index.html.erb +0 -35
- data/app/views/user_reserve_stats/new.html.erb +0 -12
- data/app/views/user_reserve_stats/show.csv.erb +0 -4
- data/app/views/user_reserve_stats/show.html.erb +0 -54
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/enju_message_test.rb +0 -7
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -10
@@ -0,0 +1,443 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sunspot/rails/spec_helper'
|
3
|
+
|
4
|
+
describe MessageTemplatesController do
|
5
|
+
fixtures :all
|
6
|
+
disconnect_sunspot
|
7
|
+
|
8
|
+
describe "GET index" do
|
9
|
+
before(:each) do
|
10
|
+
FactoryGirl.create(:message_template)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "When logged in as Administrator" do
|
14
|
+
login_admin
|
15
|
+
|
16
|
+
it "assigns all message_templates as @message_templates" do
|
17
|
+
get :index
|
18
|
+
assigns(:message_templates).should eq(MessageTemplate.all)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "When logged in as Librarian" do
|
23
|
+
login_librarian
|
24
|
+
|
25
|
+
it "assigns all message_templates as @message_templates" do
|
26
|
+
get :index
|
27
|
+
assigns(:message_templates).should eq(MessageTemplate.all)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "When logged in as User" do
|
32
|
+
login_user
|
33
|
+
|
34
|
+
it "assigns empty as @message_templates" do
|
35
|
+
get :index
|
36
|
+
assigns(:message_templates).should be_empty
|
37
|
+
response.should be_forbidden
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "When not logged in" do
|
42
|
+
it "assigns empty as @message_templates" do
|
43
|
+
get :index
|
44
|
+
assigns(:message_templates).should be_empty
|
45
|
+
response.should redirect_to(new_user_session_url)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "GET show" do
|
51
|
+
describe "When logged in as Administrator" do
|
52
|
+
login_admin
|
53
|
+
|
54
|
+
it "assigns the requested message_template as @message_template" do
|
55
|
+
message_template = FactoryGirl.create(:message_template)
|
56
|
+
get :show, :id => message_template.id
|
57
|
+
assigns(:message_template).should eq(message_template)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "When logged in as Librarian" do
|
62
|
+
login_librarian
|
63
|
+
|
64
|
+
it "assigns the requested message_template as @message_template" do
|
65
|
+
message_template = FactoryGirl.create(:message_template)
|
66
|
+
get :show, :id => message_template.id
|
67
|
+
assigns(:message_template).should eq(message_template)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "When logged in as User" do
|
72
|
+
login_user
|
73
|
+
|
74
|
+
it "assigns the requested message_template as @message_template" do
|
75
|
+
message_template = FactoryGirl.create(:message_template)
|
76
|
+
get :show, :id => message_template.id
|
77
|
+
assigns(:message_template).should eq(message_template)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "When not logged in" do
|
82
|
+
it "assigns the requested message_template as @message_template" do
|
83
|
+
message_template = FactoryGirl.create(:message_template)
|
84
|
+
get :show, :id => message_template.id
|
85
|
+
assigns(:message_template).should eq(message_template)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "GET new" do
|
91
|
+
describe "When logged in as Administrator" do
|
92
|
+
login_admin
|
93
|
+
|
94
|
+
it "assigns the requested message_template as @message_template" do
|
95
|
+
get :new
|
96
|
+
assigns(:message_template).should_not be_valid
|
97
|
+
response.should be_forbidden
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "When logged in as Librarian" do
|
102
|
+
login_librarian
|
103
|
+
|
104
|
+
it "should not assign the requested message_template as @message_template" do
|
105
|
+
get :new
|
106
|
+
assigns(:message_template).should_not be_valid
|
107
|
+
response.should be_forbidden
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "When logged in as User" do
|
112
|
+
login_user
|
113
|
+
|
114
|
+
it "should not assign the requested message_template as @message_template" do
|
115
|
+
get :new
|
116
|
+
assigns(:message_template).should_not be_valid
|
117
|
+
response.should be_forbidden
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "When not logged in" do
|
122
|
+
it "should not assign the requested message_template as @message_template" do
|
123
|
+
get :new
|
124
|
+
assigns(:message_template).should_not be_valid
|
125
|
+
response.should redirect_to(new_user_session_url)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "GET edit" do
|
131
|
+
describe "When logged in as Administrator" do
|
132
|
+
login_admin
|
133
|
+
|
134
|
+
it "assigns the requested message_template as @message_template" do
|
135
|
+
message_template = FactoryGirl.create(:message_template)
|
136
|
+
get :edit, :id => message_template.id
|
137
|
+
assigns(:message_template).should eq(message_template)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "When logged in as Librarian" do
|
142
|
+
login_librarian
|
143
|
+
|
144
|
+
it "assigns the requested message_template as @message_template" do
|
145
|
+
message_template = FactoryGirl.create(:message_template)
|
146
|
+
get :edit, :id => message_template.id
|
147
|
+
response.should be_forbidden
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "When logged in as User" do
|
152
|
+
login_user
|
153
|
+
|
154
|
+
it "assigns the requested message_template as @message_template" do
|
155
|
+
message_template = FactoryGirl.create(:message_template)
|
156
|
+
get :edit, :id => message_template.id
|
157
|
+
response.should be_forbidden
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "When not logged in" do
|
162
|
+
it "should not assign the requested message_template as @message_template" do
|
163
|
+
message_template = FactoryGirl.create(:message_template)
|
164
|
+
get :edit, :id => message_template.id
|
165
|
+
response.should redirect_to(new_user_session_url)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "POST create" do
|
171
|
+
before(:each) do
|
172
|
+
@attrs = FactoryGirl.attributes_for(:message_template)
|
173
|
+
@invalid_attrs = {:status => ''}
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "When logged in as Administrator" do
|
177
|
+
login_admin
|
178
|
+
|
179
|
+
describe "with valid params" do
|
180
|
+
it "assigns a newly created message_template as @message_template" do
|
181
|
+
post :create, :message_template => @attrs
|
182
|
+
assigns(:message_template).should be_valid
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should be forbidden" do
|
186
|
+
post :create, :message_template => @attrs
|
187
|
+
response.should be_forbidden
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "with invalid params" do
|
192
|
+
it "assigns a newly created but unsaved message_template as @message_template" do
|
193
|
+
post :create, :message_template => @invalid_attrs
|
194
|
+
assigns(:message_template).should_not be_valid
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should be forbidden" do
|
198
|
+
post :create, :message_template => @invalid_attrs
|
199
|
+
response.should be_forbidden
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "When logged in as Librarian" do
|
205
|
+
login_librarian
|
206
|
+
|
207
|
+
describe "with valid params" do
|
208
|
+
it "assigns a newly created message_template as @message_template" do
|
209
|
+
post :create, :message_template => @attrs
|
210
|
+
assigns(:message_template).should be_valid
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should be forbidden" do
|
214
|
+
post :create, :message_template => @attrs
|
215
|
+
response.should be_forbidden
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "with invalid params" do
|
220
|
+
it "assigns a newly created but unsaved message_template as @message_template" do
|
221
|
+
post :create, :message_template => @invalid_attrs
|
222
|
+
assigns(:message_template).should_not be_valid
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should be forbidden" do
|
226
|
+
post :create, :message_template => @invalid_attrs
|
227
|
+
response.should be_forbidden
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "When logged in as User" do
|
233
|
+
login_user
|
234
|
+
|
235
|
+
describe "with valid params" do
|
236
|
+
it "assigns a newly created message_template as @message_template" do
|
237
|
+
post :create, :message_template => @attrs
|
238
|
+
assigns(:message_template).should be_valid
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should be forbidden" do
|
242
|
+
post :create, :message_template => @attrs
|
243
|
+
response.should be_forbidden
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "with invalid params" do
|
248
|
+
it "assigns a newly created but unsaved message_template as @message_template" do
|
249
|
+
post :create, :message_template => @invalid_attrs
|
250
|
+
assigns(:message_template).should_not be_valid
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should be forbidden" do
|
254
|
+
post :create, :message_template => @invalid_attrs
|
255
|
+
response.should be_forbidden
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "When not logged in" do
|
261
|
+
describe "with valid params" do
|
262
|
+
it "assigns a newly created message_template as @message_template" do
|
263
|
+
post :create, :message_template => @attrs
|
264
|
+
assigns(:message_template).should be_valid
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should be forbidden" do
|
268
|
+
post :create, :message_template => @attrs
|
269
|
+
response.should redirect_to(new_user_session_url)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe "with invalid params" do
|
274
|
+
it "assigns a newly created but unsaved message_template as @message_template" do
|
275
|
+
post :create, :message_template => @invalid_attrs
|
276
|
+
assigns(:message_template).should_not be_valid
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should be forbidden" do
|
280
|
+
post :create, :message_template => @invalid_attrs
|
281
|
+
response.should redirect_to(new_user_session_url)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "PUT update" do
|
288
|
+
before(:each) do
|
289
|
+
@message_template = FactoryGirl.create(:message_template)
|
290
|
+
@attrs = FactoryGirl.attributes_for(:message_template)
|
291
|
+
@invalid_attrs = {:status => ''}
|
292
|
+
end
|
293
|
+
|
294
|
+
describe "When logged in as Administrator" do
|
295
|
+
login_admin
|
296
|
+
|
297
|
+
describe "with valid params" do
|
298
|
+
it "updates the requested message_template" do
|
299
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
300
|
+
end
|
301
|
+
|
302
|
+
it "assigns the requested message_template as @message_template" do
|
303
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
304
|
+
assigns(:message_template).should eq(@message_template)
|
305
|
+
end
|
306
|
+
|
307
|
+
it "moves its position when specified" do
|
308
|
+
put :update, :id => @message_template.id, :message_template => @attrs, :position => 2
|
309
|
+
response.should redirect_to(message_templates_url)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
describe "with invalid params" do
|
314
|
+
it "assigns the requested message_template as @message_template" do
|
315
|
+
put :update, :id => @message_template.id, :message_template => @invalid_attrs
|
316
|
+
response.should render_template("edit")
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
describe "When logged in as Librarian" do
|
322
|
+
login_librarian
|
323
|
+
|
324
|
+
describe "with valid params" do
|
325
|
+
it "updates the requested message_template" do
|
326
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
327
|
+
end
|
328
|
+
|
329
|
+
it "assigns the requested message_template as @message_template" do
|
330
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
331
|
+
assigns(:message_template).should eq(@message_template)
|
332
|
+
response.should be_forbidden
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe "with invalid params" do
|
337
|
+
it "assigns the requested message_template as @message_template" do
|
338
|
+
put :update, :id => @message_template.id, :message_template => @invalid_attrs
|
339
|
+
response.should be_forbidden
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "When logged in as User" do
|
345
|
+
login_user
|
346
|
+
|
347
|
+
describe "with valid params" do
|
348
|
+
it "updates the requested message_template" do
|
349
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
350
|
+
end
|
351
|
+
|
352
|
+
it "assigns the requested message_template as @message_template" do
|
353
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
354
|
+
assigns(:message_template).should eq(@message_template)
|
355
|
+
response.should be_forbidden
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
describe "with invalid params" do
|
360
|
+
it "assigns the requested message_template as @message_template" do
|
361
|
+
put :update, :id => @message_template.id, :message_template => @invalid_attrs
|
362
|
+
response.should be_forbidden
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe "When not logged in" do
|
368
|
+
describe "with valid params" do
|
369
|
+
it "updates the requested message_template" do
|
370
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
371
|
+
end
|
372
|
+
|
373
|
+
it "should be forbidden" do
|
374
|
+
put :update, :id => @message_template.id, :message_template => @attrs
|
375
|
+
response.should redirect_to(new_user_session_url)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "with invalid params" do
|
380
|
+
it "assigns the requested message_template as @message_template" do
|
381
|
+
put :update, :id => @message_template.id, :message_template => @invalid_attrs
|
382
|
+
response.should redirect_to(new_user_session_url)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe "DELETE destroy" do
|
389
|
+
before(:each) do
|
390
|
+
@message_template = FactoryGirl.create(:message_template)
|
391
|
+
end
|
392
|
+
|
393
|
+
describe "When logged in as Administrator" do
|
394
|
+
login_admin
|
395
|
+
|
396
|
+
it "destroys the requested message_template" do
|
397
|
+
delete :destroy, :id => @message_template.id
|
398
|
+
end
|
399
|
+
|
400
|
+
it "should be forbidden" do
|
401
|
+
delete :destroy, :id => @message_template.id
|
402
|
+
response.should be_forbidden
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
describe "When logged in as Librarian" do
|
407
|
+
login_librarian
|
408
|
+
|
409
|
+
it "destroys the requested message_template" do
|
410
|
+
delete :destroy, :id => @message_template.id
|
411
|
+
end
|
412
|
+
|
413
|
+
it "should be forbidden" do
|
414
|
+
delete :destroy, :id => @message_template.id
|
415
|
+
response.should be_forbidden
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
describe "When logged in as User" do
|
420
|
+
login_user
|
421
|
+
|
422
|
+
it "destroys the requested message_template" do
|
423
|
+
delete :destroy, :id => @message_template.id
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should be forbidden" do
|
427
|
+
delete :destroy, :id => @message_template.id
|
428
|
+
response.should be_forbidden
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
describe "When not logged in" do
|
433
|
+
it "destroys the requested message_template" do
|
434
|
+
delete :destroy, :id => @message_template.id
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should be forbidden" do
|
438
|
+
delete :destroy, :id => @message_template.id
|
439
|
+
response.should redirect_to(new_user_session_url)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|