enju_biblio 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/icons/book.png +0 -0
  3. data/app/assets/images/icons/cd.png +0 -0
  4. data/app/assets/images/icons/dvd.png +0 -0
  5. data/app/assets/images/icons/monitor.png +0 -0
  6. data/app/controllers/carrier_types_controller.rb +8 -3
  7. data/app/controllers/manifestations_controller.rb +17 -4
  8. data/app/controllers/picture_files_controller.rb +1 -1
  9. data/app/controllers/series_statements_controller.rb +6 -0
  10. data/app/helpers/manifestations_helper.rb +1 -1
  11. data/app/models/agent_import_file_transition.rb +1 -0
  12. data/app/models/carrier_type.rb +11 -7
  13. data/app/models/import_request_transition.rb +1 -0
  14. data/app/models/manifestation.rb +5 -0
  15. data/app/models/resource_export_file_transition.rb +1 -0
  16. data/app/models/resource_import_file_transition.rb +1 -0
  17. data/app/views/carrier_types/index.html.erb +4 -1
  18. data/app/views/manifestations/_show_detail_librarian.html.erb +4 -0
  19. data/app/views/manifestations/index.html.erb +3 -0
  20. data/config/locales/translation_en.yml +2 -0
  21. data/config/locales/translation_ja.yml +2 -0
  22. data/lib/enju_biblio/biblio_helper.rb +1 -12
  23. data/lib/enju_biblio/version.rb +1 -1
  24. data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +3 -3
  25. data/lib/tasks/carrier_type.rb +30 -18
  26. data/lib/tasks/enju_biblio_tasks.rake +2 -0
  27. data/spec/controllers/agent_import_files_controller_spec.rb +87 -87
  28. data/spec/controllers/agent_import_results_controller_spec.rb +22 -22
  29. data/spec/controllers/agent_merge_lists_controller_spec.rb +157 -157
  30. data/spec/controllers/agent_merges_controller_spec.rb +151 -151
  31. data/spec/controllers/agent_relationship_types_controller_spec.rb +152 -152
  32. data/spec/controllers/agent_relationships_controller_spec.rb +153 -153
  33. data/spec/controllers/agent_types_controller_spec.rb +49 -50
  34. data/spec/controllers/agents_controller_spec.rb +234 -234
  35. data/spec/controllers/carrier_types_controller_spec.rb +123 -103
  36. data/spec/controllers/content_types_controller_spec.rb +51 -52
  37. data/spec/controllers/countries_controller_spec.rb +156 -156
  38. data/spec/controllers/create_types_controller_spec.rb +48 -49
  39. data/spec/controllers/creates_controller_spec.rb +154 -154
  40. data/spec/controllers/donates_controller_spec.rb +153 -153
  41. data/spec/controllers/form_of_works_controller_spec.rb +48 -49
  42. data/spec/controllers/frequencies_controller_spec.rb +51 -52
  43. data/spec/controllers/identifier_types_controller_spec.rb +48 -49
  44. data/spec/controllers/import_requests_controller_spec.rb +165 -164
  45. data/spec/controllers/items_controller_spec.rb +214 -216
  46. data/spec/controllers/languages_controller_spec.rb +109 -109
  47. data/spec/controllers/licenses_controller_spec.rb +48 -49
  48. data/spec/controllers/manifestation_relationship_types_controller_spec.rb +152 -152
  49. data/spec/controllers/manifestation_relationships_controller_spec.rb +153 -153
  50. data/spec/controllers/manifestations_controller_spec.rb +319 -289
  51. data/spec/controllers/medium_of_performances_controller_spec.rb +48 -49
  52. data/spec/controllers/owns_controller_spec.rb +153 -153
  53. data/spec/controllers/picture_files_controller_spec.rb +156 -156
  54. data/spec/controllers/produce_types_controller_spec.rb +48 -49
  55. data/spec/controllers/produces_controller_spec.rb +154 -154
  56. data/spec/controllers/realize_types_controller_spec.rb +48 -49
  57. data/spec/controllers/realizes_controller_spec.rb +155 -155
  58. data/spec/controllers/resource_export_files_controller_spec.rb +72 -72
  59. data/spec/controllers/resource_import_files_controller_spec.rb +90 -90
  60. data/spec/controllers/resource_import_results_controller_spec.rb +43 -43
  61. data/spec/controllers/series_statement_merge_lists_controller_spec.rb +153 -153
  62. data/spec/controllers/series_statement_merges_controller_spec.rb +151 -151
  63. data/spec/controllers/series_statements_controller_spec.rb +154 -154
  64. data/spec/factories/checkout.rb +9 -0
  65. data/spec/factories/library.rb +13 -0
  66. data/spec/factories/shelf.rb +6 -0
  67. data/spec/fixtures/carrier_types.yml +11 -7
  68. data/spec/models/carrier_type_spec.rb +11 -7
  69. data/spec/models/resource_export_file_spec.rb +58 -16
  70. data/spec/support/resque.rb +0 -1
  71. data/spec/views/manifestations/show.html.erb_spec.rb +5 -0
  72. data/spec/views/resource_import_files/index.html.erb_spec.rb +1 -1
  73. data/spec/views/resource_import_files/show.html.erb_spec.rb +1 -1
  74. data/spec/views/resource_import_results/index.html.erb_spec.rb +1 -1
  75. data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
  76. metadata +49 -39
@@ -29,113 +29,113 @@ describe AgentTypesController do
29
29
  FactoryGirl.attributes_for(:agent_type)
30
30
  end
31
31
 
32
- describe "GET index" do
33
- it "assigns all agent_types as @agent_types" do
32
+ describe 'GET index' do
33
+ it 'assigns all agent_types as @agent_types' do
34
34
  agent_type = AgentType.create! valid_attributes
35
35
  get :index
36
36
  expect(assigns(:agent_types)).to eq(AgentType.order(:position))
37
37
  end
38
38
  end
39
39
 
