Event related controllers and views #1
2
Gemfile
2
Gemfile
|
@ -1,6 +1,6 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rails', '4.1.4'
|
||||
gem 'rails', '4.1.5'
|
||||
|
||||
gem 'sqlite3'
|
||||
gem 'pg'
|
||||
|
|
80
Gemfile.lock
80
Gemfile.lock
|
@ -1,27 +1,27 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.1.4)
|
||||
actionpack (= 4.1.4)
|
||||
actionview (= 4.1.4)
|
||||
actionmailer (4.1.5)
|
||||
actionpack (= 4.1.5)
|
||||
actionview (= 4.1.5)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (4.1.4)
|
||||
actionview (= 4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
actionpack (4.1.5)
|
||||
actionview (= 4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
actionview (4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
activemodel (4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.4)
|
||||
activemodel (= 4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
activerecord (4.1.5)
|
||||
activemodel (= 4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.4)
|
||||
activesupport (4.1.5)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
|
@ -46,17 +46,17 @@ GEM
|
|||
coffee-script (2.3.0)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.7.1)
|
||||
coffee-script-source (1.8.0)
|
||||
countries (0.9.3)
|
||||
currencies (~> 0.4.2)
|
||||
currencies (0.4.2)
|
||||
devise (3.2.4)
|
||||
devise (3.3.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
devise-i18n (0.10.3)
|
||||
devise-i18n (0.11.0)
|
||||
diff-lcs (1.2.5)
|
||||
erubis (2.7.0)
|
||||
execjs (2.2.1)
|
||||
|
@ -65,7 +65,7 @@ GEM
|
|||
factory_girl_rails (4.4.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.4.2)
|
||||
faker (1.4.3)
|
||||
i18n (~> 0.5)
|
||||
ffi (1.9.3)
|
||||
formatador (0.2.5)
|
||||
|
@ -75,7 +75,7 @@ GEM
|
|||
lumberjack (~> 1.0)
|
||||
pry (>= 0.9.12)
|
||||
thor (>= 0.18.1)
|
||||
guard-rspec (4.2.10)
|
||||
guard-rspec (4.3.1)
|
||||
guard (~> 2.1)
|
||||
rspec (>= 2.14, < 4.0)
|
||||
hike (1.2.3)
|
||||
|
@ -96,34 +96,34 @@ GEM
|
|||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.6.0)
|
||||
minitest (5.4.0)
|
||||
minitest (5.4.1)
|
||||
multi_json (1.10.1)
|
||||
nokogiri (1.6.3.1)
|
||||
mini_portile (= 0.6.0)
|
||||
orm_adapter (0.5.0)
|
||||
pg (0.17.1)
|
||||
phony (2.2.14)
|
||||
phony_rails (0.6.1)
|
||||
phony (2.2.15)
|
||||
phony_rails (0.6.2)
|
||||
activesupport (>= 3.0)
|
||||
countries (>= 0.8.2)
|
||||
phony (~> 2.1)
|
||||
polyglot (0.3.5)
|
||||
pry (0.10.0)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
rack (1.5.2)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (4.1.4)
|
||||
actionmailer (= 4.1.4)
|
||||
actionpack (= 4.1.4)
|
||||
actionview (= 4.1.4)
|
||||
activemodel (= 4.1.4)
|
||||
activerecord (= 4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
rails (4.1.5)
|
||||
actionmailer (= 4.1.5)
|
||||
actionpack (= 4.1.5)
|
||||
actionview (= 4.1.5)
|
||||
activemodel (= 4.1.5)
|
||||
activerecord (= 4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.4)
|
||||
railties (= 4.1.5)
|
||||
sprockets-rails (~> 2.0)
|
||||
rails-erd (1.1.0)
|
||||
activerecord (>= 3.0)
|
||||
|
@ -133,9 +133,9 @@ GEM
|
|||
rails-i18n (4.0.2)
|
||||
i18n (~> 0.6)
|
||||
rails (>= 4.0)
|
||||
railties (4.1.4)
|
||||
actionpack (= 4.1.4)
|
||||
activesupport (= 4.1.4)
|
||||
railties (4.1.5)
|
||||
actionpack (= 4.1.5)
|
||||
activesupport (= 4.1.5)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.3.2)
|
||||
|
@ -147,12 +147,12 @@ GEM
|
|||
rspec-core (~> 3.0.0)
|
||||
rspec-expectations (~> 3.0.0)
|
||||
rspec-mocks (~> 3.0.0)
|
||||
rspec-core (3.0.3)
|
||||
rspec-core (3.0.4)
|
||||
rspec-support (~> 3.0.0)
|
||||
rspec-expectations (3.0.3)
|
||||
rspec-expectations (3.0.4)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.0.0)
|
||||
rspec-mocks (3.0.3)
|
||||
rspec-mocks (3.0.4)
|
||||
rspec-support (~> 3.0.0)
|
||||
rspec-rails (3.0.2)
|
||||
actionpack (>= 3.0)
|
||||
|
@ -162,7 +162,7 @@ GEM
|
|||
rspec-expectations (~> 3.0.0)
|
||||
rspec-mocks (~> 3.0.0)
|
||||
rspec-support (~> 3.0.0)
|
||||
rspec-support (3.0.3)
|
||||
rspec-support (3.0.4)
|
||||
ruby-graphviz (1.0.9)
|
||||
sass (3.2.19)
|
||||
sass-rails (4.0.3)
|
||||
|
@ -206,7 +206,7 @@ GEM
|
|||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (1.2.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (2.5.3)
|
||||
execjs (>= 0.3.0)
|
||||
|
@ -230,7 +230,7 @@ DEPENDENCIES
|
|||
jquery-rails
|
||||
pg
|
||||
phony_rails
|
||||
rails (= 4.1.4)
|
||||
rails (= 4.1.5)
|
||||
rails-erd
|
||||
rails-i18n
|
||||
rspec-rails
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#main {
|
||||
font-size: 16px;
|
||||
}
|
||||
h1 {
|
||||
margin: 0 0 1em 0;
|
||||
font-size: 2em;
|
||||
}
|
||||
.input {
|
||||
position: relative;
|
||||
margin: 0 0 1em 0;
|
||||
border-top: 0.1em dotted #999;
|
||||
padding: 1em 0;
|
||||
}
|
||||
.input label {
|
||||
font-size: 1em;
|
||||
display: block;
|
||||
width: 12em;
|
||||
float: left;
|
||||
}
|
||||
.input input, .input textarea, .input select {
|
||||
font-size: 1em;
|
||||
width: 20em;
|
||||
float: left;
|
||||
}
|
||||
.input textarea {
|
||||
height: 8em;
|
||||
}
|
||||
.input .hint, .input .error {
|
||||
display: block;
|
||||
clear: both;
|
||||
font-size: 0.75em;
|
||||
font-style: italic;
|
||||
width: 20em;
|
||||
margin: 0 0 0 16em;
|
||||
padding: 1em 0 0 0;
|
||||
}
|
||||
.input .error {
|
||||
font-style: normal;
|
||||
padding: 1em 0 0 0;
|
||||
color: #F00;
|
||||
}
|
||||
.input .error::before {
|
||||
content: "⇧";
|
||||
display: inline-block;
|
||||
font-size: 2em;
|
||||
margin: 0 0.2em 0 0;
|
||||
transform: translate(0, 0.1em);
|
||||
}
|
||||
.btn {
|
||||
display: block;
|
||||
margin: 2em 0 0 13em;
|
||||
}
|
||||
|
||||
/* styling of the button */
|
||||
.btn {
|
||||
background: #233e83;
|
||||
padding: 0.4em 0.8em;
|
||||
border-radius: 0.2em;
|
||||
color: #FFF;
|
||||
border: none;
|
||||
border-bottom: 0.2em solid #7A95DC;
|
||||
cursor: pointer;
|
||||
transition: background 200ms, border 200ms, transform 200ms;
|
||||
-webkit-transition: background 200ms, border 200ms, transform 200ms;
|
||||
}
|
||||
.btn:hover {
|
||||
background: #152551;
|
||||
}
|
||||
.btn:active {
|
||||
background: #597AD2;
|
||||
border-bottom: 0.2em solid #000;
|
||||
transform: translate(0, 0.1em);
|
||||
-webkit-transform: translate(0, 0.1em);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
class HomeController < ApplicationController
|
||||
def index
|
||||
@current_conference = Conference.current || Conference.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
class LecturesController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_action :assign_lecture, only: [:show, :edit, :update]
|
||||
|
||||
def index
|
||||
@lectures = Lecture.where user: current_user
|
||||
end
|
||||
|
||||
def new
|
||||
@lecture = Lecture.new
|
||||
end
|
||||
|
||||
def create
|
||||
@lecture = current_user.lectures.build lecture_params
|
||||
|
||||
if @lecture.save
|
||||
redirect_to @lecture
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @lecture.update lecture_params
|
||||
redirect_to @lecture
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_lecture
|
||||
@lecture = Lecture.find params[:id]
|
||||
end
|
||||
|
||||
def lecture_params
|
||||
params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
class WorkshopsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_action :assign_lecture, only: [:show, :edit, :update]
|
||||
|
||||
def index
|
||||
@workshops = Workshop.where user: current_user
|
||||
end
|
||||
|
||||
def new
|
||||
@workshop = Workshop.new
|
||||
end
|
||||
|
||||
def create
|
||||
@workshop = current_user.workshops.build workshop_params
|
||||
|
||||
if @workshop.save
|
||||
redirect_to @workshop
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @workshop.update workshop_params
|
||||
redirect_to @workshop
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_workshop
|
||||
@workshop = Workshop.find params[:id]
|
||||
end
|
||||
|
||||
def workshop_params
|
||||
params.require(:workshop).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
|
||||
end
|
||||
end
|
|
@ -9,6 +9,12 @@ class Conference < ActiveRecord::Base
|
|||
has_many :tracks
|
||||
has_many :events, through: :tracks
|
||||
|
||||
scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') }
|
||||
|
||||
def self.current
|
||||
future.first || last
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def end_date_is_before_start_date
|
||||
|
|
|
@ -3,6 +3,7 @@ class Event < ActiveRecord::Base
|
|||
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
||||
validates :abstract, presence: true
|
||||
validates :description, presence: true
|
||||
validates :track, inclusion: { in: (Conference.current.try(:tracks) || []) }
|
||||
|
||||
belongs_to :track
|
||||
has_one :conference, through: :track
|
||||
|
|
|
@ -3,5 +3,8 @@ class User < ActiveRecord::Base
|
|||
# :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable, :confirmable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_one :speaker_profile
|
||||
has_many :lectures
|
||||
has_many :workshops
|
||||
end
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
h1.entry-title OpenFest 2014 – призив за лектори
|
||||
h1.entry-title #{@current_conference.title} - призив за лектори
|
||||
|
||||
p OpenFest e единствената по рода си в България конференция, посветена на
|
||||
свободната култура, свободния софтуер и софтуера с отворен код, свободното
|
||||
споделяне на знания – фестивал на свободното творчество. OpenFest е ежегодна
|
||||
среща на всички почитатели, създатели, поддръжници и нови фенове на свободните
|
||||
изкуства и свободния софтуер.
|
||||
|
||||
p Целта на OpenFest е да популяризира проекти, реализирани с помощта на свободен
|
||||
софтуер и софтуер с отворен код, както и да бъде форум за обмен на идеи и добри
|
||||
практики в областта. Същевременно организаторите всякога се стараят да дадат
|
||||
поле за изява и на свободното изкуство.
|
||||
= simple_format @current_conference.description
|
||||
|
||||
p Бихме искали да получим предложенията Ви за лекции и уъркшопи, принадлежащи
|
||||
към следните категории:
|
||||
|
||||
ul
|
||||
li Lorem
|
||||
li Ipsum
|
||||
- for track in @current_conference.tracks
|
||||
li = track.name
|
||||
|
||||
.centered
|
||||
button type="button" Предложи лекция
|
||||
button type="button" Предложи уъркшоп
|
||||
= link_to 'Предложи лекция', new_lecture_path
|
||||
|
||||
= link_to 'Предложи уъркшоп', new_workshop_path
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'sessions')] do %>
|
||||
<%= link_to "Вход", new_user_session_path %>
|
||||
<% end %>
|
||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %>
|
||||
<%= link_to "Регистрация", new_user_registration_path %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'lectures')] do %>
|
||||
<%= link_to "Лекции", lectures_path %>
|
||||
<% end %>
|
||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'workshops')] do %>
|
||||
<%= link_to "Уъркшопи", workshops_path %>
|
||||
<% end %>
|
||||
<%= content_tag :li, class: [('current_page_item' if controller_name == 'registrations')] do %>
|
||||
<%= link_to "Редакция на профил", edit_user_registration_path %>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
== simple_form_for @lecture do |form|
|
||||
p
|
||||
= form.error_notification
|
||||
|
||||
.form-inputs
|
||||
= form.input :title, autofocus: true
|
||||
= form.input :subtitle
|
||||
= form.association :track
|
||||
= form.input :length
|
||||
= form.input :language, collection: I18n.available_locales, include_blank: false, default: I18n.locale
|
||||
= form.input :abstract
|
||||
= form.input :description
|
||||
= form.input :notes
|
||||
= form.button :submit
|
|
@ -0,0 +1,2 @@
|
|||
h1 Lectures#create
|
||||
p Find me in app/views/lectures/create.html.slim
|
|
@ -0,0 +1,2 @@
|
|||
h1.entry-title Редакция на лекция
|
||||
= render 'form'
|
|
@ -0,0 +1,7 @@
|
|||
h1.entry-title Моите предложения за лекции
|
||||
|
||||
ul
|
||||
- for lecture in @lectures
|
||||
li = link_to lecture.title, lecture
|
||||
|
||||
= link_to 'Предложи лекция', new_lecture_path
|
|
@ -0,0 +1,2 @@
|
|||
h1.entry-title Предложи нова лекция
|
||||
= render 'form'
|
|
@ -0,0 +1,20 @@
|
|||
h1.entry-title Преглед на лекция
|
||||
|
||||
h2.lecture-title
|
||||
= @lecture.title
|
||||
span.subtitle = @lecture.subtitle
|
||||
.entry-meta
|
||||
|
|
||||
поток: „#{@lecture.track.name}“,
|
||||
продължителност: #{@lecture.length} мин.
|
||||
|
||||
section.abstract
|
||||
h3 Резюме
|
||||
= simple_format @lecture.abstract
|
||||
|
||||
section.description
|
||||
h3 Описание
|
||||
= simple_format @lecture.description
|
||||
|
||||
- if current_user == @lecture.user
|
||||
= link_to 'Редактирай', edit_lecture_path(@lecture)
|
|
@ -0,0 +1,2 @@
|
|||
h1 Lectures#update
|
||||
p Find me in app/views/lectures/update.html.slim
|
|
@ -0,0 +1,14 @@
|
|||
== simple_form_for @workshop do |form|
|
||||
p
|
||||
= form.error_notification
|
||||
|
||||
.form-inputs
|
||||
= form.input :title, autofocus: true
|
||||
= form.input :subtitle
|
||||
= form.association :track
|
||||
= form.input :length, input_html: {value: 60}
|
||||
= form.input :language, collection: I18n.available_locales, include_blank: false, default: I18n.locale
|
||||
= form.input :abstract
|
||||
= form.input :description
|
||||
= form.input :notes
|
||||
= form.button :submit
|
|
@ -0,0 +1,2 @@
|
|||
h1.entry-title Редакция на уъркшоп
|
||||
= render 'form'
|
|
@ -0,0 +1,7 @@
|
|||
h1.entry-title Моите предложения за уъркшопи
|
||||
|
||||
ul
|
||||
- for workshop in @workshops
|
||||
li = link_to workshop.title, workshop
|
||||
|
||||
= link_to 'Предложи уъркшоп', new_workshop_path
|
|
@ -0,0 +1,2 @@
|
|||
h1.entry-title Предложи нов уъркшоп
|
||||
= render 'form'
|
|
@ -0,0 +1,20 @@
|
|||
h1.entry-title Преглед на уъркшоп
|
||||
|
||||
h2.workshop-title
|
||||
= @workshop.title
|
||||
span.subtitle = @workshop.subtitle
|
||||
.entry-meta
|
||||
|
|
||||
поток: „#{@workshop.track.name}“,
|
||||
продължителност: #{@workshop.length} мин.
|
||||
|
||||
section.abstract
|
||||
h3 Резюме
|
||||
= simple_format @workshop.abstract
|
||||
|
||||
section.description
|
||||
h3 Описание
|
||||
= simple_format @workshop.description
|
||||
|
||||
- if current_user == @workshop.user
|
||||
= link_to 'Редактирай', edit_workshop_path(@workshop)
|
|
@ -20,7 +20,34 @@
|
|||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
bg:
|
||||
hello: "Здравей, свят"
|
||||
activerecord:
|
||||
models:
|
||||
lecture:
|
||||
one: Лекция
|
||||
other: Лекции
|
||||
workshop:
|
||||
one: Уъркшоп
|
||||
other: Уъркшопи
|
||||
track: Поток от лекции
|
||||
attributes:
|
||||
lecture:
|
||||
title: Заглавие
|
||||
subtitle: Подзаглавие
|
||||
length: Продължителност
|
||||
language: Език
|
||||
abstract: Резюме
|
||||
description: Описание
|
||||
notes: Забележки
|
||||
track: Поток от лекции
|
||||
workshop:
|
||||
title: Заглавие
|
||||
subtitle: Подзаглавие
|
||||
length: Продължителност
|
||||
language: Език
|
||||
abstract: Резюме
|
||||
description: Описание
|
||||
notes: Забележки
|
||||
track: Поток от лекции
|
||||
errors:
|
||||
messages:
|
||||
improbable_phone: 'не е валиден телефонен номер'
|
|
@ -6,4 +6,23 @@ bg:
|
|||
text: 'Задължително поле'
|
||||
mark: '*'
|
||||
error_notification:
|
||||
default_message: "Моля разгледайте проблемите по-долу:"
|
||||
default_message: "Моля разгледайте проблемите по-долу:"
|
||||
hints:
|
||||
lecture:
|
||||
title: Заглавието на лекцията Ви
|
||||
subtitle: Подзаглавието на лекцията Ви (ако има такова)
|
||||
track: Потокът от лекции, в който искате да попадне лекцията Ви
|
||||
length: Продължителността на лекция може да бъде от 40 до 45 минути
|
||||
language: Език, на който ще бъде водена лекцията
|
||||
abstract: Резюме на лекцията, което да може да бъде прочетено от посетителите
|
||||
description: Подробно описание на лекцията, което да бъде използвано от организаторския екип
|
||||
notes: Забележки, които искате да споделите с организаторския екип
|
||||
workshop:
|
||||
title: Заглавието на уъркшопа Ви
|
||||
subtitle: Подзаглавието на уъркшопа Ви (ако има такова)
|
||||
track: Потокът от уъркшопи, в който искате да попадне уъркшопа Ви
|
||||
length: Продължителността на уъркшоп може да бъде от 30 до 120 минути
|
||||
language: Език, на който ще бъде воден уъркшопа
|
||||
abstract: Резюме на уъркшопа, което да може да бъде прочетено от посетителите
|
||||
description: Подробно описание на уъркшопа, което да бъде използвано от организаторския екип
|
||||
notes: Забележки, които искате да споделите с организаторския екип
|
|
@ -1,5 +1,6 @@
|
|||
Rails.application.routes.draw do
|
||||
get 'home/index'
|
||||
resources :lectures, only: [:index, :new, :create, :edit, :update, :show]
|
||||
resources :workshops, only: [:index, :new, :create, :edit, :update, :show]
|
||||
|
||||
devise_for :users
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe LecturesController, type: :controller do
|
||||
let(:user) { create :user, confirmed_at: Time.now }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET index' do
|
||||
it 'returns HTTP Success status code'
|
||||
it 'assigns the lectures of the current user to @lectures'
|
||||
end
|
||||
|
||||
describe 'GET new' do
|
||||
it 'returns HTTP Success status code' do
|
||||
get :new
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'assigns a blank lecture to @lecture'
|
||||
end
|
||||
|
||||
describe 'POST create' do
|
||||
it 'assigns the new lecture to @lecture'
|
||||
|
||||
context 'when passed correct parameters' do
|
||||
it 'creates a new lecture'
|
||||
it 'redirects to the created lecture'
|
||||
end
|
||||
|
||||
context 'when passed incorrect parameters' do
|
||||
it 'renders the edit template'
|
||||
it 'returns HTTP Unprocessable Entity status code'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET edit' do
|
||||
context 'when the lecture exists' do
|
||||
it 'returns http success'
|
||||
it 'assigns the lecture to @lecture'
|
||||
end
|
||||
|
||||
context 'when the lecture does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT update' do
|
||||
context 'when the lecture does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
|
||||
context 'when the lecture exists' do
|
||||
it 'assigns the lecture to @lecture'
|
||||
|
||||
context 'when passed correct parameters' do
|
||||
it 'redirects to the updated lecture'
|
||||
end
|
||||
|
||||
context 'when passed incorrect parameters' do
|
||||
it 'renders the edit template'
|
||||
it 'returns HTTP Unprocessable Entity status code'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET show' do
|
||||
context 'when the lecture exists' do
|
||||
it 'returns HTTP Success status code'
|
||||
it 'assigns the lecture to @lecture'
|
||||
end
|
||||
|
||||
context 'when the lecture does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,78 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WorkshopsController, type: :controller do
|
||||
let(:user) { create :user, confirmed_at: Time.now }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET index' do
|
||||
it 'returns HTTP Success status code'
|
||||
it 'assigns the workshops of the current user to @workshops'
|
||||
end
|
||||
|
||||
describe 'GET new' do
|
||||
it 'returns HTTP Success status code' do
|
||||
get :new
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'assigns a blank workshop to @workshop'
|
||||
end
|
||||
|
||||
describe 'POST create' do
|
||||
it 'assigns the new workshop to @workshop'
|
||||
|
||||
context 'when passed correct parameters' do
|
||||
it 'creates a new workshop'
|
||||
it 'redirects to the created workshop'
|
||||
end
|
||||
|
||||
context 'when passed incorrect parameters' do
|
||||
it 'renders the edit template'
|
||||
it 'returns HTTP Unprocessable Entity status code'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET edit' do
|
||||
context 'when the workshop exists' do
|
||||
it 'returns http success'
|
||||
it 'assigns the workshop to @workshop'
|
||||
end
|
||||
|
||||
context 'when the workshop does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT update' do
|
||||
context 'when the workshop does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
|
||||
context 'when the workshop exists' do
|
||||
it 'assigns the workshop to @workshop'
|
||||
|
||||
context 'when passed correct parameters' do
|
||||
it 'redirects to the updated workshop'
|
||||
end
|
||||
|
||||
context 'when passed incorrect parameters' do
|
||||
it 'renders the edit template'
|
||||
it 'returns HTTP Unprocessable Entity status code'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET show' do
|
||||
context 'when the workshop exists' do
|
||||
it 'returns HTTP Success status code'
|
||||
it 'assigns the workshop to @workshop'
|
||||
end
|
||||
|
||||
context 'when the workshop does not exist' do
|
||||
it 'returns HTTP Not Found status code'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,5 +7,15 @@ FactoryGirl.define do
|
|||
description 'MyText'
|
||||
start_date '2014-07-29 21:29:13'
|
||||
end_date '2014-07-31 21:29:13'
|
||||
|
||||
factory :past_conference do
|
||||
start_date Date.today - 10.days
|
||||
end_date Date.today - 5.days
|
||||
end
|
||||
|
||||
factory :future_conference do
|
||||
start_date Date.today + 5.days
|
||||
end_date Date.today + 10.days
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,4 +39,18 @@ RSpec.describe Conference, :type => :model do
|
|||
it 'is invalid when the end date is before the start date' do
|
||||
expect(build(:conference, start_date: '2014-07-29 21:29:13', end_date: '2014-07-28 01:00:00')).to have_error_on :end_date
|
||||
end
|
||||
|
||||
describe '::current' do
|
||||
it 'returns the next conference if there is one' do
|
||||
create :past_conference
|
||||
conference = create :future_conference
|
||||
create :future_conference, start_date: Date.today + 100.years, end_date: Date.today + 150.years
|
||||
expect(Conference.current).to eq conference
|
||||
end
|
||||
|
||||
it 'returns the last conference if there is no future conference' do
|
||||
conference = create :past_conference
|
||||
expect(Conference.current).to eq conference
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
end
|
Loading…
Reference in New Issue