Sha256: 3215e640866163ae3584b036ef547b074111b559d3fd1613c337d51e1f8975a9

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

require 'spec_helper'

describe ActiveRecordSurveyApi::InstanceNodesController, :type => :controller, :instance_nodes_api => true do
	routes { ActiveRecordSurveyApi::Engine.routes }

	describe 'GET create' do
		it 'should create a new instance' do
			survey = FactoryGirl.build(:basic_survey)
			survey.save

			instance = ActiveRecordSurvey::Instance.new(:survey => survey)
			instance.save

			request.headers[:HTTP_ACCEPT_LANGUAGE] = "en"
			header_params = {
				:survey_id => survey.id,
				:instance_id => instance.id,
				:HTTP_ACCEPT_LANGUAGE => 'en',
				:CONTENT_TYPE => 'application/json',
				:ACCEPT => 'application/json'
			}

			questions = survey.questions

			survey_path = survey.as_map.as_json.first

			post :create,
			{
				:instance_node => {
					:active_record_survey_node_id => survey_path["children"].first["node_id"]
				}
			}.to_json, header_params

			json_body = JSON.parse(response.body)

			expect(json_body["data"]["id"].to_i).to eq(1)
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_record_survey_api-0.0.12 spec/controllers/active_record_survey_api/surveys/instances/instance_nodes_spec.rb
active_record_survey_api-0.0.11 spec/controllers/active_record_survey_api/surveys/instances/instance_nodes_spec.rb
active_record_survey_api-0.0.7 spec/controllers/active_record_survey_api/surveys/instances/instance_nodes_spec.rb
active_record_survey_api-0.0.6 spec/controllers/active_record_survey_api/surveys/instances/instance_nodes_spec.rb