40
- describe "GET show" do
41
- it "assigns the requested agent_type as @agent_type" do
40
+ describe 'GET show' do
41
+ it 'assigns the requested agent_type as @agent_type' do
42
42
  agent_type = AgentType.create! valid_attributes
43
- get :show, :id => agent_type.id
43
+ get :show, id: agent_type.id
44
44
  expect(assigns(:agent_type)).to eq(agent_type)
45
45
  end
46
46
  end
47
47
 
48
- describe "GET new" do
49
- it "assigns a new agent_type as @agent_type" do
48
+ describe 'GET new' do
49
+ it 'assigns a new agent_type as @agent_type' do
50
50
  get :new
51
51
  expect(assigns(:agent_type)).to be_a_new(AgentType)
52
52
  end
53
53
  end
54
54
 
55
- describe "GET edit" do
56
- it "assigns the requested agent_type as @agent_type" do
55
+ describe 'GET edit' do
56
+ it 'assigns the requested agent_type as @agent_type' do
57
57
  agent_type = AgentType.create! valid_attributes
58
- get :edit, :id => agent_type.id
58
+ get :edit, id: agent_type.id
59
59
  expect(assigns(:agent_type)).to eq(agent_type)
60
60
  end
61
61
  end
62
62
 
63
- describe "POST create" do
64
- describe "with valid params" do
65
- it "creates a new AgentType" do
66
- expect {
67
- post :create, :agent_type => valid_attributes
68
- }.to change(AgentType, :count).by(1)
63
+ describe 'POST create' do
64
+ describe 'with valid params' do
65
+ it 'creates a new AgentType' do
66
+ expect do
67
+ post :create, agent_type: valid_attributes
68
+ end.to change(AgentType, :count).by(1)
69
69
  end
70
70
 
71
- it "assigns a newly created agent_type as @agent_type" do
72
- post :create, :agent_type => valid_attributes
71
+ it 'assigns a newly created agent_type as @agent_type' do
72
+ post :create, agent_type: valid_attributes
73
73
  expect(assigns(:agent_type)).to be_a(AgentType)
74
74
  expect(assigns(:agent_type)).to be_persisted
75
75
  end
76
76
 
77
- it "redirects to the created agent_type" do
78
- post :create, :agent_type => valid_attributes
77
+ it 'redirects to the created agent_type' do
78
+ post :create, agent_type: valid_attributes
79
79
  expect(response).to redirect_to(AgentType.last)
80
80
  end
81
81
  end
82
82
 
83
- describe "with invalid params" do
84
- it "assigns a newly created but unsaved agent_type as @agent_type" do
83
+ describe 'with invalid params' do
84
+ it 'assigns a newly created but unsaved agent_type as @agent_type' do
85
85
  # Trigger the behavior that occurs when invalid params are submitted
86
86
  AgentType.any_instance.stub(:save).and_return(false)
87
- post :create, :agent_type => {name: "test"}
87
+ post :create, agent_type: { name: 'test' }
88
88
  expect(assigns(:agent_type)).to be_a_new(AgentType)
89
89
  end
90
90
 
91
91
  it "re-renders the 'new' template" do
92
92
  # Trigger the behavior that occurs when invalid params are submitted
93
93
  AgentType.any_instance.stub(:save).and_return(false)
94
- post :create, :agent_type => {name: "test"}
95
- expect(response).to render_template("new")
94
+ post :create, agent_type: { name: 'test' }
95
+ expect(response).to render_template('new')
96
96
  end
97
97
  end
98
98
  end
99
99
 
100
- describe "PUT update" do
101
- describe "with valid params" do
102
- it "updates the requested agent_type" do
100
+ describe 'PUT update' do
101
+ describe 'with valid params' do
102
+ it 'updates the requested agent_type' do
103
103
  agent_type = AgentType.create! valid_attributes
104
104
  # Assuming there are no other agent_types in the database, this
105
105
  # specifies that the AgentType created on the previous line
106
106
  # receives the :update_attributes message with whatever params are
107
107
  # submitted in the request.
108
- AgentType.any_instance.should_receive(:update_attributes).with({'name' => 'test'})
109
- put :update, :id => agent_type.id, :agent_type => {'name' => 'test'}
108
+ AgentType.any_instance.should_receive(:update_attributes).with('name' => 'test')
109
+ put :update, id: agent_type.id, agent_type: { 'name' => 'test' }
110
110
  end
111
111
 
112
- it "assigns the requested agent_type as @agent_type" do
112
+ it 'assigns the requested agent_type as @agent_type' do
113
113
  agent_type = AgentType.create! valid_attributes
114
- put :update, :id => agent_type.id, :agent_type => valid_attributes
114
+ put :update, id: agent_type.id, agent_type: valid_attributes
115
115
  expect(assigns(:agent_type)).to eq(agent_type)
116
116
  end
117
117
 
118
- it "redirects to the agent_type" do
118
+ it 'redirects to the agent_type' do
119
119
  agent_type = AgentType.create! valid_attributes
120
- put :update, :id => agent_type.id, :agent_type => valid_attributes
120
+ put :update, id: agent_type.id, agent_type: valid_attributes
121
121
  expect(response).to redirect_to(agent_type)
122
122
  end
123
123
 
124
- it "moves its position when specified" do
124
+ it 'moves its position when specified' do
125
125
  agent_type = AgentType.create! valid_attributes
126
126
  position = agent_type.position
127
- put :update, :id => agent_type.id, :move => 'higher'
127
+ put :update, id: agent_type.id, move: 'higher'
128
128
  expect(response).to redirect_to agent_types_url
129
129
  assigns(:agent_type).reload.position.should eq position - 1
130
130
  end
131
131
  end
132
132
 
133
- describe "with invalid params" do
134
- it "assigns the agent_type as @agent_type" do
133
+ describe 'with invalid params' do
134
+ it 'assigns the agent_type as @agent_type' do
135
135
  agent_type = AgentType.create! valid_attributes
136
136
  # Trigger the behavior that occurs when invalid params are submitted
137
137
  AgentType.any_instance.stub(:save).and_return(false)
