Merge branch 'dev_local' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_local

dev_local
cxt 6 years ago
commit 4f5bbbd86d

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

@ -0,0 +1,3 @@
// Place all the styles related to the local_settings controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

@ -0,0 +1,84 @@
class LocalSettingsController < ApplicationController
layout 'educoder'
# GET /local_settings
# GET /local_settings.json
def index
@local_settings = LocalSetting.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @local_settings }
end
end
# GET /local_settings/1
# GET /local_settings/1.json
def show
@local_setting = LocalSetting.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @local_setting }
end
end
# GET /local_settings/new
# GET /local_settings/new.json
def new
@local_setting = LocalSetting.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @local_setting }
end
end
# GET /local_settings/1/edit
def edit
@local_setting = LocalSetting.find(params[:id])
end
# POST /local_settings
# POST /local_settings.json
def create
@local_setting = LocalSetting.new(params[:local_setting])
respond_to do |format|
if @local_setting.save
format.html { redirect_to @local_setting, notice: 'Local setting was successfully created.' }
format.json { render json: @local_setting, status: :created, location: @local_setting }
else
format.html { render action: "new" }
format.json { render json: @local_setting.errors, status: :unprocessable_entity }
end
end
end
# PUT /local_settings/1
# PUT /local_settings/1.json
def update
@local_setting = LocalSetting.find(params[:id])
respond_to do |format|
if @local_setting.update_attributes(params[:local_setting])
format.html { redirect_to @local_setting, notice: 'Local setting was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @local_setting.errors, status: :unprocessable_entity }
end
end
end
# DELETE /local_settings/1
# DELETE /local_settings/1.json
def destroy
@local_setting = LocalSetting.find(params[:id])
@local_setting.destroy
respond_to do |format|
format.html { redirect_to local_settings_url }
format.json { head :no_content }
end
end
end

@ -0,0 +1,2 @@
module LocalSettingsHelper
end

@ -0,0 +1,3 @@
class LocalSetting < ActiveRecord::Base
attr_accessible :exam
end

@ -3,6 +3,7 @@
<div class="task_popup_con">
<%= labelled_form_for @exercise, :url =>{:controller=> 'exercise', :action => 'choose_shixuns', :id => @exercise.id, :is_search => 1}, :html => {:id => 'shixun_search_form'}, :method => "get", :remote => true do |f| %>
<div class="clearfix mb10">
<span class="fl color-orange-tip mt6">试卷仅支持只有1个关卡的实训题</span>
<div class="task-form-50 edu-position fr" style="padding:0;">
<input class="task-form-100 panel-box-sizing" placeholder="输入实训名称的关键字搜索" type="text" name="search">
<a href="javascript:void(0);" onclick="$('#shixun_search_form').submit()" class="edu-btn-search font-16 color-grey mt5"><i class="fa fa-search"></i></a>

@ -1,35 +1,86 @@
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>">
<p class="fl mt15 font-16 mb10">实训题</p>
<p class="clearfix mb10" style="margin-left: 78px;"><%= exercise_question.shixun.name %></p>
<li class="clearfix pr mb20">
<input name="question_type" value="5" type="hidden">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing questionTitle undis" name="question_title" id="poll_questions_title_<%=exercise_question.id %>"><%=exercise_question.question_title.html_safe %></textarea>
</li>
<li class="clearfix pr mb10">
<label class="panel-form-label fl"><span class="mr10">序号</span></label>
<span class="fl with80 mt6 ml20 color-dark-grey" style="display: block;">关卡名称</span>
<span class="fl mt6 color-dark-grey" style="display: block;">分值</span>
</li>
<% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %>
<li class="clearfix pr mb10">
<label class="panel-form-label fl">
<span class="option-item fr ml6 color-grey select-choice" data-tip-left="第<%= index + 1 %>关"><%= index + 1 %></span>
</label>
<span class="fl ml20 mt6 with75 task-hide" style="display: block;"><%= exercise_challenge.challenge.subject %></span>
<input value="<%= exercise_challenge.question_score %>" type="text" class="with10 ml15 mr5 pl10 fl panel-box-sizing task-height-40" name="question_score[]" />
<label class="fl" style="line-height: 40px;">分</label>
</li>
<div class="cl"></div>
<% end %>
<li class="clearfix mb20">
<p class="fr">
<span class="font-12 color-grey mb10" style="display: block;">温馨提示:[实训题]属于客观题将由系统自动评分</span>
<a href="javascript:void(0)" class="fr task-btn task-btn-orange" onclick="edit_poll_question($(this),<%= exercise_question.id %>,5);">保存</a>
<a href="javascript:void(0)" class="fr task-btn mr10" onclick="$('#edit_poll_questions_<%=exercise_question.id %>').hide();$('#show_poll_questions_<%=exercise_question.id %>').show();">取消</a>
</p>
</li>
</div>
<!-- <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%#= exercise_question.id %>">-->
<!-- <p class="fl mt15 font-16 mb10">实训题</p>-->
<!-- <p class="clearfix mb10" style="margin-left: 78px;"><%#= exercise_question.shixun.name %></p>-->
<!-- <li class="clearfix pr mb20">-->
<!-- <input name="question_type" value="5" type="hidden">-->
<!-- <label class="panel-form-label fl"><span class="mr10">要求</span></label>-->
<!-- <textarea maxlength="250" class="panel-form-width2-690 fl panel-box-sizing questionTitle undis" name="question_title" id="poll_questions_title_<%#=exercise_question.id %>"><%#=exercise_question.question_title.html_safe %></textarea>-->
<!-- </li>-->
<!-- <li class="clearfix pr mb10">-->
<!-- <label class="panel-form-label fl"><span class="mr10">序号</span></label>-->
<!-- <span class="fl with80 mt6 ml20 color-dark-grey" style="display: block;">关卡名称</span>-->
<!-- <span class="fl mt6 color-dark-grey" style="display: block;">分值</span>-->
<!-- </li>-->
<%# exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %>
<!-- <li class="clearfix pr mb10">-->
<!-- <label class="panel-form-label fl">-->
<!-- <span class="option-item fr ml6 color-grey select-choice" data-tip-left="第<%#= index + 1 %>关"><%#= index + 1 %></span>-->
<!-- </label>-->
<!-- <span class="fl ml20 mt6 with75 task-hide" style="display: block;"><%#= exercise_challenge.challenge.subject %></span>-->
<!-- <input value="<%#= exercise_challenge.question_score %>" type="text" class="with10 ml15 mr5 pl10 fl panel-box-sizing task-height-40" name="question_score[]" />-->
<!-- <label class="fl" style="line-height: 40px;">分</label>-->
<!-- </li>-->
<!-- <div class="cl"></div>-->
<%# end %>
<!-- <li class="clearfix mb20">-->
<!-- <p class="fr">-->
<!-- <span class="font-12 color-grey mb10" style="display: block;">温馨提示:[实训题]属于客观题将由系统自动评分</span>-->
<!-- <a href="javascript:void(0)" class="fr task-btn task-btn-orange" onclick="edit_poll_question($(this),<%#= exercise_question.id %>,5);">保存</a>-->
<!-- <a href="javascript:void(0)" class="fr task-btn mr10" onclick="$('#edit_poll_questions_<%=exercise_question.id %>').hide();$('#show_poll_questions_<%=exercise_question.id %>').show();">取消</a>-->
<!-- </p>-->
<!-- </li>-->
<!-- </div>-->
<% end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="answer_Temp">
<div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">实训题</div>
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121"/> 分/题
<div class="colorFF8121">*大于等于0且不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input class="borderFF8121"/> 题
<div class="colorFF8121">*不能为空</div>
<div class="colorFF8121">*必须为正整数</div>
<div class="colorFF8121">*不能大于可用题数</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
</div>
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">中级题</span>
</div>
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">高级题</span>
</div>
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">顶级题</span>
</div>
</div>

@ -3,40 +3,55 @@
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true, :id => "new_exercise_question"},
:url=>create_exercise_question_exercise_path(exercise.id)) do |f| %>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 answer_Temp" id="answer_Temp">
<p class="fl mt15 font-16 mb10">实训题</p>
<input name="question_type" value="5" type="hidden">
<input name="shixun" value="<%= @shixun.id %>" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden">
<p class="clearfix mb10" style="margin-left: 78px;"><%= @shixun.name %></p>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
</li>
<li class="clearfix pr mb10">
<label class="panel-form-label fl"><span class="mr10">序号</span></label>
<span class="fl with80 mt6 ml20 color-dark-grey" style="display: block;">关卡名称</span>
<span class="fl mt6 color-dark-grey" style="display: block;">分值</span>
</li>
<% @shixun.challenges.each_with_index do |challenge, i| %>
<li class="clearfix pr mb10">
<label class="panel-form-label fl">
<span class="option-item fr ml6 color-grey select-choice" data-tip-left="第<%= i + 1 %>关"><%= i + 1 %></span>
</label>
<span class="fl ml20 mt6 with75 task-hide" style="display: block;"><%= challenge.subject %></span>
<input value="" type="text" class="with10 ml15 mr5 pl10 fl panel-box-sizing task-height-40" name="question_score[]" />
<label class="fl" style="line-height: 40px;">分</label>
</li>
<% end %>
<li class="clearfix mb20">
<p class="fr">
<span class="font-12 color-grey mb10" style="display: block;">温馨提示:[实训题]属于客观题将由系统自动评分</span>
<a href="javascript:void(0)" class="fr task-btn task-btn-orange" id="add_new_question">保存</a>
<a href="javascript:void(0)" class="fr task-btn mr10" onclick="$(this).parent().parent().parent().parent().parent().remove();">取消</a>
</p>
</li>
</div>
<!-- <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 answer_Temp" id="answer_Temp">-->
<!-- <p class="fl mt15 font-16 mb10">实训题</p>-->
<!-- <input name="question_type" value="5" type="hidden">-->
<!-- <input name="shixun" value="<%#= @shixun.id %>" type="hidden">-->
<!-- <input name="quest_id" id="quest_id" value="0" type="hidden">-->
<!-- <p class="clearfix mb10" style="margin-left: 78px;"><%#= @shixun.name %></p>-->
<!-- <li class="clearfix pr mb20">-->
<!-- <label class="panel-form-label fl"><span class="mr10">要求</span></label>-->
<!-- <textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>-->
<!-- </li>-->
<!-- <li class="clearfix pr mb10">-->
<!-- <label class="panel-form-label fl"><span class="mr10">序号</span></label>-->
<!-- <span class="fl with80 mt6 ml20 color-dark-grey" style="display: block;">关卡名称</span>-->
<!-- <span class="fl mt6 color-dark-grey" style="display: block;">分值</span>-->
<!-- </li>-->
<%# @shixun.challenges.each_with_index do |challenge, i| %>
<!-- <li class="clearfix pr mb10">-->
<!-- <label class="panel-form-label fl">-->
<!-- <span class="option-item fr ml6 color-grey select-choice" data-tip-left="第<%#= i + 1 %>关"><%#= i + 1 %></span>-->
<!-- </label>-->
<!-- <span class="fl ml20 mt6 with75 task-hide" style="display: block;"><%#= challenge.subject %></span>-->
<!-- <input value="" type="text" class="with10 ml15 mr5 pl10 fl panel-box-sizing task-height-40" name="question_score[]" />-->
<!-- <label class="fl" style="line-height: 40px;">分</label>-->
<!-- </li>-->
<%# end %>
<!-- <li class="clearfix mb20">-->
<!-- <p class="fr">-->
<!-- <span class="font-12 color-grey mb10" style="display: block;">温馨提示:[实训题]属于客观题将由系统自动评分</span>-->
<!-- <a href="javascript:void(0)" class="fr task-btn task-btn-orange" id="add_new_question">保存</a>-->
<!-- <a href="javascript:void(0)" class="fr task-btn mr10" onclick="$(this).parent().parent().parent().parent().parent().remove();">取消</a>-->
<!-- </p>-->
<!-- </li>-->
<!-- </div>-->
<% end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="answer_Temp">
<p class="fl mt15 font-16 mb10 practicalTitle padding10 practicalTitlefont">实训题</p>
<p class="fl mt15 font-16 mb10 practicalTitle">
</p>
</div>
</div>
<% end %>
<script type="text/javascript">

@ -7,11 +7,11 @@
<th>学员数</th>
</tr>
</thead>
<tbody>
<tbody class="selecshixun" onscroll="contentViewScroll">
<% @shixuns.each do |shixun| %>
<tr>
<td class="clearfix" style="padding-left: 20px">
<input name="shixun_exercise" type="radio" class="magic-radio" id="shixun_input_<%= shixun.id %>" value="<%= shixun.id %>">
<input name="shixun_exercise" type="checkbox" class="magic-checkbox" id="shixun_input_<%= shixun.id %>" value="<%= shixun.id %>">
<label style="top:2px" for="shixun_input_<%= shixun.id %>"></label>
<%= link_to shixun.name, shixun_path(shixun), :class => "edu-info-dark task-hide mt3 ml20",:style=> "text-align:left", :target => "_blank" %>
</td>
@ -22,16 +22,41 @@
</tbody>
</table>
</div>
<p id="exercise_type_notice" class="color-red none">请至少选择一个实训</p>
<div class="clearfix">
<div class="clearfix fr mt15">
<p style="height: 20px;line-height: 20px;"><span id="exercise_type_notice" class="color-red none">请至少选择一个实训</span></p>
<div class="clearfix edu-txt-center mt10">
<div class="inline">
<a href="javascript:void(0);" class="task-btn task-btn-orange fr" onclick="new_shixun_exercise();">选择</a>
<a href="javascript:void(0);" class="task-btn fr pop_close mr10" onclick="hideModal();">取消</a>
</div>
<div class="fl pages_user_show mt10">
<ul>
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
<!-- <div class="fl pages_user_show mt10">-->
<!-- <ul>-->
<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
<!-- </ul>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
</div>
<script>
//滑动到底加载
function contentViewScroll(){
//滑动到底加载
if(e.currentTarget.scrollHeight-e.currentTarget.scrollTop===e.currentTarget.clientHeight){
<!-- var url= www.xxx.com-->
<!-- $.ajax({-->
<!-- type: "post",-->
<!-- url: url,-->
<!-- data: {-->
<!-- poll_question_id: <%#= poll_question.id %>,-->
<!-- poll_answer_id: <%#= poll_answer.id %>,-->
<!-- vote_text: obj.value-->
<!-- },-->
<!-- success: function (data) {-->
<!-- 填充到 tbody标签里-->
<!-- }-->
<!-- });-->
}
}
</script>

