Move *_url spec to controller, because the subscription model does not handle urls anymore

This commit is contained in:
Maximilian Grundke
2017-10-16 14:02:40 +02:00
parent 686d56bbd6
commit a00adbce25
2 changed files with 21 additions and 15 deletions

View File

@ -183,6 +183,27 @@ describe SubmissionsController do
expect_template(:show) expect_template(:show)
end end
describe 'GET #show.json' do
before(:each) { get :show, id: submission.id, format: :json }
expect_assigns(submission: :submission)
expect_status(200)
[:render, :run, :test].each do |action|
describe "##{action}_url" do
let(:url) { response.body.send(:"#{action}_url") }
it "starts like the #{action} path" do
filename = File.basename(__FILE__)
expect(url).to start_with(Rails.application.routes.url_helpers.send(:"#{action}_submission_path", submission, filename).sub(filename, ''))
end
it 'ends with a placeholder' do
expect(url).to end_with(Submission::FILENAME_URL_PLACEHOLDER)
end
end
end
end
describe 'GET #score' do describe 'GET #score' do
let(:request) { proc { get :score, id: submission.id } } let(:request) { proc { get :score, id: submission.id } }
before(:each) { request.call } before(:each) { request.call }

View File

@ -16,21 +16,6 @@ describe Submission do
expect(described_class.create.errors[:user_type]).to be_present expect(described_class.create.errors[:user_type]).to be_present
end end
[:render, :run, :test].each do |action|
describe "##{action}_url" do
let(:url) { submission.send(:"#{action}_url") }
it "starts like the #{action} path" do
filename = File.basename(__FILE__)
expect(url).to start_with(Rails.application.routes.url_helpers.send(:"#{action}_submission_path", submission, filename).sub(filename, ''))
end
it 'ends with a placeholder' do
expect(url).to end_with(Submission::FILENAME_URL_PLACEHOLDER)
end
end
end
describe '#main_file' do describe '#main_file' do
let(:submission) { FactoryGirl.create(:submission) } let(:submission) { FactoryGirl.create(:submission) }