enju_biblio 0.0.9 → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/app/controllers/accepts_controller.rb +83 -0
  2. data/app/controllers/items_controller.rb +2 -2
  3. data/app/controllers/manifestations_controller.rb +8 -8
  4. data/app/controllers/patrons_controller.rb +18 -4
  5. data/app/controllers/series_has_manifestations_controller.rb +1 -1
  6. data/app/controllers/series_statements_controller.rb +2 -5
  7. data/app/models/accept.rb +36 -0
  8. data/app/models/create.rb +0 -4
  9. data/app/models/donate.rb +0 -4
  10. data/app/models/exemplify.rb +0 -4
  11. data/app/models/import_request.rb +0 -4
  12. data/app/models/item.rb +2 -4
  13. data/app/models/manifestation.rb +5 -8
  14. data/app/models/own.rb +0 -3
  15. data/app/models/patron.rb +2 -4
  16. data/app/models/picture_file.rb +0 -4
  17. data/app/models/produce.rb +0 -4
  18. data/app/models/realize.rb +0 -4
  19. data/app/models/series_has_manifestation.rb +1 -3
  20. data/app/models/series_statement.rb +2 -4
  21. data/app/views/accepts/_form.html.erb +11 -0
  22. data/app/views/accepts/_list.html.erb +31 -0
  23. data/app/views/accepts/edit.html.erb +13 -0
  24. data/app/views/accepts/index.csv.erb +4 -0
  25. data/app/views/accepts/index.html.erb +49 -0
  26. data/app/views/accepts/index.js.erb +1 -0
  27. data/app/views/accepts/new.html.erb +14 -0
  28. data/app/views/accepts/show.html.erb +31 -0
  29. data/app/views/countries/index.html.erb +1 -1
  30. data/app/views/creates/_index.html.erb +1 -1
  31. data/app/views/creates/_index_patron.html.erb +1 -1
  32. data/app/views/creates/_index_work.html.erb +1 -1
  33. data/app/views/donates/index.html.erb +1 -1
  34. data/app/views/exemplifies/index.html.erb +1 -1
  35. data/app/views/extents/index.html.erb +1 -1
  36. data/app/views/import_requests/index.html.erb +1 -1
  37. data/app/views/items/index.html.erb +1 -1
  38. data/app/views/items/index.mobile.erb +1 -1
  39. data/app/views/languages/index.html.erb +1 -1
  40. data/app/views/licenses/index.html.erb +1 -1
  41. data/app/views/manifestations/_list.html.erb +2 -2
  42. data/app/views/manifestations/_manifestation.html.erb +1 -1
  43. data/app/views/manifestations/_question_list.html.erb +2 -2
  44. data/app/views/manifestations/_tab_list.html.erb +1 -1
  45. data/app/views/manifestations/index.html.erb +2 -2
  46. data/app/views/manifestations/index.mobile.erb +1 -1
  47. data/app/views/medium_of_performances/index.html.erb +1 -1
  48. data/app/views/owns/index.html.erb +1 -1
  49. data/app/views/patron_import_files/index.html.erb +1 -1
  50. data/app/views/patron_import_results/index.html.erb +1 -1
  51. data/app/views/patrons/_expression_list.html.erb +2 -2
  52. data/app/views/patrons/_index.html.erb +1 -1
  53. data/app/views/patrons/_index_expression.html.erb +1 -1
  54. data/app/views/patrons/_index_manifestation.html.erb +1 -1
  55. data/app/views/patrons/_index_patron.html.erb +1 -1
  56. data/app/views/patrons/_index_patron_merge_list.html.erb +1 -1
  57. data/app/views/patrons/_index_work.html.erb +1 -1
  58. data/app/views/patrons/_manifestation_list.html.erb +2 -2
  59. data/app/views/patrons/_work_list.html.erb +2 -2
  60. data/app/views/patrons/index.mobile.erb +1 -1
  61. data/app/views/picture_files/_index.html.erb +1 -1
  62. data/app/views/picture_files/_index_event.html.erb +1 -1
  63. data/app/views/picture_files/_index_manifestation.html.erb +1 -1
  64. data/app/views/picture_files/_index_patron.html.erb +1 -1
  65. data/app/views/picture_files/_index_shelf.html.erb +1 -1
  66. data/app/views/produces/_index.html.erb +1 -1
  67. data/app/views/produces/_index_manifestation.html.erb +1 -1
  68. data/app/views/produces/_index_patron.html.erb +1 -1
  69. data/app/views/realizes/_index.html.erb +1 -1
  70. data/app/views/realizes/_index_expression.html.erb +1 -1
  71. data/app/views/realizes/_index_patron.html.erb +1 -1
  72. data/app/views/resource_import_files/index.html.erb +1 -1
  73. data/app/views/resource_import_results/index.html.erb +1 -1
  74. data/app/views/series_has_manifestations/index.html.erb +1 -1
  75. data/app/views/series_statements/_index.html.erb +1 -1
  76. data/app/views/series_statements/_index_manifestation.html.erb +1 -1
  77. data/app/views/series_statements/_index_series_statement_merge_list.html.erb +1 -1
  78. data/app/views/series_statements/_manifestation_list.html.erb +2 -2
  79. data/{spec/dummy/db → db}/migrate/120_create_baskets.rb +0 -0
  80. data/{spec/dummy/db → db}/migrate/20120319173203_create_accepts.rb +0 -0
  81. data/lib/enju_biblio.rb +4 -0
  82. data/lib/enju_biblio/engine.rb +0 -3
  83. data/lib/enju_biblio/version.rb +1 -1
  84. data/lib/generators/enju_biblio/views_generator.rb +51 -0
  85. data/spec/controllers/accepts_controller_spec.rb +304 -0
  86. data/spec/dummy/app/models/ability.rb +2 -0
  87. data/spec/dummy/config/application.rb +9 -1
  88. data/spec/dummy/config/initializers/kaminari_config.rb +9 -0
  89. data/spec/dummy/db/test.sqlite3 +0 -0
  90. data/spec/dummy/lib/plugins/ext.rb +0 -2
  91. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  92. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  93. data/spec/factories/accepts.rb +9 -0
  94. data/spec/factories/basket.rb +5 -0
  95. data/spec/models/accept_spec.rb +22 -0
  96. data/spec/requests/accepts_spec.rb +11 -0
  97. data/spec/routing/accepts_routing_spec.rb +27 -0
  98. data/spec/views/accepts/edit.html.erb_spec.rb +18 -0
  99. data/spec/views/accepts/index.html.erb_spec.rb +25 -0
  100. data/spec/views/accepts/new.html.erb_spec.rb +29 -0
  101. data/spec/views/accepts/show.html.erb_spec.rb +17 -0
  102. data/spec/views/creates/index.html.erb_spec.rb +2 -2
  103. data/spec/views/exemplifies/index.html.erb_spec.rb +2 -2
  104. data/spec/views/owns/index.html.erb_spec.rb +2 -2
  105. data/spec/views/produces/index.html.erb_spec.rb +2 -2
  106. data/spec/views/realizes/index.html.erb_spec.rb +2 -2
  107. data/spec/views/series_has_manifestations/index.html.erb_spec.rb +2 -2
  108. metadata +50 -42
  109. data/app/views/resource_import_files/_show_object_list.html.erb +0 -26
  110. data/spec/dummy/lib/enju_leaf.rb +0 -9
  111. data/spec/dummy/lib/enju_leaf/calculate_stat.rb +0 -30
  112. data/spec/dummy/lib/plugins/ext/will_paginate.rb +0 -64
