Skip to content

Commit

Permalink
Merge branch 'dev' into feature/#160-remove-files-course-overview
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianjost authored Jan 16, 2020
2 parents 894ee73 + c9b18fc commit 844c42f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pull_request_rules:
- name: automatic merge on CI success when label is set
conditions:
- label~=ready to merge
actions:
merge:
method: squash
strict: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.com/hpi-swt2/lecture-portal.svg?branch=master)](https://travis-ci.com/hpi-swt2/lecture-portal)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![mergify-status](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/hpi-swt2/lecture-portal&style=flat)](https://dashboard.mergify.io/installation/6258647/repositories)

Web application for organizing and managing lecture participation, written in [Ruby on Rails](https://rubyonrails.org/).
Created in the [Software Engineering II course](https://hpi.de/plattner/teaching/winter-term-201920/softwaretechnik-ii.html) at HPI in Potsdam.
Expand Down
6 changes: 5 additions & 1 deletion app/models/lecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Lecture < ApplicationRecord
validates :end_time, presence: true

validates :name, presence: true, length: { in: 2..40 }
validates :enrollment_key, presence: true, length: { in: 3..20 }
validates :enrollment_key, length: { in: 3..20, if: :enrollment_key_present? }
scope :active, -> { where status: "running" }


Expand Down Expand Up @@ -61,4 +61,8 @@ def readonly?
end
false
end

def enrollment_key_present?
enrollment_key.present?
end
end
15 changes: 14 additions & 1 deletion spec/models/lecture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@
expect(@lecture).not_to be_valid
end

it "is not valid without a enrollment key" do
it "is valid without an enrollment key" do
@lecture.enrollment_key = ""
expect(@lecture).to be_valid
end

it "is valid with an enrollment key with 3 characters" do
@lecture.enrollment_key = "123"
expect(@lecture).to be_valid
end

it "is not valid with an enrollment key with 1 to 2 characters" do
@lecture.enrollment_key = "1"
expect(@lecture).not_to be_valid

@lecture.enrollment_key = "12"
expect(@lecture).not_to be_valid
end

Expand Down

0 comments on commit 844c42f

Please sign in to comment.