Skip to content

Commit

Permalink
Merge pull request #77 from abdullahallmehedi/49758_RSpec_for_Supervi…
Browse files Browse the repository at this point in the history
…sor_Course_View_for_start_course_feature

RSpec for Supervisor Course View for start course feature 49758
  • Loading branch information
dieunb committed Dec 28, 2015
2 parents 1fb2a01 + 1b9f7f5 commit 568911a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/supervisor/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def edit
def update
if course_params.has_key? :update_status
@course.update_status!
if @course.created?
if @course.started?
flash[:success] = t ".success", action: "Started"
else
flash[:success] = t ".success", action: "Finished"
Expand Down
8 changes: 2 additions & 6 deletions spec/controllers/supervisor/courses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
context "when the course updated successfully" do
it {expect(response).to redirect_to supervisor_course_path course}
end

context "when the course failed to update" do
before do
allow(course).to receive(:update_attributes).and_return false
Expand All @@ -121,11 +120,10 @@
it {expect(response).to render_template :edit}
end
end

context "when request is to start or finish the course" do
before do
allow(course).to receive :update_status!
allow(course).to receive(:created?).and_return true
allow(course).to receive(:started?).and_return true
end
context "when course start" do
before {put :update, {id: english, course: {name: "bengali",
Expand All @@ -136,16 +134,14 @@
end
context "when course finish" do
before do
allow(course).to receive(:created?).and_return false
allow(course).to receive(:started?).and_return false
put :update, {id: english, course: {name: "bengali", update_status:
""}}
end
it {expect(flash[:success]).to eq I18n.t(
"supervisor.courses.update.success", action: "Finished")}
it {expect(response).to redirect_to supervisor_course_path course}
end


end
end
context "while course failed .check_course" do
Expand Down
23 changes: 23 additions & 0 deletions spec/features/start_course_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "rails_helper"

feature "Start course" do
subject {page}
let(:supervisor) {FactoryGirl.create :supervisor}
let!(:course){FactoryGirl.create :course, user_ids: [supervisor.id]}
before :each do
login_as supervisor, scope: :user
visit supervisor_course_path course
end

scenario "has update status field" do
is_expected.to have_selector "input#course_update_status", visible: false
end
scenario "has submit button" do
is_expected.to have_button I18n.t "supervisor.courses.show.start"
end
scenario "edit course feature", js: true do
click_button I18n.t "supervisor.courses.show.start"
is_expected.to have_text I18n.t("supervisor.courses.update.success", action:
"Started")
end
end

0 comments on commit 568911a

Please sign in to comment.