Files
grecia/spec/features/admin/budget_phases_spec.rb
Javi Martín 307cf24846 Use describe on feature tests
The `type: :feature` is automatically detected by RSpec because these
tests are inside the `spec/features` folder. Using `feature` re-adds a
`type: :feature` to these files, which will result in a conflict when we
upgrade to Rails 5.1's system tests.

Because of this change, we also need to change `background` to `before`
or else these tests will fail.
2019-05-28 16:36:54 +02:00

40 lines
1.4 KiB
Ruby

require "rails_helper"
describe "Admin budget phases" do
let(:budget) { create(:budget) }
context "Edit" do
before do
admin = create(:administrator)
login_as(admin.user)
end
it_behaves_like "translatable",
"budget_phase",
"edit_admin_budget_budget_phase_path",
[],
{ "description" => :ckeditor, "summary" => :ckeditor }
scenario "Update phase", :js do
visit edit_admin_budget_budget_phase_path(budget, budget.current_phase)
fill_in "start_date", with: Date.current + 1.days
fill_in "end_date", with: Date.current + 12.days
fill_in_translatable_ckeditor "summary", :en, with: "New summary of the phase."
fill_in_translatable_ckeditor "description", :en, with: "New description of the phase."
uncheck "budget_phase_enabled"
click_button "Save changes"
expect(page).to have_current_path(edit_admin_budget_path(budget))
expect(page).to have_content "Changes saved"
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.days).to_date)
expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date)
expect(budget.current_phase.summary).to include("New summary of the phase.")
expect(budget.current_phase.description).to include("New description of the phase.")
expect(budget.current_phase.enabled).to be(false)
end
end
end