BigW Consortium Gitlab

Commit d9d417d4 by Jose Ivan Vargas

Added a variable_controller_spec test to test for flash messages on the #create action

parent 9739f2c9
require 'spec_helper'
describe Projects::VariablesController do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
before do
sign_in(user)
project.team << [user, :master]
end
describe 'POST #create' do
context 'variable is valid' do
it 'shows a success flash message' do
post :create, namespace_id: project.namespace.to_param, project_id: project.to_param,
variable: { key: "one", value: "two" }
expect(flash[:notice]).to include 'Variables were successfully updated.'
expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project))
end
end
context 'variable is invalid' do
it 'shows a failure flash message' do
post :create, namespace_id: project.namespace.to_param, project_id: project.to_param,
variable: { key: "..one", value: "two" }
expect(flash[:alert]).to include 'Key can contain only letters, digits and \'_\'.'
expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project))
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment