-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from fsek/contact-fix
Fixing News and Contact.
- Loading branch information
Showing
4 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ Från: <%=@name%> | |
E-post: <%=@email%> | ||
|
||
Meddelande: | ||
<%=@msg%> | ||
<%=simple_format(@msg)%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe NewsController, type: :controller do | ||
let(:user) { create(:user) } | ||
let(:news) { create(:news, user: user) } | ||
|
||
allow_user_to(:manage, News) | ||
before(:each) do | ||
allow(controller).to receive(:current_user) { user } | ||
end | ||
describe 'GET #show' do | ||
it 'assigns the requested news as @news' do | ||
get(:show, id: news.to_param) | ||
assigns(:news).should eq(news) | ||
end | ||
end | ||
|
||
describe 'GET #new' do | ||
it 'assigns a new news as @news' do | ||
get(:new) | ||
assigns(:news).new_record?.should be_truthy | ||
assigns(:news).instance_of?(News).should be_truthy | ||
end | ||
end | ||
|
||
describe 'GET #index' do | ||
it 'assigns news sorted as @news' do | ||
get(:index) | ||
assigns(:news).should eq(News.all.order(created_at: :asc)) | ||
end | ||
end | ||
|
||
describe 'POST #create' do | ||
it 'posts new news' do | ||
lambda do | ||
post :create, news: attributes_for(:news) | ||
end.should change(News, :count).by(1) | ||
|
||
response.should redirect_to(News.last) | ||
end | ||
end | ||
|
||
describe 'PATCH #update' do | ||
it 'update news' do | ||
patch :update, id: news.to_param, news: { title: 'Hej' } | ||
news.reload | ||
news.title.should eq('Hej') | ||
response.should redirect_to(news) | ||
end | ||
end | ||
end |