138
- put :update, :id => agent_type.id, :agent_type => {name: "test"}
138
+ put :update, id: agent_type.id, agent_type: { name: 'test' }
139
139
  expect(assigns(:agent_type)).to eq(agent_type)
140
140
  end
141
141
 
@@ -143,30 +143,29 @@ describe AgentTypesController do
143
143
  agent_type = AgentType.create! valid_attributes
144
144
  # Trigger the behavior that occurs when invalid params are submitted
145
145
  AgentType.any_instance.stub(:save).and_return(false)
146
- put :update, :id => agent_type.id, :agent_type => {name: "test"}
147
- expect(response).to render_template("edit")
146
+ put :update, id: agent_type.id, agent_type: { name: 'test' }
147
+ expect(response).to render_template('edit')
148
148
  end
149
149
  end
150
150
  end
151
151
 
152
- describe "DELETE destroy" do
153
- it "destroys the requested agent_type" do
152
+ describe 'DELETE destroy' do
153
+ it 'destroys the requested agent_type' do
154
154
  agent_type = AgentType.create! valid_attributes
155
- expect {
156
- delete :destroy, :id => agent_type.id
157
- }.to change(AgentType, :count).by(-1)
155
+ expect do
156
+ delete :destroy, id: agent_type.id
157
+ end.to change(AgentType, :count).by(-1)
158
158
  end
159
159
 
160
- it "redirects to the agent_types list" do
160
+ it 'redirects to the agent_types list' do
161
161
  agent_type = AgentType.create! valid_attributes
162
- delete :destroy, :id => agent_type.id
162
+ delete :destroy, id: agent_type.id
163
163
  expect(response).to redirect_to(agent_types_url)
164
164
  end
165
165
 
166
- it "should not destroy agent_type that contains agents" do
166
+ it 'should not destroy agent_type that contains agents' do
167
167
  delete :destroy, id: agent_types(:agent_type_00001)
168
168
  expect(response).to be_forbidden
169
169
  end
170
170
  end
171
-
172
171
  end
@@ -7,218 +7,218 @@ describe AgentsController do
7
7
  FactoryGirl.attributes_for(:agent)
8
8
  end
9
9
 
10
- describe "GET index", :solr => true do
10
+ describe 'GET index', solr: true do
11
11
  before do
12
12
  Agent.reindex
13
13
  end
14
14
 
15
- describe "When logged in as Administrator" do
15
+ describe 'When logged in as Administrator' do
16
16
  login_fixture_admin
17
17
 
18
- it "assigns all agents as @agents" do
18
+ it 'assigns all agents as @agents' do
19
19
  get :index
20
20
  expect(assigns(:agents)).not_to be_empty
21
21
  end
22
22
 
23
- it "should get index with agent_id" do
24
- get :index, :agent_id => 1
23
+ it 'should get index with agent_id' do
24
+ get :index, agent_id: 1
25
25
  expect(response).to be_success
26
26
  expect(assigns(:agent)).to eq Agent.find(1)
27
27
  expect(assigns(:agents)).to eq assigns(:agent).derived_agents.where('required_role_id >= 1').page(1)
28
28
  end
29
29
 
30
- it "should get index with query" do
31
- get :index, :query => 'Librarian1'
30
+ it 'should get index with query' do
31
+ get :index, query: 'Librarian1'
32
32
  expect(assigns(:agents)).not_to be_empty
33
33
  expect(response).to be_success
34
34
  end
35
35
  end
36
36
 
37
- describe "When logged in as Librarian" do
37
+ describe 'When logged in as Librarian' do
38
38
  login_fixture_librarian
39
39
 
40
- it "assigns all agents as @agents" do
40
+ it 'assigns all agents as @agents' do
41
41
  get :index
42
42
  expect(assigns(:agents)).not_to be_empty
43
43
  end
44
44
  end
45
45
 
46
- describe "When logged in as User" do
46
+ describe 'When logged in as User' do
47
47
  login_fixture_user
48
48
 
49
- it "assigns all agents as @agents" do
49
+ it 'assigns all agents as @agents' do
50
50
  get :index
51
51
  expect(assigns(:agents)).not_to be_empty
52
52
  end
53
53
  end
54
54
 
55
- describe "When not logged in" do
56
- it "assigns all agents as @agents" do
55
+ describe 'When not logged in' do
56
+ it 'assigns all agents as @agents' do
57
57
  get :index
58
58
  expect(assigns(:agents)).not_to be_empty
59
59
  end
60
60
 
61
- it "assigns all agents as @agents in rss format" do
62
- get :index, :format => :rss
61
+ it 'assigns all agents as @agents in rss format' do
62
+ get :index, format: :rss
63
63
  expect(assigns(:agents)).not_to be_empty
64
64
  end
65
65
 
66
- it "assigns all agents as @agents in atom format" do
67
- get :index, :format => :atom
66
+ it 'assigns all agents as @agents in atom format' do
67
+ get :index, format: :atom
68
68
  expect(assigns(:agents)).not_to be_empty
69
69
  end
70
70
 
71
- it "should get index with agent_id" do
72
- get :index, :agent_id => 1
71
+ it 'should get index with agent_id' do
72
+ get :index, agent_id: 1
73
73
  expect(response).to be_success
74
74
  expect(assigns(:agent)).to eq Agent.find(1)
75
- expect(assigns(:agents)).to eq assigns(:agent).derived_agents.where(:required_role_id => 1).page(1)
75
+ expect(assigns(:agents)).to eq assigns(:agent).derived_agents.where(required_role_id: 1).page(1)
76
76
  end
77
77
 
78
- it "should get index with manifestation_id" do
79
- get :index, :manifestation_id => 1
78
+ it 'should get index with manifestation_id' do
79
+ get :index, manifestation_id: 1
80
80
  assigns(:manifestation).should eq Manifestation.find(1)
