2014-04-02 23:40:05 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SubscribesController do
|
|
|
|
|
|
|
|
describe "POST 'create'" do
|
|
|
|
it "post ok" do
|
2014-04-03 16:49:59 +08:00
|
|
|
post 'create', email: 'tester@test.com'
|
2014-07-21 14:51:21 +08:00
|
|
|
expect(JSON.parse(response.body)['success']).to be_truthy
|
2014-04-02 23:40:05 +08:00
|
|
|
expect(Subscribe.all.size).to eq(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "post with disabled email" do
|
2014-04-03 16:49:59 +08:00
|
|
|
subscribe = Subscribe.create(email: 'tester@test.com', enable: false)
|
|
|
|
post 'create', email: 'tester@test.com'
|
2014-07-21 14:51:21 +08:00
|
|
|
expect(JSON.parse(response.body)['success']).to be_truthy
|
|
|
|
expect(subscribe.reload.enable).to be_truthy
|
2014-04-02 23:40:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|