require 'rails_helper'
RSpec.describe 'account/articles/new', type: :view do
it 'renders new article form' do
stub_article { Article.new }
render
expect(rendered).to match(%r{form.+id="new_article".+action=\"#{account_articles_path}".+accept-charset=\"UTF-8\".+method=\"post\"})
end
def stub_article(&block)
controller.singleton_class.class_exec(block) do
helper_method :article
define_method :article do
block.call
end
end
end
end
require 'rails_helper'
RSpec.describe 'account/articles/new', type: :view do
it 'renders new article form' do
def view.article
Article.new
end
render
expect(rendered).to match %r{form.+id="new_article".+action=\"#{account_articles_path}".+accept-charset=\"UTF-8\".+method=\"post\"}
end
end
def callback_profile
render json: { text: 'Запрос успешно прошел.'}
end
$ ->
$("#callback_profile").on("ajax:success", (e, data, status, xhr) ->
$("#btn_submit").replaceWith data['text']
).on "ajax:error", (xhr, status, error) ->
$("#btn_submit").replaceWith 'Error!'