81
- expect(assigns(:agents)).to eq assigns(:manifestation).publishers.where(:required_role_id => 1).page(1)
81
+ expect(assigns(:agents)).to eq assigns(:manifestation).publishers.where(required_role_id: 1).page(1)
82
82
  end
83
83
 
84
- it "should get index with query" do
85
- get :index, :query => 'Librarian1'
84
+ it 'should get index with query' do
85
+ get :index, query: 'Librarian1'
86
86
  expect(assigns(:agents)).to be_empty
87
87
  expect(response).to be_success
88
88
  end
89
89
  end
90
90
  end
91
91
 
92
- describe "GET show" do
92
+ describe 'GET show' do
93
93
  before(:each) do
94
94
  @agent = FactoryGirl.create(:agent)
95
95
  end
96
96
 
97
- describe "When logged in as Administrator" do
97
+ describe 'When logged in as Administrator' do
98
98
  login_fixture_admin
99
99
 
100
- it "assigns the requested agent as @agent" do
101
- get :show, :id => @agent.id
100
+ it 'assigns the requested agent as @agent' do
101
+ get :show, id: @agent.id
102
102
  expect(assigns(:agent)).to eq(@agent)
103
103
  end
104
104
  end
105
105
 
106
- describe "When logged in as Librarian" do
106
+ describe 'When logged in as Librarian' do
107
107
  login_fixture_librarian
108
108
 
109
- it "assigns the requested agent as @agent" do
110
- get :show, :id => @agent.id
109
+ it 'assigns the requested agent as @agent' do
110
+ get :show, id: @agent.id
111
111
  expect(assigns(:agent)).to eq(@agent)
112
112
  end
113
113
 
114
- #it "should show agent when required_role is user" do
114
+ # it "should show agent when required_role is user" do
115
115
  # get :show, :id => users(:user2).agent.id
116
116
  # expect(assigns(:agent)).to eq(users(:user2).agent)
117
117
  # expect(response).to be_success
118
- #end
118
+ # end
119
119
 
120
- #it "should show patron when required_role is librarian" do
120
+ # it "should show patron when required_role is librarian" do
121
121
  # get :show, :id => users(:user1).agent.id
122
122
  # expect(assigns(:agent)).to eq(users(:user1).agent)
123
123
  # expect(response).to be_success
124
- #end
124
+ # end
125
125
 
126
- it "should not show agent who does not create a work" do
127
- lambda{
128
- get :show, :id => 3, :work_id => 3
129
- }.should raise_error(ActiveRecord::RecordNotFound)
130
- #expect(response).to be_missing
126
+ it 'should not show agent who does not create a work' do
127
+ lambda do
128
+ get :show, id: 3, work_id: 3
129
+ end.should raise_error(ActiveRecord::RecordNotFound)
130
+ # expect(response).to be_missing
131
131
  end
132
132
 
133
- it "should not show agent who does not produce a manifestation" do
134
- lambda{
135
- get :show, :id => 4, :manifestation_id => 4
136
- }.should raise_error(ActiveRecord::RecordNotFound)
137
- #expect(response).to be_missing
133
+ it 'should not show agent who does not produce a manifestation' do
134
+ lambda do
135
+ get :show, id: 4, manifestation_id: 4
136
+ end.should raise_error(ActiveRecord::RecordNotFound)
137
+ # expect(response).to be_missing
138
138
  end
139
139
 
140
- #it "should not show agent when required_role is 'Administrator'" do
140
+ # it "should not show agent when required_role is 'Administrator'" do
141
141
  # sign_in users(:librarian2)
142
142
  # get :show, :id => users(:librarian1).agent.id
143
143
  # expect(response).to be_forbidden
144
- #end
144
+ # end
145
145
  end
146
146
 
147
- describe "When logged in as User" do
147
+ describe 'When logged in as User' do
148
148
  login_fixture_user
149
149
 
150
- it "assigns the requested agent as @agent" do
151
- get :show, :id => @agent.id
150
+ it 'assigns the requested agent as @agent' do
151
+ get :show, id: @agent.id
152
152
  expect(assigns(:agent)).to eq(@agent)
153
153
  end
154
154
 
155
- #it "should show user" do
155
+ # it "should show user" do
156
156
  # get :show, :id => users(:user2).agent.id
157
157
  # assigns(:agent).required_role.name.should eq 'User'
158
158
  # expect(response).to be_success
159
- #end
159
+ # end
160
160
 
161
- #it "should not show agent when required_role is 'Librarian'" do
161
+ # it "should not show agent when required_role is 'Librarian'" do
162
162
  # sign_in users(:user2)
163
163
  # get :show, :id => users(:user1).agent.id
164
164
  # expect(response).to be_forbidden
165
- #end
165
+ # end
166
166
  end
167
167
 
168
- describe "When not logged in" do
169
- it "assigns the requested agent as @agent" do
170
- get :show, :id => @agent.id
168
+ describe 'When not logged in' do
169
+ it 'assigns the requested agent as @agent' do
170
+ get :show, id: @agent.id
171
171
  expect(assigns(:agent)).to eq(@agent)
172
172
  end
173
173
 
174
- it "should show agent with work" do
175
- get :show, :id => 1, :work_id => 1
174
+ it 'should show agent with work' do
175
+ get :show, id: 1, work_id: 1
176
176
  expect(assigns(:agent)).to eq assigns(:work).creators.first
177
177
  end
178
178
 
179
- it "should show agent with manifestation" do
180
- get :show, :id => 1, :manifestation_id => 1
179
+ it 'should show agent with manifestation' do
180
+ get :show, id: 1, manifestation_id: 1
181
181
  expect(assigns(:agent)).to eq assigns(:manifestation).publishers.first
182
182
  end
183
183
 
184
184
  it "should not show agent when required_role is 'User'" do
185
- get :show, :id => 5
185
+ get :show, id: 5
186
186
  expect(response).to redirect_to new_user_session_url
187
187
  end
188
188
  end
189
189
  end
190
190
 
191
- describe "GET new" do
192
- describe "When logged in as Administrator" do
191
+ describe 'GET new' do
192
+ describe 'When logged in as Administrator' do
193
193
  login_fixture_admin
