Skip to content
Permalink
Browse files

Refactoring: Migrate email_process_state_open_test to RSpec

  • Loading branch information...
rlue authored and znuny-robo committed May 6, 2019
1 parent d4b0d95 commit 3b1e51c7896990113279850fd5dfd6601f6c7b68
Showing with 24 additions and 153 deletions.
  1. +12 −0 spec/models/channel/email_parser_spec.rb
  2. +12 −2 spec/models/ticket_spec.rb
  3. +0 −151 test/unit/email_process_state_open_set.rb
@@ -121,6 +121,12 @@

expect(Ticket::Article.last.sender.name).to eq('Agent')
end

it 'sets ticket.state to "new"' do
Channel::EmailParser.new.process({}, raw_mail)

expect(Ticket.last.state.name).to eq('new')
end
end

context 'when from address matches an existing customer' do
@@ -131,6 +137,12 @@

expect(Ticket.last.articles.first.sender.name).to eq('Customer')
end

it 'sets ticket.state to "new"' do
Channel::EmailParser.new.process({}, raw_mail)

expect(Ticket.last.state.name).to eq('new')
end
end

context 'when from address is unrecognized' do
@@ -339,12 +339,22 @@
end

describe '#state' do
context 'when originally "new"' do
context 'when originally "new" (default)' do
context 'and a customer article is added' do
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Customer') }

it 'stays "new"' do
expect { article }
.not_to change { ticket.state.name }.from('new')
end
end

context 'and a non-customer article is added' do
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }

it 'switches to "open"' do
expect { article }.to change { ticket.state.name }.from('new').to('open')
expect { article }
.to change { ticket.state.name }.from('new').to('open')
end
end
end

This file was deleted.

Oops, something went wrong.

0 comments on commit 3b1e51c

Please sign in to comment.
You can’t perform that action at this time.