|
|
|
|
@ -171,10 +171,16 @@ RSpec.describe SalesLogsController, type: :request do
|
|
|
|
|
post "/sales-logs", headers: |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "sets the stock-owning org as user's org" do |
|
|
|
|
it "does not set owning organisation" do |
|
|
|
|
created_id = response.location.match(/[0-9]+/)[0] |
|
|
|
|
sales_log = SalesLog.find_by(id: created_id) |
|
|
|
|
expect(sales_log.owning_organisation.name).to eq("User org") |
|
|
|
|
expect(sales_log.owning_organisation).to be_nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "sets managing organisation as the user organisation" do |
|
|
|
|
created_id = response.location.match(/[0-9]+/)[0] |
|
|
|
|
sales_log = SalesLog.find_by(id: created_id) |
|
|
|
|
expect(sales_log.managing_organisation.name).to eq("User org") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
@ -879,6 +885,23 @@ RSpec.describe SalesLogsController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with sales logs that are managed by your organisation" do |
|
|
|
|
before do |
|
|
|
|
completed_sales_log.update!(managing_organisation_id: user.organisation.id, owning_organisation_id: nil) |
|
|
|
|
get "/sales-logs/#{completed_sales_log.id}", headers:, params: {} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
Timecop.return |
|
|
|
|
Singleton.__init__(FormHandler) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows the tasklist for sales logs you have access to" do |
|
|
|
|
expect(response.body).to match("Log") |
|
|
|
|
expect(response.body).to match(completed_sales_log.id.to_s) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with sales logs from a closed collection period before the previous collection" do |
|
|
|
|
before do |
|
|
|
|
sign_in user |
|
|
|
|
|