194
194
 
195
- it "assigns the requested agent as @agent" do
195
+ it 'assigns the requested agent as @agent' do
196
196
  get :new
197
197
  expect(assigns(:agent)).not_to be_valid
198
198
  end
199
199
  end
200
200
 
201
- describe "When logged in as Librarian" do
201
+ describe 'When logged in as Librarian' do
202
202
  login_fixture_librarian
203
203
 
204
- it "assigns the requested agent as @agent" do
204
+ it 'assigns the requested agent as @agent' do
205
205
  get :new
206
206
  expect(assigns(:agent)).not_to be_valid
207
207
  end
208
208
  end
209
209
 
210
- describe "When logged in as User" do
210
+ describe 'When logged in as User' do
211
211
  login_fixture_user
212
212
 
213
- it "should not assign the requested agent as @agent" do
213
+ it 'should not assign the requested agent as @agent' do
214
214
  get :new
215
215
  expect(assigns(:agent)).to be_nil
216
216
  expect(response).to be_forbidden
217
217
  end
218
218
  end
219
219
 
220
- describe "When not logged in" do
221
- it "should not assign the requested agent as @agent" do
220
+ describe 'When not logged in' do
221
+ it 'should not assign the requested agent as @agent' do
222
222
  get :new
223
223
  expect(assigns(:agent)).to be_nil
224
224
  expect(response).to redirect_to(new_user_session_url)
@@ -226,417 +226,417 @@ describe AgentsController do
226
226
  end
227
227
  end
228
228
 
229
- describe "GET edit" do
230
- describe "When logged in as Administrator" do
229
+ describe 'GET edit' do
230
+ describe 'When logged in as Administrator' do
231
231
  login_fixture_admin
232
232
 
233
- it "assigns the requested agent as @agent" do
233
+ it 'assigns the requested agent as @agent' do
234
234
  agent = Agent.find(1)
235
- get :edit, :id => agent.id
235
+ get :edit, id: agent.id
236
236
  expect(assigns(:agent)).to eq(agent)
237
237
  end
238
238
  end
239
239
 
240
- describe "When logged in as Librarian" do
240
+ describe 'When logged in as Librarian' do
241
241
  login_fixture_librarian
242
242
 
243
- it "assigns the requested agent as @agent" do
243
+ it 'assigns the requested agent as @agent' do
244
244
  agent = Agent.find(1)
245
- get :edit, :id => agent.id
245
+ get :edit, id: agent.id
246
246
  expect(assigns(:agent)).to eq(agent)
247
247
  end
248
248
 
249
- #it "should edit agent when its required_role is 'User'" do
249
+ # it "should edit agent when its required_role is 'User'" do
250
250
  # get :edit, :id => users(:user2).agent.id
251
251
  # expect(response).to be_success
252
- #end
252
+ # end
253
253
 
254
- #it "should edit agent when its required_role is 'Librarian'" do
254
+ # it "should edit agent when its required_role is 'Librarian'" do
255
255
  # get :edit, :id => users(:user1).agent.id
256
256
  # expect(response).to be_success
257
- #end
258
-
259
- #it "should edit admin" do
257
+ # end
258
+
259
+ # it "should edit admin" do
260
260
  # get :edit, :id => users(:admin).agent.id
261
261
  # expect(response).to be_forbidden
262
- #end
262
+ # end
263
263
  end
264
264
 
265
- describe "When logged in as User" do
265
+ describe 'When logged in as User' do
266
266
  login_fixture_user
267
267
 
268
- it "assigns the requested agent as @agent" do
268
+ it 'assigns the requested agent as @agent' do
269
269
  agent = Agent.find(1)
270
- get :edit, :id => agent.id
270
+ get :edit, id: agent.id
271
271
  expect(response).to be_forbidden
272
272
  end
273
273
 
274
- #it "should edit myself" do
274
+ # it "should edit myself" do
275
275
  # get :edit, :id => users(:user1).agent.id
276
276
  # expect(response).to be_success
277
- #end
277
+ # end
278
278
 
279
- #it "should not edit other user's agent profile" do
279
+ # it "should not edit other user's agent profile" do
280
280
  # get :edit, :id => users(:user2).agent.id
281
281
  # expect(response).to be_forbidden
282
- #end
282
+ # end
283
283
  end
284
284
 
285
- describe "When not logged in" do
286
- it "should not assign the requested agent as @agent" do
285
+ describe 'When not logged in' do
286
+ it 'should not assign the requested agent as @agent' do
287
287
  agent = Agent.find(1)
288
- get :edit, :id => agent.id
288
+ get :edit, id: agent.id
289
289
  expect(response).to redirect_to(new_user_session_url)
290
290
  end
291
291
  end
292
292
  end
293
293
 
294
- describe "POST create" do
294
+ describe 'POST create' do
295
295
  before(:each) do
296
296
  @attrs = valid_attributes
297
- @invalid_attrs = FactoryGirl.attributes_for(:agent, :full_name => '')
297
+ @invalid_attrs = FactoryGirl.attributes_for(:agent, full_name: '')
298
298
  end
299
299
 
300
- describe "When logged in as Administrator" do
300
+ describe 'When logged in as Administrator' do
301
301
  login_fixture_admin
302
302
 
303
- describe "with valid params" do
304
- it "assigns a newly created agent as @agent" do
305
- post :create, :agent => @attrs
303
+ describe 'with valid params' do
304
+ it 'assigns a newly created agent as @agent' do
305
+ post :create, agent: @attrs
306
306
  expect(assigns(:agent)).to be_valid
307
307
  end
308
308
 
309
- it "redirects to the created agent" do
310
- post :create, :agent => @attrs
309
+ it 'redirects to the created agent' do
310
+ post :create, agent: @attrs
311
311
  expect(response).to redirect_to(agent_url(assigns(:agent)))
312
312
  end
313
313
  end
314
314
 
