diff --git a/Gemfile b/Gemfile index 8cc1e58..4fb2c5c 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem "importmap-rails" # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] gem "turbo-rails" -gem 'sassc-rails' +gem "sassc-rails" # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] gem "stimulus-rails" diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 3d00b20..ed773a4 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -14,14 +14,14 @@ def show def upvote vote(1) respond_to do |format| - format.json { render json: { new_score: @article.score } } + format.json { render json: {new_score: @article.score} } end end def downvote vote(-1) respond_to do |format| - format.json { render json: { new_score: @article.score } } + format.json { render json: {new_score: @article.score} } end end diff --git a/spec/controllers/articles_controller_spec.rb b/spec/controllers/articles_controller_spec.rb index f891f60..b46d0cb 100644 --- a/spec/controllers/articles_controller_spec.rb +++ b/spec/controllers/articles_controller_spec.rb @@ -40,37 +40,37 @@ end describe "POST #upvote" do - it "sets vote value to 1 if user has not voted" do - expect { - post :upvote, params: {id: article.id}, format: :json - }.to change { article.votes.count }.by(1) - expect(article.reload.votes.last.value).to eq(1) - end + it "sets vote value to 1 if user has not voted" do + expect { + post :upvote, params: {id: article.id}, format: :json + }.to change { article.votes.count }.by(1) + expect(article.reload.votes.last.value).to eq(1) + end - it "sets vote value to 0 if user has already upvoted" do - create(:vote, votable: article, user: user, value: 1) - expect { - post :upvote, params: {id: article.id}, format: :json - }.not_to change { article.votes.count } - expect(article.reload.votes.last.value).to eq(0) + it "sets vote value to 0 if user has already upvoted" do + create(:vote, votable: article, user: user, value: 1) + expect { + post :upvote, params: {id: article.id}, format: :json + }.not_to change { article.votes.count } + expect(article.reload.votes.last.value).to eq(0) + end end - end - describe "POST #downvote" do - it "sets vote value to -1 if user has not already downvoted" do - expect { - post :downvote, params: {id: article.id}, format: :json - }.to change { article.votes.count }.by(1) - expect(article.reload.votes.last.value).to eq(-1) - end + describe "POST #downvote" do + it "sets vote value to -1 if user has not already downvoted" do + expect { + post :downvote, params: {id: article.id}, format: :json + }.to change { article.votes.count }.by(1) + expect(article.reload.votes.last.value).to eq(-1) + end - it "sets vote value to 0 if user has already downvoted" do - create(:vote, votable: article, user: user, value: -1) - expect { - post :downvote, params: {id: article.id}, format: :json - }.not_to change { article.votes.count } - expect(article.reload.votes.last.value).to eq(0) + it "sets vote value to 0 if user has already downvoted" do + create(:vote, votable: article, user: user, value: -1) + expect { + post :downvote, params: {id: article.id}, format: :json + }.not_to change { article.votes.count } + expect(article.reload.votes.last.value).to eq(0) + end end end end -end