Skip to content

Commit

Permalink
Minor specs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nanego committed Apr 5, 2024
1 parent bc890b1 commit e20380c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions spec/controllers/issue_templates_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@
end

context "GET copy" do
let (:template_origin) { IssueTemplate.find(3) }

let!(:template_origin) { IssueTemplate.find(3) }

it "forbids issue copy if user has no permission" do
role.remove_permission!(:create_issue_templates)
get :copy, params: { id: template.id }
expect(response).to have_http_status(:forbidden)
end

it "Should duplicate all attributes of the original template" do
it "duplicates all attributes of the original template" do
get :copy, params: { id: template_origin.id }
expect(response).to be_successful

Expand All @@ -91,7 +92,7 @@
expect(assigns(:issue_template).tracker).to eq template_origin.tracker
end

it "Should duplicate all section groups of the original template" do
it "duplicates all section groups of the original template" do
get :copy, params: { id: template_origin.id }

expect(assigns(:issue_template).section_groups.size).to eq(template_origin.section_groups.count)
Expand All @@ -102,7 +103,7 @@
end
end

it "Should duplicate all projects of the original template" do
it "duplicates all projects of the original template" do

template_origin.secondary_projects = [Project.find(3), Project.find(4)] if Redmine::Plugin.installed?(:redmine_multiprojects_issue)
template_origin.save
Expand All @@ -122,7 +123,7 @@
end
end

it "Should duplicate all custom_field_values of the original template" do
it "duplicates all custom_field_values of the original template" do
template_origin = IssueTemplate.find(3)
field_attributes = { :field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all }

Expand All @@ -131,14 +132,14 @@
IssueCustomField.create!(field_attributes.merge(:name => 'Field 3', :visible => false, :role_ids => [1, 3]))

3.times do |i|
template_origin.custom_field_values = { i + 1 => "Value for field #{i+1}" }
template_origin.custom_field_values = { i + 1 => "Value for field #{i + 1}" }
end
template_origin.save

get :copy, params: { id: template_origin.id }

assigns(:issue_template).custom_field_values.each_with_index do |field, ind|
expect(field.value).to eq("Value for field #{ind+1}")
expect(field.value).to eq("Value for field #{ind + 1}")
end
end
end
Expand Down

0 comments on commit e20380c

Please sign in to comment.