@@ -42,7 +42,7 @@
42
42
  <%- end -%>
43
43
  </table>
44
44
 
45
- <%= will_paginate(@patrons) -%>
45
+ <%= paginate(@patrons) -%>
46
46
  </div>
47
47
  </div>
48
48
 
@@ -50,7 +50,7 @@
50
50
  <%- end -%>
51
51
  </table>
52
52
 
53
- <%= will_paginate(@patrons) -%>
53
+ <%= paginate(@patrons) -%>
54
54
  </div>
55
55
  </div>
56
56
 
@@ -1,5 +1,5 @@
1
1
  <div id="manifestation">
2
- <%= will_paginate(@manifestations, :param_name => :manifestation_list_page, :class => 'content_pagination digg_pagination') -%>
2
+ <%= paginate(@manifestations, :param_name => :manifestation_list_page, :remote => true) -%>
3
3
  <ul>
4
4
  <%- @manifestations.each do |manifestation| -%>
5
5
  <li>
@@ -15,5 +15,5 @@
15
15
  </li>
16
16
  <%- end -%>
17
17
  </ul>
18
- <%= will_paginate(@manifestations, :param_name => :manifestation_list_page, :class => 'content_pagination digg_pagination') -%>
18
+ <%= paginate(@manifestations, :param_name => :manifestation_list_page, :remote => true) -%>
19
19
  </div>
@@ -1,5 +1,5 @@
1
1
  <div id="work">
2
- <%= will_paginate(@works, :param_name => :work_list_page, :class => 'content_pagination digg_pagination') -%>
2
+ <%= paginate(@works, :param_name => :work_list_page, :remote => true -%>
3
3
  <ul>
4
4
  <%- @works.each do |work| -%>
5
5
  <li>
@@ -9,6 +9,6 @@
9
9
  </li>
10
10
  <%- end -%>
11
11
  </ul>
12
- <%= will_paginate(@works, :param_name => :work_list_page, :class => 'content_pagination digg_pagination') -%>
12
+ <%= paginate(@works, :param_name => :work_list_page, :remote => true) -%>
13
13
  </div>
14
14
 
@@ -20,4 +20,4 @@
20
20
  <%- end -%>
21
21
  </ul>
22
22
 
23
- <%= will_paginate(@patrons, :renderer => WillPaginateJqueryMobileRenderer) %>
23
+ <%= paginate(@patrons) %>
@@ -34,7 +34,7 @@
34
34
  <%- end -%>
35
35
  </table>
36
36
 
37
- <%= will_paginate(@picture_files) -%>
37
+ <%= paginate(@picture_files) -%>
38
38
  </div>
39
39
  </div>
40
40
 
@@ -39,7 +39,7 @@
39
39
  <%- end -%>
40
40
  </table>
41
41
 
42
- <%= will_paginate(@picture_files) -%>
42
+ <%= paginate(@picture_files) -%>
43
43
  </div>
44
44
  </div>
45
45
 
@@ -41,7 +41,7 @@
41
41
  <%- end -%>
42
42
  </table>
43
43
 
44
- <%= will_paginate(@picture_files) -%>
44
+ <%= paginate(@picture_files) -%>
45
45
  </div>
46
46
  </div>
47
47
 
@@ -41,7 +41,7 @@
41
41
  <%- end -%>
42
42
  </table>
43
43
 
44
- <%= will_paginate(@picture_files) -%>
44
+ <%= paginate(@picture_files) -%>
45
45
  </div>
46
46
  </div>
47
47
 
@@ -39,7 +39,7 @@
39
39
  <%- end -%>
40
40
  </table>
41
41
 
42
- <%= will_paginate(@picture_files) -%>
42
+ <%= paginate(@picture_files) -%>
43
43
  </div>
44
44
  </div>
45
45
 
@@ -23,7 +23,7 @@
23
23
  <%- end -%>
24
24
  </table>
25
25
 
26
- <%= will_paginate(@produces) -%>
26
+ <%= paginate(@produces) -%>
27
27
  </div>
28
28
  </div>
29
29
 
@@ -28,7 +28,7 @@
28
28
  <%- end -%>
29
29
  </table>
30
30
 
31
- <%= will_paginate(@produces) -%>
31
+ <%= paginate(@produces) -%>
32
32
 
33
33
  </div>
34
34
  </div>
@@ -26,7 +26,7 @@
26
26
  <%- end -%>
27
27
  </table>
28
28
 
29
- <%= will_paginate(@produces) -%>
29
+ <%= paginate(@produces) -%>
30
30
 
31
31
  </div>
32
32
  </div>
@@ -23,7 +23,7 @@
23
23
  <%- end -%>
24
24
  </table>
25
25
 
26
- <%= will_paginate(@realizes) -%>
26
+ <%= paginate(@realizes) -%>
27
27
  </div>
28
28
  </div>
29
29
 
@@ -28,7 +28,7 @@
28
28
  <%- end -%>
29
29
  </table>
30
30
 
31
- <%= will_paginate(@realizes) -%>
31
+ <%= paginate(@realizes) -%>
32
32
 
33
33
  </div>
34
34
  </div>
@@ -26,7 +26,7 @@
26
26
  <%- end -%>
27
27
  </table>
28
28
 
29
- <%= will_paginate(@realizes) -%>
29
+ <%= paginate(@realizes) -%>
30
30
 
31
31
  </div>
32
32
  </div>
@@ -29,7 +29,7 @@
29
29
  <%- end -%>
30
30
  </table>
31
31
 
32
- <%= will_paginate(@resource_import_files) -%>
32
+ <%= paginate(@resource_import_files) -%>
33
33
  </div>
34
34
  </div>
35
35
 
@@ -32,7 +32,7 @@
32
32
  <% end %>
33
33
  </table>
34
34
 
35
- <%= will_paginate(@resource_import_results) %>
35
+ <%= paginate(@resource_import_results) %>
36
36
 
37
37
  </div>
38
38
  </div>
@@ -22,7 +22,7 @@
22
22
  <% end %>
23
23
  </table>
24
24
 
25
- <%= will_paginate(@series_has_manifestations) %>
25
+ <%= paginate(@series_has_manifestations) %>
26
26
 
27
27
  </div>
28
28
  </div>
@@ -43,7 +43,7 @@
43
43
  <% end %>
44
44
  </table>
45
45
 
46
- <%= will_paginate(@series_statements) -%>
46
+ <%= paginate(@series_statements) -%>
47
47
 
48
48
  </div>
49
49
  </div>
@@ -47,7 +47,7 @@
47
47
  <% end %>
48
48
  </table>
49
49
 
50
- <%= will_paginate(@series_statements) -%>
50
+ <%= paginate(@series_statements) -%>
51
51
 
52
52
  </div>
53
53
  </div>
@@ -42,7 +42,7 @@
42
42
  <%- end -%>
43
43
  </table>
44
44
 
45
- <%= will_paginate(@series_statements) -%>
45
+ <%= paginate(@series_statements) -%>
46
46
  </div>
47
47
  </div>
48
48
 
@@ -1,5 +1,5 @@
1
1
  <div id="manifestation">
2
- <%= will_paginate(@manifestations, :param_name => :manifestation_page, :class => 'content_pagination digg_pagination') -%>
2
+ <%= paginate(@manifestations, :param_name => :manifestation_page, :remote => true) -%>
3
3
  <table class="table table-striped index">
4
4
  <%- @manifestations.each do |manifestation| -%>
5
5
  <% next if manifestation.periodical_master? %>
@@ -13,5 +13,5 @@
13
13
  </tr>
14
14
  <%- end -%>
15
15
  </table>
16
- <%= will_paginate(@manifestations, :param_name => :manifestation_page, :class => 'content_pagination digg_pagination') -%>
16
+ <%= paginate(@manifestations, :param_name => :manifestation_page, :remote => true) -%>
17
17
  </div>
@@ -50,6 +50,10 @@ module EnjuBiblio
50
50
  def get_series_statement
51
51
  @series_statement = SeriesStatement.find(params[:series_statement_id]) if params[:series_statement_id]
52
52
  end
53
+
54
+ def get_basket
55
+ @basket = Basket.find(params[:basket_id]) if params[:basket_id]
56
+ end
53
57
  end
54
58
  end
55
59
 
@@ -1,8 +1,6 @@
1
1
  require 'enju_core'
2
- require 'enju_export'
3
2
  require 'inherited_resources'
4
3
  require 'paper_trail'
5
- require 'configatron'
6
4
  require 'paperclip'
7
5
  require 'state_machine'
8
6
  require 'validates_timeliness'
@@ -11,7 +9,6 @@ require 'has_scope'
11
9
  require 'enju_ndl'
12
10
  require 'dynamic_form'
13
11
  require 'simple_form'
14
- require 'will_paginate/array'
15
12
  require 'resque_mailer'
16
13
 
17
14
  module EnjuBiblio
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0.pre"
3
3
  end
@@ -0,0 +1,51 @@
1
+ module EnjuBiblio
2
+ module Generators
3
+ class ViewsGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../../../app/views', __FILE__)
5
+
6
+ def copy_files
7
+ directories = %w(
8
+ accepts
9
+ carrier_types
10
+ content_types
11
+ countries
12
+ create_types
13
+ creates
14
+ donates
15
+ exemplifies
16
+ extents
17
+ form_of_works
18
+ frequencies
19
+ import_requests
20
+ items
21
+ languages
22
+ licenses
23
+ manifestation_relationship_types
24
+ manifestation_relationships
25
+ manifestations
26
+ medium_of_performances
27
+ owns
28
+ patron_import_files
29
+ patron_import_results
30
+ patron_relationship_types
31
+ patron_relationships
32
+ patron_types
33
+ patrons
34
+ picture_files
35
+ produce_types
36
+ produces
37
+ realize_types
38
+ realizes
39
+ resource_import_files
40
+ resource_import_results
41
+ series_has_manifestations
42
+ series_statements
43
+ )
44
+
45
+ directories.each do |dir|
46
+ directory dir, "app/views/#{dir}"
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,304 @@
1
+ require 'spec_helper'
2
+
3
+ describe AcceptsController do
4
+ fixtures :all
5
+
6
+ def mock_user(stubs={})
7
+ (@mock_user ||= mock_model(Accept).as_null_object).tap do |user|
8
+ user.stub(stubs) unless stubs.empty?
9
+ end
10
+ end
11
+
12
+ describe "GET index" do
13
+ describe "When logged in as Administrator" do
14
+ login_fixture_admin
15
+
16
+ it "assigns all accepts as @accepts" do
17
+ get :index
18
+ assigns(:accepts).should_not be_nil
19
+ response.should be_success
20
+ end
21
+
22
+ describe "When basket_id is specified" do
23
+ it "assigns all accepts as @accepts" do
24
+ get :index, :basket_id => 10
25
+ assigns(:accepts).should eq Basket.find(10).accepts.page(1)
26
+ response.should be_success
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "When logged in as Librarian" do
32
+ login_fixture_librarian
33
+
34
+ it "assigns all accepts as @accepts" do
35
+ get :index
36
+ assigns(:accepts).should_not be_nil
37
+ response.should be_success
38
+ end
39
+
40
+ describe "When basket_id is specified" do
41
+ it "assigns all accepts as @accepts" do
42
+ get :index, :basket_id => 9
43
+ assigns(:accepts).should eq Basket.find(9).accepts.page(1)
44
+ response.should be_success
45
+ end
46
+ end
47
+ end
48
+
49
+ describe "When logged in as User" do
50
+ login_fixture_user
51
+
52
+ it "should not assign all accepts as @accepts" do
53
+ get :index
54
+ assigns(:accepts).should be_nil
55
+ response.should be_forbidden
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "GET show" do
61
+ describe "When logged in as Administrator" do
62
+ login_fixture_admin
63
+
64
+ it "assigns the requested accept as @accept" do
65
+ accept = FactoryGirl.create(:accept)
66
+ get :show, :id => accept.id
67
+ assigns(:accept).should eq(accept)
68
+ end
69
+
70
+ it "should not show missing accept" do
71
+ get :show, :id => 'missing'
72
+ response.should be_missing
73
+ end
74
+ end
75
+
76
+ describe "When logged in as Librarian" do
77
+ login_fixture_librarian
78
+
79
+ it "assigns the requested accept as @accept" do
80
+ accept = FactoryGirl.create(:accept)
81
+ get :show, :id => accept.id
82
+ assigns(:accept).should eq(accept)
83
+ end
84
+ end
85
+
86
+ describe "When logged in as User" do
87
+ login_fixture_user
88
+
89
+ it "assigns the requested accept as @accept" do
90
+ accept = FactoryGirl.create(:accept)
91
+ get :show, :id => accept.id
92
+ assigns(:accept).should eq(accept)
93
+ response.should be_forbidden
94
+ end
95
+ end
96
+
97
+ describe "When not logged in" do
98
+ it "assigns the requested accept as @accept" do
99
+ accept = FactoryGirl.create(:accept)
100
+ get :show, :id => accept.id
101
+ assigns(:accept).should eq(accept)
102
+ response.should redirect_to new_user_session_url
103
+ end
104
+ end
105
+ end
106
+
107
+ describe "GET new" do
108
+ describe "When logged in as Administrator" do
109
+ login_fixture_admin
110
+
111
+ it "assigns the requested accept as @accept" do
112
+ get :new
113
+ assigns(:accept).should_not be_valid
114
+ end
115
+ end
116
+
117
+ describe "When logged in as Librarian" do
118
+ login_fixture_librarian
119
+
120
+ it "assigns the requested accept as @accept" do
121
+ get :new
122
+ assigns(:accept).should_not be_valid
123
+ end
124
+ end
125
+
126
+ describe "When logged in as User" do
127
+ login_fixture_user
128
+
129
+ it "should not assign the requested accept as @accept" do
130
+ get :new
131
+ assigns(:accept).should_not be_valid
132
+ response.should be_forbidden
133
+ end
134
+ end
135
+
136
+ describe "When not logged in" do
137
+ it "should not assign the requested accept as @accept" do
138
+ get :new
139
+ assigns(:accept).should_not be_valid
140
+ response.should redirect_to(new_user_session_url)
141
+ end
142
+ end
143
+ end
144
+
145
+ describe "POST create" do
146
+ before(:each) do
147
+ @attrs = {:item_identifier => '00003'}
148
+ @invalid_attrs = {:item_identifier => 'invalid'}
149
+ end
150
+
151
+ describe "When logged in as Administrator" do
152
+ login_fixture_admin
153
+
154
+ describe "with valid params" do
155
+ it "assigns a newly created accept as @accept" do
156
+ post :create, :accept => @attrs
157
+ assigns(:accept).should_not be_valid
158
+ end
159
+
160
+ it "should not create a new accept without basket_id" do
161
+ post :create, :accept => @attrs
162
+ response.should be_forbidden
163
+ end
164
+
165
+ describe "When basket_id is specified" do
166
+ it "redirects to the created accept" do
167
+ post :create, :accept => @attrs, :basket_id => 9
168
+ response.should redirect_to(basket_accepts_url(assigns(:accept).basket))
169
+ assigns(:accept).item.circulation_status.name.should eq 'Available On Shelf'
170
+ end
171
+ end
172
+ end
173
+
174
+ describe "with invalid params" do
175
+ it "assigns a newly created but unsaved accept as @accept" do
176
+ post :create, :accept => @invalid_attrs
177
+ assigns(:accept).should_not be_valid
178
+ end
179
+
180
+ it "should be forbidden" do
181
+ post :create, :accept => @invalid_attrs
182
+ response.should be_forbidden
183
+ end
184
+ end
185
+
186
+ it "should not create accept without item_id" do
187
+ post :create, :accept => {:item_identifier => nil}, :basket_id => 9
188
+ assigns(:accept).should_not be_valid
189
+ response.should be_success
190
+ end
191
+ end
192
+
193
+ describe "When logged in as Librarian" do
194
+ login_fixture_librarian
195
+
196
+ describe "with valid params" do
197
+ it "assigns a newly created accept as @accept" do
198
+ post :create, :accept => @attrs
199
+ assigns(:accept).should_not be_valid
200
+ end
201
+
202
+ it "should not create a new accept without basket_id" do
203
+ post :create, :accept => @attrs
204
+ response.should be_forbidden
205
+ end
206
+ end
207
+ end
208
+
209
+ describe "When logged in as User" do
210
+ login_fixture_user
211
+
212
+ describe "with valid params" do
213
+ it "assigns a newly created accept as @accept" do
214
+ post :create, :accept => @attrs
215
+ assigns(:accept).should_not be_valid
216
+ end
217
+
218
+ it "should be forbidden" do
219
+ post :create, :accept => @attrs
220
+ response.should be_forbidden
221
+ end
222
+ end
223
+ end
224
+
225
+ describe "When not logged in" do
226
+ before(:each) do
227
+ @attrs = {:item_identifier => '00003'}
228
+ @invalid_attrs = {:item_identifier => 'invalid'}
229
+ end
230
+
231
+ describe "with valid params" do
232
+ it "assigns a newly created accept as @accept" do
233
+ post :create, :accept => @attrs
234
+ end
235
+
236
+ it "should redirect to new session url" do
237
+ post :create, :accept => @attrs
238
+ response.should redirect_to new_user_session_url
239
+ end
240
+ end
241
+ end
242
+ end
243
+
244
+ describe "DELETE destroy" do
245
+ before(:each) do
246
+ @accept = FactoryGirl.create(:accept)
247
+ end
248
+
249
+ describe "When logged in as Administrator" do
250
+ login_fixture_admin
251
+
252
+ it "destroys the requested accept" do
253
+ delete :destroy, :id => @accept.id
254
+ end
255
+
256
+ it "redirects to the accepts list" do
257
+ delete :destroy, :id => @accept.id
258
+ response.should redirect_to(accepts_url)
259
+ end
260
+
261
+ it "should not destroy missing accept" do
262
+ delete :destroy, :id => 'missing'
263
+ response.should be_missing
264
+ end
265
+ end
266
+
267
+ describe "When logged in as Librarian" do
268
+ login_fixture_librarian
269
+
270
+ it "destroys the requested accept" do
271
+ delete :destroy, :id => @accept.id
272
+ end
273
+
274
+ it "redirects to the accepts list" do
275
+ delete :destroy, :id => @accept.id
276
+ response.should redirect_to(accepts_url)
277
+ end
278
+ end
279
+
280
+ describe "When logged in as User" do
281
+ login_fixture_user
282
+
283
+ it "destroys the requested accept" do
284
+ delete :destroy, :id => @accept.id
285
+ end
286
+
287
+ it "should be forbidden" do
288
+ delete :destroy, :id => @accept.id
289
+ response.should be_forbidden
290
+ end
291
+ end
292
+
293
+ describe "When not logged in" do
294
+ it "destroys the requested accept" do
295
+ delete :destroy, :id => @accept.id
296
+ end
297
+
298
+ it "should be forbidden" do
299
+ delete :destroy, :id => @accept.id
300
+ response.should redirect_to(new_user_session_url)
301
+ end
302
+ end
303
+ end
304
+ end