315
- describe "with invalid params" do
316
- it "assigns a newly created but unsaved agent as @agent" do
317
- post :create, :agent => @invalid_attrs
315
+ describe 'with invalid params' do
316
+ it 'assigns a newly created but unsaved agent as @agent' do
317
+ post :create, agent: @invalid_attrs
318
318
  expect(assigns(:agent)).not_to be_valid
319
319
  end
320
320
 
321
321
  it "re-renders the 'new' template" do
322
- post :create, :agent => @invalid_attrs
323
- expect(response).to render_template("new")
322
+ post :create, agent: @invalid_attrs
323
+ expect(response).to render_template('new')
324
324
  end
325
325
  end
326
326
  end
327
327
 
328
- describe "When logged in as Librarian" do
328
+ describe 'When logged in as Librarian' do
329
329
  login_fixture_librarian
330
330
 
331
- describe "with valid params" do
332
- it "assigns a newly created agent as @agent" do
333
- post :create, :agent => @attrs
331
+ describe 'with valid params' do
332
+ it 'assigns a newly created agent as @agent' do
333
+ post :create, agent: @attrs
334
334
  expect(assigns(:agent)).to be_valid
335
335
  end
336
336
 
337
- it "redirects to the created agent" do
338
- post :create, :agent => @attrs
337
+ it 'redirects to the created agent' do
338
+ post :create, agent: @attrs
339
339
  expect(response).to redirect_to(agent_url(assigns(:agent)))
340
340
  end
341
341
 
342
- it "should create a relationship if work_id is set" do
343
- post :create, :agent => @attrs, :work_id => 1
342
+ it 'should create a relationship if work_id is set' do
343
+ post :create, agent: @attrs, work_id: 1
344
344
  expect(response).to redirect_to(agent_url(assigns(:agent)))
345
345
  assigns(:agent).works.should eq [Manifestation.find(1)]
346
346
  end
347
347
 
348
- it "should create a relationship if manifestation_id is set" do
349
- post :create, :agent => @attrs, :manifestation_id => 1
348
+ it 'should create a relationship if manifestation_id is set' do
349
+ post :create, agent: @attrs, manifestation_id: 1
350
350
  expect(response).to redirect_to(agent_url(assigns(:agent)))
351
351
  assigns(:agent).manifestations.should eq [Manifestation.find(1)]
352
352
  end
353
353
 
354
- it "should create a relationship if item_id is set" do
355
- post :create, :agent => @attrs, :item_id => 1
354
+ it 'should create a relationship if item_id is set' do
355
+ post :create, agent: @attrs, item_id: 1
356
356
  expect(response).to redirect_to(agent_url(assigns(:agent)))
357
357
  assigns(:agent).items.should eq [Item.find(1)]
358
358
  end
359
359
  end
360
360
 
361
- describe "with invalid params" do
362
- it "assigns a newly created but unsaved agent as @agent" do
363
- post :create, :agent => @invalid_attrs
361
+ describe 'with invalid params' do
362
+ it 'assigns a newly created but unsaved agent as @agent' do
363
+ post :create, agent: @invalid_attrs
364
364
  expect(assigns(:agent)).not_to be_valid
365
365
  end
366
366
 
367
367
  it "re-renders the 'new' template" do
368
- post :create, :agent => @invalid_attrs
369
- expect(response).to render_template("new")
368
+ post :create, agent: @invalid_attrs
369
+ expect(response).to render_template('new')
370
370
  end
371
371
  end
372
372
 
373
373
  # TODO: full_name以外での判断
374
- it "should create agent without full_name" do
375
- post :create, :agent => { :first_name => 'test' }
374
+ it 'should create agent without full_name' do
375
+ post :create, agent: { first_name: 'test' }
376
376
  expect(response).to redirect_to agent_url(assigns(:agent))
377
377
  end
378
378
  end
379
379
 
380
- describe "When logged in as User" do
380
+ describe 'When logged in as User' do
381
381
  login_fixture_user
382
382
 
383
- describe "with valid params" do
384
- it "assigns a newly created agent as @agent" do
385
- post :create, :agent => @attrs
383
+ describe 'with valid params' do
384
+ it 'assigns a newly created agent as @agent' do
385
+ post :create, agent: @attrs
386
386
  expect(assigns(:agent)).to be_nil
387
387
  end
388
388
 
389
- it "should be forbidden" do
390
- post :create, :agent => @attrs
389
+ it 'should be forbidden' do
390
+ post :create, agent: @attrs
391
391
  expect(response).to be_forbidden
392
392
  end
393
393
  end
394
394
 
395
- describe "with invalid params" do
396
- it "assigns a newly created but unsaved agent as @agent" do
397
- post :create, :agent => @invalid_attrs
395
+ describe 'with invalid params' do
396
+ it 'assigns a newly created but unsaved agent as @agent' do
397
+ post :create, agent: @invalid_attrs
398
398
  expect(assigns(:agent)).to be_nil
399
399
  end
400
400
 
401
- it "should be forbidden" do
402
- post :create, :agent => @invalid_attrs
401
+ it 'should be forbidden' do
402
+ post :create, agent: @invalid_attrs
403
403
  expect(response).to be_forbidden
404
404
  end
405
405
  end
406
406
 
407
- #it "should not create agent myself" do
407
+ # it "should not create agent myself" do
408
408
  # post :create, :agent => { :full_name => 'test', :user_username => users(:user1).username }
409
409
  # expect(assigns(:agent)).not_to be_valid
410
410
  # expect(response).to be_success
411
- #end
411
+ # end
412
412
 
413
- #it "should not create other agent" do
413
+ # it "should not create other agent" do
414
414
  # post :create, :agent => { :full_name => 'test', :user_id => users(:user2).username }
415
415
  # expect(response).to be_forbidden
416
- #end
416
+ # end
417
417
  end
418
418
 
419
- describe "When not logged in" do
420
- describe "with valid params" do
421
- it "assigns a newly created agent as @agent" do
422
- post :create, :agent => @attrs
419
+ describe 'When not logged in' do
420
+ describe 'with valid params' do
421
+ it 'assigns a newly created agent as @agent' do
422
+ post :create, agent: @attrs
423
423
  expect(assigns(:agent)).to be_nil
