diff --git a/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_1.yml b/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_1.yml new file mode 100644 index 00000000000..4d905267a8a --- /dev/null +++ b/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_1.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/_meta?user=tom + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="tom" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '129' + body: + encoding: UTF-8 + string: | + <project name="home:tom"> + <title> + + + + http_version: + recorded_at: Fri, 03 Mar 2017 13:00:46 GMT +recorded_with: VCR 3.0.3 diff --git a/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_2.yml b/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_2.yml new file mode 100644 index 00000000000..4d905267a8a --- /dev/null +++ b/src/api/spec/cassettes/SourceController/GET_show_project_meta/1_4_2.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/_meta?user=tom + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="tom" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '129' + body: + encoding: UTF-8 + string: | + <project name="home:tom"> + <title> + + + + http_version: + recorded_at: Fri, 03 Mar 2017 13:00:46 GMT +recorded_with: VCR 3.0.3 diff --git a/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_1.yml b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_1.yml new file mode 100644 index 00000000000..2657420c073 --- /dev/null +++ b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_1.yml @@ -0,0 +1,79 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/_meta?user=tom + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="tom" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '129' + body: + encoding: UTF-8 + string: | + <project name="home:tom"> + <title> + + + + http_version: + recorded_at: Fri, 03 Mar 2017 13:21:13 GMT +- request: + method: put + uri: http://localhost:3200/source/home:tom/_config?comment=Updated%20by%20test&user=tom + body: + encoding: ASCII-8BIT + string: comment=Updated+by+test + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + Content-Length: + - '23' + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '21' + body: + encoding: UTF-8 + string: ' + +' + http_version: + recorded_at: Fri, 03 Mar 2017 13:31:55 GMT +recorded_with: VCR 3.0.3 diff --git a/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_2.yml b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_2.yml new file mode 100644 index 00000000000..ccafa0133b9 --- /dev/null +++ b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_2.yml @@ -0,0 +1,110 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/_meta?user=tom + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="tom" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '129' + body: + encoding: UTF-8 + string: | + <project name="home:tom"> + <title> + + + + http_version: + recorded_at: Mon, 06 Mar 2017 12:10:48 GMT +- request: + method: put + uri: http://localhost:3200/source/home:tom/_config?comment=Updated%20by%20test&user=tom + body: + encoding: ASCII-8BIT + string: comment=Updated+by+test + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + Content-Length: + - '23' + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '21' + body: + encoding: UTF-8 + string: ' + +' + http_version: + recorded_at: Mon, 06 Mar 2017 12:10:49 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/_config + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/plain + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '23' + body: + encoding: UTF-8 + string: comment=Updated+by+test + http_version: + recorded_at: Mon, 06 Mar 2017 13:14:33 GMT +recorded_with: VCR 3.0.3 diff --git a/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_3.yml b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_3.yml new file mode 100644 index 00000000000..c61d7152056 --- /dev/null +++ b/src/api/spec/cassettes/SourceController/PUT_update_project_config/1_5_3.yml @@ -0,0 +1,110 @@ +--- +http_interactions: +- request: + method: put + uri: http://localhost:3200/source/home:tom/_meta?user=tom + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="tom" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '129' + body: + encoding: UTF-8 + string: | + <project name="home:tom"> + <title> + + + + http_version: + recorded_at: Wed, 08 Mar 2017 13:30:16 GMT +- request: + method: put + uri: http://localhost:3200/source/home:tom/_config?comment=Updated%20by%20test&user=tom + body: + encoding: ASCII-8BIT + string: comment=Updated+by+test + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + Content-Length: + - '23' + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '21' + body: + encoding: UTF-8 + string: ' + +' + http_version: + recorded_at: Wed, 08 Mar 2017 13:30:17 GMT +- request: + method: get + uri: http://localhost:3200/source/home:tom/_config + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/plain + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '23' + body: + encoding: UTF-8 + string: comment=Updated+by+test + http_version: + recorded_at: Wed, 08 Mar 2017 13:30:17 GMT +recorded_with: VCR 3.0.3 diff --git a/src/api/spec/controllers/source_controller_spec.rb b/src/api/spec/controllers/source_controller_spec.rb index 4cd3058e23d..29901e9bfc1 100644 --- a/src/api/spec/controllers/source_controller_spec.rb +++ b/src/api/spec/controllers/source_controller_spec.rb @@ -1,6 +1,12 @@ require 'rails_helper' +# WARNING: Some tests require real backend answers, so make sure you uncomment +# this line and start a test backend. +# CONFIG['global_write_through'] = true RSpec.describe SourceController, vcr: true do + let(:user) { create(:confirmed_user, login: "tom") } + let(:project) { user.home_project } + describe "POST #global_command_orderkiwirepos" do it "is accessible anonymously and forwards backend errors" do post :global_command_orderkiwirepos, params: { cmd: "orderkiwirepos" } @@ -24,4 +30,24 @@ expect(response).to redirect_to(root_path) end end + + describe "GET #show_project_meta" do + before do + login user + get :show_project_meta, params: { project: project } + end + + it { expect(response).to be_success } + it { expect(Xmlhash.parse(response.body)["name"]).to eq(project.name) } + end + + describe "PUT #update_project_config" do + before do + login user + put :update_project_config, params: { project: project, comment: 'Updated by test' } + end + + it { expect(response).to be_success } + it { expect(project.config.to_s).to include('Updated', 'by', 'test') } + end end