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.
- checksums.yaml +4 -4
- data/app/assets/images/icons/book.png +0 -0
- data/app/assets/images/icons/cd.png +0 -0
- data/app/assets/images/icons/dvd.png +0 -0
- data/app/assets/images/icons/monitor.png +0 -0
- data/app/controllers/carrier_types_controller.rb +8 -3
- data/app/controllers/manifestations_controller.rb +17 -4
- data/app/controllers/picture_files_controller.rb +1 -1
- data/app/controllers/series_statements_controller.rb +6 -0
- data/app/helpers/manifestations_helper.rb +1 -1
- data/app/models/agent_import_file_transition.rb +1 -0
- data/app/models/carrier_type.rb +11 -7
- data/app/models/import_request_transition.rb +1 -0
- data/app/models/manifestation.rb +5 -0
- data/app/models/resource_export_file_transition.rb +1 -0
- data/app/models/resource_import_file_transition.rb +1 -0
- data/app/views/carrier_types/index.html.erb +4 -1
- data/app/views/manifestations/_show_detail_librarian.html.erb +4 -0
- data/app/views/manifestations/index.html.erb +3 -0
- data/config/locales/translation_en.yml +2 -0
- data/config/locales/translation_ja.yml +2 -0
- data/lib/enju_biblio/biblio_helper.rb +1 -12
- data/lib/enju_biblio/version.rb +1 -1
- data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +3 -3
- data/lib/tasks/carrier_type.rb +30 -18
- data/lib/tasks/enju_biblio_tasks.rake +2 -0
- data/spec/controllers/agent_import_files_controller_spec.rb +87 -87
- data/spec/controllers/agent_import_results_controller_spec.rb +22 -22
- data/spec/controllers/agent_merge_lists_controller_spec.rb +157 -157
- data/spec/controllers/agent_merges_controller_spec.rb +151 -151
- data/spec/controllers/agent_relationship_types_controller_spec.rb +152 -152
- data/spec/controllers/agent_relationships_controller_spec.rb +153 -153
- data/spec/controllers/agent_types_controller_spec.rb +49 -50
- data/spec/controllers/agents_controller_spec.rb +234 -234
- data/spec/controllers/carrier_types_controller_spec.rb +123 -103
- data/spec/controllers/content_types_controller_spec.rb +51 -52
- data/spec/controllers/countries_controller_spec.rb +156 -156
- data/spec/controllers/create_types_controller_spec.rb +48 -49
- data/spec/controllers/creates_controller_spec.rb +154 -154
- data/spec/controllers/donates_controller_spec.rb +153 -153
- data/spec/controllers/form_of_works_controller_spec.rb +48 -49
- data/spec/controllers/frequencies_controller_spec.rb +51 -52
- data/spec/controllers/identifier_types_controller_spec.rb +48 -49
- data/spec/controllers/import_requests_controller_spec.rb +165 -164
- data/spec/controllers/items_controller_spec.rb +214 -216
- data/spec/controllers/languages_controller_spec.rb +109 -109
- data/spec/controllers/licenses_controller_spec.rb +48 -49
- data/spec/controllers/manifestation_relationship_types_controller_spec.rb +152 -152
- data/spec/controllers/manifestation_relationships_controller_spec.rb +153 -153
- data/spec/controllers/manifestations_controller_spec.rb +319 -289
- data/spec/controllers/medium_of_performances_controller_spec.rb +48 -49
- data/spec/controllers/owns_controller_spec.rb +153 -153
- data/spec/controllers/picture_files_controller_spec.rb +156 -156
- data/spec/controllers/produce_types_controller_spec.rb +48 -49
- data/spec/controllers/produces_controller_spec.rb +154 -154
- data/spec/controllers/realize_types_controller_spec.rb +48 -49
- data/spec/controllers/realizes_controller_spec.rb +155 -155
- data/spec/controllers/resource_export_files_controller_spec.rb +72 -72
- data/spec/controllers/resource_import_files_controller_spec.rb +90 -90
- data/spec/controllers/resource_import_results_controller_spec.rb +43 -43
- data/spec/controllers/series_statement_merge_lists_controller_spec.rb +153 -153
- data/spec/controllers/series_statement_merges_controller_spec.rb +151 -151
- data/spec/controllers/series_statements_controller_spec.rb +154 -154
- data/spec/factories/checkout.rb +9 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/shelf.rb +6 -0
- data/spec/fixtures/carrier_types.yml +11 -7
- data/spec/models/carrier_type_spec.rb +11 -7
- data/spec/models/resource_export_file_spec.rb +58 -16
- data/spec/support/resque.rb +0 -1
- data/spec/views/manifestations/show.html.erb_spec.rb +5 -0
- data/spec/views/resource_import_files/index.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_files/show.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_results/index.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
- metadata +49 -39
@@ -29,113 +29,113 @@ describe AgentTypesController do
|
|
29
29
|
FactoryGirl.attributes_for(:agent_type)
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it
|
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
|
41
|
-
it
|
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, :
|
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
|
49
|
-
it
|
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
|
56
|
-
it
|
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, :
|
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
|
64
|
-
describe
|
65
|
-
it
|
66
|
-
expect
|
67
|
-
post :create, :
|
68
|
-
|
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
|
72
|
-
post :create, :
|
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
|
78
|
-
post :create, :
|
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
|
84
|
-
it
|
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, :
|
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, :
|
95
|
-
expect(response).to render_template(
|
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
|
101
|
-
describe
|
102
|
-
it
|
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(
|
109
|
-
put :update, :
|
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
|
112
|
+
it 'assigns the requested agent_type as @agent_type' do
|
113
113
|
agent_type = AgentType.create! valid_attributes
|
114
|
-
put :update, :
|
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
|
118
|
+
it 'redirects to the agent_type' do
|
119
119
|
agent_type = AgentType.create! valid_attributes
|
120
|
-
put :update, :
|
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
|
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, :
|
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
|
134
|
-
it
|
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, :
|
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, :
|
147
|
-
expect(response).to render_template(
|
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
|
153
|
-
it
|
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, :
|
157
|
-
|
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
|
160
|
+
it 'redirects to the agent_types list' do
|
161
161
|
agent_type = AgentType.create! valid_attributes
|
162
|
-
delete :destroy, :
|
162
|
+
delete :destroy, id: agent_type.id
|
163
163
|
expect(response).to redirect_to(agent_types_url)
|
164
164
|
end
|
165
165
|
|
166
|
-
it
|
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
|
10
|
+
describe 'GET index', solr: true do
|
11
11
|
before do
|
12
12
|
Agent.reindex
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe 'When logged in as Administrator' do
|
16
16
|
login_fixture_admin
|
17
17
|
|
18
|
-
it
|
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
|
24
|
-
get :index, :
|
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
|
31
|
-
get :index, :
|
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
|
37
|
+
describe 'When logged in as Librarian' do
|
38
38
|
login_fixture_librarian
|
39
39
|
|
40
|
-
it
|
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
|
46
|
+
describe 'When logged in as User' do
|
47
47
|
login_fixture_user
|
48
48
|
|
49
|
-
it
|
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
|
56
|
-
it
|
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
|
62
|
-
get :index, :
|
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
|
67
|
-
get :index, :
|
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
|
72
|
-
get :index, :
|
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(:
|
75
|
+
expect(assigns(:agents)).to eq assigns(:agent).derived_agents.where(required_role_id: 1).page(1)
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
79
|
-
get :index, :
|
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(:
|
81
|
+
expect(assigns(:agents)).to eq assigns(:manifestation).publishers.where(required_role_id: 1).page(1)
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
85
|
-
get :index, :
|
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
|
92
|
+
describe 'GET show' do
|
93
93
|
before(:each) do
|
94
94
|
@agent = FactoryGirl.create(:agent)
|
95
95
|
end
|
96
96
|
|
97
|
-
describe
|
97
|
+
describe 'When logged in as Administrator' do
|
98
98
|
login_fixture_admin
|
99
99
|
|
100
|
-
it
|
101
|
-
get :show, :
|
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
|
106
|
+
describe 'When logged in as Librarian' do
|
107
107
|
login_fixture_librarian
|
108
108
|
|
109
|
-
it
|
110
|
-
get :show, :
|
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
|
127
|
-
lambda
|
128
|
-
get :show, :
|
129
|
-
|
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
|
134
|
-
lambda
|
135
|
-
get :show, :
|
136
|
-
|
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
|
147
|
+
describe 'When logged in as User' do
|
148
148
|
login_fixture_user
|
149
149
|
|
150
|
-
it
|
151
|
-
get :show, :
|
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
|
169
|
-
it
|
170
|
-
get :show, :
|
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
|
175
|
-
get :show, :
|
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
|
180
|
-
get :show, :
|
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, :
|
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
|
192
|
-
describe
|
191
|
+
describe 'GET new' do
|
192
|
+
describe 'When logged in as Administrator' do
|
193
193
|
login_fixture_admin
|
194
194
|
|
195
|
-
it
|
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
|
201
|
+
describe 'When logged in as Librarian' do
|
202
202
|
login_fixture_librarian
|
203
203
|
|
204
|
-
it
|
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
|
210
|
+
describe 'When logged in as User' do
|
211
211
|
login_fixture_user
|
212
212
|
|
213
|
-
it
|
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
|
221
|
-
it
|
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
|
230
|
-
describe
|
229
|
+
describe 'GET edit' do
|
230
|
+
describe 'When logged in as Administrator' do
|
231
231
|
login_fixture_admin
|
232
232
|
|
233
|
-
it
|
233
|
+
it 'assigns the requested agent as @agent' do
|
234
234
|
agent = Agent.find(1)
|
235
|
-
get :edit, :
|
235
|
+
get :edit, id: agent.id
|
236
236
|
expect(assigns(:agent)).to eq(agent)
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
-
describe
|
240
|
+
describe 'When logged in as Librarian' do
|
241
241
|
login_fixture_librarian
|
242
242
|
|
243
|
-
it
|
243
|
+
it 'assigns the requested agent as @agent' do
|
244
244
|
agent = Agent.find(1)
|
245
|
-
get :edit, :
|
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
|
265
|
+
describe 'When logged in as User' do
|
266
266
|
login_fixture_user
|
267
267
|
|
268
|
-
it
|
268
|
+
it 'assigns the requested agent as @agent' do
|
269
269
|
agent = Agent.find(1)
|
270
|
-
get :edit, :
|
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
|
286
|
-
it
|
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, :
|
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
|
294
|
+
describe 'POST create' do
|
295
295
|
before(:each) do
|
296
296
|
@attrs = valid_attributes
|
297
|
-
@invalid_attrs = FactoryGirl.attributes_for(:agent, :
|
297
|
+
@invalid_attrs = FactoryGirl.attributes_for(:agent, full_name: '')
|
298
298
|
end
|
299
299
|
|
300
|
-
describe
|
300
|
+
describe 'When logged in as Administrator' do
|
301
301
|
login_fixture_admin
|
302
302
|
|
303
|
-
describe
|
304
|
-
it
|
305
|
-
post :create, :
|
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
|
310
|
-
post :create, :
|
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
|
316
|
-
it
|
317
|
-
post :create, :
|
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, :
|
323
|
-
expect(response).to render_template(
|
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
|
328
|
+
describe 'When logged in as Librarian' do
|
329
329
|
login_fixture_librarian
|
330
330
|
|
331
|
-
describe
|
332
|
-
it
|
333
|
-
post :create, :
|
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
|
338
|
-
post :create, :
|
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
|
343
|
-
post :create, :
|
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
|
349
|
-
post :create, :
|
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
|
355
|
-
post :create, :
|
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
|
362
|
-
it
|
363
|
-
post :create, :
|
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, :
|
369
|
-
expect(response).to render_template(
|
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
|
375
|
-
post :create, :
|
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
|
380
|
+
describe 'When logged in as User' do
|
381
381
|
login_fixture_user
|
382
382
|
|
383
|
-
describe
|
384
|
-
it
|
385
|
-
post :create, :
|
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
|
390
|
-
post :create, :
|
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
|
396
|
-
it
|
397
|
-
post :create, :
|
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
|
402
|
-
post :create, :
|
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
|
420
|
-
describe
|
421
|
-
it
|
422
|
-
post :create, :
|
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
|
427
|
-
post :create, :
|
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
|
433
|
-
it
|
434
|
-
post :create, :
|
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
|
439
|
-
post :create, :
|
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
|
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, :
|
450
|
+
@invalid_attrs = FactoryGirl.attributes_for(:agent, full_name: '')
|
451
451
|
end
|
452
452
|
|
453
|
-
describe
|
453
|
+
describe 'When logged in as Administrator' do
|
454
454
|
login_fixture_admin
|
455
455
|
|
456
|
-
describe
|
457
|
-
it
|
458
|
-
put :update, :
|
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
|
462
|
-
put :update, :
|
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
|
468
|
-
it
|
469
|
-
put :update, :
|
470
|
-
expect(response).to render_template(
|
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
|
475
|
+
describe 'When logged in as Librarian' do
|
476
476
|
login_fixture_librarian
|
477
477
|
|
478
|
-
describe
|
479
|
-
it
|
480
|
-
put :update, :
|
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
|
484
|
-
put :update, :
|
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
|
491
|
-
it
|
492
|
-
put :update, :
|
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, :
|
498
|
-
expect(response).to render_template(
|
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
|
508
|
+
describe 'When logged in as User' do
|
509
509
|
login_fixture_user
|
510
510
|
|
511
|
-
describe
|
512
|
-
it
|
513
|
-
put :update, :
|
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
|
517
|
-
put :update, :
|
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
|
524
|
-
it
|
525
|
-
put :update, :
|
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
|
549
|
-
describe
|
550
|
-
it
|
551
|
-
put :update, :
|
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
|
555
|
-
put :update, :
|
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
|
561
|
-
it
|
562
|
-
put :update, :
|
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
|
569
|
+
describe 'DELETE destroy' do
|
570
570
|
before(:each) do
|
571
571
|
@agent = FactoryGirl.create(:agent)
|
572
572
|
end
|
573
573
|
|
574
|
-
describe
|
574
|
+
describe 'When logged in as Administrator' do
|
575
575
|
login_fixture_admin
|
576
576
|
|
577
|
-
it
|
578
|
-
delete :destroy, :
|
577
|
+
it 'destroys the requested agent' do
|
578
|
+
delete :destroy, id: @agent.id
|
579
579
|
end
|
580
580
|
|
581
|
-
it
|
582
|
-
delete :destroy, :
|
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
|
597
|
+
describe 'When logged in as Librarian' do
|
598
598
|
login_fixture_librarian
|
599
599
|
|
600
|
-
it
|
601
|
-
delete :destroy, :
|
600
|
+
it 'destroys the requested agent' do
|
601
|
+
delete :destroy, id: @agent.id
|
602
602
|
end
|
603
603
|
|
604
|
-
it
|
605
|
-
delete :destroy, :
|
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
|
615
|
+
describe 'When logged in as User' do
|
616
616
|
login_fixture_user
|
617
617
|
|
618
|
-
it
|
619
|
-
delete :destroy, :
|
618
|
+
it 'destroys the requested agent' do
|
619
|
+
delete :destroy, id: @agent.id
|
620
620
|
end
|
621
621
|
|
622
|
-
it
|
623
|
-
delete :destroy, :
|
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
|
634
|
-
it
|
635
|
-
delete :destroy, :
|
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
|
639
|
-
delete :destroy, :
|
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
|