424
424
  end
425
425
 
426
- it "should be forbidden" do
427
- post :create, :agent => @attrs
426
+ it 'should be forbidden' do
427
+ post :create, agent: @attrs
428
428
  expect(response).to redirect_to(new_user_session_url)
429
429
  end
430
430
  end
431
431
 
432
- describe "with invalid params" do
433
- it "assigns a newly created but unsaved agent as @agent" do
434
- post :create, :agent => @invalid_attrs
432
+ describe 'with invalid params' do
433
+ it 'assigns a newly created but unsaved agent as @agent' do
434
+ post :create, agent: @invalid_attrs
435
435
  expect(assigns(:agent)).to be_nil
436
436
  end
437
437
 
438
- it "should be forbidden" do
439
- post :create, :agent => @invalid_attrs
438
+ it 'should be forbidden' do
439
+ post :create, agent: @invalid_attrs
440
440
  expect(response).to redirect_to(new_user_session_url)
441
441
  end
442
442
  end
443
443
  end
444
444
  end
445
445
 
446
- describe "PUT update" do
446
+ describe 'PUT update' do
447
447
  before(:each) do
448
448
  @agent = FactoryGirl.create(:agent)
449
449
  @attrs = valid_attributes
450
- @invalid_attrs = FactoryGirl.attributes_for(:agent, :full_name => '')
450
+ @invalid_attrs = FactoryGirl.attributes_for(:agent, full_name: '')
451
451
  end
452
452
 
453
- describe "When logged in as Administrator" do
453
+ describe 'When logged in as Administrator' do
454
454
  login_fixture_admin
455
455
 
456
- describe "with valid params" do
457
- it "updates the requested agent" do
458
- put :update, :id => @agent.id, :agent => @attrs
456
+ describe 'with valid params' do
457
+ it 'updates the requested agent' do
458
+ put :update, id: @agent.id, agent: @attrs
459
459
  end
460
460
 
461
- it "assigns the requested agent as @agent" do
462
- put :update, :id => @agent.id, :agent => @attrs
461
+ it 'assigns the requested agent as @agent' do
462
+ put :update, id: @agent.id, agent: @attrs
463
463
  expect(assigns(:agent)).to eq(@agent)
464
464
  end
465
465
  end
466
466
 
467
- describe "with invalid params" do
468
- it "assigns the requested agent as @agent" do
469
- put :update, :id => @agent.id, :agent => @invalid_attrs
470
- expect(response).to render_template("edit")
467
+ describe 'with invalid params' do
468
+ it 'assigns the requested agent as @agent' do
469
+ put :update, id: @agent.id, agent: @invalid_attrs
470
+ expect(response).to render_template('edit')
471
471
  end
472
472
  end
473
473
  end
474
474
 
475
- describe "When logged in as Librarian" do
475
+ describe 'When logged in as Librarian' do
476
476
  login_fixture_librarian
477
477
 
478
- describe "with valid params" do
479
- it "updates the requested agent" do
480
- put :update, :id => @agent.id, :agent => @attrs
478
+ describe 'with valid params' do
479
+ it 'updates the requested agent' do
480
+ put :update, id: @agent.id, agent: @attrs
481
481
  end
482
482
 
483
- it "assigns the requested agent as @agent" do
484
- put :update, :id => @agent.id, :agent => @attrs
483
+ it 'assigns the requested agent as @agent' do
484
+ put :update, id: @agent.id, agent: @attrs
485
485
  expect(assigns(:agent)).to eq(@agent)
486
486
  expect(response).to redirect_to(@agent)
487
487
  end
488
488
  end
489
489
 
490
- describe "with invalid params" do
491
- it "assigns the agent as @agent" do
492
- put :update, :id => @agent, :agent => @invalid_attrs
490
+ describe 'with invalid params' do
491
+ it 'assigns the agent as @agent' do
492
+ put :update, id: @agent, agent: @invalid_attrs
493
493
  expect(assigns(:agent)).not_to be_valid
494
494
  end
495
495
 
496
496
  it "re-renders the 'edit' template" do
497
- put :update, :id => @agent, :agent => @invalid_attrs
498
- expect(response).to render_template("edit")
497
+ put :update, id: @agent, agent: @invalid_attrs
498
+ expect(response).to render_template('edit')
499
499
  end
500
500
  end
501
501
 
502
- #it "should update other agent" do
502
+ # it "should update other agent" do
503
503
  # put :update, :id => users(:user2).agent.id, :agent => { :full_name => 'test' }
504
504
  # expect(response).to redirect_to agent_url(assigns(:agent))
505
- #end
505
+ # end
506
506
  end
507
507
 
508
- describe "When logged in as User" do
508
+ describe 'When logged in as User' do
509
509
  login_fixture_user
510
510
 
511
- describe "with valid params" do
512
- it "updates the requested agent" do
513
- put :update, :id => @agent.id, :agent => @attrs
511
+ describe 'with valid params' do
512
+ it 'updates the requested agent' do
513
+ put :update, id: @agent.id, agent: @attrs
514
514
  end
515
515
 
516
- it "assigns the requested agent as @agent" do
517
- put :update, :id => @agent.id, :agent => @attrs
516
+ it 'assigns the requested agent as @agent' do
517
+ put :update, id: @agent.id, agent: @attrs
518
518
  expect(assigns(:agent)).to eq(@agent)
519
519
  expect(response).to be_forbidden
520
520
  end
521
521
  end
522
522
 
523
- describe "with invalid params" do
524
- it "assigns the requested agent as @agent" do
525
- put :update, :id => @agent.id, :agent => @invalid_attrs
523
+ describe 'with invalid params' do
524
+ it 'assigns the requested agent as @agent' do
525
+ put :update, id: @agent.id, agent: @invalid_attrs
526
526
  expect(response).to be_forbidden
