Skip to content

Commit

Permalink
Merge branch 'release/0.13.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Jan 26, 2017
2 parents d329ebc + 8b0bba1 commit 76f2e5c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 68 deletions.
2 changes: 1 addition & 1 deletion app/models/activity_lines/lider/ya_lider/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ActivityLines::Lider::YaLider::Stage < ActiveRecord::Base
has_many :participations, class_name: 'ActivityLines::Lider::YaLider::Participation'
has_many :participants, through: :participations

validates :number, presence: true, uniqueness: { scope: :ya_lider_id }
validates :number, presence: true, uniqueness: { scope: :contest_id }

state_machine :state, initial: :active do
state :active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
= fa_icon :plus
= t('.create_user')
= f.input :state_event, as: :state_event
= f.input :contest_id, as: :hidden, input_html: { value: (@participant_form.model.contest_id || params[:activity_lines_lider_ya_lider_particpant][:contest_id]) }
= f.input :contest_id, as: :hidden, input_html: { value: (@participant_form.model.contest_id || params[:activity_lines_lider_ya_lider_participant][:contest_id]) }
= f.button :submit, class: 'btn-success', value: t('helpers.links.save')
-#= link_to t('helpers.links.back'), admin_activity_lines_lider_ya_lider_path(ya_lider_id), class: 'btn btn-default'
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
= t("enumerize.activity_lines/lider/ya_lider/participant_field.title.esse")
%td
- if @participant.esse.present?
= link_to fa_icon(:download), @participant.esse.value, class: 'btn btn-success'
= link_to fa_icon(:download), "#{configus.it_projects.ul_lider.rul}#{@participant.esse.value}", class: 'btn btn-success'
- else
Не синхронизировалось Эссе! Обратитесь к администратору сайта
= link_to fa_icon(:exclamation), new_admin_activity_lines_lider_ya_lider_participant_field_path(activity_lines_lider_ya_lider_participant_field: { field_type: :file, title: :esse, participant_id: @participant.id }), class: 'btn btn-danger'
Expand Down
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
t.integer "stage_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "state"
end

create_table "activity_lines_lider_ya_lider_stages", force: :cascade do |t|
Expand Down Expand Up @@ -500,6 +499,9 @@
t.integer "user_id"
end

add_index "teams_users", ["team_id"], name: "index_teams_users_on_team_id", using: :btree
add_index "teams_users", ["user_id"], name: "index_teams_users_on_user_id", using: :btree

create_table "test_paper_questions", force: :cascade do |t|
t.text "text"
t.integer "test_paper_id"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
require 'test_helper'

class Web::Admin::ActivityLines::Lider::YaLider::ParticipantsControllerTest < ActionController::TestCase
# setup do
# admin = create :admin
# sign_in admin
# create :ya_lider
# @participant = create :ya_lider_participant
# @exceptions_attributes = ['id', 'created_at', 'updated_at', 'begin_date', 'end_date']
# end
#
# test 'should get new' do
# get :new, activity_lines_lider_ya_lider_participant: { ya_lider_id: ActivityLines::Lider::YaLider.last.id }
# assert_response :success, @response.body
# end
#
# test 'should create participant' do
# attributes = attributes_for :ya_lider_participant
# attributes[:arguments_attributes] = {}
# attributes[:arguments_attributes]['0'] = attributes_for :argument
# post :create, activity_lines_lider_ya_lider_participant: attributes
# participant = ActivityLines::Lider::YaLider::Participant.last
# assert_response :redirect, @response.body
# assert_redirected_to admin_activity_lines_lider_ya_liders_path
# participant.attributes.keys.except(*@exceptions_attributes).each do |key|
# assert_equal attributes[key.to_sym], participant.send(key), key
# end
# end
#
# test 'should not create participant' do
# attributes = { user_id: @participant.user_id }
# post :create, activity_lines_lider_ya_lider_participant: attributes
# assert_response :success
# end
#
# test 'should get edit by admin' do
# 4.times { create :argument }
# get :edit, id: @participant
# assert_response :success
# end
#
# test 'should update participant by admin' do
# attributes = attributes_for :ya_lider_participant
# put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
# assert_response :redirect
# assert_redirected_to admin_activity_lines_lider_ya_liders_path
# @participant.reload
# @participant.attributes.keys.except(*@exceptions_attributes).each do |key|
# assert_equal attributes[key.to_sym], @participant.send(key), key
# end
# end
#
# test 'should not update participant by admin' do
# attributes = attributes_for :ya_lider_participant
# attributes[:user_id] = nil
# count_before_save = ActivityLines::Lider::YaLider::Participant.count
# put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
# assert_equal ActivityLines::Lider::YaLider::Participant.count, count_before_save
# assert_response :success
# end
#
# test 'should destroy participant' do
# delete :destroy, id: @participant
# @participant.reload
# assert @participant.removed?
# end
setup do
admin = create :admin
sign_in admin
create :ya_lider
@participant = create :ya_lider_participant
@exceptions_attributes = ['id', 'created_at', 'updated_at', 'begin_date', 'end_date']
end

test 'should get new' do
get :new, activity_lines_lider_ya_lider_participant: { contest_id: ActivityLines::Lider::YaLider.last.id }
assert_response :success, @response.body
end

test 'should create participant' do
attributes = attributes_for :ya_lider_participant
attributes[:arguments_attributes] = {}
attributes[:arguments_attributes]['0'] = attributes_for :argument
post :create, activity_lines_lider_ya_lider_participant: attributes
participant = ActivityLines::Lider::YaLider::Participant.last
assert_response :redirect, @response.body
assert_redirected_to admin_activity_lines_lider_ya_liders_path
participant.attributes.keys.except(*@exceptions_attributes).each do |key|
assert_equal attributes[key.to_sym], participant.send(key), key
end
end

test 'should not create participant' do
attributes = { user_id: @participant.user_id }
post :create, activity_lines_lider_ya_lider_participant: attributes
assert_response :success
end

test 'should get edit by admin' do
4.times { create :argument }
get :edit, id: @participant
assert_response :success
end

test 'should update participant by admin' do
attributes = attributes_for :ya_lider_participant
put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
assert_response :redirect
assert_redirected_to admin_activity_lines_lider_ya_liders_path
@participant.reload
@participant.attributes.keys.except(*@exceptions_attributes).each do |key|
assert_equal attributes[key.to_sym], @participant.send(key), key
end
end

test 'should not update participant by admin' do
attributes = attributes_for :ya_lider_participant
attributes[:user_id] = nil
count_before_save = ActivityLines::Lider::YaLider::Participant.count
put :update, id: @participant, activity_lines_lider_ya_lider_participant: attributes
assert_equal ActivityLines::Lider::YaLider::Participant.count, count_before_save
assert_response :success
end

test 'should destroy participant' do
delete :destroy, id: @participant
@participant.reload
assert @participant.removed?
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :ya_lider_participant, class: 'ActivityLines::Lider::YaLider::Participant' do
contest_year { generate :integer }
contest_id { create(:ya_lider_with_stages) }
user_id { User.last ? User.last.id : create(:user).id }
#state { ActivityLines::Lider::YaLider::Participant.state_machines[:state].states.map(&:name).first.to_s }
end
Expand Down
6 changes: 6 additions & 0 deletions test/factories/activity_lines/lider/ya_liders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
create :token, record_type: 'ActivityLines::Lider::YaLider'
end
end

factory :ya_lider_with_stages, parent: :ya_lider do
after :create do
create :ya_lider_stage, number: 1
end
end
end

0 comments on commit 76f2e5c

Please sign in to comment.