Skip to content

Commit

Permalink
Updating event spec to test event locking functionality, and updating…
Browse files Browse the repository at this point in the history
… admin controller spec to handle admin name and password settings.
  • Loading branch information
aeschright committed Feb 14, 2015
1 parent 4c6a6d2 commit 3286160
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/controllers/admin_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

RSpec.describe AdminController, :type => :controller do

before do
SECRETS.admin_username = nil
SECRETS.admin_password = nil
end

describe "GET #index" do
it "returns http success" do
get :index
Expand Down
24 changes: 24 additions & 0 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
event = Event.new(:title => "Foo bar cialis", :start_time => Time.zone.parse('2008.04.12'), :url => 'google.com')
expect(event).not_to be_valid
end

it "can be locked" do
event = Event.create(:title => "Event title", :start_time => Time.zone.parse('2008.04.12'))
event.lock_editing!
expect(event.locked).to eq(true)
end

it "can be unlocked" do
event = Event.create(:title => "Event title", :start_time => Time.zone.parse('2008.04.12'), :locked => true)
event.unlock_editing!
expect(event.locked).to eq(false)
end

it "can't be updated if it's locked" do
event = Event.create(:title => "Event title", :start_time => Time.zone.parse('2008.04.12'))
event.lock_editing!
expect(event.update_attributes(:title => "New title")).to eq(false)
end

it "can't be deleted if it's locked" do
event = Event.create(:title => "Event title", :start_time => Time.zone.parse('2008.04.12'))
event.lock_editing!
expect(event.destroy).to eq(false)
end
end

describe "when checking time status" do
Expand Down

0 comments on commit 3286160

Please sign in to comment.