527
527
  end
528
528
  end
529
529
 
530
- #it "should update myself" do
530
+ # it "should update myself" do
531
531
  # put :update, :id => users(:user1).agent.id, :agent => { :full_name => 'test' }
532
532
  # expect(assigns(:agent)).to be_valid
533
533
  # expect(response).to redirect_to agent_url(assigns(:agent))
534
- #end
535
-
536
- #it "should not update myself without name" do
534
+ # end
535
+
536
+ # it "should not update myself without name" do
537
537
  # put :update, :id => users(:user1).agent.id, :agent => { :first_name => '', :last_name => '', :full_name => '' }
538
538
  # expect(assigns(:agent)).not_to be_valid
539
539
  # expect(response).to be_success
540
- #end
541
-
542
- #it "should not update other agent" do
540
+ # end
541
+
542
+ # it "should not update other agent" do
543
543
  # put :update, :id => users(:user2).agent.id, :agent => { :full_name => 'test' }
544
544
  # expect(response).to be_forbidden
545
- #end
545
+ # end
546
546
  end
547
547
 
548
- describe "When not logged in" do
549
- describe "with valid params" do
550
- it "updates the requested agent" do
551
- put :update, :id => @agent.id, :agent => @attrs
548
+ describe 'When not logged in' do
549
+ describe 'with valid params' do
550
+ it 'updates the requested agent' do
551
+ put :update, id: @agent.id, agent: @attrs
552
552
  end
553
553
 
554
- it "should be forbidden" do
555
- put :update, :id => @agent.id, :agent => @attrs
554
+ it 'should be forbidden' do
555
+ put :update, id: @agent.id, agent: @attrs
556
556
  expect(response).to redirect_to(new_user_session_url)
557
557
  end
558
558
  end
559
559
 
560
- describe "with invalid params" do
561
- it "assigns the requested agent as @agent" do
562
- put :update, :id => @agent.id, :agent => @invalid_attrs
560
+ describe 'with invalid params' do
561
+ it 'assigns the requested agent as @agent' do
562
+ put :update, id: @agent.id, agent: @invalid_attrs
563
563
  expect(response).to redirect_to(new_user_session_url)
564
564
  end
565
565
  end
566
566
  end
567
567
  end
568
568
 
569
- describe "DELETE destroy" do
569
+ describe 'DELETE destroy' do
570
570
  before(:each) do
571
571
  @agent = FactoryGirl.create(:agent)
572
572
  end
573
573
 
574
- describe "When logged in as Administrator" do
574
+ describe 'When logged in as Administrator' do
575
575
  login_fixture_admin
576
576
 
577
- it "destroys the requested agent" do
578
- delete :destroy, :id => @agent.id
577
+ it 'destroys the requested agent' do
578
+ delete :destroy, id: @agent.id
579
579
  end
580
580
 
581
- it "redirects to the agents list" do
582
- delete :destroy, :id => @agent.id
581
+ it 'redirects to the agents list' do
582
+ delete :destroy, id: @agent.id
583
583
  expect(response).to redirect_to(agents_url)
584
584
  end
585
585
 
586
- #it "should not destroy librarian who has items checked out" do
586
+ # it "should not destroy librarian who has items checked out" do
587
587
  # delete :destroy, :id => users(:librarian1).agent.id
588
588
  # expect(response).to be_forbidden
589
- #end
589
+ # end
590
590
 
591
- #it "should destroy librarian who does not have items checked out" do
591
+ # it "should destroy librarian who does not have items checked out" do
592
592
  # delete :destroy, :id => users(:librarian2).agent.id
593
593
  # expect(response).to redirect_to agents_url
594
- #end
594
+ # end
595
595
  end
596
596
 
597
- describe "When logged in as Librarian" do
597
+ describe 'When logged in as Librarian' do
598
598
  login_fixture_librarian
599
599
 
600
- it "destroys the requested agent" do
601
- delete :destroy, :id => @agent.id
600
+ it 'destroys the requested agent' do
601
+ delete :destroy, id: @agent.id
602
602
  end
603
603
 
604
- it "redirects to the agents list" do
605
- delete :destroy, :id => @agent.id
604
+ it 'redirects to the agents list' do
605
+ delete :destroy, id: @agent.id
606
606
  expect(response).to redirect_to(agents_url)
607
607
  end
608
608
 
609
- #it "should not destroy librarian" do
609
+ # it "should not destroy librarian" do
610
610
  # delete :destroy, :id => users(:librarian2).agent.id
611
611
  # expect(response).to be_forbidden
612
- #end
612
+ # end
613
613
  end
614
614
 
615
- describe "When logged in as User" do
615
+ describe 'When logged in as User' do
616
616
  login_fixture_user
617
617
 
618
- it "destroys the requested agent" do
619
- delete :destroy, :id => @agent.id
618
+ it 'destroys the requested agent' do
619
+ delete :destroy, id: @agent.id
620
620
  end
621
621
 
622
- it "should be forbidden" do
623
- delete :destroy, :id => @agent.id
622
+ it 'should be forbidden' do
623
+ delete :destroy, id: @agent.id
624
624
  expect(response).to be_forbidden
625
625
  end
626
626
 
627
- #it "should not destroy agent" do
627
+ # it "should not destroy agent" do
628
628
  # delete :destroy, :id => users(:user1).agent.id
629
629
  # expect(response).to be_forbidden
630
- #end
630
+ # end
631
631
  end
632
632
 
633
- describe "When not logged in" do
634
- it "destroys the requested agent" do
635
- delete :destroy, :id => @agent.id
633
+ describe 'When not logged in' do
634
+ it 'destroys the requested agent' do
635
+ delete :destroy, id: @agent.id
636
636
  end
637
637
 
638
- it "should be forbidden" do
639
- delete :destroy, :id => @agent.id
638
+ it 'should be forbidden' do
639
+ delete :destroy, id: @agent.id
640
640
  expect(response).to redirect_to(new_user_session_url)
641
641
  end
642
642
  end