@ -0,0 +1,21 @@
<%= form_for(@local_setting) do |f| %>
<% if @local_setting.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@local_setting.errors.count, "error") %> prohibited this local_setting from being saved:</h2>
<ul>
<% @local_setting.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :考试模式 %><br />
<%= f.check_box :exam %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

@ -0,0 +1,9 @@
<div class="ml10">
<h1>编辑配置参数</h1>
<%= render 'form' %>
<%= link_to '详情', @local_setting %> |
<%= link_to 'Back', local_settings_path %>
</div>

@ -0,0 +1,26 @@
<div class="ml10">
<h1>本地配置</h1>
<table>
<tr>
<th>考试模式</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @local_settings.each do |local_setting| %>
<tr>
<td><%= local_setting.exam %></td>
<td><%= link_to '显示', local_setting %></td>
<td><%= link_to '编辑', edit_local_setting_path(local_setting) %></td>
<td><%= link_to '删除', local_setting, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to '新增配置', new_local_setting_path %>
</div>

@ -0,0 +1,8 @@
<div class="ml10">
<h1>新建配置参数</h1>
<%= render 'form' %>
<%= link_to 'Back', local_settings_path %>
</div>

@ -0,0 +1,12 @@
<div class="ml10">
<p id="notice"><%= notice %></p>
<p>
<b>考试模式:</b>
<%= @local_setting.exam %>
</p>
<%= link_to '编辑', edit_local_setting_path(@local_setting) %> |
<%= link_to 'Back', local_settings_path %>
</div>

@ -39,6 +39,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'ecloud/ps_new', to: 'ecloud#ps_new'
post 'ecloud/ps_update', to: 'ecloud#ps_update'
resources :local_settings
resources :cooperates do
member do

@ -0,0 +1,9 @@
class CreateLocalSettings < ActiveRecord::Migration
def change
create_table :local_settings do |t|
t.boolean :exam
t.timestamps
end
end
end

@ -149,7 +149,8 @@ a.decoration{text-decoration: underline}
.padding20-15{padding: 20px 15px;box-sizing: border-box}
.padding20-10{padding: 20px 10px;box-sizing: border-box}
.padding20-25{padding: 20px 25px;box-sizing: border-box}
.padding10{padding: 10px;box-sizing: border-box}
.padding20{padding: 20px;box-sizing: border-box}
.padding30{padding: 30px;box-sizing: border-box}
.padding30-20{padding: 30px 20px;box-sizing: border-box}
.padding30-40{padding: 30px 40px;box-sizing: border-box}
@ -883,3 +884,58 @@ html>body #ajax-indicator { position: fixed; }
margin-top: 60px;
margin-left: -26px;
}
.selecshixun{
overflow-y: scroll;
}
.practicalTemp{
width:1200px;
height:950px;
background:rgba(255,255,255,1);
border:1px solid rgba(238,238,238,1);
}
.practicalTitlefont{
font-size:18px;
font-family:MicrosoftYaHei;
font-weight:400;
color:rgba(102,102,102,1);
width: 1200px;
height: 60px;
line-height: 25px;
padding-left: 10px;
border-bottom: 1px solid rgba(238,238,238,1);
}
.practicalTitle{
width: 1160px;
padding: 20px;
border-bottom:1px solid rgba(238,238,238,1);
}
.Titlefont{
width: 48px;
height: 30px;
font-size: 15px;
font-family: MicrosoftYaHei;
font-weight: 400;
color: rgba(5,16,26,1);
}
.shixun-title-font{
font-size:16px;
font-family:MicrosoftYaHei;
font-weight:400;
color:#828282;
}
.colorFF8121{
color: #FF8121;
font-size: 12px;
text-align: left;
width: 110px;
margin-left: 117px;
}
.borderFF8121{
border:1px solid #FF8121
}

@ -0,0 +1,159 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
RSpec.describe LocalSettingsController, :type => :controller do
# This should return the minimal set of attributes required to create a valid
# LocalSetting. As you add validations to LocalSetting, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# LocalSettingsController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all local_settings as @local_settings" do
local_setting = LocalSetting.create! valid_attributes
get :index, {}, valid_session
expect(assigns(:local_settings)).to eq([local_setting])
end
end
describe "GET #show" do
it "assigns the requested local_setting as @local_setting" do
local_setting = LocalSetting.create! valid_attributes
get :show, {:id => local_setting.to_param}, valid_session
expect(assigns(:local_setting)).to eq(local_setting)
end
end
describe "GET #new" do
it "assigns a new local_setting as @local_setting" do
get :new, {}, valid_session
expect(assigns(:local_setting)).to be_a_new(LocalSetting)
end
end
describe "GET #edit" do
it "assigns the requested local_setting as @local_setting" do
local_setting = LocalSetting.create! valid_attributes
get :edit, {:id => local_setting.to_param}, valid_session
expect(assigns(:local_setting)).to eq(local_setting)
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new LocalSetting" do
expect {
post :create, {:local_setting => valid_attributes}, valid_session
}.to change(LocalSetting, :count).by(1)
end
it "assigns a newly created local_setting as @local_setting" do
post :create, {:local_setting => valid_attributes}, valid_session
expect(assigns(:local_setting)).to be_a(LocalSetting)
expect(assigns(:local_setting)).to be_persisted
end
it "redirects to the created local_setting" do
post :create, {:local_setting => valid_attributes}, valid_session
expect(response).to redirect_to(LocalSetting.last)
end
end
context "with invalid params" do
it "assigns a newly created but unsaved local_setting as @local_setting" do
post :create, {:local_setting => invalid_attributes}, valid_session
expect(assigns(:local_setting)).to be_a_new(LocalSetting)
end
it "re-renders the 'new' template" do
post :create, {:local_setting => invalid_attributes}, valid_session
expect(response).to render_template("new")
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested local_setting" do
local_setting = LocalSetting.create! valid_attributes
put :update, {:id => local_setting.to_param, :local_setting => new_attributes}, valid_session
local_setting.reload
skip("Add assertions for updated state")
end
it "assigns the requested local_setting as @local_setting" do
local_setting = LocalSetting.create! valid_attributes
put :update, {:id => local_setting.to_param, :local_setting => valid_attributes}, valid_session
expect(assigns(:local_setting)).to eq(local_setting)
end
it "redirects to the local_setting" do
local_setting = LocalSetting.create! valid_attributes
put :update, {:id => local_setting.to_param, :local_setting => valid_attributes}, valid_session
expect(response).to redirect_to(local_setting)
end
end
context "with invalid params" do
it "assigns the local_setting as @local_setting" do
local_setting = LocalSetting.create! valid_attributes
put :update, {:id => local_setting.to_param, :local_setting => invalid_attributes}, valid_session
expect(assigns(:local_setting)).to eq(local_setting)
end
it "re-renders the 'edit' template" do
local_setting = LocalSetting.create! valid_attributes
put :update, {:id => local_setting.to_param, :local_setting => invalid_attributes}, valid_session
expect(response).to render_template("edit")
end
end
end
describe "DELETE #destroy" do
it "destroys the requested local_setting" do
local_setting = LocalSetting.create! valid_attributes
expect {
delete :destroy, {:id => local_setting.to_param}, valid_session
}.to change(LocalSetting, :count).by(-1)
end
it "redirects to the local_settings list" do
local_setting = LocalSetting.create! valid_attributes
delete :destroy, {:id => local_setting.to_param}, valid_session
expect(response).to redirect_to(local_settings_url)
end
end
end

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :local_setting do
exam false
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe LocalSetting, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save