serializations_controller_spec.rb revision bdc69d2e103b81dfabf3965a968cad610feecfff
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenrequire 'spec_helper'
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainendescribe SerializationsController do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen let!(:user) { FactoryGirl.create :user }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen let!(:language) { FactoryGirl.create :language, user: user }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen let!(:serial) { FactoryGirl.create :serialization, language: language }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'signed in as owner' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen sign_in user
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'on get to show' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen get :show, id: serial.id
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it { should respond_with :success }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it { should render_template :show }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it { should_not set_the_flash }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'on get to new' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen get :new
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it { should respond_with :success }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it { should render_template :new }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'on POST to CREATE' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen post :create, serialization: {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen name: 'test132',
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mimetype: 'text',
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen language_id: language.id
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'create the record' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen let!(:serial_from_db) { Serialization.find_by_name('test132') }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should exist' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen expect(serial_from_db).not_to be_nil
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should have correct mime type' do
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen expect(serial_from_db.mimetype).to eq('text')
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should have correct name' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen expect(serial_from_db.name).to eq('test132')
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'on PUT to Update' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen put :update, id: serial.id, serialization: {
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen name: 'test4325',
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen mimetype: 'texttext' }
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'change the record' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen let!(:serial_from_db) { Serialization.find_by_name('test4325') }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should exist' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen expect(serial_from_db).not_to be_nil
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should have correct mime type' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen expect(serial_from_db.mimetype).to eq('texttext')
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'should have correct name' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen expect(serial_from_db.name).to eq('test4325')
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'on POST to DELETE' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen delete :destroy, id: serial.id
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen it 'remove the record' do
659fe5d24825b160cae512538088020d97a60239Timo Sirainen expect(Serialization.find_by_id(serial.id)).to be_nil
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen context 'on GET to EDIT' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen before do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen get :edit, id: serial.id
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should respond_with :success }
659fe5d24825b160cae512538088020d97a60239Timo Sirainen it { should render_template :edit }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should_not set_the_flash }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen context 'signed in as not-owner' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen let(:user2) { FactoryGirl.create :user }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen before { sign_in user2 }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen context 'on get to show' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen before do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen get :show, id: serial.id
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should respond_with :success }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should render_template :show }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should_not set_the_flash }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen context 'on get to new' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen before do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen get :new
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should respond_with :success }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it { should render_template :new }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
3cfff0ca01961d885bdbd6ef08d761880116af07Timo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'on POST to CREATE' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen before do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen post :create, serialization: {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen name: 'test132',
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen mimetype: 'text',
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen language_id: language.id }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'create the record' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen let!(:serial_from_db) { Serialization.find_by_name('test132') }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen it 'should exist' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen expect(serial_from_db).not_to be_nil
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen it 'should have correct mime type' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen expect(serial_from_db.mimetype).to eq('text')
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen it 'should have correct name' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen expect(serial_from_db.name).to eq('test132')
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'on PUT to Update' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen before do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen put :update, id: serial.id, serialization: {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen name: 'test4325',
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen mimetype: 'texttext'
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'change the record' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen let!(:serial_from_db) { Serialization.find_by_name('test4325') }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it 'should exist' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen expect(serial_from_db).not_to be_nil
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it 'should have correct mime type' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen expect(serial_from_db.mimetype).to eq('texttext')
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it 'should have correct name' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen expect(serial_from_db.name).to eq('test4325')
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'on POST to DELETE' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen before do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen delete :destroy, id: serial.id
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it 'remove the record' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen expect(Serialization.find_by_id(serial.id)).to be_nil
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'on GET to EDIT' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen before do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen get :edit, id: serial.id
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should respond_with :success }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should render_template :edit }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should_not set_the_flash }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'not signed in' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'on get to show' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen before do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen get :show, id: serial.id, language_id: language.id
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should respond_with :success }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should render_template :show }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should_not set_the_flash }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen context 'on get to new' do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen before do
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen get :new, language_id: language.id
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should respond_with :redirect }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it { should set_the_flash }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen end
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen context 'on POST to CREATE' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen before do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen put :update, id: serial.id, serialization: {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen name: 'test2',
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen mimetype: 'text',
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen language_id: language.id
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen }
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen it 'not create the record' do
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen expect(Serialization.find_by_name('test2')).to be_nil
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen end
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen context 'on PUT to Update' do
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen before do
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen put :update, id: serial.id, serialization: {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen name: 'test2',
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen mimetype: 'text',
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen language_id: language.id
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen }
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen it 'not change the record' do
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen expect(Serialization.find_by_name('test2')).to be_nil
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'on POST to DELETE' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen before do
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen delete :destroy, id: serial.id
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen end
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen it 'not remove the record' do
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen expect(Serialization.find_by_id(serial.id)).to eq(serial)
3cfff0ca01961d885bdbd6ef08d761880116af07Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen end
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainenend
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen